app.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942
  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/assetinfo.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/assetinfo.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. //
  1618. //
  1619. //
  1620. /* harmony default export */ __webpack_exports__["default"] = ({
  1621. props: ['asset'],
  1622. data: function data() {
  1623. return {
  1624. data: JSON.parse(this.asset)
  1625. };
  1626. },
  1627. mounted: function mounted() {
  1628. var _this = this;
  1629. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1630. _this.data = JSON.parse(e.data);
  1631. });
  1632. }
  1633. });
  1634. /***/ }),
  1635. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1636. /*!*****************************************************************************************************************************************************************!*\
  1637. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  1638. \*****************************************************************************************************************************************************************/
  1639. /*! exports provided: default */
  1640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1641. "use strict";
  1642. __webpack_require__.r(__webpack_exports__);
  1643. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. //
  1653. //
  1654. //
  1655. //
  1656. //
  1657. //
  1658. //
  1659. //
  1660. //
  1661. //
  1662. /* harmony default export */ __webpack_exports__["default"] = ({
  1663. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1664. props: ['workOrder'],
  1665. data: function data() {
  1666. return {
  1667. data: JSON.parse(this.workOrder)
  1668. };
  1669. },
  1670. mounted: function mounted() {
  1671. var _this = this;
  1672. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1673. _this.data = JSON.parse(e.data);
  1674. });
  1675. }
  1676. });
  1677. /***/ }),
  1678. /***/ "./node_modules/base64-js/index.js":
  1679. /*!*****************************************!*\
  1680. !*** ./node_modules/base64-js/index.js ***!
  1681. \*****************************************/
  1682. /*! no static exports found */
  1683. /***/ (function(module, exports, __webpack_require__) {
  1684. "use strict";
  1685. exports.byteLength = byteLength
  1686. exports.toByteArray = toByteArray
  1687. exports.fromByteArray = fromByteArray
  1688. var lookup = []
  1689. var revLookup = []
  1690. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1691. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1692. for (var i = 0, len = code.length; i < len; ++i) {
  1693. lookup[i] = code[i]
  1694. revLookup[code.charCodeAt(i)] = i
  1695. }
  1696. // Support decoding URL-safe base64 strings, as Node.js does.
  1697. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1698. revLookup['-'.charCodeAt(0)] = 62
  1699. revLookup['_'.charCodeAt(0)] = 63
  1700. function getLens (b64) {
  1701. var len = b64.length
  1702. if (len % 4 > 0) {
  1703. throw new Error('Invalid string. Length must be a multiple of 4')
  1704. }
  1705. // Trim off extra bytes after placeholder bytes are found
  1706. // See: https://github.com/beatgammit/base64-js/issues/42
  1707. var validLen = b64.indexOf('=')
  1708. if (validLen === -1) validLen = len
  1709. var placeHoldersLen = validLen === len
  1710. ? 0
  1711. : 4 - (validLen % 4)
  1712. return [validLen, placeHoldersLen]
  1713. }
  1714. // base64 is 4/3 + up to two characters of the original data
  1715. function byteLength (b64) {
  1716. var lens = getLens(b64)
  1717. var validLen = lens[0]
  1718. var placeHoldersLen = lens[1]
  1719. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1720. }
  1721. function _byteLength (b64, validLen, placeHoldersLen) {
  1722. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1723. }
  1724. function toByteArray (b64) {
  1725. var tmp
  1726. var lens = getLens(b64)
  1727. var validLen = lens[0]
  1728. var placeHoldersLen = lens[1]
  1729. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1730. var curByte = 0
  1731. // if there are placeholders, only get up to the last complete 4 chars
  1732. var len = placeHoldersLen > 0
  1733. ? validLen - 4
  1734. : validLen
  1735. var i
  1736. for (i = 0; i < len; i += 4) {
  1737. tmp =
  1738. (revLookup[b64.charCodeAt(i)] << 18) |
  1739. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1740. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1741. revLookup[b64.charCodeAt(i + 3)]
  1742. arr[curByte++] = (tmp >> 16) & 0xFF
  1743. arr[curByte++] = (tmp >> 8) & 0xFF
  1744. arr[curByte++] = tmp & 0xFF
  1745. }
  1746. if (placeHoldersLen === 2) {
  1747. tmp =
  1748. (revLookup[b64.charCodeAt(i)] << 2) |
  1749. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1750. arr[curByte++] = tmp & 0xFF
  1751. }
  1752. if (placeHoldersLen === 1) {
  1753. tmp =
  1754. (revLookup[b64.charCodeAt(i)] << 10) |
  1755. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1756. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1757. arr[curByte++] = (tmp >> 8) & 0xFF
  1758. arr[curByte++] = tmp & 0xFF
  1759. }
  1760. return arr
  1761. }
  1762. function tripletToBase64 (num) {
  1763. return lookup[num >> 18 & 0x3F] +
  1764. lookup[num >> 12 & 0x3F] +
  1765. lookup[num >> 6 & 0x3F] +
  1766. lookup[num & 0x3F]
  1767. }
  1768. function encodeChunk (uint8, start, end) {
  1769. var tmp
  1770. var output = []
  1771. for (var i = start; i < end; i += 3) {
  1772. tmp =
  1773. ((uint8[i] << 16) & 0xFF0000) +
  1774. ((uint8[i + 1] << 8) & 0xFF00) +
  1775. (uint8[i + 2] & 0xFF)
  1776. output.push(tripletToBase64(tmp))
  1777. }
  1778. return output.join('')
  1779. }
  1780. function fromByteArray (uint8) {
  1781. var tmp
  1782. var len = uint8.length
  1783. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1784. var parts = []
  1785. var maxChunkLength = 16383 // must be multiple of 3
  1786. // go through the array every three bytes, we'll deal with trailing stuff later
  1787. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1788. parts.push(encodeChunk(
  1789. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1790. ))
  1791. }
  1792. // pad the end with zeros, but make sure to not forget the extra bytes
  1793. if (extraBytes === 1) {
  1794. tmp = uint8[len - 1]
  1795. parts.push(
  1796. lookup[tmp >> 2] +
  1797. lookup[(tmp << 4) & 0x3F] +
  1798. '=='
  1799. )
  1800. } else if (extraBytes === 2) {
  1801. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1802. parts.push(
  1803. lookup[tmp >> 10] +
  1804. lookup[(tmp >> 4) & 0x3F] +
  1805. lookup[(tmp << 2) & 0x3F] +
  1806. '='
  1807. )
  1808. }
  1809. return parts.join('')
  1810. }
  1811. /***/ }),
  1812. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1813. /*!*****************************************************!*\
  1814. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1815. \*****************************************************/
  1816. /*! no static exports found */
  1817. /***/ (function(module, exports, __webpack_require__) {
  1818. /*!
  1819. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1820. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1821. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1822. */
  1823. (function (global, factory) {
  1824. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1825. undefined;
  1826. }(this, (function (exports, $, Popper) { 'use strict';
  1827. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1828. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1829. function _defineProperties(target, props) {
  1830. for (var i = 0; i < props.length; i++) {
  1831. var descriptor = props[i];
  1832. descriptor.enumerable = descriptor.enumerable || false;
  1833. descriptor.configurable = true;
  1834. if ("value" in descriptor) descriptor.writable = true;
  1835. Object.defineProperty(target, descriptor.key, descriptor);
  1836. }
  1837. }
  1838. function _createClass(Constructor, protoProps, staticProps) {
  1839. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1840. if (staticProps) _defineProperties(Constructor, staticProps);
  1841. return Constructor;
  1842. }
  1843. function _defineProperty(obj, key, value) {
  1844. if (key in obj) {
  1845. Object.defineProperty(obj, key, {
  1846. value: value,
  1847. enumerable: true,
  1848. configurable: true,
  1849. writable: true
  1850. });
  1851. } else {
  1852. obj[key] = value;
  1853. }
  1854. return obj;
  1855. }
  1856. function ownKeys(object, enumerableOnly) {
  1857. var keys = Object.keys(object);
  1858. if (Object.getOwnPropertySymbols) {
  1859. var symbols = Object.getOwnPropertySymbols(object);
  1860. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1861. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1862. });
  1863. keys.push.apply(keys, symbols);
  1864. }
  1865. return keys;
  1866. }
  1867. function _objectSpread2(target) {
  1868. for (var i = 1; i < arguments.length; i++) {
  1869. var source = arguments[i] != null ? arguments[i] : {};
  1870. if (i % 2) {
  1871. ownKeys(Object(source), true).forEach(function (key) {
  1872. _defineProperty(target, key, source[key]);
  1873. });
  1874. } else if (Object.getOwnPropertyDescriptors) {
  1875. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1876. } else {
  1877. ownKeys(Object(source)).forEach(function (key) {
  1878. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1879. });
  1880. }
  1881. }
  1882. return target;
  1883. }
  1884. function _inheritsLoose(subClass, superClass) {
  1885. subClass.prototype = Object.create(superClass.prototype);
  1886. subClass.prototype.constructor = subClass;
  1887. subClass.__proto__ = superClass;
  1888. }
  1889. /**
  1890. * --------------------------------------------------------------------------
  1891. * Bootstrap (v4.4.1): util.js
  1892. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1893. * --------------------------------------------------------------------------
  1894. */
  1895. /**
  1896. * ------------------------------------------------------------------------
  1897. * Private TransitionEnd Helpers
  1898. * ------------------------------------------------------------------------
  1899. */
  1900. var TRANSITION_END = 'transitionend';
  1901. var MAX_UID = 1000000;
  1902. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1903. function toType(obj) {
  1904. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1905. }
  1906. function getSpecialTransitionEndEvent() {
  1907. return {
  1908. bindType: TRANSITION_END,
  1909. delegateType: TRANSITION_END,
  1910. handle: function handle(event) {
  1911. if ($(event.target).is(this)) {
  1912. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1913. }
  1914. return undefined; // eslint-disable-line no-undefined
  1915. }
  1916. };
  1917. }
  1918. function transitionEndEmulator(duration) {
  1919. var _this = this;
  1920. var called = false;
  1921. $(this).one(Util.TRANSITION_END, function () {
  1922. called = true;
  1923. });
  1924. setTimeout(function () {
  1925. if (!called) {
  1926. Util.triggerTransitionEnd(_this);
  1927. }
  1928. }, duration);
  1929. return this;
  1930. }
  1931. function setTransitionEndSupport() {
  1932. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1933. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1934. }
  1935. /**
  1936. * --------------------------------------------------------------------------
  1937. * Public Util Api
  1938. * --------------------------------------------------------------------------
  1939. */
  1940. var Util = {
  1941. TRANSITION_END: 'bsTransitionEnd',
  1942. getUID: function getUID(prefix) {
  1943. do {
  1944. // eslint-disable-next-line no-bitwise
  1945. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1946. } while (document.getElementById(prefix));
  1947. return prefix;
  1948. },
  1949. getSelectorFromElement: function getSelectorFromElement(element) {
  1950. var selector = element.getAttribute('data-target');
  1951. if (!selector || selector === '#') {
  1952. var hrefAttr = element.getAttribute('href');
  1953. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1954. }
  1955. try {
  1956. return document.querySelector(selector) ? selector : null;
  1957. } catch (err) {
  1958. return null;
  1959. }
  1960. },
  1961. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1962. if (!element) {
  1963. return 0;
  1964. } // Get transition-duration of the element
  1965. var transitionDuration = $(element).css('transition-duration');
  1966. var transitionDelay = $(element).css('transition-delay');
  1967. var floatTransitionDuration = parseFloat(transitionDuration);
  1968. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1969. if (!floatTransitionDuration && !floatTransitionDelay) {
  1970. return 0;
  1971. } // If multiple durations are defined, take the first
  1972. transitionDuration = transitionDuration.split(',')[0];
  1973. transitionDelay = transitionDelay.split(',')[0];
  1974. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1975. },
  1976. reflow: function reflow(element) {
  1977. return element.offsetHeight;
  1978. },
  1979. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1980. $(element).trigger(TRANSITION_END);
  1981. },
  1982. // TODO: Remove in v5
  1983. supportsTransitionEnd: function supportsTransitionEnd() {
  1984. return Boolean(TRANSITION_END);
  1985. },
  1986. isElement: function isElement(obj) {
  1987. return (obj[0] || obj).nodeType;
  1988. },
  1989. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1990. for (var property in configTypes) {
  1991. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1992. var expectedTypes = configTypes[property];
  1993. var value = config[property];
  1994. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1995. if (!new RegExp(expectedTypes).test(valueType)) {
  1996. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1997. }
  1998. }
  1999. }
  2000. },
  2001. findShadowRoot: function findShadowRoot(element) {
  2002. if (!document.documentElement.attachShadow) {
  2003. return null;
  2004. } // Can find the shadow root otherwise it'll return the document
  2005. if (typeof element.getRootNode === 'function') {
  2006. var root = element.getRootNode();
  2007. return root instanceof ShadowRoot ? root : null;
  2008. }
  2009. if (element instanceof ShadowRoot) {
  2010. return element;
  2011. } // when we don't find a shadow root
  2012. if (!element.parentNode) {
  2013. return null;
  2014. }
  2015. return Util.findShadowRoot(element.parentNode);
  2016. },
  2017. jQueryDetection: function jQueryDetection() {
  2018. if (typeof $ === 'undefined') {
  2019. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2020. }
  2021. var version = $.fn.jquery.split(' ')[0].split('.');
  2022. var minMajor = 1;
  2023. var ltMajor = 2;
  2024. var minMinor = 9;
  2025. var minPatch = 1;
  2026. var maxMajor = 4;
  2027. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2028. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2029. }
  2030. }
  2031. };
  2032. Util.jQueryDetection();
  2033. setTransitionEndSupport();
  2034. /**
  2035. * ------------------------------------------------------------------------
  2036. * Constants
  2037. * ------------------------------------------------------------------------
  2038. */
  2039. var NAME = 'alert';
  2040. var VERSION = '4.4.1';
  2041. var DATA_KEY = 'bs.alert';
  2042. var EVENT_KEY = "." + DATA_KEY;
  2043. var DATA_API_KEY = '.data-api';
  2044. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2045. var Selector = {
  2046. DISMISS: '[data-dismiss="alert"]'
  2047. };
  2048. var Event = {
  2049. CLOSE: "close" + EVENT_KEY,
  2050. CLOSED: "closed" + EVENT_KEY,
  2051. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2052. };
  2053. var ClassName = {
  2054. ALERT: 'alert',
  2055. FADE: 'fade',
  2056. SHOW: 'show'
  2057. };
  2058. /**
  2059. * ------------------------------------------------------------------------
  2060. * Class Definition
  2061. * ------------------------------------------------------------------------
  2062. */
  2063. var Alert =
  2064. /*#__PURE__*/
  2065. function () {
  2066. function Alert(element) {
  2067. this._element = element;
  2068. } // Getters
  2069. var _proto = Alert.prototype;
  2070. // Public
  2071. _proto.close = function close(element) {
  2072. var rootElement = this._element;
  2073. if (element) {
  2074. rootElement = this._getRootElement(element);
  2075. }
  2076. var customEvent = this._triggerCloseEvent(rootElement);
  2077. if (customEvent.isDefaultPrevented()) {
  2078. return;
  2079. }
  2080. this._removeElement(rootElement);
  2081. };
  2082. _proto.dispose = function dispose() {
  2083. $.removeData(this._element, DATA_KEY);
  2084. this._element = null;
  2085. } // Private
  2086. ;
  2087. _proto._getRootElement = function _getRootElement(element) {
  2088. var selector = Util.getSelectorFromElement(element);
  2089. var parent = false;
  2090. if (selector) {
  2091. parent = document.querySelector(selector);
  2092. }
  2093. if (!parent) {
  2094. parent = $(element).closest("." + ClassName.ALERT)[0];
  2095. }
  2096. return parent;
  2097. };
  2098. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2099. var closeEvent = $.Event(Event.CLOSE);
  2100. $(element).trigger(closeEvent);
  2101. return closeEvent;
  2102. };
  2103. _proto._removeElement = function _removeElement(element) {
  2104. var _this = this;
  2105. $(element).removeClass(ClassName.SHOW);
  2106. if (!$(element).hasClass(ClassName.FADE)) {
  2107. this._destroyElement(element);
  2108. return;
  2109. }
  2110. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2111. $(element).one(Util.TRANSITION_END, function (event) {
  2112. return _this._destroyElement(element, event);
  2113. }).emulateTransitionEnd(transitionDuration);
  2114. };
  2115. _proto._destroyElement = function _destroyElement(element) {
  2116. $(element).detach().trigger(Event.CLOSED).remove();
  2117. } // Static
  2118. ;
  2119. Alert._jQueryInterface = function _jQueryInterface(config) {
  2120. return this.each(function () {
  2121. var $element = $(this);
  2122. var data = $element.data(DATA_KEY);
  2123. if (!data) {
  2124. data = new Alert(this);
  2125. $element.data(DATA_KEY, data);
  2126. }
  2127. if (config === 'close') {
  2128. data[config](this);
  2129. }
  2130. });
  2131. };
  2132. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2133. return function (event) {
  2134. if (event) {
  2135. event.preventDefault();
  2136. }
  2137. alertInstance.close(this);
  2138. };
  2139. };
  2140. _createClass(Alert, null, [{
  2141. key: "VERSION",
  2142. get: function get() {
  2143. return VERSION;
  2144. }
  2145. }]);
  2146. return Alert;
  2147. }();
  2148. /**
  2149. * ------------------------------------------------------------------------
  2150. * Data Api implementation
  2151. * ------------------------------------------------------------------------
  2152. */
  2153. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2154. /**
  2155. * ------------------------------------------------------------------------
  2156. * jQuery
  2157. * ------------------------------------------------------------------------
  2158. */
  2159. $.fn[NAME] = Alert._jQueryInterface;
  2160. $.fn[NAME].Constructor = Alert;
  2161. $.fn[NAME].noConflict = function () {
  2162. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2163. return Alert._jQueryInterface;
  2164. };
  2165. /**
  2166. * ------------------------------------------------------------------------
  2167. * Constants
  2168. * ------------------------------------------------------------------------
  2169. */
  2170. var NAME$1 = 'button';
  2171. var VERSION$1 = '4.4.1';
  2172. var DATA_KEY$1 = 'bs.button';
  2173. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2174. var DATA_API_KEY$1 = '.data-api';
  2175. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2176. var ClassName$1 = {
  2177. ACTIVE: 'active',
  2178. BUTTON: 'btn',
  2179. FOCUS: 'focus'
  2180. };
  2181. var Selector$1 = {
  2182. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2183. DATA_TOGGLES: '[data-toggle="buttons"]',
  2184. DATA_TOGGLE: '[data-toggle="button"]',
  2185. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2186. INPUT: 'input:not([type="hidden"])',
  2187. ACTIVE: '.active',
  2188. BUTTON: '.btn'
  2189. };
  2190. var Event$1 = {
  2191. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2192. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2193. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2194. };
  2195. /**
  2196. * ------------------------------------------------------------------------
  2197. * Class Definition
  2198. * ------------------------------------------------------------------------
  2199. */
  2200. var Button =
  2201. /*#__PURE__*/
  2202. function () {
  2203. function Button(element) {
  2204. this._element = element;
  2205. } // Getters
  2206. var _proto = Button.prototype;
  2207. // Public
  2208. _proto.toggle = function toggle() {
  2209. var triggerChangeEvent = true;
  2210. var addAriaPressed = true;
  2211. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2212. if (rootElement) {
  2213. var input = this._element.querySelector(Selector$1.INPUT);
  2214. if (input) {
  2215. if (input.type === 'radio') {
  2216. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2217. triggerChangeEvent = false;
  2218. } else {
  2219. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2220. if (activeElement) {
  2221. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2222. }
  2223. }
  2224. } else if (input.type === 'checkbox') {
  2225. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2226. triggerChangeEvent = false;
  2227. }
  2228. } else {
  2229. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2230. triggerChangeEvent = false;
  2231. }
  2232. if (triggerChangeEvent) {
  2233. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2234. $(input).trigger('change');
  2235. }
  2236. input.focus();
  2237. addAriaPressed = false;
  2238. }
  2239. }
  2240. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2241. if (addAriaPressed) {
  2242. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2243. }
  2244. if (triggerChangeEvent) {
  2245. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2246. }
  2247. }
  2248. };
  2249. _proto.dispose = function dispose() {
  2250. $.removeData(this._element, DATA_KEY$1);
  2251. this._element = null;
  2252. } // Static
  2253. ;
  2254. Button._jQueryInterface = function _jQueryInterface(config) {
  2255. return this.each(function () {
  2256. var data = $(this).data(DATA_KEY$1);
  2257. if (!data) {
  2258. data = new Button(this);
  2259. $(this).data(DATA_KEY$1, data);
  2260. }
  2261. if (config === 'toggle') {
  2262. data[config]();
  2263. }
  2264. });
  2265. };
  2266. _createClass(Button, null, [{
  2267. key: "VERSION",
  2268. get: function get() {
  2269. return VERSION$1;
  2270. }
  2271. }]);
  2272. return Button;
  2273. }();
  2274. /**
  2275. * ------------------------------------------------------------------------
  2276. * Data Api implementation
  2277. * ------------------------------------------------------------------------
  2278. */
  2279. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2280. var button = event.target;
  2281. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2282. button = $(button).closest(Selector$1.BUTTON)[0];
  2283. }
  2284. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2285. event.preventDefault(); // work around Firefox bug #1540995
  2286. } else {
  2287. var inputBtn = button.querySelector(Selector$1.INPUT);
  2288. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2289. event.preventDefault(); // work around Firefox bug #1540995
  2290. return;
  2291. }
  2292. Button._jQueryInterface.call($(button), 'toggle');
  2293. }
  2294. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2295. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2296. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2297. });
  2298. $(window).on(Event$1.LOAD_DATA_API, function () {
  2299. // ensure correct active class is set to match the controls' actual values/states
  2300. // find all checkboxes/readio buttons inside data-toggle groups
  2301. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2302. for (var i = 0, len = buttons.length; i < len; i++) {
  2303. var button = buttons[i];
  2304. var input = button.querySelector(Selector$1.INPUT);
  2305. if (input.checked || input.hasAttribute('checked')) {
  2306. button.classList.add(ClassName$1.ACTIVE);
  2307. } else {
  2308. button.classList.remove(ClassName$1.ACTIVE);
  2309. }
  2310. } // find all button toggles
  2311. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2312. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2313. var _button = buttons[_i];
  2314. if (_button.getAttribute('aria-pressed') === 'true') {
  2315. _button.classList.add(ClassName$1.ACTIVE);
  2316. } else {
  2317. _button.classList.remove(ClassName$1.ACTIVE);
  2318. }
  2319. }
  2320. });
  2321. /**
  2322. * ------------------------------------------------------------------------
  2323. * jQuery
  2324. * ------------------------------------------------------------------------
  2325. */
  2326. $.fn[NAME$1] = Button._jQueryInterface;
  2327. $.fn[NAME$1].Constructor = Button;
  2328. $.fn[NAME$1].noConflict = function () {
  2329. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2330. return Button._jQueryInterface;
  2331. };
  2332. /**
  2333. * ------------------------------------------------------------------------
  2334. * Constants
  2335. * ------------------------------------------------------------------------
  2336. */
  2337. var NAME$2 = 'carousel';
  2338. var VERSION$2 = '4.4.1';
  2339. var DATA_KEY$2 = 'bs.carousel';
  2340. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2341. var DATA_API_KEY$2 = '.data-api';
  2342. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2343. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2344. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2345. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2346. var SWIPE_THRESHOLD = 40;
  2347. var Default = {
  2348. interval: 5000,
  2349. keyboard: true,
  2350. slide: false,
  2351. pause: 'hover',
  2352. wrap: true,
  2353. touch: true
  2354. };
  2355. var DefaultType = {
  2356. interval: '(number|boolean)',
  2357. keyboard: 'boolean',
  2358. slide: '(boolean|string)',
  2359. pause: '(string|boolean)',
  2360. wrap: 'boolean',
  2361. touch: 'boolean'
  2362. };
  2363. var Direction = {
  2364. NEXT: 'next',
  2365. PREV: 'prev',
  2366. LEFT: 'left',
  2367. RIGHT: 'right'
  2368. };
  2369. var Event$2 = {
  2370. SLIDE: "slide" + EVENT_KEY$2,
  2371. SLID: "slid" + EVENT_KEY$2,
  2372. KEYDOWN: "keydown" + EVENT_KEY$2,
  2373. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2374. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2375. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2376. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2377. TOUCHEND: "touchend" + EVENT_KEY$2,
  2378. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2379. POINTERUP: "pointerup" + EVENT_KEY$2,
  2380. DRAG_START: "dragstart" + EVENT_KEY$2,
  2381. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2382. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2383. };
  2384. var ClassName$2 = {
  2385. CAROUSEL: 'carousel',
  2386. ACTIVE: 'active',
  2387. SLIDE: 'slide',
  2388. RIGHT: 'carousel-item-right',
  2389. LEFT: 'carousel-item-left',
  2390. NEXT: 'carousel-item-next',
  2391. PREV: 'carousel-item-prev',
  2392. ITEM: 'carousel-item',
  2393. POINTER_EVENT: 'pointer-event'
  2394. };
  2395. var Selector$2 = {
  2396. ACTIVE: '.active',
  2397. ACTIVE_ITEM: '.active.carousel-item',
  2398. ITEM: '.carousel-item',
  2399. ITEM_IMG: '.carousel-item img',
  2400. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2401. INDICATORS: '.carousel-indicators',
  2402. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2403. DATA_RIDE: '[data-ride="carousel"]'
  2404. };
  2405. var PointerType = {
  2406. TOUCH: 'touch',
  2407. PEN: 'pen'
  2408. };
  2409. /**
  2410. * ------------------------------------------------------------------------
  2411. * Class Definition
  2412. * ------------------------------------------------------------------------
  2413. */
  2414. var Carousel =
  2415. /*#__PURE__*/
  2416. function () {
  2417. function Carousel(element, config) {
  2418. this._items = null;
  2419. this._interval = null;
  2420. this._activeElement = null;
  2421. this._isPaused = false;
  2422. this._isSliding = false;
  2423. this.touchTimeout = null;
  2424. this.touchStartX = 0;
  2425. this.touchDeltaX = 0;
  2426. this._config = this._getConfig(config);
  2427. this._element = element;
  2428. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2429. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2430. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2431. this._addEventListeners();
  2432. } // Getters
  2433. var _proto = Carousel.prototype;
  2434. // Public
  2435. _proto.next = function next() {
  2436. if (!this._isSliding) {
  2437. this._slide(Direction.NEXT);
  2438. }
  2439. };
  2440. _proto.nextWhenVisible = function nextWhenVisible() {
  2441. // Don't call next when the page isn't visible
  2442. // or the carousel or its parent isn't visible
  2443. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2444. this.next();
  2445. }
  2446. };
  2447. _proto.prev = function prev() {
  2448. if (!this._isSliding) {
  2449. this._slide(Direction.PREV);
  2450. }
  2451. };
  2452. _proto.pause = function pause(event) {
  2453. if (!event) {
  2454. this._isPaused = true;
  2455. }
  2456. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2457. Util.triggerTransitionEnd(this._element);
  2458. this.cycle(true);
  2459. }
  2460. clearInterval(this._interval);
  2461. this._interval = null;
  2462. };
  2463. _proto.cycle = function cycle(event) {
  2464. if (!event) {
  2465. this._isPaused = false;
  2466. }
  2467. if (this._interval) {
  2468. clearInterval(this._interval);
  2469. this._interval = null;
  2470. }
  2471. if (this._config.interval && !this._isPaused) {
  2472. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2473. }
  2474. };
  2475. _proto.to = function to(index) {
  2476. var _this = this;
  2477. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2478. var activeIndex = this._getItemIndex(this._activeElement);
  2479. if (index > this._items.length - 1 || index < 0) {
  2480. return;
  2481. }
  2482. if (this._isSliding) {
  2483. $(this._element).one(Event$2.SLID, function () {
  2484. return _this.to(index);
  2485. });
  2486. return;
  2487. }
  2488. if (activeIndex === index) {
  2489. this.pause();
  2490. this.cycle();
  2491. return;
  2492. }
  2493. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2494. this._slide(direction, this._items[index]);
  2495. };
  2496. _proto.dispose = function dispose() {
  2497. $(this._element).off(EVENT_KEY$2);
  2498. $.removeData(this._element, DATA_KEY$2);
  2499. this._items = null;
  2500. this._config = null;
  2501. this._element = null;
  2502. this._interval = null;
  2503. this._isPaused = null;
  2504. this._isSliding = null;
  2505. this._activeElement = null;
  2506. this._indicatorsElement = null;
  2507. } // Private
  2508. ;
  2509. _proto._getConfig = function _getConfig(config) {
  2510. config = _objectSpread2({}, Default, {}, config);
  2511. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2512. return config;
  2513. };
  2514. _proto._handleSwipe = function _handleSwipe() {
  2515. var absDeltax = Math.abs(this.touchDeltaX);
  2516. if (absDeltax <= SWIPE_THRESHOLD) {
  2517. return;
  2518. }
  2519. var direction = absDeltax / this.touchDeltaX;
  2520. this.touchDeltaX = 0; // swipe left
  2521. if (direction > 0) {
  2522. this.prev();
  2523. } // swipe right
  2524. if (direction < 0) {
  2525. this.next();
  2526. }
  2527. };
  2528. _proto._addEventListeners = function _addEventListeners() {
  2529. var _this2 = this;
  2530. if (this._config.keyboard) {
  2531. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2532. return _this2._keydown(event);
  2533. });
  2534. }
  2535. if (this._config.pause === 'hover') {
  2536. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2537. return _this2.pause(event);
  2538. }).on(Event$2.MOUSELEAVE, function (event) {
  2539. return _this2.cycle(event);
  2540. });
  2541. }
  2542. if (this._config.touch) {
  2543. this._addTouchEventListeners();
  2544. }
  2545. };
  2546. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2547. var _this3 = this;
  2548. if (!this._touchSupported) {
  2549. return;
  2550. }
  2551. var start = function start(event) {
  2552. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2553. _this3.touchStartX = event.originalEvent.clientX;
  2554. } else if (!_this3._pointerEvent) {
  2555. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2556. }
  2557. };
  2558. var move = function move(event) {
  2559. // ensure swiping with one touch and not pinching
  2560. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2561. _this3.touchDeltaX = 0;
  2562. } else {
  2563. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2564. }
  2565. };
  2566. var end = function end(event) {
  2567. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2568. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2569. }
  2570. _this3._handleSwipe();
  2571. if (_this3._config.pause === 'hover') {
  2572. // If it's a touch-enabled device, mouseenter/leave are fired as
  2573. // part of the mouse compatibility events on first tap - the carousel
  2574. // would stop cycling until user tapped out of it;
  2575. // here, we listen for touchend, explicitly pause the carousel
  2576. // (as if it's the second time we tap on it, mouseenter compat event
  2577. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2578. // events to fire) we explicitly restart cycling
  2579. _this3.pause();
  2580. if (_this3.touchTimeout) {
  2581. clearTimeout(_this3.touchTimeout);
  2582. }
  2583. _this3.touchTimeout = setTimeout(function (event) {
  2584. return _this3.cycle(event);
  2585. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2586. }
  2587. };
  2588. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2589. return e.preventDefault();
  2590. });
  2591. if (this._pointerEvent) {
  2592. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2593. return start(event);
  2594. });
  2595. $(this._element).on(Event$2.POINTERUP, function (event) {
  2596. return end(event);
  2597. });
  2598. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2599. } else {
  2600. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2601. return start(event);
  2602. });
  2603. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2604. return move(event);
  2605. });
  2606. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2607. return end(event);
  2608. });
  2609. }
  2610. };
  2611. _proto._keydown = function _keydown(event) {
  2612. if (/input|textarea/i.test(event.target.tagName)) {
  2613. return;
  2614. }
  2615. switch (event.which) {
  2616. case ARROW_LEFT_KEYCODE:
  2617. event.preventDefault();
  2618. this.prev();
  2619. break;
  2620. case ARROW_RIGHT_KEYCODE:
  2621. event.preventDefault();
  2622. this.next();
  2623. break;
  2624. }
  2625. };
  2626. _proto._getItemIndex = function _getItemIndex(element) {
  2627. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2628. return this._items.indexOf(element);
  2629. };
  2630. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2631. var isNextDirection = direction === Direction.NEXT;
  2632. var isPrevDirection = direction === Direction.PREV;
  2633. var activeIndex = this._getItemIndex(activeElement);
  2634. var lastItemIndex = this._items.length - 1;
  2635. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2636. if (isGoingToWrap && !this._config.wrap) {
  2637. return activeElement;
  2638. }
  2639. var delta = direction === Direction.PREV ? -1 : 1;
  2640. var itemIndex = (activeIndex + delta) % this._items.length;
  2641. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2642. };
  2643. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2644. var targetIndex = this._getItemIndex(relatedTarget);
  2645. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2646. var slideEvent = $.Event(Event$2.SLIDE, {
  2647. relatedTarget: relatedTarget,
  2648. direction: eventDirectionName,
  2649. from: fromIndex,
  2650. to: targetIndex
  2651. });
  2652. $(this._element).trigger(slideEvent);
  2653. return slideEvent;
  2654. };
  2655. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2656. if (this._indicatorsElement) {
  2657. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2658. $(indicators).removeClass(ClassName$2.ACTIVE);
  2659. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2660. if (nextIndicator) {
  2661. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2662. }
  2663. }
  2664. };
  2665. _proto._slide = function _slide(direction, element) {
  2666. var _this4 = this;
  2667. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2668. var activeElementIndex = this._getItemIndex(activeElement);
  2669. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2670. var nextElementIndex = this._getItemIndex(nextElement);
  2671. var isCycling = Boolean(this._interval);
  2672. var directionalClassName;
  2673. var orderClassName;
  2674. var eventDirectionName;
  2675. if (direction === Direction.NEXT) {
  2676. directionalClassName = ClassName$2.LEFT;
  2677. orderClassName = ClassName$2.NEXT;
  2678. eventDirectionName = Direction.LEFT;
  2679. } else {
  2680. directionalClassName = ClassName$2.RIGHT;
  2681. orderClassName = ClassName$2.PREV;
  2682. eventDirectionName = Direction.RIGHT;
  2683. }
  2684. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2685. this._isSliding = false;
  2686. return;
  2687. }
  2688. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2689. if (slideEvent.isDefaultPrevented()) {
  2690. return;
  2691. }
  2692. if (!activeElement || !nextElement) {
  2693. // Some weirdness is happening, so we bail
  2694. return;
  2695. }
  2696. this._isSliding = true;
  2697. if (isCycling) {
  2698. this.pause();
  2699. }
  2700. this._setActiveIndicatorElement(nextElement);
  2701. var slidEvent = $.Event(Event$2.SLID, {
  2702. relatedTarget: nextElement,
  2703. direction: eventDirectionName,
  2704. from: activeElementIndex,
  2705. to: nextElementIndex
  2706. });
  2707. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2708. $(nextElement).addClass(orderClassName);
  2709. Util.reflow(nextElement);
  2710. $(activeElement).addClass(directionalClassName);
  2711. $(nextElement).addClass(directionalClassName);
  2712. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2713. if (nextElementInterval) {
  2714. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2715. this._config.interval = nextElementInterval;
  2716. } else {
  2717. this._config.interval = this._config.defaultInterval || this._config.interval;
  2718. }
  2719. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2720. $(activeElement).one(Util.TRANSITION_END, function () {
  2721. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2722. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2723. _this4._isSliding = false;
  2724. setTimeout(function () {
  2725. return $(_this4._element).trigger(slidEvent);
  2726. }, 0);
  2727. }).emulateTransitionEnd(transitionDuration);
  2728. } else {
  2729. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2730. $(nextElement).addClass(ClassName$2.ACTIVE);
  2731. this._isSliding = false;
  2732. $(this._element).trigger(slidEvent);
  2733. }
  2734. if (isCycling) {
  2735. this.cycle();
  2736. }
  2737. } // Static
  2738. ;
  2739. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2740. return this.each(function () {
  2741. var data = $(this).data(DATA_KEY$2);
  2742. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2743. if (typeof config === 'object') {
  2744. _config = _objectSpread2({}, _config, {}, config);
  2745. }
  2746. var action = typeof config === 'string' ? config : _config.slide;
  2747. if (!data) {
  2748. data = new Carousel(this, _config);
  2749. $(this).data(DATA_KEY$2, data);
  2750. }
  2751. if (typeof config === 'number') {
  2752. data.to(config);
  2753. } else if (typeof action === 'string') {
  2754. if (typeof data[action] === 'undefined') {
  2755. throw new TypeError("No method named \"" + action + "\"");
  2756. }
  2757. data[action]();
  2758. } else if (_config.interval && _config.ride) {
  2759. data.pause();
  2760. data.cycle();
  2761. }
  2762. });
  2763. };
  2764. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2765. var selector = Util.getSelectorFromElement(this);
  2766. if (!selector) {
  2767. return;
  2768. }
  2769. var target = $(selector)[0];
  2770. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2771. return;
  2772. }
  2773. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2774. var slideIndex = this.getAttribute('data-slide-to');
  2775. if (slideIndex) {
  2776. config.interval = false;
  2777. }
  2778. Carousel._jQueryInterface.call($(target), config);
  2779. if (slideIndex) {
  2780. $(target).data(DATA_KEY$2).to(slideIndex);
  2781. }
  2782. event.preventDefault();
  2783. };
  2784. _createClass(Carousel, null, [{
  2785. key: "VERSION",
  2786. get: function get() {
  2787. return VERSION$2;
  2788. }
  2789. }, {
  2790. key: "Default",
  2791. get: function get() {
  2792. return Default;
  2793. }
  2794. }]);
  2795. return Carousel;
  2796. }();
  2797. /**
  2798. * ------------------------------------------------------------------------
  2799. * Data Api implementation
  2800. * ------------------------------------------------------------------------
  2801. */
  2802. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2803. $(window).on(Event$2.LOAD_DATA_API, function () {
  2804. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2805. for (var i = 0, len = carousels.length; i < len; i++) {
  2806. var $carousel = $(carousels[i]);
  2807. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2808. }
  2809. });
  2810. /**
  2811. * ------------------------------------------------------------------------
  2812. * jQuery
  2813. * ------------------------------------------------------------------------
  2814. */
  2815. $.fn[NAME$2] = Carousel._jQueryInterface;
  2816. $.fn[NAME$2].Constructor = Carousel;
  2817. $.fn[NAME$2].noConflict = function () {
  2818. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2819. return Carousel._jQueryInterface;
  2820. };
  2821. /**
  2822. * ------------------------------------------------------------------------
  2823. * Constants
  2824. * ------------------------------------------------------------------------
  2825. */
  2826. var NAME$3 = 'collapse';
  2827. var VERSION$3 = '4.4.1';
  2828. var DATA_KEY$3 = 'bs.collapse';
  2829. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2830. var DATA_API_KEY$3 = '.data-api';
  2831. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2832. var Default$1 = {
  2833. toggle: true,
  2834. parent: ''
  2835. };
  2836. var DefaultType$1 = {
  2837. toggle: 'boolean',
  2838. parent: '(string|element)'
  2839. };
  2840. var Event$3 = {
  2841. SHOW: "show" + EVENT_KEY$3,
  2842. SHOWN: "shown" + EVENT_KEY$3,
  2843. HIDE: "hide" + EVENT_KEY$3,
  2844. HIDDEN: "hidden" + EVENT_KEY$3,
  2845. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2846. };
  2847. var ClassName$3 = {
  2848. SHOW: 'show',
  2849. COLLAPSE: 'collapse',
  2850. COLLAPSING: 'collapsing',
  2851. COLLAPSED: 'collapsed'
  2852. };
  2853. var Dimension = {
  2854. WIDTH: 'width',
  2855. HEIGHT: 'height'
  2856. };
  2857. var Selector$3 = {
  2858. ACTIVES: '.show, .collapsing',
  2859. DATA_TOGGLE: '[data-toggle="collapse"]'
  2860. };
  2861. /**
  2862. * ------------------------------------------------------------------------
  2863. * Class Definition
  2864. * ------------------------------------------------------------------------
  2865. */
  2866. var Collapse =
  2867. /*#__PURE__*/
  2868. function () {
  2869. function Collapse(element, config) {
  2870. this._isTransitioning = false;
  2871. this._element = element;
  2872. this._config = this._getConfig(config);
  2873. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2874. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2875. for (var i = 0, len = toggleList.length; i < len; i++) {
  2876. var elem = toggleList[i];
  2877. var selector = Util.getSelectorFromElement(elem);
  2878. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2879. return foundElem === element;
  2880. });
  2881. if (selector !== null && filterElement.length > 0) {
  2882. this._selector = selector;
  2883. this._triggerArray.push(elem);
  2884. }
  2885. }
  2886. this._parent = this._config.parent ? this._getParent() : null;
  2887. if (!this._config.parent) {
  2888. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2889. }
  2890. if (this._config.toggle) {
  2891. this.toggle();
  2892. }
  2893. } // Getters
  2894. var _proto = Collapse.prototype;
  2895. // Public
  2896. _proto.toggle = function toggle() {
  2897. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2898. this.hide();
  2899. } else {
  2900. this.show();
  2901. }
  2902. };
  2903. _proto.show = function show() {
  2904. var _this = this;
  2905. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2906. return;
  2907. }
  2908. var actives;
  2909. var activesData;
  2910. if (this._parent) {
  2911. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2912. if (typeof _this._config.parent === 'string') {
  2913. return elem.getAttribute('data-parent') === _this._config.parent;
  2914. }
  2915. return elem.classList.contains(ClassName$3.COLLAPSE);
  2916. });
  2917. if (actives.length === 0) {
  2918. actives = null;
  2919. }
  2920. }
  2921. if (actives) {
  2922. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2923. if (activesData && activesData._isTransitioning) {
  2924. return;
  2925. }
  2926. }
  2927. var startEvent = $.Event(Event$3.SHOW);
  2928. $(this._element).trigger(startEvent);
  2929. if (startEvent.isDefaultPrevented()) {
  2930. return;
  2931. }
  2932. if (actives) {
  2933. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2934. if (!activesData) {
  2935. $(actives).data(DATA_KEY$3, null);
  2936. }
  2937. }
  2938. var dimension = this._getDimension();
  2939. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2940. this._element.style[dimension] = 0;
  2941. if (this._triggerArray.length) {
  2942. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2943. }
  2944. this.setTransitioning(true);
  2945. var complete = function complete() {
  2946. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2947. _this._element.style[dimension] = '';
  2948. _this.setTransitioning(false);
  2949. $(_this._element).trigger(Event$3.SHOWN);
  2950. };
  2951. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2952. var scrollSize = "scroll" + capitalizedDimension;
  2953. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2954. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2955. this._element.style[dimension] = this._element[scrollSize] + "px";
  2956. };
  2957. _proto.hide = function hide() {
  2958. var _this2 = this;
  2959. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2960. return;
  2961. }
  2962. var startEvent = $.Event(Event$3.HIDE);
  2963. $(this._element).trigger(startEvent);
  2964. if (startEvent.isDefaultPrevented()) {
  2965. return;
  2966. }
  2967. var dimension = this._getDimension();
  2968. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2969. Util.reflow(this._element);
  2970. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2971. var triggerArrayLength = this._triggerArray.length;
  2972. if (triggerArrayLength > 0) {
  2973. for (var i = 0; i < triggerArrayLength; i++) {
  2974. var trigger = this._triggerArray[i];
  2975. var selector = Util.getSelectorFromElement(trigger);
  2976. if (selector !== null) {
  2977. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2978. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2979. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2980. }
  2981. }
  2982. }
  2983. }
  2984. this.setTransitioning(true);
  2985. var complete = function complete() {
  2986. _this2.setTransitioning(false);
  2987. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2988. };
  2989. this._element.style[dimension] = '';
  2990. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2991. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2992. };
  2993. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2994. this._isTransitioning = isTransitioning;
  2995. };
  2996. _proto.dispose = function dispose() {
  2997. $.removeData(this._element, DATA_KEY$3);
  2998. this._config = null;
  2999. this._parent = null;
  3000. this._element = null;
  3001. this._triggerArray = null;
  3002. this._isTransitioning = null;
  3003. } // Private
  3004. ;
  3005. _proto._getConfig = function _getConfig(config) {
  3006. config = _objectSpread2({}, Default$1, {}, config);
  3007. config.toggle = Boolean(config.toggle); // Coerce string values
  3008. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3009. return config;
  3010. };
  3011. _proto._getDimension = function _getDimension() {
  3012. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3013. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3014. };
  3015. _proto._getParent = function _getParent() {
  3016. var _this3 = this;
  3017. var parent;
  3018. if (Util.isElement(this._config.parent)) {
  3019. parent = this._config.parent; // It's a jQuery object
  3020. if (typeof this._config.parent.jquery !== 'undefined') {
  3021. parent = this._config.parent[0];
  3022. }
  3023. } else {
  3024. parent = document.querySelector(this._config.parent);
  3025. }
  3026. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3027. var children = [].slice.call(parent.querySelectorAll(selector));
  3028. $(children).each(function (i, element) {
  3029. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3030. });
  3031. return parent;
  3032. };
  3033. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3034. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3035. if (triggerArray.length) {
  3036. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3037. }
  3038. } // Static
  3039. ;
  3040. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3041. var selector = Util.getSelectorFromElement(element);
  3042. return selector ? document.querySelector(selector) : null;
  3043. };
  3044. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3045. return this.each(function () {
  3046. var $this = $(this);
  3047. var data = $this.data(DATA_KEY$3);
  3048. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3049. if (!data && _config.toggle && /show|hide/.test(config)) {
  3050. _config.toggle = false;
  3051. }
  3052. if (!data) {
  3053. data = new Collapse(this, _config);
  3054. $this.data(DATA_KEY$3, data);
  3055. }
  3056. if (typeof config === 'string') {
  3057. if (typeof data[config] === 'undefined') {
  3058. throw new TypeError("No method named \"" + config + "\"");
  3059. }
  3060. data[config]();
  3061. }
  3062. });
  3063. };
  3064. _createClass(Collapse, null, [{
  3065. key: "VERSION",
  3066. get: function get() {
  3067. return VERSION$3;
  3068. }
  3069. }, {
  3070. key: "Default",
  3071. get: function get() {
  3072. return Default$1;
  3073. }
  3074. }]);
  3075. return Collapse;
  3076. }();
  3077. /**
  3078. * ------------------------------------------------------------------------
  3079. * Data Api implementation
  3080. * ------------------------------------------------------------------------
  3081. */
  3082. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3083. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3084. if (event.currentTarget.tagName === 'A') {
  3085. event.preventDefault();
  3086. }
  3087. var $trigger = $(this);
  3088. var selector = Util.getSelectorFromElement(this);
  3089. var selectors = [].slice.call(document.querySelectorAll(selector));
  3090. $(selectors).each(function () {
  3091. var $target = $(this);
  3092. var data = $target.data(DATA_KEY$3);
  3093. var config = data ? 'toggle' : $trigger.data();
  3094. Collapse._jQueryInterface.call($target, config);
  3095. });
  3096. });
  3097. /**
  3098. * ------------------------------------------------------------------------
  3099. * jQuery
  3100. * ------------------------------------------------------------------------
  3101. */
  3102. $.fn[NAME$3] = Collapse._jQueryInterface;
  3103. $.fn[NAME$3].Constructor = Collapse;
  3104. $.fn[NAME$3].noConflict = function () {
  3105. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3106. return Collapse._jQueryInterface;
  3107. };
  3108. /**
  3109. * ------------------------------------------------------------------------
  3110. * Constants
  3111. * ------------------------------------------------------------------------
  3112. */
  3113. var NAME$4 = 'dropdown';
  3114. var VERSION$4 = '4.4.1';
  3115. var DATA_KEY$4 = 'bs.dropdown';
  3116. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3117. var DATA_API_KEY$4 = '.data-api';
  3118. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3119. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3120. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3121. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3122. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3123. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3124. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3125. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3126. var Event$4 = {
  3127. HIDE: "hide" + EVENT_KEY$4,
  3128. HIDDEN: "hidden" + EVENT_KEY$4,
  3129. SHOW: "show" + EVENT_KEY$4,
  3130. SHOWN: "shown" + EVENT_KEY$4,
  3131. CLICK: "click" + EVENT_KEY$4,
  3132. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3133. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3134. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3135. };
  3136. var ClassName$4 = {
  3137. DISABLED: 'disabled',
  3138. SHOW: 'show',
  3139. DROPUP: 'dropup',
  3140. DROPRIGHT: 'dropright',
  3141. DROPLEFT: 'dropleft',
  3142. MENURIGHT: 'dropdown-menu-right',
  3143. MENULEFT: 'dropdown-menu-left',
  3144. POSITION_STATIC: 'position-static'
  3145. };
  3146. var Selector$4 = {
  3147. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3148. FORM_CHILD: '.dropdown form',
  3149. MENU: '.dropdown-menu',
  3150. NAVBAR_NAV: '.navbar-nav',
  3151. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3152. };
  3153. var AttachmentMap = {
  3154. TOP: 'top-start',
  3155. TOPEND: 'top-end',
  3156. BOTTOM: 'bottom-start',
  3157. BOTTOMEND: 'bottom-end',
  3158. RIGHT: 'right-start',
  3159. RIGHTEND: 'right-end',
  3160. LEFT: 'left-start',
  3161. LEFTEND: 'left-end'
  3162. };
  3163. var Default$2 = {
  3164. offset: 0,
  3165. flip: true,
  3166. boundary: 'scrollParent',
  3167. reference: 'toggle',
  3168. display: 'dynamic',
  3169. popperConfig: null
  3170. };
  3171. var DefaultType$2 = {
  3172. offset: '(number|string|function)',
  3173. flip: 'boolean',
  3174. boundary: '(string|element)',
  3175. reference: '(string|element)',
  3176. display: 'string',
  3177. popperConfig: '(null|object)'
  3178. };
  3179. /**
  3180. * ------------------------------------------------------------------------
  3181. * Class Definition
  3182. * ------------------------------------------------------------------------
  3183. */
  3184. var Dropdown =
  3185. /*#__PURE__*/
  3186. function () {
  3187. function Dropdown(element, config) {
  3188. this._element = element;
  3189. this._popper = null;
  3190. this._config = this._getConfig(config);
  3191. this._menu = this._getMenuElement();
  3192. this._inNavbar = this._detectNavbar();
  3193. this._addEventListeners();
  3194. } // Getters
  3195. var _proto = Dropdown.prototype;
  3196. // Public
  3197. _proto.toggle = function toggle() {
  3198. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3199. return;
  3200. }
  3201. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3202. Dropdown._clearMenus();
  3203. if (isActive) {
  3204. return;
  3205. }
  3206. this.show(true);
  3207. };
  3208. _proto.show = function show(usePopper) {
  3209. if (usePopper === void 0) {
  3210. usePopper = false;
  3211. }
  3212. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3213. return;
  3214. }
  3215. var relatedTarget = {
  3216. relatedTarget: this._element
  3217. };
  3218. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3219. var parent = Dropdown._getParentFromElement(this._element);
  3220. $(parent).trigger(showEvent);
  3221. if (showEvent.isDefaultPrevented()) {
  3222. return;
  3223. } // Disable totally Popper.js for Dropdown in Navbar
  3224. if (!this._inNavbar && usePopper) {
  3225. /**
  3226. * Check for Popper dependency
  3227. * Popper - https://popper.js.org
  3228. */
  3229. if (typeof Popper === 'undefined') {
  3230. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3231. }
  3232. var referenceElement = this._element;
  3233. if (this._config.reference === 'parent') {
  3234. referenceElement = parent;
  3235. } else if (Util.isElement(this._config.reference)) {
  3236. referenceElement = this._config.reference; // Check if it's jQuery element
  3237. if (typeof this._config.reference.jquery !== 'undefined') {
  3238. referenceElement = this._config.reference[0];
  3239. }
  3240. } // If boundary is not `scrollParent`, then set position to `static`
  3241. // to allow the menu to "escape" the scroll parent's boundaries
  3242. // https://github.com/twbs/bootstrap/issues/24251
  3243. if (this._config.boundary !== 'scrollParent') {
  3244. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3245. }
  3246. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3247. } // If this is a touch-enabled device we add extra
  3248. // empty mouseover listeners to the body's immediate children;
  3249. // only needed because of broken event delegation on iOS
  3250. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3251. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3252. $(document.body).children().on('mouseover', null, $.noop);
  3253. }
  3254. this._element.focus();
  3255. this._element.setAttribute('aria-expanded', true);
  3256. $(this._menu).toggleClass(ClassName$4.SHOW);
  3257. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3258. };
  3259. _proto.hide = function hide() {
  3260. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3261. return;
  3262. }
  3263. var relatedTarget = {
  3264. relatedTarget: this._element
  3265. };
  3266. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3267. var parent = Dropdown._getParentFromElement(this._element);
  3268. $(parent).trigger(hideEvent);
  3269. if (hideEvent.isDefaultPrevented()) {
  3270. return;
  3271. }
  3272. if (this._popper) {
  3273. this._popper.destroy();
  3274. }
  3275. $(this._menu).toggleClass(ClassName$4.SHOW);
  3276. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3277. };
  3278. _proto.dispose = function dispose() {
  3279. $.removeData(this._element, DATA_KEY$4);
  3280. $(this._element).off(EVENT_KEY$4);
  3281. this._element = null;
  3282. this._menu = null;
  3283. if (this._popper !== null) {
  3284. this._popper.destroy();
  3285. this._popper = null;
  3286. }
  3287. };
  3288. _proto.update = function update() {
  3289. this._inNavbar = this._detectNavbar();
  3290. if (this._popper !== null) {
  3291. this._popper.scheduleUpdate();
  3292. }
  3293. } // Private
  3294. ;
  3295. _proto._addEventListeners = function _addEventListeners() {
  3296. var _this = this;
  3297. $(this._element).on(Event$4.CLICK, function (event) {
  3298. event.preventDefault();
  3299. event.stopPropagation();
  3300. _this.toggle();
  3301. });
  3302. };
  3303. _proto._getConfig = function _getConfig(config) {
  3304. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3305. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3306. return config;
  3307. };
  3308. _proto._getMenuElement = function _getMenuElement() {
  3309. if (!this._menu) {
  3310. var parent = Dropdown._getParentFromElement(this._element);
  3311. if (parent) {
  3312. this._menu = parent.querySelector(Selector$4.MENU);
  3313. }
  3314. }
  3315. return this._menu;
  3316. };
  3317. _proto._getPlacement = function _getPlacement() {
  3318. var $parentDropdown = $(this._element.parentNode);
  3319. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3320. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3321. placement = AttachmentMap.TOP;
  3322. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3323. placement = AttachmentMap.TOPEND;
  3324. }
  3325. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3326. placement = AttachmentMap.RIGHT;
  3327. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3328. placement = AttachmentMap.LEFT;
  3329. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3330. placement = AttachmentMap.BOTTOMEND;
  3331. }
  3332. return placement;
  3333. };
  3334. _proto._detectNavbar = function _detectNavbar() {
  3335. return $(this._element).closest('.navbar').length > 0;
  3336. };
  3337. _proto._getOffset = function _getOffset() {
  3338. var _this2 = this;
  3339. var offset = {};
  3340. if (typeof this._config.offset === 'function') {
  3341. offset.fn = function (data) {
  3342. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3343. return data;
  3344. };
  3345. } else {
  3346. offset.offset = this._config.offset;
  3347. }
  3348. return offset;
  3349. };
  3350. _proto._getPopperConfig = function _getPopperConfig() {
  3351. var popperConfig = {
  3352. placement: this._getPlacement(),
  3353. modifiers: {
  3354. offset: this._getOffset(),
  3355. flip: {
  3356. enabled: this._config.flip
  3357. },
  3358. preventOverflow: {
  3359. boundariesElement: this._config.boundary
  3360. }
  3361. }
  3362. }; // Disable Popper.js if we have a static display
  3363. if (this._config.display === 'static') {
  3364. popperConfig.modifiers.applyStyle = {
  3365. enabled: false
  3366. };
  3367. }
  3368. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3369. } // Static
  3370. ;
  3371. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3372. return this.each(function () {
  3373. var data = $(this).data(DATA_KEY$4);
  3374. var _config = typeof config === 'object' ? config : null;
  3375. if (!data) {
  3376. data = new Dropdown(this, _config);
  3377. $(this).data(DATA_KEY$4, data);
  3378. }
  3379. if (typeof config === 'string') {
  3380. if (typeof data[config] === 'undefined') {
  3381. throw new TypeError("No method named \"" + config + "\"");
  3382. }
  3383. data[config]();
  3384. }
  3385. });
  3386. };
  3387. Dropdown._clearMenus = function _clearMenus(event) {
  3388. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3389. return;
  3390. }
  3391. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3392. for (var i = 0, len = toggles.length; i < len; i++) {
  3393. var parent = Dropdown._getParentFromElement(toggles[i]);
  3394. var context = $(toggles[i]).data(DATA_KEY$4);
  3395. var relatedTarget = {
  3396. relatedTarget: toggles[i]
  3397. };
  3398. if (event && event.type === 'click') {
  3399. relatedTarget.clickEvent = event;
  3400. }
  3401. if (!context) {
  3402. continue;
  3403. }
  3404. var dropdownMenu = context._menu;
  3405. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3406. continue;
  3407. }
  3408. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3409. continue;
  3410. }
  3411. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3412. $(parent).trigger(hideEvent);
  3413. if (hideEvent.isDefaultPrevented()) {
  3414. continue;
  3415. } // If this is a touch-enabled device we remove the extra
  3416. // empty mouseover listeners we added for iOS support
  3417. if ('ontouchstart' in document.documentElement) {
  3418. $(document.body).children().off('mouseover', null, $.noop);
  3419. }
  3420. toggles[i].setAttribute('aria-expanded', 'false');
  3421. if (context._popper) {
  3422. context._popper.destroy();
  3423. }
  3424. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3425. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3426. }
  3427. };
  3428. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3429. var parent;
  3430. var selector = Util.getSelectorFromElement(element);
  3431. if (selector) {
  3432. parent = document.querySelector(selector);
  3433. }
  3434. return parent || element.parentNode;
  3435. } // eslint-disable-next-line complexity
  3436. ;
  3437. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3438. // If not input/textarea:
  3439. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3440. // If input/textarea:
  3441. // - If space key => not a dropdown command
  3442. // - If key is other than escape
  3443. // - If key is not up or down => not a dropdown command
  3444. // - If trigger inside the menu => not a dropdown command
  3445. 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)) {
  3446. return;
  3447. }
  3448. event.preventDefault();
  3449. event.stopPropagation();
  3450. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3451. return;
  3452. }
  3453. var parent = Dropdown._getParentFromElement(this);
  3454. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3455. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3456. return;
  3457. }
  3458. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3459. if (event.which === ESCAPE_KEYCODE) {
  3460. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3461. $(toggle).trigger('focus');
  3462. }
  3463. $(this).trigger('click');
  3464. return;
  3465. }
  3466. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3467. return $(item).is(':visible');
  3468. });
  3469. if (items.length === 0) {
  3470. return;
  3471. }
  3472. var index = items.indexOf(event.target);
  3473. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3474. // Up
  3475. index--;
  3476. }
  3477. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3478. // Down
  3479. index++;
  3480. }
  3481. if (index < 0) {
  3482. index = 0;
  3483. }
  3484. items[index].focus();
  3485. };
  3486. _createClass(Dropdown, null, [{
  3487. key: "VERSION",
  3488. get: function get() {
  3489. return VERSION$4;
  3490. }
  3491. }, {
  3492. key: "Default",
  3493. get: function get() {
  3494. return Default$2;
  3495. }
  3496. }, {
  3497. key: "DefaultType",
  3498. get: function get() {
  3499. return DefaultType$2;
  3500. }
  3501. }]);
  3502. return Dropdown;
  3503. }();
  3504. /**
  3505. * ------------------------------------------------------------------------
  3506. * Data Api implementation
  3507. * ------------------------------------------------------------------------
  3508. */
  3509. $(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) {
  3510. event.preventDefault();
  3511. event.stopPropagation();
  3512. Dropdown._jQueryInterface.call($(this), 'toggle');
  3513. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3514. e.stopPropagation();
  3515. });
  3516. /**
  3517. * ------------------------------------------------------------------------
  3518. * jQuery
  3519. * ------------------------------------------------------------------------
  3520. */
  3521. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3522. $.fn[NAME$4].Constructor = Dropdown;
  3523. $.fn[NAME$4].noConflict = function () {
  3524. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3525. return Dropdown._jQueryInterface;
  3526. };
  3527. /**
  3528. * ------------------------------------------------------------------------
  3529. * Constants
  3530. * ------------------------------------------------------------------------
  3531. */
  3532. var NAME$5 = 'modal';
  3533. var VERSION$5 = '4.4.1';
  3534. var DATA_KEY$5 = 'bs.modal';
  3535. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3536. var DATA_API_KEY$5 = '.data-api';
  3537. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3538. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3539. var Default$3 = {
  3540. backdrop: true,
  3541. keyboard: true,
  3542. focus: true,
  3543. show: true
  3544. };
  3545. var DefaultType$3 = {
  3546. backdrop: '(boolean|string)',
  3547. keyboard: 'boolean',
  3548. focus: 'boolean',
  3549. show: 'boolean'
  3550. };
  3551. var Event$5 = {
  3552. HIDE: "hide" + EVENT_KEY$5,
  3553. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3554. HIDDEN: "hidden" + EVENT_KEY$5,
  3555. SHOW: "show" + EVENT_KEY$5,
  3556. SHOWN: "shown" + EVENT_KEY$5,
  3557. FOCUSIN: "focusin" + EVENT_KEY$5,
  3558. RESIZE: "resize" + EVENT_KEY$5,
  3559. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3560. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3561. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3562. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3563. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3564. };
  3565. var ClassName$5 = {
  3566. SCROLLABLE: 'modal-dialog-scrollable',
  3567. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3568. BACKDROP: 'modal-backdrop',
  3569. OPEN: 'modal-open',
  3570. FADE: 'fade',
  3571. SHOW: 'show',
  3572. STATIC: 'modal-static'
  3573. };
  3574. var Selector$5 = {
  3575. DIALOG: '.modal-dialog',
  3576. MODAL_BODY: '.modal-body',
  3577. DATA_TOGGLE: '[data-toggle="modal"]',
  3578. DATA_DISMISS: '[data-dismiss="modal"]',
  3579. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3580. STICKY_CONTENT: '.sticky-top'
  3581. };
  3582. /**
  3583. * ------------------------------------------------------------------------
  3584. * Class Definition
  3585. * ------------------------------------------------------------------------
  3586. */
  3587. var Modal =
  3588. /*#__PURE__*/
  3589. function () {
  3590. function Modal(element, config) {
  3591. this._config = this._getConfig(config);
  3592. this._element = element;
  3593. this._dialog = element.querySelector(Selector$5.DIALOG);
  3594. this._backdrop = null;
  3595. this._isShown = false;
  3596. this._isBodyOverflowing = false;
  3597. this._ignoreBackdropClick = false;
  3598. this._isTransitioning = false;
  3599. this._scrollbarWidth = 0;
  3600. } // Getters
  3601. var _proto = Modal.prototype;
  3602. // Public
  3603. _proto.toggle = function toggle(relatedTarget) {
  3604. return this._isShown ? this.hide() : this.show(relatedTarget);
  3605. };
  3606. _proto.show = function show(relatedTarget) {
  3607. var _this = this;
  3608. if (this._isShown || this._isTransitioning) {
  3609. return;
  3610. }
  3611. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3612. this._isTransitioning = true;
  3613. }
  3614. var showEvent = $.Event(Event$5.SHOW, {
  3615. relatedTarget: relatedTarget
  3616. });
  3617. $(this._element).trigger(showEvent);
  3618. if (this._isShown || showEvent.isDefaultPrevented()) {
  3619. return;
  3620. }
  3621. this._isShown = true;
  3622. this._checkScrollbar();
  3623. this._setScrollbar();
  3624. this._adjustDialog();
  3625. this._setEscapeEvent();
  3626. this._setResizeEvent();
  3627. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3628. return _this.hide(event);
  3629. });
  3630. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3631. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3632. if ($(event.target).is(_this._element)) {
  3633. _this._ignoreBackdropClick = true;
  3634. }
  3635. });
  3636. });
  3637. this._showBackdrop(function () {
  3638. return _this._showElement(relatedTarget);
  3639. });
  3640. };
  3641. _proto.hide = function hide(event) {
  3642. var _this2 = this;
  3643. if (event) {
  3644. event.preventDefault();
  3645. }
  3646. if (!this._isShown || this._isTransitioning) {
  3647. return;
  3648. }
  3649. var hideEvent = $.Event(Event$5.HIDE);
  3650. $(this._element).trigger(hideEvent);
  3651. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3652. return;
  3653. }
  3654. this._isShown = false;
  3655. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3656. if (transition) {
  3657. this._isTransitioning = true;
  3658. }
  3659. this._setEscapeEvent();
  3660. this._setResizeEvent();
  3661. $(document).off(Event$5.FOCUSIN);
  3662. $(this._element).removeClass(ClassName$5.SHOW);
  3663. $(this._element).off(Event$5.CLICK_DISMISS);
  3664. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3665. if (transition) {
  3666. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3667. $(this._element).one(Util.TRANSITION_END, function (event) {
  3668. return _this2._hideModal(event);
  3669. }).emulateTransitionEnd(transitionDuration);
  3670. } else {
  3671. this._hideModal();
  3672. }
  3673. };
  3674. _proto.dispose = function dispose() {
  3675. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3676. return $(htmlElement).off(EVENT_KEY$5);
  3677. });
  3678. /**
  3679. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3680. * Do not move `document` in `htmlElements` array
  3681. * It will remove `Event.CLICK_DATA_API` event that should remain
  3682. */
  3683. $(document).off(Event$5.FOCUSIN);
  3684. $.removeData(this._element, DATA_KEY$5);
  3685. this._config = null;
  3686. this._element = null;
  3687. this._dialog = null;
  3688. this._backdrop = null;
  3689. this._isShown = null;
  3690. this._isBodyOverflowing = null;
  3691. this._ignoreBackdropClick = null;
  3692. this._isTransitioning = null;
  3693. this._scrollbarWidth = null;
  3694. };
  3695. _proto.handleUpdate = function handleUpdate() {
  3696. this._adjustDialog();
  3697. } // Private
  3698. ;
  3699. _proto._getConfig = function _getConfig(config) {
  3700. config = _objectSpread2({}, Default$3, {}, config);
  3701. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3702. return config;
  3703. };
  3704. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3705. var _this3 = this;
  3706. if (this._config.backdrop === 'static') {
  3707. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3708. $(this._element).trigger(hideEventPrevented);
  3709. if (hideEventPrevented.defaultPrevented) {
  3710. return;
  3711. }
  3712. this._element.classList.add(ClassName$5.STATIC);
  3713. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3714. $(this._element).one(Util.TRANSITION_END, function () {
  3715. _this3._element.classList.remove(ClassName$5.STATIC);
  3716. }).emulateTransitionEnd(modalTransitionDuration);
  3717. this._element.focus();
  3718. } else {
  3719. this.hide();
  3720. }
  3721. };
  3722. _proto._showElement = function _showElement(relatedTarget) {
  3723. var _this4 = this;
  3724. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3725. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3726. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3727. // Don't move modal's DOM position
  3728. document.body.appendChild(this._element);
  3729. }
  3730. this._element.style.display = 'block';
  3731. this._element.removeAttribute('aria-hidden');
  3732. this._element.setAttribute('aria-modal', true);
  3733. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3734. modalBody.scrollTop = 0;
  3735. } else {
  3736. this._element.scrollTop = 0;
  3737. }
  3738. if (transition) {
  3739. Util.reflow(this._element);
  3740. }
  3741. $(this._element).addClass(ClassName$5.SHOW);
  3742. if (this._config.focus) {
  3743. this._enforceFocus();
  3744. }
  3745. var shownEvent = $.Event(Event$5.SHOWN, {
  3746. relatedTarget: relatedTarget
  3747. });
  3748. var transitionComplete = function transitionComplete() {
  3749. if (_this4._config.focus) {
  3750. _this4._element.focus();
  3751. }
  3752. _this4._isTransitioning = false;
  3753. $(_this4._element).trigger(shownEvent);
  3754. };
  3755. if (transition) {
  3756. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3757. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3758. } else {
  3759. transitionComplete();
  3760. }
  3761. };
  3762. _proto._enforceFocus = function _enforceFocus() {
  3763. var _this5 = this;
  3764. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3765. .on(Event$5.FOCUSIN, function (event) {
  3766. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3767. _this5._element.focus();
  3768. }
  3769. });
  3770. };
  3771. _proto._setEscapeEvent = function _setEscapeEvent() {
  3772. var _this6 = this;
  3773. if (this._isShown && this._config.keyboard) {
  3774. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3775. if (event.which === ESCAPE_KEYCODE$1) {
  3776. _this6._triggerBackdropTransition();
  3777. }
  3778. });
  3779. } else if (!this._isShown) {
  3780. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3781. }
  3782. };
  3783. _proto._setResizeEvent = function _setResizeEvent() {
  3784. var _this7 = this;
  3785. if (this._isShown) {
  3786. $(window).on(Event$5.RESIZE, function (event) {
  3787. return _this7.handleUpdate(event);
  3788. });
  3789. } else {
  3790. $(window).off(Event$5.RESIZE);
  3791. }
  3792. };
  3793. _proto._hideModal = function _hideModal() {
  3794. var _this8 = this;
  3795. this._element.style.display = 'none';
  3796. this._element.setAttribute('aria-hidden', true);
  3797. this._element.removeAttribute('aria-modal');
  3798. this._isTransitioning = false;
  3799. this._showBackdrop(function () {
  3800. $(document.body).removeClass(ClassName$5.OPEN);
  3801. _this8._resetAdjustments();
  3802. _this8._resetScrollbar();
  3803. $(_this8._element).trigger(Event$5.HIDDEN);
  3804. });
  3805. };
  3806. _proto._removeBackdrop = function _removeBackdrop() {
  3807. if (this._backdrop) {
  3808. $(this._backdrop).remove();
  3809. this._backdrop = null;
  3810. }
  3811. };
  3812. _proto._showBackdrop = function _showBackdrop(callback) {
  3813. var _this9 = this;
  3814. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3815. if (this._isShown && this._config.backdrop) {
  3816. this._backdrop = document.createElement('div');
  3817. this._backdrop.className = ClassName$5.BACKDROP;
  3818. if (animate) {
  3819. this._backdrop.classList.add(animate);
  3820. }
  3821. $(this._backdrop).appendTo(document.body);
  3822. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3823. if (_this9._ignoreBackdropClick) {
  3824. _this9._ignoreBackdropClick = false;
  3825. return;
  3826. }
  3827. if (event.target !== event.currentTarget) {
  3828. return;
  3829. }
  3830. _this9._triggerBackdropTransition();
  3831. });
  3832. if (animate) {
  3833. Util.reflow(this._backdrop);
  3834. }
  3835. $(this._backdrop).addClass(ClassName$5.SHOW);
  3836. if (!callback) {
  3837. return;
  3838. }
  3839. if (!animate) {
  3840. callback();
  3841. return;
  3842. }
  3843. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3844. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3845. } else if (!this._isShown && this._backdrop) {
  3846. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3847. var callbackRemove = function callbackRemove() {
  3848. _this9._removeBackdrop();
  3849. if (callback) {
  3850. callback();
  3851. }
  3852. };
  3853. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3854. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3855. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3856. } else {
  3857. callbackRemove();
  3858. }
  3859. } else if (callback) {
  3860. callback();
  3861. }
  3862. } // ----------------------------------------------------------------------
  3863. // the following methods are used to handle overflowing modals
  3864. // todo (fat): these should probably be refactored out of modal.js
  3865. // ----------------------------------------------------------------------
  3866. ;
  3867. _proto._adjustDialog = function _adjustDialog() {
  3868. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3869. if (!this._isBodyOverflowing && isModalOverflowing) {
  3870. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3871. }
  3872. if (this._isBodyOverflowing && !isModalOverflowing) {
  3873. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3874. }
  3875. };
  3876. _proto._resetAdjustments = function _resetAdjustments() {
  3877. this._element.style.paddingLeft = '';
  3878. this._element.style.paddingRight = '';
  3879. };
  3880. _proto._checkScrollbar = function _checkScrollbar() {
  3881. var rect = document.body.getBoundingClientRect();
  3882. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3883. this._scrollbarWidth = this._getScrollbarWidth();
  3884. };
  3885. _proto._setScrollbar = function _setScrollbar() {
  3886. var _this10 = this;
  3887. if (this._isBodyOverflowing) {
  3888. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3889. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3890. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3891. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3892. $(fixedContent).each(function (index, element) {
  3893. var actualPadding = element.style.paddingRight;
  3894. var calculatedPadding = $(element).css('padding-right');
  3895. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3896. }); // Adjust sticky content margin
  3897. $(stickyContent).each(function (index, element) {
  3898. var actualMargin = element.style.marginRight;
  3899. var calculatedMargin = $(element).css('margin-right');
  3900. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3901. }); // Adjust body padding
  3902. var actualPadding = document.body.style.paddingRight;
  3903. var calculatedPadding = $(document.body).css('padding-right');
  3904. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3905. }
  3906. $(document.body).addClass(ClassName$5.OPEN);
  3907. };
  3908. _proto._resetScrollbar = function _resetScrollbar() {
  3909. // Restore fixed content padding
  3910. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3911. $(fixedContent).each(function (index, element) {
  3912. var padding = $(element).data('padding-right');
  3913. $(element).removeData('padding-right');
  3914. element.style.paddingRight = padding ? padding : '';
  3915. }); // Restore sticky content
  3916. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3917. $(elements).each(function (index, element) {
  3918. var margin = $(element).data('margin-right');
  3919. if (typeof margin !== 'undefined') {
  3920. $(element).css('margin-right', margin).removeData('margin-right');
  3921. }
  3922. }); // Restore body padding
  3923. var padding = $(document.body).data('padding-right');
  3924. $(document.body).removeData('padding-right');
  3925. document.body.style.paddingRight = padding ? padding : '';
  3926. };
  3927. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3928. // thx d.walsh
  3929. var scrollDiv = document.createElement('div');
  3930. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3931. document.body.appendChild(scrollDiv);
  3932. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3933. document.body.removeChild(scrollDiv);
  3934. return scrollbarWidth;
  3935. } // Static
  3936. ;
  3937. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3938. return this.each(function () {
  3939. var data = $(this).data(DATA_KEY$5);
  3940. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3941. if (!data) {
  3942. data = new Modal(this, _config);
  3943. $(this).data(DATA_KEY$5, data);
  3944. }
  3945. if (typeof config === 'string') {
  3946. if (typeof data[config] === 'undefined') {
  3947. throw new TypeError("No method named \"" + config + "\"");
  3948. }
  3949. data[config](relatedTarget);
  3950. } else if (_config.show) {
  3951. data.show(relatedTarget);
  3952. }
  3953. });
  3954. };
  3955. _createClass(Modal, null, [{
  3956. key: "VERSION",
  3957. get: function get() {
  3958. return VERSION$5;
  3959. }
  3960. }, {
  3961. key: "Default",
  3962. get: function get() {
  3963. return Default$3;
  3964. }
  3965. }]);
  3966. return Modal;
  3967. }();
  3968. /**
  3969. * ------------------------------------------------------------------------
  3970. * Data Api implementation
  3971. * ------------------------------------------------------------------------
  3972. */
  3973. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3974. var _this11 = this;
  3975. var target;
  3976. var selector = Util.getSelectorFromElement(this);
  3977. if (selector) {
  3978. target = document.querySelector(selector);
  3979. }
  3980. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3981. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3982. event.preventDefault();
  3983. }
  3984. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3985. if (showEvent.isDefaultPrevented()) {
  3986. // Only register focus restorer if modal will actually get shown
  3987. return;
  3988. }
  3989. $target.one(Event$5.HIDDEN, function () {
  3990. if ($(_this11).is(':visible')) {
  3991. _this11.focus();
  3992. }
  3993. });
  3994. });
  3995. Modal._jQueryInterface.call($(target), config, this);
  3996. });
  3997. /**
  3998. * ------------------------------------------------------------------------
  3999. * jQuery
  4000. * ------------------------------------------------------------------------
  4001. */
  4002. $.fn[NAME$5] = Modal._jQueryInterface;
  4003. $.fn[NAME$5].Constructor = Modal;
  4004. $.fn[NAME$5].noConflict = function () {
  4005. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4006. return Modal._jQueryInterface;
  4007. };
  4008. /**
  4009. * --------------------------------------------------------------------------
  4010. * Bootstrap (v4.4.1): tools/sanitizer.js
  4011. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4012. * --------------------------------------------------------------------------
  4013. */
  4014. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4015. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4016. var DefaultWhitelist = {
  4017. // Global attributes allowed on any supplied element below.
  4018. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4019. a: ['target', 'href', 'title', 'rel'],
  4020. area: [],
  4021. b: [],
  4022. br: [],
  4023. col: [],
  4024. code: [],
  4025. div: [],
  4026. em: [],
  4027. hr: [],
  4028. h1: [],
  4029. h2: [],
  4030. h3: [],
  4031. h4: [],
  4032. h5: [],
  4033. h6: [],
  4034. i: [],
  4035. img: ['src', 'alt', 'title', 'width', 'height'],
  4036. li: [],
  4037. ol: [],
  4038. p: [],
  4039. pre: [],
  4040. s: [],
  4041. small: [],
  4042. span: [],
  4043. sub: [],
  4044. sup: [],
  4045. strong: [],
  4046. u: [],
  4047. ul: []
  4048. };
  4049. /**
  4050. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4051. *
  4052. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4053. */
  4054. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4055. /**
  4056. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4057. *
  4058. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4059. */
  4060. 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;
  4061. function allowedAttribute(attr, allowedAttributeList) {
  4062. var attrName = attr.nodeName.toLowerCase();
  4063. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4064. if (uriAttrs.indexOf(attrName) !== -1) {
  4065. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4066. }
  4067. return true;
  4068. }
  4069. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4070. return attrRegex instanceof RegExp;
  4071. }); // Check if a regular expression validates the attribute.
  4072. for (var i = 0, l = regExp.length; i < l; i++) {
  4073. if (attrName.match(regExp[i])) {
  4074. return true;
  4075. }
  4076. }
  4077. return false;
  4078. }
  4079. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4080. if (unsafeHtml.length === 0) {
  4081. return unsafeHtml;
  4082. }
  4083. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4084. return sanitizeFn(unsafeHtml);
  4085. }
  4086. var domParser = new window.DOMParser();
  4087. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4088. var whitelistKeys = Object.keys(whiteList);
  4089. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4090. var _loop = function _loop(i, len) {
  4091. var el = elements[i];
  4092. var elName = el.nodeName.toLowerCase();
  4093. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4094. el.parentNode.removeChild(el);
  4095. return "continue";
  4096. }
  4097. var attributeList = [].slice.call(el.attributes);
  4098. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4099. attributeList.forEach(function (attr) {
  4100. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4101. el.removeAttribute(attr.nodeName);
  4102. }
  4103. });
  4104. };
  4105. for (var i = 0, len = elements.length; i < len; i++) {
  4106. var _ret = _loop(i);
  4107. if (_ret === "continue") continue;
  4108. }
  4109. return createdDocument.body.innerHTML;
  4110. }
  4111. /**
  4112. * ------------------------------------------------------------------------
  4113. * Constants
  4114. * ------------------------------------------------------------------------
  4115. */
  4116. var NAME$6 = 'tooltip';
  4117. var VERSION$6 = '4.4.1';
  4118. var DATA_KEY$6 = 'bs.tooltip';
  4119. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4120. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4121. var CLASS_PREFIX = 'bs-tooltip';
  4122. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4123. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4124. var DefaultType$4 = {
  4125. animation: 'boolean',
  4126. template: 'string',
  4127. title: '(string|element|function)',
  4128. trigger: 'string',
  4129. delay: '(number|object)',
  4130. html: 'boolean',
  4131. selector: '(string|boolean)',
  4132. placement: '(string|function)',
  4133. offset: '(number|string|function)',
  4134. container: '(string|element|boolean)',
  4135. fallbackPlacement: '(string|array)',
  4136. boundary: '(string|element)',
  4137. sanitize: 'boolean',
  4138. sanitizeFn: '(null|function)',
  4139. whiteList: 'object',
  4140. popperConfig: '(null|object)'
  4141. };
  4142. var AttachmentMap$1 = {
  4143. AUTO: 'auto',
  4144. TOP: 'top',
  4145. RIGHT: 'right',
  4146. BOTTOM: 'bottom',
  4147. LEFT: 'left'
  4148. };
  4149. var Default$4 = {
  4150. animation: true,
  4151. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4152. trigger: 'hover focus',
  4153. title: '',
  4154. delay: 0,
  4155. html: false,
  4156. selector: false,
  4157. placement: 'top',
  4158. offset: 0,
  4159. container: false,
  4160. fallbackPlacement: 'flip',
  4161. boundary: 'scrollParent',
  4162. sanitize: true,
  4163. sanitizeFn: null,
  4164. whiteList: DefaultWhitelist,
  4165. popperConfig: null
  4166. };
  4167. var HoverState = {
  4168. SHOW: 'show',
  4169. OUT: 'out'
  4170. };
  4171. var Event$6 = {
  4172. HIDE: "hide" + EVENT_KEY$6,
  4173. HIDDEN: "hidden" + EVENT_KEY$6,
  4174. SHOW: "show" + EVENT_KEY$6,
  4175. SHOWN: "shown" + EVENT_KEY$6,
  4176. INSERTED: "inserted" + EVENT_KEY$6,
  4177. CLICK: "click" + EVENT_KEY$6,
  4178. FOCUSIN: "focusin" + EVENT_KEY$6,
  4179. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4180. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4181. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4182. };
  4183. var ClassName$6 = {
  4184. FADE: 'fade',
  4185. SHOW: 'show'
  4186. };
  4187. var Selector$6 = {
  4188. TOOLTIP: '.tooltip',
  4189. TOOLTIP_INNER: '.tooltip-inner',
  4190. ARROW: '.arrow'
  4191. };
  4192. var Trigger = {
  4193. HOVER: 'hover',
  4194. FOCUS: 'focus',
  4195. CLICK: 'click',
  4196. MANUAL: 'manual'
  4197. };
  4198. /**
  4199. * ------------------------------------------------------------------------
  4200. * Class Definition
  4201. * ------------------------------------------------------------------------
  4202. */
  4203. var Tooltip =
  4204. /*#__PURE__*/
  4205. function () {
  4206. function Tooltip(element, config) {
  4207. if (typeof Popper === 'undefined') {
  4208. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4209. } // private
  4210. this._isEnabled = true;
  4211. this._timeout = 0;
  4212. this._hoverState = '';
  4213. this._activeTrigger = {};
  4214. this._popper = null; // Protected
  4215. this.element = element;
  4216. this.config = this._getConfig(config);
  4217. this.tip = null;
  4218. this._setListeners();
  4219. } // Getters
  4220. var _proto = Tooltip.prototype;
  4221. // Public
  4222. _proto.enable = function enable() {
  4223. this._isEnabled = true;
  4224. };
  4225. _proto.disable = function disable() {
  4226. this._isEnabled = false;
  4227. };
  4228. _proto.toggleEnabled = function toggleEnabled() {
  4229. this._isEnabled = !this._isEnabled;
  4230. };
  4231. _proto.toggle = function toggle(event) {
  4232. if (!this._isEnabled) {
  4233. return;
  4234. }
  4235. if (event) {
  4236. var dataKey = this.constructor.DATA_KEY;
  4237. var context = $(event.currentTarget).data(dataKey);
  4238. if (!context) {
  4239. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4240. $(event.currentTarget).data(dataKey, context);
  4241. }
  4242. context._activeTrigger.click = !context._activeTrigger.click;
  4243. if (context._isWithActiveTrigger()) {
  4244. context._enter(null, context);
  4245. } else {
  4246. context._leave(null, context);
  4247. }
  4248. } else {
  4249. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4250. this._leave(null, this);
  4251. return;
  4252. }
  4253. this._enter(null, this);
  4254. }
  4255. };
  4256. _proto.dispose = function dispose() {
  4257. clearTimeout(this._timeout);
  4258. $.removeData(this.element, this.constructor.DATA_KEY);
  4259. $(this.element).off(this.constructor.EVENT_KEY);
  4260. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4261. if (this.tip) {
  4262. $(this.tip).remove();
  4263. }
  4264. this._isEnabled = null;
  4265. this._timeout = null;
  4266. this._hoverState = null;
  4267. this._activeTrigger = null;
  4268. if (this._popper) {
  4269. this._popper.destroy();
  4270. }
  4271. this._popper = null;
  4272. this.element = null;
  4273. this.config = null;
  4274. this.tip = null;
  4275. };
  4276. _proto.show = function show() {
  4277. var _this = this;
  4278. if ($(this.element).css('display') === 'none') {
  4279. throw new Error('Please use show on visible elements');
  4280. }
  4281. var showEvent = $.Event(this.constructor.Event.SHOW);
  4282. if (this.isWithContent() && this._isEnabled) {
  4283. $(this.element).trigger(showEvent);
  4284. var shadowRoot = Util.findShadowRoot(this.element);
  4285. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4286. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4287. return;
  4288. }
  4289. var tip = this.getTipElement();
  4290. var tipId = Util.getUID(this.constructor.NAME);
  4291. tip.setAttribute('id', tipId);
  4292. this.element.setAttribute('aria-describedby', tipId);
  4293. this.setContent();
  4294. if (this.config.animation) {
  4295. $(tip).addClass(ClassName$6.FADE);
  4296. }
  4297. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4298. var attachment = this._getAttachment(placement);
  4299. this.addAttachmentClass(attachment);
  4300. var container = this._getContainer();
  4301. $(tip).data(this.constructor.DATA_KEY, this);
  4302. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4303. $(tip).appendTo(container);
  4304. }
  4305. $(this.element).trigger(this.constructor.Event.INSERTED);
  4306. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4307. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4308. // empty mouseover listeners to the body's immediate children;
  4309. // only needed because of broken event delegation on iOS
  4310. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4311. if ('ontouchstart' in document.documentElement) {
  4312. $(document.body).children().on('mouseover', null, $.noop);
  4313. }
  4314. var complete = function complete() {
  4315. if (_this.config.animation) {
  4316. _this._fixTransition();
  4317. }
  4318. var prevHoverState = _this._hoverState;
  4319. _this._hoverState = null;
  4320. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4321. if (prevHoverState === HoverState.OUT) {
  4322. _this._leave(null, _this);
  4323. }
  4324. };
  4325. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4326. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4327. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4328. } else {
  4329. complete();
  4330. }
  4331. }
  4332. };
  4333. _proto.hide = function hide(callback) {
  4334. var _this2 = this;
  4335. var tip = this.getTipElement();
  4336. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4337. var complete = function complete() {
  4338. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4339. tip.parentNode.removeChild(tip);
  4340. }
  4341. _this2._cleanTipClass();
  4342. _this2.element.removeAttribute('aria-describedby');
  4343. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4344. if (_this2._popper !== null) {
  4345. _this2._popper.destroy();
  4346. }
  4347. if (callback) {
  4348. callback();
  4349. }
  4350. };
  4351. $(this.element).trigger(hideEvent);
  4352. if (hideEvent.isDefaultPrevented()) {
  4353. return;
  4354. }
  4355. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4356. // empty mouseover listeners we added for iOS support
  4357. if ('ontouchstart' in document.documentElement) {
  4358. $(document.body).children().off('mouseover', null, $.noop);
  4359. }
  4360. this._activeTrigger[Trigger.CLICK] = false;
  4361. this._activeTrigger[Trigger.FOCUS] = false;
  4362. this._activeTrigger[Trigger.HOVER] = false;
  4363. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4364. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4365. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4366. } else {
  4367. complete();
  4368. }
  4369. this._hoverState = '';
  4370. };
  4371. _proto.update = function update() {
  4372. if (this._popper !== null) {
  4373. this._popper.scheduleUpdate();
  4374. }
  4375. } // Protected
  4376. ;
  4377. _proto.isWithContent = function isWithContent() {
  4378. return Boolean(this.getTitle());
  4379. };
  4380. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4381. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4382. };
  4383. _proto.getTipElement = function getTipElement() {
  4384. this.tip = this.tip || $(this.config.template)[0];
  4385. return this.tip;
  4386. };
  4387. _proto.setContent = function setContent() {
  4388. var tip = this.getTipElement();
  4389. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4390. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4391. };
  4392. _proto.setElementContent = function setElementContent($element, content) {
  4393. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4394. // Content is a DOM node or a jQuery
  4395. if (this.config.html) {
  4396. if (!$(content).parent().is($element)) {
  4397. $element.empty().append(content);
  4398. }
  4399. } else {
  4400. $element.text($(content).text());
  4401. }
  4402. return;
  4403. }
  4404. if (this.config.html) {
  4405. if (this.config.sanitize) {
  4406. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4407. }
  4408. $element.html(content);
  4409. } else {
  4410. $element.text(content);
  4411. }
  4412. };
  4413. _proto.getTitle = function getTitle() {
  4414. var title = this.element.getAttribute('data-original-title');
  4415. if (!title) {
  4416. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4417. }
  4418. return title;
  4419. } // Private
  4420. ;
  4421. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4422. var _this3 = this;
  4423. var defaultBsConfig = {
  4424. placement: attachment,
  4425. modifiers: {
  4426. offset: this._getOffset(),
  4427. flip: {
  4428. behavior: this.config.fallbackPlacement
  4429. },
  4430. arrow: {
  4431. element: Selector$6.ARROW
  4432. },
  4433. preventOverflow: {
  4434. boundariesElement: this.config.boundary
  4435. }
  4436. },
  4437. onCreate: function onCreate(data) {
  4438. if (data.originalPlacement !== data.placement) {
  4439. _this3._handlePopperPlacementChange(data);
  4440. }
  4441. },
  4442. onUpdate: function onUpdate(data) {
  4443. return _this3._handlePopperPlacementChange(data);
  4444. }
  4445. };
  4446. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4447. };
  4448. _proto._getOffset = function _getOffset() {
  4449. var _this4 = this;
  4450. var offset = {};
  4451. if (typeof this.config.offset === 'function') {
  4452. offset.fn = function (data) {
  4453. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4454. return data;
  4455. };
  4456. } else {
  4457. offset.offset = this.config.offset;
  4458. }
  4459. return offset;
  4460. };
  4461. _proto._getContainer = function _getContainer() {
  4462. if (this.config.container === false) {
  4463. return document.body;
  4464. }
  4465. if (Util.isElement(this.config.container)) {
  4466. return $(this.config.container);
  4467. }
  4468. return $(document).find(this.config.container);
  4469. };
  4470. _proto._getAttachment = function _getAttachment(placement) {
  4471. return AttachmentMap$1[placement.toUpperCase()];
  4472. };
  4473. _proto._setListeners = function _setListeners() {
  4474. var _this5 = this;
  4475. var triggers = this.config.trigger.split(' ');
  4476. triggers.forEach(function (trigger) {
  4477. if (trigger === 'click') {
  4478. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4479. return _this5.toggle(event);
  4480. });
  4481. } else if (trigger !== Trigger.MANUAL) {
  4482. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4483. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4484. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4485. return _this5._enter(event);
  4486. }).on(eventOut, _this5.config.selector, function (event) {
  4487. return _this5._leave(event);
  4488. });
  4489. }
  4490. });
  4491. this._hideModalHandler = function () {
  4492. if (_this5.element) {
  4493. _this5.hide();
  4494. }
  4495. };
  4496. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4497. if (this.config.selector) {
  4498. this.config = _objectSpread2({}, this.config, {
  4499. trigger: 'manual',
  4500. selector: ''
  4501. });
  4502. } else {
  4503. this._fixTitle();
  4504. }
  4505. };
  4506. _proto._fixTitle = function _fixTitle() {
  4507. var titleType = typeof this.element.getAttribute('data-original-title');
  4508. if (this.element.getAttribute('title') || titleType !== 'string') {
  4509. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4510. this.element.setAttribute('title', '');
  4511. }
  4512. };
  4513. _proto._enter = function _enter(event, context) {
  4514. var dataKey = this.constructor.DATA_KEY;
  4515. context = context || $(event.currentTarget).data(dataKey);
  4516. if (!context) {
  4517. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4518. $(event.currentTarget).data(dataKey, context);
  4519. }
  4520. if (event) {
  4521. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4522. }
  4523. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4524. context._hoverState = HoverState.SHOW;
  4525. return;
  4526. }
  4527. clearTimeout(context._timeout);
  4528. context._hoverState = HoverState.SHOW;
  4529. if (!context.config.delay || !context.config.delay.show) {
  4530. context.show();
  4531. return;
  4532. }
  4533. context._timeout = setTimeout(function () {
  4534. if (context._hoverState === HoverState.SHOW) {
  4535. context.show();
  4536. }
  4537. }, context.config.delay.show);
  4538. };
  4539. _proto._leave = function _leave(event, context) {
  4540. var dataKey = this.constructor.DATA_KEY;
  4541. context = context || $(event.currentTarget).data(dataKey);
  4542. if (!context) {
  4543. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4544. $(event.currentTarget).data(dataKey, context);
  4545. }
  4546. if (event) {
  4547. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4548. }
  4549. if (context._isWithActiveTrigger()) {
  4550. return;
  4551. }
  4552. clearTimeout(context._timeout);
  4553. context._hoverState = HoverState.OUT;
  4554. if (!context.config.delay || !context.config.delay.hide) {
  4555. context.hide();
  4556. return;
  4557. }
  4558. context._timeout = setTimeout(function () {
  4559. if (context._hoverState === HoverState.OUT) {
  4560. context.hide();
  4561. }
  4562. }, context.config.delay.hide);
  4563. };
  4564. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4565. for (var trigger in this._activeTrigger) {
  4566. if (this._activeTrigger[trigger]) {
  4567. return true;
  4568. }
  4569. }
  4570. return false;
  4571. };
  4572. _proto._getConfig = function _getConfig(config) {
  4573. var dataAttributes = $(this.element).data();
  4574. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4575. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4576. delete dataAttributes[dataAttr];
  4577. }
  4578. });
  4579. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4580. if (typeof config.delay === 'number') {
  4581. config.delay = {
  4582. show: config.delay,
  4583. hide: config.delay
  4584. };
  4585. }
  4586. if (typeof config.title === 'number') {
  4587. config.title = config.title.toString();
  4588. }
  4589. if (typeof config.content === 'number') {
  4590. config.content = config.content.toString();
  4591. }
  4592. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4593. if (config.sanitize) {
  4594. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4595. }
  4596. return config;
  4597. };
  4598. _proto._getDelegateConfig = function _getDelegateConfig() {
  4599. var config = {};
  4600. if (this.config) {
  4601. for (var key in this.config) {
  4602. if (this.constructor.Default[key] !== this.config[key]) {
  4603. config[key] = this.config[key];
  4604. }
  4605. }
  4606. }
  4607. return config;
  4608. };
  4609. _proto._cleanTipClass = function _cleanTipClass() {
  4610. var $tip = $(this.getTipElement());
  4611. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4612. if (tabClass !== null && tabClass.length) {
  4613. $tip.removeClass(tabClass.join(''));
  4614. }
  4615. };
  4616. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4617. var popperInstance = popperData.instance;
  4618. this.tip = popperInstance.popper;
  4619. this._cleanTipClass();
  4620. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4621. };
  4622. _proto._fixTransition = function _fixTransition() {
  4623. var tip = this.getTipElement();
  4624. var initConfigAnimation = this.config.animation;
  4625. if (tip.getAttribute('x-placement') !== null) {
  4626. return;
  4627. }
  4628. $(tip).removeClass(ClassName$6.FADE);
  4629. this.config.animation = false;
  4630. this.hide();
  4631. this.show();
  4632. this.config.animation = initConfigAnimation;
  4633. } // Static
  4634. ;
  4635. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4636. return this.each(function () {
  4637. var data = $(this).data(DATA_KEY$6);
  4638. var _config = typeof config === 'object' && config;
  4639. if (!data && /dispose|hide/.test(config)) {
  4640. return;
  4641. }
  4642. if (!data) {
  4643. data = new Tooltip(this, _config);
  4644. $(this).data(DATA_KEY$6, data);
  4645. }
  4646. if (typeof config === 'string') {
  4647. if (typeof data[config] === 'undefined') {
  4648. throw new TypeError("No method named \"" + config + "\"");
  4649. }
  4650. data[config]();
  4651. }
  4652. });
  4653. };
  4654. _createClass(Tooltip, null, [{
  4655. key: "VERSION",
  4656. get: function get() {
  4657. return VERSION$6;
  4658. }
  4659. }, {
  4660. key: "Default",
  4661. get: function get() {
  4662. return Default$4;
  4663. }
  4664. }, {
  4665. key: "NAME",
  4666. get: function get() {
  4667. return NAME$6;
  4668. }
  4669. }, {
  4670. key: "DATA_KEY",
  4671. get: function get() {
  4672. return DATA_KEY$6;
  4673. }
  4674. }, {
  4675. key: "Event",
  4676. get: function get() {
  4677. return Event$6;
  4678. }
  4679. }, {
  4680. key: "EVENT_KEY",
  4681. get: function get() {
  4682. return EVENT_KEY$6;
  4683. }
  4684. }, {
  4685. key: "DefaultType",
  4686. get: function get() {
  4687. return DefaultType$4;
  4688. }
  4689. }]);
  4690. return Tooltip;
  4691. }();
  4692. /**
  4693. * ------------------------------------------------------------------------
  4694. * jQuery
  4695. * ------------------------------------------------------------------------
  4696. */
  4697. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4698. $.fn[NAME$6].Constructor = Tooltip;
  4699. $.fn[NAME$6].noConflict = function () {
  4700. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4701. return Tooltip._jQueryInterface;
  4702. };
  4703. /**
  4704. * ------------------------------------------------------------------------
  4705. * Constants
  4706. * ------------------------------------------------------------------------
  4707. */
  4708. var NAME$7 = 'popover';
  4709. var VERSION$7 = '4.4.1';
  4710. var DATA_KEY$7 = 'bs.popover';
  4711. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4712. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4713. var CLASS_PREFIX$1 = 'bs-popover';
  4714. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4715. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4716. placement: 'right',
  4717. trigger: 'click',
  4718. content: '',
  4719. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4720. });
  4721. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4722. content: '(string|element|function)'
  4723. });
  4724. var ClassName$7 = {
  4725. FADE: 'fade',
  4726. SHOW: 'show'
  4727. };
  4728. var Selector$7 = {
  4729. TITLE: '.popover-header',
  4730. CONTENT: '.popover-body'
  4731. };
  4732. var Event$7 = {
  4733. HIDE: "hide" + EVENT_KEY$7,
  4734. HIDDEN: "hidden" + EVENT_KEY$7,
  4735. SHOW: "show" + EVENT_KEY$7,
  4736. SHOWN: "shown" + EVENT_KEY$7,
  4737. INSERTED: "inserted" + EVENT_KEY$7,
  4738. CLICK: "click" + EVENT_KEY$7,
  4739. FOCUSIN: "focusin" + EVENT_KEY$7,
  4740. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4741. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4742. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4743. };
  4744. /**
  4745. * ------------------------------------------------------------------------
  4746. * Class Definition
  4747. * ------------------------------------------------------------------------
  4748. */
  4749. var Popover =
  4750. /*#__PURE__*/
  4751. function (_Tooltip) {
  4752. _inheritsLoose(Popover, _Tooltip);
  4753. function Popover() {
  4754. return _Tooltip.apply(this, arguments) || this;
  4755. }
  4756. var _proto = Popover.prototype;
  4757. // Overrides
  4758. _proto.isWithContent = function isWithContent() {
  4759. return this.getTitle() || this._getContent();
  4760. };
  4761. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4762. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4763. };
  4764. _proto.getTipElement = function getTipElement() {
  4765. this.tip = this.tip || $(this.config.template)[0];
  4766. return this.tip;
  4767. };
  4768. _proto.setContent = function setContent() {
  4769. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4770. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4771. var content = this._getContent();
  4772. if (typeof content === 'function') {
  4773. content = content.call(this.element);
  4774. }
  4775. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4776. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4777. } // Private
  4778. ;
  4779. _proto._getContent = function _getContent() {
  4780. return this.element.getAttribute('data-content') || this.config.content;
  4781. };
  4782. _proto._cleanTipClass = function _cleanTipClass() {
  4783. var $tip = $(this.getTipElement());
  4784. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4785. if (tabClass !== null && tabClass.length > 0) {
  4786. $tip.removeClass(tabClass.join(''));
  4787. }
  4788. } // Static
  4789. ;
  4790. Popover._jQueryInterface = function _jQueryInterface(config) {
  4791. return this.each(function () {
  4792. var data = $(this).data(DATA_KEY$7);
  4793. var _config = typeof config === 'object' ? config : null;
  4794. if (!data && /dispose|hide/.test(config)) {
  4795. return;
  4796. }
  4797. if (!data) {
  4798. data = new Popover(this, _config);
  4799. $(this).data(DATA_KEY$7, data);
  4800. }
  4801. if (typeof config === 'string') {
  4802. if (typeof data[config] === 'undefined') {
  4803. throw new TypeError("No method named \"" + config + "\"");
  4804. }
  4805. data[config]();
  4806. }
  4807. });
  4808. };
  4809. _createClass(Popover, null, [{
  4810. key: "VERSION",
  4811. // Getters
  4812. get: function get() {
  4813. return VERSION$7;
  4814. }
  4815. }, {
  4816. key: "Default",
  4817. get: function get() {
  4818. return Default$5;
  4819. }
  4820. }, {
  4821. key: "NAME",
  4822. get: function get() {
  4823. return NAME$7;
  4824. }
  4825. }, {
  4826. key: "DATA_KEY",
  4827. get: function get() {
  4828. return DATA_KEY$7;
  4829. }
  4830. }, {
  4831. key: "Event",
  4832. get: function get() {
  4833. return Event$7;
  4834. }
  4835. }, {
  4836. key: "EVENT_KEY",
  4837. get: function get() {
  4838. return EVENT_KEY$7;
  4839. }
  4840. }, {
  4841. key: "DefaultType",
  4842. get: function get() {
  4843. return DefaultType$5;
  4844. }
  4845. }]);
  4846. return Popover;
  4847. }(Tooltip);
  4848. /**
  4849. * ------------------------------------------------------------------------
  4850. * jQuery
  4851. * ------------------------------------------------------------------------
  4852. */
  4853. $.fn[NAME$7] = Popover._jQueryInterface;
  4854. $.fn[NAME$7].Constructor = Popover;
  4855. $.fn[NAME$7].noConflict = function () {
  4856. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4857. return Popover._jQueryInterface;
  4858. };
  4859. /**
  4860. * ------------------------------------------------------------------------
  4861. * Constants
  4862. * ------------------------------------------------------------------------
  4863. */
  4864. var NAME$8 = 'scrollspy';
  4865. var VERSION$8 = '4.4.1';
  4866. var DATA_KEY$8 = 'bs.scrollspy';
  4867. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4868. var DATA_API_KEY$6 = '.data-api';
  4869. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4870. var Default$6 = {
  4871. offset: 10,
  4872. method: 'auto',
  4873. target: ''
  4874. };
  4875. var DefaultType$6 = {
  4876. offset: 'number',
  4877. method: 'string',
  4878. target: '(string|element)'
  4879. };
  4880. var Event$8 = {
  4881. ACTIVATE: "activate" + EVENT_KEY$8,
  4882. SCROLL: "scroll" + EVENT_KEY$8,
  4883. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4884. };
  4885. var ClassName$8 = {
  4886. DROPDOWN_ITEM: 'dropdown-item',
  4887. DROPDOWN_MENU: 'dropdown-menu',
  4888. ACTIVE: 'active'
  4889. };
  4890. var Selector$8 = {
  4891. DATA_SPY: '[data-spy="scroll"]',
  4892. ACTIVE: '.active',
  4893. NAV_LIST_GROUP: '.nav, .list-group',
  4894. NAV_LINKS: '.nav-link',
  4895. NAV_ITEMS: '.nav-item',
  4896. LIST_ITEMS: '.list-group-item',
  4897. DROPDOWN: '.dropdown',
  4898. DROPDOWN_ITEMS: '.dropdown-item',
  4899. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4900. };
  4901. var OffsetMethod = {
  4902. OFFSET: 'offset',
  4903. POSITION: 'position'
  4904. };
  4905. /**
  4906. * ------------------------------------------------------------------------
  4907. * Class Definition
  4908. * ------------------------------------------------------------------------
  4909. */
  4910. var ScrollSpy =
  4911. /*#__PURE__*/
  4912. function () {
  4913. function ScrollSpy(element, config) {
  4914. var _this = this;
  4915. this._element = element;
  4916. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4917. this._config = this._getConfig(config);
  4918. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4919. this._offsets = [];
  4920. this._targets = [];
  4921. this._activeTarget = null;
  4922. this._scrollHeight = 0;
  4923. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4924. return _this._process(event);
  4925. });
  4926. this.refresh();
  4927. this._process();
  4928. } // Getters
  4929. var _proto = ScrollSpy.prototype;
  4930. // Public
  4931. _proto.refresh = function refresh() {
  4932. var _this2 = this;
  4933. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4934. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4935. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4936. this._offsets = [];
  4937. this._targets = [];
  4938. this._scrollHeight = this._getScrollHeight();
  4939. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4940. targets.map(function (element) {
  4941. var target;
  4942. var targetSelector = Util.getSelectorFromElement(element);
  4943. if (targetSelector) {
  4944. target = document.querySelector(targetSelector);
  4945. }
  4946. if (target) {
  4947. var targetBCR = target.getBoundingClientRect();
  4948. if (targetBCR.width || targetBCR.height) {
  4949. // TODO (fat): remove sketch reliance on jQuery position/offset
  4950. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4951. }
  4952. }
  4953. return null;
  4954. }).filter(function (item) {
  4955. return item;
  4956. }).sort(function (a, b) {
  4957. return a[0] - b[0];
  4958. }).forEach(function (item) {
  4959. _this2._offsets.push(item[0]);
  4960. _this2._targets.push(item[1]);
  4961. });
  4962. };
  4963. _proto.dispose = function dispose() {
  4964. $.removeData(this._element, DATA_KEY$8);
  4965. $(this._scrollElement).off(EVENT_KEY$8);
  4966. this._element = null;
  4967. this._scrollElement = null;
  4968. this._config = null;
  4969. this._selector = null;
  4970. this._offsets = null;
  4971. this._targets = null;
  4972. this._activeTarget = null;
  4973. this._scrollHeight = null;
  4974. } // Private
  4975. ;
  4976. _proto._getConfig = function _getConfig(config) {
  4977. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4978. if (typeof config.target !== 'string') {
  4979. var id = $(config.target).attr('id');
  4980. if (!id) {
  4981. id = Util.getUID(NAME$8);
  4982. $(config.target).attr('id', id);
  4983. }
  4984. config.target = "#" + id;
  4985. }
  4986. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4987. return config;
  4988. };
  4989. _proto._getScrollTop = function _getScrollTop() {
  4990. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4991. };
  4992. _proto._getScrollHeight = function _getScrollHeight() {
  4993. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4994. };
  4995. _proto._getOffsetHeight = function _getOffsetHeight() {
  4996. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4997. };
  4998. _proto._process = function _process() {
  4999. var scrollTop = this._getScrollTop() + this._config.offset;
  5000. var scrollHeight = this._getScrollHeight();
  5001. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5002. if (this._scrollHeight !== scrollHeight) {
  5003. this.refresh();
  5004. }
  5005. if (scrollTop >= maxScroll) {
  5006. var target = this._targets[this._targets.length - 1];
  5007. if (this._activeTarget !== target) {
  5008. this._activate(target);
  5009. }
  5010. return;
  5011. }
  5012. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5013. this._activeTarget = null;
  5014. this._clear();
  5015. return;
  5016. }
  5017. var offsetLength = this._offsets.length;
  5018. for (var i = offsetLength; i--;) {
  5019. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5020. if (isActiveTarget) {
  5021. this._activate(this._targets[i]);
  5022. }
  5023. }
  5024. };
  5025. _proto._activate = function _activate(target) {
  5026. this._activeTarget = target;
  5027. this._clear();
  5028. var queries = this._selector.split(',').map(function (selector) {
  5029. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5030. });
  5031. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5032. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5033. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5034. $link.addClass(ClassName$8.ACTIVE);
  5035. } else {
  5036. // Set triggered link as active
  5037. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5038. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5039. $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
  5040. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5041. }
  5042. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5043. relatedTarget: target
  5044. });
  5045. };
  5046. _proto._clear = function _clear() {
  5047. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5048. return node.classList.contains(ClassName$8.ACTIVE);
  5049. }).forEach(function (node) {
  5050. return node.classList.remove(ClassName$8.ACTIVE);
  5051. });
  5052. } // Static
  5053. ;
  5054. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5055. return this.each(function () {
  5056. var data = $(this).data(DATA_KEY$8);
  5057. var _config = typeof config === 'object' && config;
  5058. if (!data) {
  5059. data = new ScrollSpy(this, _config);
  5060. $(this).data(DATA_KEY$8, data);
  5061. }
  5062. if (typeof config === 'string') {
  5063. if (typeof data[config] === 'undefined') {
  5064. throw new TypeError("No method named \"" + config + "\"");
  5065. }
  5066. data[config]();
  5067. }
  5068. });
  5069. };
  5070. _createClass(ScrollSpy, null, [{
  5071. key: "VERSION",
  5072. get: function get() {
  5073. return VERSION$8;
  5074. }
  5075. }, {
  5076. key: "Default",
  5077. get: function get() {
  5078. return Default$6;
  5079. }
  5080. }]);
  5081. return ScrollSpy;
  5082. }();
  5083. /**
  5084. * ------------------------------------------------------------------------
  5085. * Data Api implementation
  5086. * ------------------------------------------------------------------------
  5087. */
  5088. $(window).on(Event$8.LOAD_DATA_API, function () {
  5089. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5090. var scrollSpysLength = scrollSpys.length;
  5091. for (var i = scrollSpysLength; i--;) {
  5092. var $spy = $(scrollSpys[i]);
  5093. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5094. }
  5095. });
  5096. /**
  5097. * ------------------------------------------------------------------------
  5098. * jQuery
  5099. * ------------------------------------------------------------------------
  5100. */
  5101. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5102. $.fn[NAME$8].Constructor = ScrollSpy;
  5103. $.fn[NAME$8].noConflict = function () {
  5104. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5105. return ScrollSpy._jQueryInterface;
  5106. };
  5107. /**
  5108. * ------------------------------------------------------------------------
  5109. * Constants
  5110. * ------------------------------------------------------------------------
  5111. */
  5112. var NAME$9 = 'tab';
  5113. var VERSION$9 = '4.4.1';
  5114. var DATA_KEY$9 = 'bs.tab';
  5115. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5116. var DATA_API_KEY$7 = '.data-api';
  5117. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5118. var Event$9 = {
  5119. HIDE: "hide" + EVENT_KEY$9,
  5120. HIDDEN: "hidden" + EVENT_KEY$9,
  5121. SHOW: "show" + EVENT_KEY$9,
  5122. SHOWN: "shown" + EVENT_KEY$9,
  5123. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5124. };
  5125. var ClassName$9 = {
  5126. DROPDOWN_MENU: 'dropdown-menu',
  5127. ACTIVE: 'active',
  5128. DISABLED: 'disabled',
  5129. FADE: 'fade',
  5130. SHOW: 'show'
  5131. };
  5132. var Selector$9 = {
  5133. DROPDOWN: '.dropdown',
  5134. NAV_LIST_GROUP: '.nav, .list-group',
  5135. ACTIVE: '.active',
  5136. ACTIVE_UL: '> li > .active',
  5137. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5138. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5139. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5140. };
  5141. /**
  5142. * ------------------------------------------------------------------------
  5143. * Class Definition
  5144. * ------------------------------------------------------------------------
  5145. */
  5146. var Tab =
  5147. /*#__PURE__*/
  5148. function () {
  5149. function Tab(element) {
  5150. this._element = element;
  5151. } // Getters
  5152. var _proto = Tab.prototype;
  5153. // Public
  5154. _proto.show = function show() {
  5155. var _this = this;
  5156. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5157. return;
  5158. }
  5159. var target;
  5160. var previous;
  5161. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5162. var selector = Util.getSelectorFromElement(this._element);
  5163. if (listElement) {
  5164. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5165. previous = $.makeArray($(listElement).find(itemSelector));
  5166. previous = previous[previous.length - 1];
  5167. }
  5168. var hideEvent = $.Event(Event$9.HIDE, {
  5169. relatedTarget: this._element
  5170. });
  5171. var showEvent = $.Event(Event$9.SHOW, {
  5172. relatedTarget: previous
  5173. });
  5174. if (previous) {
  5175. $(previous).trigger(hideEvent);
  5176. }
  5177. $(this._element).trigger(showEvent);
  5178. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5179. return;
  5180. }
  5181. if (selector) {
  5182. target = document.querySelector(selector);
  5183. }
  5184. this._activate(this._element, listElement);
  5185. var complete = function complete() {
  5186. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5187. relatedTarget: _this._element
  5188. });
  5189. var shownEvent = $.Event(Event$9.SHOWN, {
  5190. relatedTarget: previous
  5191. });
  5192. $(previous).trigger(hiddenEvent);
  5193. $(_this._element).trigger(shownEvent);
  5194. };
  5195. if (target) {
  5196. this._activate(target, target.parentNode, complete);
  5197. } else {
  5198. complete();
  5199. }
  5200. };
  5201. _proto.dispose = function dispose() {
  5202. $.removeData(this._element, DATA_KEY$9);
  5203. this._element = null;
  5204. } // Private
  5205. ;
  5206. _proto._activate = function _activate(element, container, callback) {
  5207. var _this2 = this;
  5208. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5209. var active = activeElements[0];
  5210. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5211. var complete = function complete() {
  5212. return _this2._transitionComplete(element, active, callback);
  5213. };
  5214. if (active && isTransitioning) {
  5215. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5216. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5217. } else {
  5218. complete();
  5219. }
  5220. };
  5221. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5222. if (active) {
  5223. $(active).removeClass(ClassName$9.ACTIVE);
  5224. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5225. if (dropdownChild) {
  5226. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5227. }
  5228. if (active.getAttribute('role') === 'tab') {
  5229. active.setAttribute('aria-selected', false);
  5230. }
  5231. }
  5232. $(element).addClass(ClassName$9.ACTIVE);
  5233. if (element.getAttribute('role') === 'tab') {
  5234. element.setAttribute('aria-selected', true);
  5235. }
  5236. Util.reflow(element);
  5237. if (element.classList.contains(ClassName$9.FADE)) {
  5238. element.classList.add(ClassName$9.SHOW);
  5239. }
  5240. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5241. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5242. if (dropdownElement) {
  5243. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5244. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5245. }
  5246. element.setAttribute('aria-expanded', true);
  5247. }
  5248. if (callback) {
  5249. callback();
  5250. }
  5251. } // Static
  5252. ;
  5253. Tab._jQueryInterface = function _jQueryInterface(config) {
  5254. return this.each(function () {
  5255. var $this = $(this);
  5256. var data = $this.data(DATA_KEY$9);
  5257. if (!data) {
  5258. data = new Tab(this);
  5259. $this.data(DATA_KEY$9, data);
  5260. }
  5261. if (typeof config === 'string') {
  5262. if (typeof data[config] === 'undefined') {
  5263. throw new TypeError("No method named \"" + config + "\"");
  5264. }
  5265. data[config]();
  5266. }
  5267. });
  5268. };
  5269. _createClass(Tab, null, [{
  5270. key: "VERSION",
  5271. get: function get() {
  5272. return VERSION$9;
  5273. }
  5274. }]);
  5275. return Tab;
  5276. }();
  5277. /**
  5278. * ------------------------------------------------------------------------
  5279. * Data Api implementation
  5280. * ------------------------------------------------------------------------
  5281. */
  5282. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5283. event.preventDefault();
  5284. Tab._jQueryInterface.call($(this), 'show');
  5285. });
  5286. /**
  5287. * ------------------------------------------------------------------------
  5288. * jQuery
  5289. * ------------------------------------------------------------------------
  5290. */
  5291. $.fn[NAME$9] = Tab._jQueryInterface;
  5292. $.fn[NAME$9].Constructor = Tab;
  5293. $.fn[NAME$9].noConflict = function () {
  5294. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5295. return Tab._jQueryInterface;
  5296. };
  5297. /**
  5298. * ------------------------------------------------------------------------
  5299. * Constants
  5300. * ------------------------------------------------------------------------
  5301. */
  5302. var NAME$a = 'toast';
  5303. var VERSION$a = '4.4.1';
  5304. var DATA_KEY$a = 'bs.toast';
  5305. var EVENT_KEY$a = "." + DATA_KEY$a;
  5306. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5307. var Event$a = {
  5308. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5309. HIDE: "hide" + EVENT_KEY$a,
  5310. HIDDEN: "hidden" + EVENT_KEY$a,
  5311. SHOW: "show" + EVENT_KEY$a,
  5312. SHOWN: "shown" + EVENT_KEY$a
  5313. };
  5314. var ClassName$a = {
  5315. FADE: 'fade',
  5316. HIDE: 'hide',
  5317. SHOW: 'show',
  5318. SHOWING: 'showing'
  5319. };
  5320. var DefaultType$7 = {
  5321. animation: 'boolean',
  5322. autohide: 'boolean',
  5323. delay: 'number'
  5324. };
  5325. var Default$7 = {
  5326. animation: true,
  5327. autohide: true,
  5328. delay: 500
  5329. };
  5330. var Selector$a = {
  5331. DATA_DISMISS: '[data-dismiss="toast"]'
  5332. };
  5333. /**
  5334. * ------------------------------------------------------------------------
  5335. * Class Definition
  5336. * ------------------------------------------------------------------------
  5337. */
  5338. var Toast =
  5339. /*#__PURE__*/
  5340. function () {
  5341. function Toast(element, config) {
  5342. this._element = element;
  5343. this._config = this._getConfig(config);
  5344. this._timeout = null;
  5345. this._setListeners();
  5346. } // Getters
  5347. var _proto = Toast.prototype;
  5348. // Public
  5349. _proto.show = function show() {
  5350. var _this = this;
  5351. var showEvent = $.Event(Event$a.SHOW);
  5352. $(this._element).trigger(showEvent);
  5353. if (showEvent.isDefaultPrevented()) {
  5354. return;
  5355. }
  5356. if (this._config.animation) {
  5357. this._element.classList.add(ClassName$a.FADE);
  5358. }
  5359. var complete = function complete() {
  5360. _this._element.classList.remove(ClassName$a.SHOWING);
  5361. _this._element.classList.add(ClassName$a.SHOW);
  5362. $(_this._element).trigger(Event$a.SHOWN);
  5363. if (_this._config.autohide) {
  5364. _this._timeout = setTimeout(function () {
  5365. _this.hide();
  5366. }, _this._config.delay);
  5367. }
  5368. };
  5369. this._element.classList.remove(ClassName$a.HIDE);
  5370. Util.reflow(this._element);
  5371. this._element.classList.add(ClassName$a.SHOWING);
  5372. if (this._config.animation) {
  5373. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5374. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5375. } else {
  5376. complete();
  5377. }
  5378. };
  5379. _proto.hide = function hide() {
  5380. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5381. return;
  5382. }
  5383. var hideEvent = $.Event(Event$a.HIDE);
  5384. $(this._element).trigger(hideEvent);
  5385. if (hideEvent.isDefaultPrevented()) {
  5386. return;
  5387. }
  5388. this._close();
  5389. };
  5390. _proto.dispose = function dispose() {
  5391. clearTimeout(this._timeout);
  5392. this._timeout = null;
  5393. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5394. this._element.classList.remove(ClassName$a.SHOW);
  5395. }
  5396. $(this._element).off(Event$a.CLICK_DISMISS);
  5397. $.removeData(this._element, DATA_KEY$a);
  5398. this._element = null;
  5399. this._config = null;
  5400. } // Private
  5401. ;
  5402. _proto._getConfig = function _getConfig(config) {
  5403. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5404. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5405. return config;
  5406. };
  5407. _proto._setListeners = function _setListeners() {
  5408. var _this2 = this;
  5409. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5410. return _this2.hide();
  5411. });
  5412. };
  5413. _proto._close = function _close() {
  5414. var _this3 = this;
  5415. var complete = function complete() {
  5416. _this3._element.classList.add(ClassName$a.HIDE);
  5417. $(_this3._element).trigger(Event$a.HIDDEN);
  5418. };
  5419. this._element.classList.remove(ClassName$a.SHOW);
  5420. if (this._config.animation) {
  5421. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5422. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5423. } else {
  5424. complete();
  5425. }
  5426. } // Static
  5427. ;
  5428. Toast._jQueryInterface = function _jQueryInterface(config) {
  5429. return this.each(function () {
  5430. var $element = $(this);
  5431. var data = $element.data(DATA_KEY$a);
  5432. var _config = typeof config === 'object' && config;
  5433. if (!data) {
  5434. data = new Toast(this, _config);
  5435. $element.data(DATA_KEY$a, data);
  5436. }
  5437. if (typeof config === 'string') {
  5438. if (typeof data[config] === 'undefined') {
  5439. throw new TypeError("No method named \"" + config + "\"");
  5440. }
  5441. data[config](this);
  5442. }
  5443. });
  5444. };
  5445. _createClass(Toast, null, [{
  5446. key: "VERSION",
  5447. get: function get() {
  5448. return VERSION$a;
  5449. }
  5450. }, {
  5451. key: "DefaultType",
  5452. get: function get() {
  5453. return DefaultType$7;
  5454. }
  5455. }, {
  5456. key: "Default",
  5457. get: function get() {
  5458. return Default$7;
  5459. }
  5460. }]);
  5461. return Toast;
  5462. }();
  5463. /**
  5464. * ------------------------------------------------------------------------
  5465. * jQuery
  5466. * ------------------------------------------------------------------------
  5467. */
  5468. $.fn[NAME$a] = Toast._jQueryInterface;
  5469. $.fn[NAME$a].Constructor = Toast;
  5470. $.fn[NAME$a].noConflict = function () {
  5471. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5472. return Toast._jQueryInterface;
  5473. };
  5474. exports.Alert = Alert;
  5475. exports.Button = Button;
  5476. exports.Carousel = Carousel;
  5477. exports.Collapse = Collapse;
  5478. exports.Dropdown = Dropdown;
  5479. exports.Modal = Modal;
  5480. exports.Popover = Popover;
  5481. exports.Scrollspy = ScrollSpy;
  5482. exports.Tab = Tab;
  5483. exports.Toast = Toast;
  5484. exports.Tooltip = Tooltip;
  5485. exports.Util = Util;
  5486. Object.defineProperty(exports, '__esModule', { value: true });
  5487. })));
  5488. //# sourceMappingURL=bootstrap.js.map
  5489. /***/ }),
  5490. /***/ "./node_modules/buffer/index.js":
  5491. /*!**************************************!*\
  5492. !*** ./node_modules/buffer/index.js ***!
  5493. \**************************************/
  5494. /*! no static exports found */
  5495. /***/ (function(module, exports, __webpack_require__) {
  5496. "use strict";
  5497. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5498. * The buffer module from node.js, for the browser.
  5499. *
  5500. * @author Feross Aboukhadijeh <http://feross.org>
  5501. * @license MIT
  5502. */
  5503. /* eslint-disable no-proto */
  5504. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5505. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5506. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5507. exports.Buffer = Buffer
  5508. exports.SlowBuffer = SlowBuffer
  5509. exports.INSPECT_MAX_BYTES = 50
  5510. /**
  5511. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5512. * === true Use Uint8Array implementation (fastest)
  5513. * === false Use Object implementation (most compatible, even IE6)
  5514. *
  5515. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5516. * Opera 11.6+, iOS 4.2+.
  5517. *
  5518. * Due to various browser bugs, sometimes the Object implementation will be used even
  5519. * when the browser supports typed arrays.
  5520. *
  5521. * Note:
  5522. *
  5523. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5524. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5525. *
  5526. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5527. *
  5528. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5529. * incorrect length in some situations.
  5530. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5531. * get the Object implementation, which is slower but behaves correctly.
  5532. */
  5533. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5534. ? global.TYPED_ARRAY_SUPPORT
  5535. : typedArraySupport()
  5536. /*
  5537. * Export kMaxLength after typed array support is determined.
  5538. */
  5539. exports.kMaxLength = kMaxLength()
  5540. function typedArraySupport () {
  5541. try {
  5542. var arr = new Uint8Array(1)
  5543. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5544. return arr.foo() === 42 && // typed array instances can be augmented
  5545. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5546. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5547. } catch (e) {
  5548. return false
  5549. }
  5550. }
  5551. function kMaxLength () {
  5552. return Buffer.TYPED_ARRAY_SUPPORT
  5553. ? 0x7fffffff
  5554. : 0x3fffffff
  5555. }
  5556. function createBuffer (that, length) {
  5557. if (kMaxLength() < length) {
  5558. throw new RangeError('Invalid typed array length')
  5559. }
  5560. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5561. // Return an augmented `Uint8Array` instance, for best performance
  5562. that = new Uint8Array(length)
  5563. that.__proto__ = Buffer.prototype
  5564. } else {
  5565. // Fallback: Return an object instance of the Buffer class
  5566. if (that === null) {
  5567. that = new Buffer(length)
  5568. }
  5569. that.length = length
  5570. }
  5571. return that
  5572. }
  5573. /**
  5574. * The Buffer constructor returns instances of `Uint8Array` that have their
  5575. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5576. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5577. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5578. * returns a single octet.
  5579. *
  5580. * The `Uint8Array` prototype remains unmodified.
  5581. */
  5582. function Buffer (arg, encodingOrOffset, length) {
  5583. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5584. return new Buffer(arg, encodingOrOffset, length)
  5585. }
  5586. // Common case.
  5587. if (typeof arg === 'number') {
  5588. if (typeof encodingOrOffset === 'string') {
  5589. throw new Error(
  5590. 'If encoding is specified then the first argument must be a string'
  5591. )
  5592. }
  5593. return allocUnsafe(this, arg)
  5594. }
  5595. return from(this, arg, encodingOrOffset, length)
  5596. }
  5597. Buffer.poolSize = 8192 // not used by this implementation
  5598. // TODO: Legacy, not needed anymore. Remove in next major version.
  5599. Buffer._augment = function (arr) {
  5600. arr.__proto__ = Buffer.prototype
  5601. return arr
  5602. }
  5603. function from (that, value, encodingOrOffset, length) {
  5604. if (typeof value === 'number') {
  5605. throw new TypeError('"value" argument must not be a number')
  5606. }
  5607. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5608. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5609. }
  5610. if (typeof value === 'string') {
  5611. return fromString(that, value, encodingOrOffset)
  5612. }
  5613. return fromObject(that, value)
  5614. }
  5615. /**
  5616. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5617. * if value is a number.
  5618. * Buffer.from(str[, encoding])
  5619. * Buffer.from(array)
  5620. * Buffer.from(buffer)
  5621. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5622. **/
  5623. Buffer.from = function (value, encodingOrOffset, length) {
  5624. return from(null, value, encodingOrOffset, length)
  5625. }
  5626. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5627. Buffer.prototype.__proto__ = Uint8Array.prototype
  5628. Buffer.__proto__ = Uint8Array
  5629. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5630. Buffer[Symbol.species] === Buffer) {
  5631. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5632. Object.defineProperty(Buffer, Symbol.species, {
  5633. value: null,
  5634. configurable: true
  5635. })
  5636. }
  5637. }
  5638. function assertSize (size) {
  5639. if (typeof size !== 'number') {
  5640. throw new TypeError('"size" argument must be a number')
  5641. } else if (size < 0) {
  5642. throw new RangeError('"size" argument must not be negative')
  5643. }
  5644. }
  5645. function alloc (that, size, fill, encoding) {
  5646. assertSize(size)
  5647. if (size <= 0) {
  5648. return createBuffer(that, size)
  5649. }
  5650. if (fill !== undefined) {
  5651. // Only pay attention to encoding if it's a string. This
  5652. // prevents accidentally sending in a number that would
  5653. // be interpretted as a start offset.
  5654. return typeof encoding === 'string'
  5655. ? createBuffer(that, size).fill(fill, encoding)
  5656. : createBuffer(that, size).fill(fill)
  5657. }
  5658. return createBuffer(that, size)
  5659. }
  5660. /**
  5661. * Creates a new filled Buffer instance.
  5662. * alloc(size[, fill[, encoding]])
  5663. **/
  5664. Buffer.alloc = function (size, fill, encoding) {
  5665. return alloc(null, size, fill, encoding)
  5666. }
  5667. function allocUnsafe (that, size) {
  5668. assertSize(size)
  5669. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5670. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5671. for (var i = 0; i < size; ++i) {
  5672. that[i] = 0
  5673. }
  5674. }
  5675. return that
  5676. }
  5677. /**
  5678. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5679. * */
  5680. Buffer.allocUnsafe = function (size) {
  5681. return allocUnsafe(null, size)
  5682. }
  5683. /**
  5684. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5685. */
  5686. Buffer.allocUnsafeSlow = function (size) {
  5687. return allocUnsafe(null, size)
  5688. }
  5689. function fromString (that, string, encoding) {
  5690. if (typeof encoding !== 'string' || encoding === '') {
  5691. encoding = 'utf8'
  5692. }
  5693. if (!Buffer.isEncoding(encoding)) {
  5694. throw new TypeError('"encoding" must be a valid string encoding')
  5695. }
  5696. var length = byteLength(string, encoding) | 0
  5697. that = createBuffer(that, length)
  5698. var actual = that.write(string, encoding)
  5699. if (actual !== length) {
  5700. // Writing a hex string, for example, that contains invalid characters will
  5701. // cause everything after the first invalid character to be ignored. (e.g.
  5702. // 'abxxcd' will be treated as 'ab')
  5703. that = that.slice(0, actual)
  5704. }
  5705. return that
  5706. }
  5707. function fromArrayLike (that, array) {
  5708. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5709. that = createBuffer(that, length)
  5710. for (var i = 0; i < length; i += 1) {
  5711. that[i] = array[i] & 255
  5712. }
  5713. return that
  5714. }
  5715. function fromArrayBuffer (that, array, byteOffset, length) {
  5716. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5717. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5718. throw new RangeError('\'offset\' is out of bounds')
  5719. }
  5720. if (array.byteLength < byteOffset + (length || 0)) {
  5721. throw new RangeError('\'length\' is out of bounds')
  5722. }
  5723. if (byteOffset === undefined && length === undefined) {
  5724. array = new Uint8Array(array)
  5725. } else if (length === undefined) {
  5726. array = new Uint8Array(array, byteOffset)
  5727. } else {
  5728. array = new Uint8Array(array, byteOffset, length)
  5729. }
  5730. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5731. // Return an augmented `Uint8Array` instance, for best performance
  5732. that = array
  5733. that.__proto__ = Buffer.prototype
  5734. } else {
  5735. // Fallback: Return an object instance of the Buffer class
  5736. that = fromArrayLike(that, array)
  5737. }
  5738. return that
  5739. }
  5740. function fromObject (that, obj) {
  5741. if (Buffer.isBuffer(obj)) {
  5742. var len = checked(obj.length) | 0
  5743. that = createBuffer(that, len)
  5744. if (that.length === 0) {
  5745. return that
  5746. }
  5747. obj.copy(that, 0, 0, len)
  5748. return that
  5749. }
  5750. if (obj) {
  5751. if ((typeof ArrayBuffer !== 'undefined' &&
  5752. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5753. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5754. return createBuffer(that, 0)
  5755. }
  5756. return fromArrayLike(that, obj)
  5757. }
  5758. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5759. return fromArrayLike(that, obj.data)
  5760. }
  5761. }
  5762. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5763. }
  5764. function checked (length) {
  5765. // Note: cannot use `length < kMaxLength()` here because that fails when
  5766. // length is NaN (which is otherwise coerced to zero.)
  5767. if (length >= kMaxLength()) {
  5768. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5769. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5770. }
  5771. return length | 0
  5772. }
  5773. function SlowBuffer (length) {
  5774. if (+length != length) { // eslint-disable-line eqeqeq
  5775. length = 0
  5776. }
  5777. return Buffer.alloc(+length)
  5778. }
  5779. Buffer.isBuffer = function isBuffer (b) {
  5780. return !!(b != null && b._isBuffer)
  5781. }
  5782. Buffer.compare = function compare (a, b) {
  5783. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5784. throw new TypeError('Arguments must be Buffers')
  5785. }
  5786. if (a === b) return 0
  5787. var x = a.length
  5788. var y = b.length
  5789. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5790. if (a[i] !== b[i]) {
  5791. x = a[i]
  5792. y = b[i]
  5793. break
  5794. }
  5795. }
  5796. if (x < y) return -1
  5797. if (y < x) return 1
  5798. return 0
  5799. }
  5800. Buffer.isEncoding = function isEncoding (encoding) {
  5801. switch (String(encoding).toLowerCase()) {
  5802. case 'hex':
  5803. case 'utf8':
  5804. case 'utf-8':
  5805. case 'ascii':
  5806. case 'latin1':
  5807. case 'binary':
  5808. case 'base64':
  5809. case 'ucs2':
  5810. case 'ucs-2':
  5811. case 'utf16le':
  5812. case 'utf-16le':
  5813. return true
  5814. default:
  5815. return false
  5816. }
  5817. }
  5818. Buffer.concat = function concat (list, length) {
  5819. if (!isArray(list)) {
  5820. throw new TypeError('"list" argument must be an Array of Buffers')
  5821. }
  5822. if (list.length === 0) {
  5823. return Buffer.alloc(0)
  5824. }
  5825. var i
  5826. if (length === undefined) {
  5827. length = 0
  5828. for (i = 0; i < list.length; ++i) {
  5829. length += list[i].length
  5830. }
  5831. }
  5832. var buffer = Buffer.allocUnsafe(length)
  5833. var pos = 0
  5834. for (i = 0; i < list.length; ++i) {
  5835. var buf = list[i]
  5836. if (!Buffer.isBuffer(buf)) {
  5837. throw new TypeError('"list" argument must be an Array of Buffers')
  5838. }
  5839. buf.copy(buffer, pos)
  5840. pos += buf.length
  5841. }
  5842. return buffer
  5843. }
  5844. function byteLength (string, encoding) {
  5845. if (Buffer.isBuffer(string)) {
  5846. return string.length
  5847. }
  5848. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5849. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5850. return string.byteLength
  5851. }
  5852. if (typeof string !== 'string') {
  5853. string = '' + string
  5854. }
  5855. var len = string.length
  5856. if (len === 0) return 0
  5857. // Use a for loop to avoid recursion
  5858. var loweredCase = false
  5859. for (;;) {
  5860. switch (encoding) {
  5861. case 'ascii':
  5862. case 'latin1':
  5863. case 'binary':
  5864. return len
  5865. case 'utf8':
  5866. case 'utf-8':
  5867. case undefined:
  5868. return utf8ToBytes(string).length
  5869. case 'ucs2':
  5870. case 'ucs-2':
  5871. case 'utf16le':
  5872. case 'utf-16le':
  5873. return len * 2
  5874. case 'hex':
  5875. return len >>> 1
  5876. case 'base64':
  5877. return base64ToBytes(string).length
  5878. default:
  5879. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5880. encoding = ('' + encoding).toLowerCase()
  5881. loweredCase = true
  5882. }
  5883. }
  5884. }
  5885. Buffer.byteLength = byteLength
  5886. function slowToString (encoding, start, end) {
  5887. var loweredCase = false
  5888. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5889. // property of a typed array.
  5890. // This behaves neither like String nor Uint8Array in that we set start/end
  5891. // to their upper/lower bounds if the value passed is out of range.
  5892. // undefined is handled specially as per ECMA-262 6th Edition,
  5893. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5894. if (start === undefined || start < 0) {
  5895. start = 0
  5896. }
  5897. // Return early if start > this.length. Done here to prevent potential uint32
  5898. // coercion fail below.
  5899. if (start > this.length) {
  5900. return ''
  5901. }
  5902. if (end === undefined || end > this.length) {
  5903. end = this.length
  5904. }
  5905. if (end <= 0) {
  5906. return ''
  5907. }
  5908. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5909. end >>>= 0
  5910. start >>>= 0
  5911. if (end <= start) {
  5912. return ''
  5913. }
  5914. if (!encoding) encoding = 'utf8'
  5915. while (true) {
  5916. switch (encoding) {
  5917. case 'hex':
  5918. return hexSlice(this, start, end)
  5919. case 'utf8':
  5920. case 'utf-8':
  5921. return utf8Slice(this, start, end)
  5922. case 'ascii':
  5923. return asciiSlice(this, start, end)
  5924. case 'latin1':
  5925. case 'binary':
  5926. return latin1Slice(this, start, end)
  5927. case 'base64':
  5928. return base64Slice(this, start, end)
  5929. case 'ucs2':
  5930. case 'ucs-2':
  5931. case 'utf16le':
  5932. case 'utf-16le':
  5933. return utf16leSlice(this, start, end)
  5934. default:
  5935. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5936. encoding = (encoding + '').toLowerCase()
  5937. loweredCase = true
  5938. }
  5939. }
  5940. }
  5941. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5942. // Buffer instances.
  5943. Buffer.prototype._isBuffer = true
  5944. function swap (b, n, m) {
  5945. var i = b[n]
  5946. b[n] = b[m]
  5947. b[m] = i
  5948. }
  5949. Buffer.prototype.swap16 = function swap16 () {
  5950. var len = this.length
  5951. if (len % 2 !== 0) {
  5952. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5953. }
  5954. for (var i = 0; i < len; i += 2) {
  5955. swap(this, i, i + 1)
  5956. }
  5957. return this
  5958. }
  5959. Buffer.prototype.swap32 = function swap32 () {
  5960. var len = this.length
  5961. if (len % 4 !== 0) {
  5962. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5963. }
  5964. for (var i = 0; i < len; i += 4) {
  5965. swap(this, i, i + 3)
  5966. swap(this, i + 1, i + 2)
  5967. }
  5968. return this
  5969. }
  5970. Buffer.prototype.swap64 = function swap64 () {
  5971. var len = this.length
  5972. if (len % 8 !== 0) {
  5973. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5974. }
  5975. for (var i = 0; i < len; i += 8) {
  5976. swap(this, i, i + 7)
  5977. swap(this, i + 1, i + 6)
  5978. swap(this, i + 2, i + 5)
  5979. swap(this, i + 3, i + 4)
  5980. }
  5981. return this
  5982. }
  5983. Buffer.prototype.toString = function toString () {
  5984. var length = this.length | 0
  5985. if (length === 0) return ''
  5986. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5987. return slowToString.apply(this, arguments)
  5988. }
  5989. Buffer.prototype.equals = function equals (b) {
  5990. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5991. if (this === b) return true
  5992. return Buffer.compare(this, b) === 0
  5993. }
  5994. Buffer.prototype.inspect = function inspect () {
  5995. var str = ''
  5996. var max = exports.INSPECT_MAX_BYTES
  5997. if (this.length > 0) {
  5998. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5999. if (this.length > max) str += ' ... '
  6000. }
  6001. return '<Buffer ' + str + '>'
  6002. }
  6003. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6004. if (!Buffer.isBuffer(target)) {
  6005. throw new TypeError('Argument must be a Buffer')
  6006. }
  6007. if (start === undefined) {
  6008. start = 0
  6009. }
  6010. if (end === undefined) {
  6011. end = target ? target.length : 0
  6012. }
  6013. if (thisStart === undefined) {
  6014. thisStart = 0
  6015. }
  6016. if (thisEnd === undefined) {
  6017. thisEnd = this.length
  6018. }
  6019. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6020. throw new RangeError('out of range index')
  6021. }
  6022. if (thisStart >= thisEnd && start >= end) {
  6023. return 0
  6024. }
  6025. if (thisStart >= thisEnd) {
  6026. return -1
  6027. }
  6028. if (start >= end) {
  6029. return 1
  6030. }
  6031. start >>>= 0
  6032. end >>>= 0
  6033. thisStart >>>= 0
  6034. thisEnd >>>= 0
  6035. if (this === target) return 0
  6036. var x = thisEnd - thisStart
  6037. var y = end - start
  6038. var len = Math.min(x, y)
  6039. var thisCopy = this.slice(thisStart, thisEnd)
  6040. var targetCopy = target.slice(start, end)
  6041. for (var i = 0; i < len; ++i) {
  6042. if (thisCopy[i] !== targetCopy[i]) {
  6043. x = thisCopy[i]
  6044. y = targetCopy[i]
  6045. break
  6046. }
  6047. }
  6048. if (x < y) return -1
  6049. if (y < x) return 1
  6050. return 0
  6051. }
  6052. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6053. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6054. //
  6055. // Arguments:
  6056. // - buffer - a Buffer to search
  6057. // - val - a string, Buffer, or number
  6058. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6059. // - encoding - an optional encoding, relevant is val is a string
  6060. // - dir - true for indexOf, false for lastIndexOf
  6061. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6062. // Empty buffer means no match
  6063. if (buffer.length === 0) return -1
  6064. // Normalize byteOffset
  6065. if (typeof byteOffset === 'string') {
  6066. encoding = byteOffset
  6067. byteOffset = 0
  6068. } else if (byteOffset > 0x7fffffff) {
  6069. byteOffset = 0x7fffffff
  6070. } else if (byteOffset < -0x80000000) {
  6071. byteOffset = -0x80000000
  6072. }
  6073. byteOffset = +byteOffset // Coerce to Number.
  6074. if (isNaN(byteOffset)) {
  6075. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6076. byteOffset = dir ? 0 : (buffer.length - 1)
  6077. }
  6078. // Normalize byteOffset: negative offsets start from the end of the buffer
  6079. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6080. if (byteOffset >= buffer.length) {
  6081. if (dir) return -1
  6082. else byteOffset = buffer.length - 1
  6083. } else if (byteOffset < 0) {
  6084. if (dir) byteOffset = 0
  6085. else return -1
  6086. }
  6087. // Normalize val
  6088. if (typeof val === 'string') {
  6089. val = Buffer.from(val, encoding)
  6090. }
  6091. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6092. if (Buffer.isBuffer(val)) {
  6093. // Special case: looking for empty string/buffer always fails
  6094. if (val.length === 0) {
  6095. return -1
  6096. }
  6097. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6098. } else if (typeof val === 'number') {
  6099. val = val & 0xFF // Search for a byte value [0-255]
  6100. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6101. typeof Uint8Array.prototype.indexOf === 'function') {
  6102. if (dir) {
  6103. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6104. } else {
  6105. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6106. }
  6107. }
  6108. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6109. }
  6110. throw new TypeError('val must be string, number or Buffer')
  6111. }
  6112. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6113. var indexSize = 1
  6114. var arrLength = arr.length
  6115. var valLength = val.length
  6116. if (encoding !== undefined) {
  6117. encoding = String(encoding).toLowerCase()
  6118. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6119. encoding === 'utf16le' || encoding === 'utf-16le') {
  6120. if (arr.length < 2 || val.length < 2) {
  6121. return -1
  6122. }
  6123. indexSize = 2
  6124. arrLength /= 2
  6125. valLength /= 2
  6126. byteOffset /= 2
  6127. }
  6128. }
  6129. function read (buf, i) {
  6130. if (indexSize === 1) {
  6131. return buf[i]
  6132. } else {
  6133. return buf.readUInt16BE(i * indexSize)
  6134. }
  6135. }
  6136. var i
  6137. if (dir) {
  6138. var foundIndex = -1
  6139. for (i = byteOffset; i < arrLength; i++) {
  6140. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6141. if (foundIndex === -1) foundIndex = i
  6142. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6143. } else {
  6144. if (foundIndex !== -1) i -= i - foundIndex
  6145. foundIndex = -1
  6146. }
  6147. }
  6148. } else {
  6149. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6150. for (i = byteOffset; i >= 0; i--) {
  6151. var found = true
  6152. for (var j = 0; j < valLength; j++) {
  6153. if (read(arr, i + j) !== read(val, j)) {
  6154. found = false
  6155. break
  6156. }
  6157. }
  6158. if (found) return i
  6159. }
  6160. }
  6161. return -1
  6162. }
  6163. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6164. return this.indexOf(val, byteOffset, encoding) !== -1
  6165. }
  6166. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6167. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6168. }
  6169. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6170. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6171. }
  6172. function hexWrite (buf, string, offset, length) {
  6173. offset = Number(offset) || 0
  6174. var remaining = buf.length - offset
  6175. if (!length) {
  6176. length = remaining
  6177. } else {
  6178. length = Number(length)
  6179. if (length > remaining) {
  6180. length = remaining
  6181. }
  6182. }
  6183. // must be an even number of digits
  6184. var strLen = string.length
  6185. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6186. if (length > strLen / 2) {
  6187. length = strLen / 2
  6188. }
  6189. for (var i = 0; i < length; ++i) {
  6190. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6191. if (isNaN(parsed)) return i
  6192. buf[offset + i] = parsed
  6193. }
  6194. return i
  6195. }
  6196. function utf8Write (buf, string, offset, length) {
  6197. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6198. }
  6199. function asciiWrite (buf, string, offset, length) {
  6200. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6201. }
  6202. function latin1Write (buf, string, offset, length) {
  6203. return asciiWrite(buf, string, offset, length)
  6204. }
  6205. function base64Write (buf, string, offset, length) {
  6206. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6207. }
  6208. function ucs2Write (buf, string, offset, length) {
  6209. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6210. }
  6211. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6212. // Buffer#write(string)
  6213. if (offset === undefined) {
  6214. encoding = 'utf8'
  6215. length = this.length
  6216. offset = 0
  6217. // Buffer#write(string, encoding)
  6218. } else if (length === undefined && typeof offset === 'string') {
  6219. encoding = offset
  6220. length = this.length
  6221. offset = 0
  6222. // Buffer#write(string, offset[, length][, encoding])
  6223. } else if (isFinite(offset)) {
  6224. offset = offset | 0
  6225. if (isFinite(length)) {
  6226. length = length | 0
  6227. if (encoding === undefined) encoding = 'utf8'
  6228. } else {
  6229. encoding = length
  6230. length = undefined
  6231. }
  6232. // legacy write(string, encoding, offset, length) - remove in v0.13
  6233. } else {
  6234. throw new Error(
  6235. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6236. )
  6237. }
  6238. var remaining = this.length - offset
  6239. if (length === undefined || length > remaining) length = remaining
  6240. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6241. throw new RangeError('Attempt to write outside buffer bounds')
  6242. }
  6243. if (!encoding) encoding = 'utf8'
  6244. var loweredCase = false
  6245. for (;;) {
  6246. switch (encoding) {
  6247. case 'hex':
  6248. return hexWrite(this, string, offset, length)
  6249. case 'utf8':
  6250. case 'utf-8':
  6251. return utf8Write(this, string, offset, length)
  6252. case 'ascii':
  6253. return asciiWrite(this, string, offset, length)
  6254. case 'latin1':
  6255. case 'binary':
  6256. return latin1Write(this, string, offset, length)
  6257. case 'base64':
  6258. // Warning: maxLength not taken into account in base64Write
  6259. return base64Write(this, string, offset, length)
  6260. case 'ucs2':
  6261. case 'ucs-2':
  6262. case 'utf16le':
  6263. case 'utf-16le':
  6264. return ucs2Write(this, string, offset, length)
  6265. default:
  6266. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6267. encoding = ('' + encoding).toLowerCase()
  6268. loweredCase = true
  6269. }
  6270. }
  6271. }
  6272. Buffer.prototype.toJSON = function toJSON () {
  6273. return {
  6274. type: 'Buffer',
  6275. data: Array.prototype.slice.call(this._arr || this, 0)
  6276. }
  6277. }
  6278. function base64Slice (buf, start, end) {
  6279. if (start === 0 && end === buf.length) {
  6280. return base64.fromByteArray(buf)
  6281. } else {
  6282. return base64.fromByteArray(buf.slice(start, end))
  6283. }
  6284. }
  6285. function utf8Slice (buf, start, end) {
  6286. end = Math.min(buf.length, end)
  6287. var res = []
  6288. var i = start
  6289. while (i < end) {
  6290. var firstByte = buf[i]
  6291. var codePoint = null
  6292. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6293. : (firstByte > 0xDF) ? 3
  6294. : (firstByte > 0xBF) ? 2
  6295. : 1
  6296. if (i + bytesPerSequence <= end) {
  6297. var secondByte, thirdByte, fourthByte, tempCodePoint
  6298. switch (bytesPerSequence) {
  6299. case 1:
  6300. if (firstByte < 0x80) {
  6301. codePoint = firstByte
  6302. }
  6303. break
  6304. case 2:
  6305. secondByte = buf[i + 1]
  6306. if ((secondByte & 0xC0) === 0x80) {
  6307. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6308. if (tempCodePoint > 0x7F) {
  6309. codePoint = tempCodePoint
  6310. }
  6311. }
  6312. break
  6313. case 3:
  6314. secondByte = buf[i + 1]
  6315. thirdByte = buf[i + 2]
  6316. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6317. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6318. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6319. codePoint = tempCodePoint
  6320. }
  6321. }
  6322. break
  6323. case 4:
  6324. secondByte = buf[i + 1]
  6325. thirdByte = buf[i + 2]
  6326. fourthByte = buf[i + 3]
  6327. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6328. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6329. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6330. codePoint = tempCodePoint
  6331. }
  6332. }
  6333. }
  6334. }
  6335. if (codePoint === null) {
  6336. // we did not generate a valid codePoint so insert a
  6337. // replacement char (U+FFFD) and advance only 1 byte
  6338. codePoint = 0xFFFD
  6339. bytesPerSequence = 1
  6340. } else if (codePoint > 0xFFFF) {
  6341. // encode to utf16 (surrogate pair dance)
  6342. codePoint -= 0x10000
  6343. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6344. codePoint = 0xDC00 | codePoint & 0x3FF
  6345. }
  6346. res.push(codePoint)
  6347. i += bytesPerSequence
  6348. }
  6349. return decodeCodePointsArray(res)
  6350. }
  6351. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6352. // the lowest limit is Chrome, with 0x10000 args.
  6353. // We go 1 magnitude less, for safety
  6354. var MAX_ARGUMENTS_LENGTH = 0x1000
  6355. function decodeCodePointsArray (codePoints) {
  6356. var len = codePoints.length
  6357. if (len <= MAX_ARGUMENTS_LENGTH) {
  6358. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6359. }
  6360. // Decode in chunks to avoid "call stack size exceeded".
  6361. var res = ''
  6362. var i = 0
  6363. while (i < len) {
  6364. res += String.fromCharCode.apply(
  6365. String,
  6366. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6367. )
  6368. }
  6369. return res
  6370. }
  6371. function asciiSlice (buf, start, end) {
  6372. var ret = ''
  6373. end = Math.min(buf.length, end)
  6374. for (var i = start; i < end; ++i) {
  6375. ret += String.fromCharCode(buf[i] & 0x7F)
  6376. }
  6377. return ret
  6378. }
  6379. function latin1Slice (buf, start, end) {
  6380. var ret = ''
  6381. end = Math.min(buf.length, end)
  6382. for (var i = start; i < end; ++i) {
  6383. ret += String.fromCharCode(buf[i])
  6384. }
  6385. return ret
  6386. }
  6387. function hexSlice (buf, start, end) {
  6388. var len = buf.length
  6389. if (!start || start < 0) start = 0
  6390. if (!end || end < 0 || end > len) end = len
  6391. var out = ''
  6392. for (var i = start; i < end; ++i) {
  6393. out += toHex(buf[i])
  6394. }
  6395. return out
  6396. }
  6397. function utf16leSlice (buf, start, end) {
  6398. var bytes = buf.slice(start, end)
  6399. var res = ''
  6400. for (var i = 0; i < bytes.length; i += 2) {
  6401. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6402. }
  6403. return res
  6404. }
  6405. Buffer.prototype.slice = function slice (start, end) {
  6406. var len = this.length
  6407. start = ~~start
  6408. end = end === undefined ? len : ~~end
  6409. if (start < 0) {
  6410. start += len
  6411. if (start < 0) start = 0
  6412. } else if (start > len) {
  6413. start = len
  6414. }
  6415. if (end < 0) {
  6416. end += len
  6417. if (end < 0) end = 0
  6418. } else if (end > len) {
  6419. end = len
  6420. }
  6421. if (end < start) end = start
  6422. var newBuf
  6423. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6424. newBuf = this.subarray(start, end)
  6425. newBuf.__proto__ = Buffer.prototype
  6426. } else {
  6427. var sliceLen = end - start
  6428. newBuf = new Buffer(sliceLen, undefined)
  6429. for (var i = 0; i < sliceLen; ++i) {
  6430. newBuf[i] = this[i + start]
  6431. }
  6432. }
  6433. return newBuf
  6434. }
  6435. /*
  6436. * Need to make sure that buffer isn't trying to write out of bounds.
  6437. */
  6438. function checkOffset (offset, ext, length) {
  6439. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6440. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6441. }
  6442. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6443. offset = offset | 0
  6444. byteLength = byteLength | 0
  6445. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6446. var val = this[offset]
  6447. var mul = 1
  6448. var i = 0
  6449. while (++i < byteLength && (mul *= 0x100)) {
  6450. val += this[offset + i] * mul
  6451. }
  6452. return val
  6453. }
  6454. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6455. offset = offset | 0
  6456. byteLength = byteLength | 0
  6457. if (!noAssert) {
  6458. checkOffset(offset, byteLength, this.length)
  6459. }
  6460. var val = this[offset + --byteLength]
  6461. var mul = 1
  6462. while (byteLength > 0 && (mul *= 0x100)) {
  6463. val += this[offset + --byteLength] * mul
  6464. }
  6465. return val
  6466. }
  6467. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6468. if (!noAssert) checkOffset(offset, 1, this.length)
  6469. return this[offset]
  6470. }
  6471. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6472. if (!noAssert) checkOffset(offset, 2, this.length)
  6473. return this[offset] | (this[offset + 1] << 8)
  6474. }
  6475. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6476. if (!noAssert) checkOffset(offset, 2, this.length)
  6477. return (this[offset] << 8) | this[offset + 1]
  6478. }
  6479. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6480. if (!noAssert) checkOffset(offset, 4, this.length)
  6481. return ((this[offset]) |
  6482. (this[offset + 1] << 8) |
  6483. (this[offset + 2] << 16)) +
  6484. (this[offset + 3] * 0x1000000)
  6485. }
  6486. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6487. if (!noAssert) checkOffset(offset, 4, this.length)
  6488. return (this[offset] * 0x1000000) +
  6489. ((this[offset + 1] << 16) |
  6490. (this[offset + 2] << 8) |
  6491. this[offset + 3])
  6492. }
  6493. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6494. offset = offset | 0
  6495. byteLength = byteLength | 0
  6496. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6497. var val = this[offset]
  6498. var mul = 1
  6499. var i = 0
  6500. while (++i < byteLength && (mul *= 0x100)) {
  6501. val += this[offset + i] * mul
  6502. }
  6503. mul *= 0x80
  6504. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6505. return val
  6506. }
  6507. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6508. offset = offset | 0
  6509. byteLength = byteLength | 0
  6510. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6511. var i = byteLength
  6512. var mul = 1
  6513. var val = this[offset + --i]
  6514. while (i > 0 && (mul *= 0x100)) {
  6515. val += this[offset + --i] * mul
  6516. }
  6517. mul *= 0x80
  6518. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6519. return val
  6520. }
  6521. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6522. if (!noAssert) checkOffset(offset, 1, this.length)
  6523. if (!(this[offset] & 0x80)) return (this[offset])
  6524. return ((0xff - this[offset] + 1) * -1)
  6525. }
  6526. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6527. if (!noAssert) checkOffset(offset, 2, this.length)
  6528. var val = this[offset] | (this[offset + 1] << 8)
  6529. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6530. }
  6531. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6532. if (!noAssert) checkOffset(offset, 2, this.length)
  6533. var val = this[offset + 1] | (this[offset] << 8)
  6534. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6535. }
  6536. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6537. if (!noAssert) checkOffset(offset, 4, this.length)
  6538. return (this[offset]) |
  6539. (this[offset + 1] << 8) |
  6540. (this[offset + 2] << 16) |
  6541. (this[offset + 3] << 24)
  6542. }
  6543. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6544. if (!noAssert) checkOffset(offset, 4, this.length)
  6545. return (this[offset] << 24) |
  6546. (this[offset + 1] << 16) |
  6547. (this[offset + 2] << 8) |
  6548. (this[offset + 3])
  6549. }
  6550. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6551. if (!noAssert) checkOffset(offset, 4, this.length)
  6552. return ieee754.read(this, offset, true, 23, 4)
  6553. }
  6554. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6555. if (!noAssert) checkOffset(offset, 4, this.length)
  6556. return ieee754.read(this, offset, false, 23, 4)
  6557. }
  6558. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6559. if (!noAssert) checkOffset(offset, 8, this.length)
  6560. return ieee754.read(this, offset, true, 52, 8)
  6561. }
  6562. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6563. if (!noAssert) checkOffset(offset, 8, this.length)
  6564. return ieee754.read(this, offset, false, 52, 8)
  6565. }
  6566. function checkInt (buf, value, offset, ext, max, min) {
  6567. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6568. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6569. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6570. }
  6571. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6572. value = +value
  6573. offset = offset | 0
  6574. byteLength = byteLength | 0
  6575. if (!noAssert) {
  6576. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6577. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6578. }
  6579. var mul = 1
  6580. var i = 0
  6581. this[offset] = value & 0xFF
  6582. while (++i < byteLength && (mul *= 0x100)) {
  6583. this[offset + i] = (value / mul) & 0xFF
  6584. }
  6585. return offset + byteLength
  6586. }
  6587. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6588. value = +value
  6589. offset = offset | 0
  6590. byteLength = byteLength | 0
  6591. if (!noAssert) {
  6592. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6593. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6594. }
  6595. var i = byteLength - 1
  6596. var mul = 1
  6597. this[offset + i] = value & 0xFF
  6598. while (--i >= 0 && (mul *= 0x100)) {
  6599. this[offset + i] = (value / mul) & 0xFF
  6600. }
  6601. return offset + byteLength
  6602. }
  6603. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6604. value = +value
  6605. offset = offset | 0
  6606. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6607. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6608. this[offset] = (value & 0xff)
  6609. return offset + 1
  6610. }
  6611. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6612. if (value < 0) value = 0xffff + value + 1
  6613. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6614. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6615. (littleEndian ? i : 1 - i) * 8
  6616. }
  6617. }
  6618. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6619. value = +value
  6620. offset = offset | 0
  6621. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6622. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6623. this[offset] = (value & 0xff)
  6624. this[offset + 1] = (value >>> 8)
  6625. } else {
  6626. objectWriteUInt16(this, value, offset, true)
  6627. }
  6628. return offset + 2
  6629. }
  6630. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6631. value = +value
  6632. offset = offset | 0
  6633. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6634. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6635. this[offset] = (value >>> 8)
  6636. this[offset + 1] = (value & 0xff)
  6637. } else {
  6638. objectWriteUInt16(this, value, offset, false)
  6639. }
  6640. return offset + 2
  6641. }
  6642. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6643. if (value < 0) value = 0xffffffff + value + 1
  6644. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6645. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6646. }
  6647. }
  6648. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6649. value = +value
  6650. offset = offset | 0
  6651. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6652. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6653. this[offset + 3] = (value >>> 24)
  6654. this[offset + 2] = (value >>> 16)
  6655. this[offset + 1] = (value >>> 8)
  6656. this[offset] = (value & 0xff)
  6657. } else {
  6658. objectWriteUInt32(this, value, offset, true)
  6659. }
  6660. return offset + 4
  6661. }
  6662. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6663. value = +value
  6664. offset = offset | 0
  6665. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6666. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6667. this[offset] = (value >>> 24)
  6668. this[offset + 1] = (value >>> 16)
  6669. this[offset + 2] = (value >>> 8)
  6670. this[offset + 3] = (value & 0xff)
  6671. } else {
  6672. objectWriteUInt32(this, value, offset, false)
  6673. }
  6674. return offset + 4
  6675. }
  6676. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6677. value = +value
  6678. offset = offset | 0
  6679. if (!noAssert) {
  6680. var limit = Math.pow(2, 8 * byteLength - 1)
  6681. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6682. }
  6683. var i = 0
  6684. var mul = 1
  6685. var sub = 0
  6686. this[offset] = value & 0xFF
  6687. while (++i < byteLength && (mul *= 0x100)) {
  6688. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6689. sub = 1
  6690. }
  6691. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6692. }
  6693. return offset + byteLength
  6694. }
  6695. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6696. value = +value
  6697. offset = offset | 0
  6698. if (!noAssert) {
  6699. var limit = Math.pow(2, 8 * byteLength - 1)
  6700. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6701. }
  6702. var i = byteLength - 1
  6703. var mul = 1
  6704. var sub = 0
  6705. this[offset + i] = value & 0xFF
  6706. while (--i >= 0 && (mul *= 0x100)) {
  6707. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6708. sub = 1
  6709. }
  6710. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6711. }
  6712. return offset + byteLength
  6713. }
  6714. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6715. value = +value
  6716. offset = offset | 0
  6717. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6718. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6719. if (value < 0) value = 0xff + value + 1
  6720. this[offset] = (value & 0xff)
  6721. return offset + 1
  6722. }
  6723. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6724. value = +value
  6725. offset = offset | 0
  6726. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6727. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6728. this[offset] = (value & 0xff)
  6729. this[offset + 1] = (value >>> 8)
  6730. } else {
  6731. objectWriteUInt16(this, value, offset, true)
  6732. }
  6733. return offset + 2
  6734. }
  6735. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6736. value = +value
  6737. offset = offset | 0
  6738. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6739. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6740. this[offset] = (value >>> 8)
  6741. this[offset + 1] = (value & 0xff)
  6742. } else {
  6743. objectWriteUInt16(this, value, offset, false)
  6744. }
  6745. return offset + 2
  6746. }
  6747. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6748. value = +value
  6749. offset = offset | 0
  6750. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6751. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6752. this[offset] = (value & 0xff)
  6753. this[offset + 1] = (value >>> 8)
  6754. this[offset + 2] = (value >>> 16)
  6755. this[offset + 3] = (value >>> 24)
  6756. } else {
  6757. objectWriteUInt32(this, value, offset, true)
  6758. }
  6759. return offset + 4
  6760. }
  6761. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6762. value = +value
  6763. offset = offset | 0
  6764. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6765. if (value < 0) value = 0xffffffff + value + 1
  6766. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6767. this[offset] = (value >>> 24)
  6768. this[offset + 1] = (value >>> 16)
  6769. this[offset + 2] = (value >>> 8)
  6770. this[offset + 3] = (value & 0xff)
  6771. } else {
  6772. objectWriteUInt32(this, value, offset, false)
  6773. }
  6774. return offset + 4
  6775. }
  6776. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6777. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6778. if (offset < 0) throw new RangeError('Index out of range')
  6779. }
  6780. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6781. if (!noAssert) {
  6782. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6783. }
  6784. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6785. return offset + 4
  6786. }
  6787. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6788. return writeFloat(this, value, offset, true, noAssert)
  6789. }
  6790. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6791. return writeFloat(this, value, offset, false, noAssert)
  6792. }
  6793. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6794. if (!noAssert) {
  6795. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6796. }
  6797. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6798. return offset + 8
  6799. }
  6800. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6801. return writeDouble(this, value, offset, true, noAssert)
  6802. }
  6803. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6804. return writeDouble(this, value, offset, false, noAssert)
  6805. }
  6806. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6807. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6808. if (!start) start = 0
  6809. if (!end && end !== 0) end = this.length
  6810. if (targetStart >= target.length) targetStart = target.length
  6811. if (!targetStart) targetStart = 0
  6812. if (end > 0 && end < start) end = start
  6813. // Copy 0 bytes; we're done
  6814. if (end === start) return 0
  6815. if (target.length === 0 || this.length === 0) return 0
  6816. // Fatal error conditions
  6817. if (targetStart < 0) {
  6818. throw new RangeError('targetStart out of bounds')
  6819. }
  6820. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6821. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6822. // Are we oob?
  6823. if (end > this.length) end = this.length
  6824. if (target.length - targetStart < end - start) {
  6825. end = target.length - targetStart + start
  6826. }
  6827. var len = end - start
  6828. var i
  6829. if (this === target && start < targetStart && targetStart < end) {
  6830. // descending copy from end
  6831. for (i = len - 1; i >= 0; --i) {
  6832. target[i + targetStart] = this[i + start]
  6833. }
  6834. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6835. // ascending copy from start
  6836. for (i = 0; i < len; ++i) {
  6837. target[i + targetStart] = this[i + start]
  6838. }
  6839. } else {
  6840. Uint8Array.prototype.set.call(
  6841. target,
  6842. this.subarray(start, start + len),
  6843. targetStart
  6844. )
  6845. }
  6846. return len
  6847. }
  6848. // Usage:
  6849. // buffer.fill(number[, offset[, end]])
  6850. // buffer.fill(buffer[, offset[, end]])
  6851. // buffer.fill(string[, offset[, end]][, encoding])
  6852. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6853. // Handle string cases:
  6854. if (typeof val === 'string') {
  6855. if (typeof start === 'string') {
  6856. encoding = start
  6857. start = 0
  6858. end = this.length
  6859. } else if (typeof end === 'string') {
  6860. encoding = end
  6861. end = this.length
  6862. }
  6863. if (val.length === 1) {
  6864. var code = val.charCodeAt(0)
  6865. if (code < 256) {
  6866. val = code
  6867. }
  6868. }
  6869. if (encoding !== undefined && typeof encoding !== 'string') {
  6870. throw new TypeError('encoding must be a string')
  6871. }
  6872. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6873. throw new TypeError('Unknown encoding: ' + encoding)
  6874. }
  6875. } else if (typeof val === 'number') {
  6876. val = val & 255
  6877. }
  6878. // Invalid ranges are not set to a default, so can range check early.
  6879. if (start < 0 || this.length < start || this.length < end) {
  6880. throw new RangeError('Out of range index')
  6881. }
  6882. if (end <= start) {
  6883. return this
  6884. }
  6885. start = start >>> 0
  6886. end = end === undefined ? this.length : end >>> 0
  6887. if (!val) val = 0
  6888. var i
  6889. if (typeof val === 'number') {
  6890. for (i = start; i < end; ++i) {
  6891. this[i] = val
  6892. }
  6893. } else {
  6894. var bytes = Buffer.isBuffer(val)
  6895. ? val
  6896. : utf8ToBytes(new Buffer(val, encoding).toString())
  6897. var len = bytes.length
  6898. for (i = 0; i < end - start; ++i) {
  6899. this[i + start] = bytes[i % len]
  6900. }
  6901. }
  6902. return this
  6903. }
  6904. // HELPER FUNCTIONS
  6905. // ================
  6906. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6907. function base64clean (str) {
  6908. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6909. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6910. // Node converts strings with length < 2 to ''
  6911. if (str.length < 2) return ''
  6912. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6913. while (str.length % 4 !== 0) {
  6914. str = str + '='
  6915. }
  6916. return str
  6917. }
  6918. function stringtrim (str) {
  6919. if (str.trim) return str.trim()
  6920. return str.replace(/^\s+|\s+$/g, '')
  6921. }
  6922. function toHex (n) {
  6923. if (n < 16) return '0' + n.toString(16)
  6924. return n.toString(16)
  6925. }
  6926. function utf8ToBytes (string, units) {
  6927. units = units || Infinity
  6928. var codePoint
  6929. var length = string.length
  6930. var leadSurrogate = null
  6931. var bytes = []
  6932. for (var i = 0; i < length; ++i) {
  6933. codePoint = string.charCodeAt(i)
  6934. // is surrogate component
  6935. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6936. // last char was a lead
  6937. if (!leadSurrogate) {
  6938. // no lead yet
  6939. if (codePoint > 0xDBFF) {
  6940. // unexpected trail
  6941. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6942. continue
  6943. } else if (i + 1 === length) {
  6944. // unpaired lead
  6945. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6946. continue
  6947. }
  6948. // valid lead
  6949. leadSurrogate = codePoint
  6950. continue
  6951. }
  6952. // 2 leads in a row
  6953. if (codePoint < 0xDC00) {
  6954. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6955. leadSurrogate = codePoint
  6956. continue
  6957. }
  6958. // valid surrogate pair
  6959. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6960. } else if (leadSurrogate) {
  6961. // valid bmp char, but last char was a lead
  6962. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6963. }
  6964. leadSurrogate = null
  6965. // encode utf8
  6966. if (codePoint < 0x80) {
  6967. if ((units -= 1) < 0) break
  6968. bytes.push(codePoint)
  6969. } else if (codePoint < 0x800) {
  6970. if ((units -= 2) < 0) break
  6971. bytes.push(
  6972. codePoint >> 0x6 | 0xC0,
  6973. codePoint & 0x3F | 0x80
  6974. )
  6975. } else if (codePoint < 0x10000) {
  6976. if ((units -= 3) < 0) break
  6977. bytes.push(
  6978. codePoint >> 0xC | 0xE0,
  6979. codePoint >> 0x6 & 0x3F | 0x80,
  6980. codePoint & 0x3F | 0x80
  6981. )
  6982. } else if (codePoint < 0x110000) {
  6983. if ((units -= 4) < 0) break
  6984. bytes.push(
  6985. codePoint >> 0x12 | 0xF0,
  6986. codePoint >> 0xC & 0x3F | 0x80,
  6987. codePoint >> 0x6 & 0x3F | 0x80,
  6988. codePoint & 0x3F | 0x80
  6989. )
  6990. } else {
  6991. throw new Error('Invalid code point')
  6992. }
  6993. }
  6994. return bytes
  6995. }
  6996. function asciiToBytes (str) {
  6997. var byteArray = []
  6998. for (var i = 0; i < str.length; ++i) {
  6999. // Node's code seems to be doing this and not & 0x7F..
  7000. byteArray.push(str.charCodeAt(i) & 0xFF)
  7001. }
  7002. return byteArray
  7003. }
  7004. function utf16leToBytes (str, units) {
  7005. var c, hi, lo
  7006. var byteArray = []
  7007. for (var i = 0; i < str.length; ++i) {
  7008. if ((units -= 2) < 0) break
  7009. c = str.charCodeAt(i)
  7010. hi = c >> 8
  7011. lo = c % 256
  7012. byteArray.push(lo)
  7013. byteArray.push(hi)
  7014. }
  7015. return byteArray
  7016. }
  7017. function base64ToBytes (str) {
  7018. return base64.toByteArray(base64clean(str))
  7019. }
  7020. function blitBuffer (src, dst, offset, length) {
  7021. for (var i = 0; i < length; ++i) {
  7022. if ((i + offset >= dst.length) || (i >= src.length)) break
  7023. dst[i + offset] = src[i]
  7024. }
  7025. return i
  7026. }
  7027. function isnan (val) {
  7028. return val !== val // eslint-disable-line no-self-compare
  7029. }
  7030. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7031. /***/ }),
  7032. /***/ "./node_modules/ieee754/index.js":
  7033. /*!***************************************!*\
  7034. !*** ./node_modules/ieee754/index.js ***!
  7035. \***************************************/
  7036. /*! no static exports found */
  7037. /***/ (function(module, exports) {
  7038. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7039. var e, m
  7040. var eLen = (nBytes * 8) - mLen - 1
  7041. var eMax = (1 << eLen) - 1
  7042. var eBias = eMax >> 1
  7043. var nBits = -7
  7044. var i = isLE ? (nBytes - 1) : 0
  7045. var d = isLE ? -1 : 1
  7046. var s = buffer[offset + i]
  7047. i += d
  7048. e = s & ((1 << (-nBits)) - 1)
  7049. s >>= (-nBits)
  7050. nBits += eLen
  7051. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7052. m = e & ((1 << (-nBits)) - 1)
  7053. e >>= (-nBits)
  7054. nBits += mLen
  7055. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7056. if (e === 0) {
  7057. e = 1 - eBias
  7058. } else if (e === eMax) {
  7059. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7060. } else {
  7061. m = m + Math.pow(2, mLen)
  7062. e = e - eBias
  7063. }
  7064. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7065. }
  7066. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7067. var e, m, c
  7068. var eLen = (nBytes * 8) - mLen - 1
  7069. var eMax = (1 << eLen) - 1
  7070. var eBias = eMax >> 1
  7071. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7072. var i = isLE ? 0 : (nBytes - 1)
  7073. var d = isLE ? 1 : -1
  7074. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7075. value = Math.abs(value)
  7076. if (isNaN(value) || value === Infinity) {
  7077. m = isNaN(value) ? 1 : 0
  7078. e = eMax
  7079. } else {
  7080. e = Math.floor(Math.log(value) / Math.LN2)
  7081. if (value * (c = Math.pow(2, -e)) < 1) {
  7082. e--
  7083. c *= 2
  7084. }
  7085. if (e + eBias >= 1) {
  7086. value += rt / c
  7087. } else {
  7088. value += rt * Math.pow(2, 1 - eBias)
  7089. }
  7090. if (value * c >= 2) {
  7091. e++
  7092. c /= 2
  7093. }
  7094. if (e + eBias >= eMax) {
  7095. m = 0
  7096. e = eMax
  7097. } else if (e + eBias >= 1) {
  7098. m = ((value * c) - 1) * Math.pow(2, mLen)
  7099. e = e + eBias
  7100. } else {
  7101. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7102. e = 0
  7103. }
  7104. }
  7105. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7106. e = (e << mLen) | m
  7107. eLen += mLen
  7108. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7109. buffer[offset + i - d] |= s * 128
  7110. }
  7111. /***/ }),
  7112. /***/ "./node_modules/isarray/index.js":
  7113. /*!***************************************!*\
  7114. !*** ./node_modules/isarray/index.js ***!
  7115. \***************************************/
  7116. /*! no static exports found */
  7117. /***/ (function(module, exports) {
  7118. var toString = {}.toString;
  7119. module.exports = Array.isArray || function (arr) {
  7120. return toString.call(arr) == '[object Array]';
  7121. };
  7122. /***/ }),
  7123. /***/ "./node_modules/jquery/dist/jquery.js":
  7124. /*!********************************************!*\
  7125. !*** ./node_modules/jquery/dist/jquery.js ***!
  7126. \********************************************/
  7127. /*! no static exports found */
  7128. /***/ (function(module, exports, __webpack_require__) {
  7129. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7130. * jQuery JavaScript Library v3.4.1
  7131. * https://jquery.com/
  7132. *
  7133. * Includes Sizzle.js
  7134. * https://sizzlejs.com/
  7135. *
  7136. * Copyright JS Foundation and other contributors
  7137. * Released under the MIT license
  7138. * https://jquery.org/license
  7139. *
  7140. * Date: 2019-05-01T21:04Z
  7141. */
  7142. ( function( global, factory ) {
  7143. "use strict";
  7144. if ( true && typeof module.exports === "object" ) {
  7145. // For CommonJS and CommonJS-like environments where a proper `window`
  7146. // is present, execute the factory and get jQuery.
  7147. // For environments that do not have a `window` with a `document`
  7148. // (such as Node.js), expose a factory as module.exports.
  7149. // This accentuates the need for the creation of a real `window`.
  7150. // e.g. var jQuery = require("jquery")(window);
  7151. // See ticket #14549 for more info.
  7152. module.exports = global.document ?
  7153. factory( global, true ) :
  7154. function( w ) {
  7155. if ( !w.document ) {
  7156. throw new Error( "jQuery requires a window with a document" );
  7157. }
  7158. return factory( w );
  7159. };
  7160. } else {
  7161. factory( global );
  7162. }
  7163. // Pass this if window is not defined yet
  7164. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7165. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7166. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7167. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7168. // enough that all such attempts are guarded in a try block.
  7169. "use strict";
  7170. var arr = [];
  7171. var document = window.document;
  7172. var getProto = Object.getPrototypeOf;
  7173. var slice = arr.slice;
  7174. var concat = arr.concat;
  7175. var push = arr.push;
  7176. var indexOf = arr.indexOf;
  7177. var class2type = {};
  7178. var toString = class2type.toString;
  7179. var hasOwn = class2type.hasOwnProperty;
  7180. var fnToString = hasOwn.toString;
  7181. var ObjectFunctionString = fnToString.call( Object );
  7182. var support = {};
  7183. var isFunction = function isFunction( obj ) {
  7184. // Support: Chrome <=57, Firefox <=52
  7185. // In some browsers, typeof returns "function" for HTML <object> elements
  7186. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7187. // We don't want to classify *any* DOM node as a function.
  7188. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7189. };
  7190. var isWindow = function isWindow( obj ) {
  7191. return obj != null && obj === obj.window;
  7192. };
  7193. var preservedScriptAttributes = {
  7194. type: true,
  7195. src: true,
  7196. nonce: true,
  7197. noModule: true
  7198. };
  7199. function DOMEval( code, node, doc ) {
  7200. doc = doc || document;
  7201. var i, val,
  7202. script = doc.createElement( "script" );
  7203. script.text = code;
  7204. if ( node ) {
  7205. for ( i in preservedScriptAttributes ) {
  7206. // Support: Firefox 64+, Edge 18+
  7207. // Some browsers don't support the "nonce" property on scripts.
  7208. // On the other hand, just using `getAttribute` is not enough as
  7209. // the `nonce` attribute is reset to an empty string whenever it
  7210. // becomes browsing-context connected.
  7211. // See https://github.com/whatwg/html/issues/2369
  7212. // See https://html.spec.whatwg.org/#nonce-attributes
  7213. // The `node.getAttribute` check was added for the sake of
  7214. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7215. // via an object.
  7216. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7217. if ( val ) {
  7218. script.setAttribute( i, val );
  7219. }
  7220. }
  7221. }
  7222. doc.head.appendChild( script ).parentNode.removeChild( script );
  7223. }
  7224. function toType( obj ) {
  7225. if ( obj == null ) {
  7226. return obj + "";
  7227. }
  7228. // Support: Android <=2.3 only (functionish RegExp)
  7229. return typeof obj === "object" || typeof obj === "function" ?
  7230. class2type[ toString.call( obj ) ] || "object" :
  7231. typeof obj;
  7232. }
  7233. /* global Symbol */
  7234. // Defining this global in .eslintrc.json would create a danger of using the global
  7235. // unguarded in another place, it seems safer to define global only for this module
  7236. var
  7237. version = "3.4.1",
  7238. // Define a local copy of jQuery
  7239. jQuery = function( selector, context ) {
  7240. // The jQuery object is actually just the init constructor 'enhanced'
  7241. // Need init if jQuery is called (just allow error to be thrown if not included)
  7242. return new jQuery.fn.init( selector, context );
  7243. },
  7244. // Support: Android <=4.0 only
  7245. // Make sure we trim BOM and NBSP
  7246. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7247. jQuery.fn = jQuery.prototype = {
  7248. // The current version of jQuery being used
  7249. jquery: version,
  7250. constructor: jQuery,
  7251. // The default length of a jQuery object is 0
  7252. length: 0,
  7253. toArray: function() {
  7254. return slice.call( this );
  7255. },
  7256. // Get the Nth element in the matched element set OR
  7257. // Get the whole matched element set as a clean array
  7258. get: function( num ) {
  7259. // Return all the elements in a clean array
  7260. if ( num == null ) {
  7261. return slice.call( this );
  7262. }
  7263. // Return just the one element from the set
  7264. return num < 0 ? this[ num + this.length ] : this[ num ];
  7265. },
  7266. // Take an array of elements and push it onto the stack
  7267. // (returning the new matched element set)
  7268. pushStack: function( elems ) {
  7269. // Build a new jQuery matched element set
  7270. var ret = jQuery.merge( this.constructor(), elems );
  7271. // Add the old object onto the stack (as a reference)
  7272. ret.prevObject = this;
  7273. // Return the newly-formed element set
  7274. return ret;
  7275. },
  7276. // Execute a callback for every element in the matched set.
  7277. each: function( callback ) {
  7278. return jQuery.each( this, callback );
  7279. },
  7280. map: function( callback ) {
  7281. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7282. return callback.call( elem, i, elem );
  7283. } ) );
  7284. },
  7285. slice: function() {
  7286. return this.pushStack( slice.apply( this, arguments ) );
  7287. },
  7288. first: function() {
  7289. return this.eq( 0 );
  7290. },
  7291. last: function() {
  7292. return this.eq( -1 );
  7293. },
  7294. eq: function( i ) {
  7295. var len = this.length,
  7296. j = +i + ( i < 0 ? len : 0 );
  7297. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7298. },
  7299. end: function() {
  7300. return this.prevObject || this.constructor();
  7301. },
  7302. // For internal use only.
  7303. // Behaves like an Array's method, not like a jQuery method.
  7304. push: push,
  7305. sort: arr.sort,
  7306. splice: arr.splice
  7307. };
  7308. jQuery.extend = jQuery.fn.extend = function() {
  7309. var options, name, src, copy, copyIsArray, clone,
  7310. target = arguments[ 0 ] || {},
  7311. i = 1,
  7312. length = arguments.length,
  7313. deep = false;
  7314. // Handle a deep copy situation
  7315. if ( typeof target === "boolean" ) {
  7316. deep = target;
  7317. // Skip the boolean and the target
  7318. target = arguments[ i ] || {};
  7319. i++;
  7320. }
  7321. // Handle case when target is a string or something (possible in deep copy)
  7322. if ( typeof target !== "object" && !isFunction( target ) ) {
  7323. target = {};
  7324. }
  7325. // Extend jQuery itself if only one argument is passed
  7326. if ( i === length ) {
  7327. target = this;
  7328. i--;
  7329. }
  7330. for ( ; i < length; i++ ) {
  7331. // Only deal with non-null/undefined values
  7332. if ( ( options = arguments[ i ] ) != null ) {
  7333. // Extend the base object
  7334. for ( name in options ) {
  7335. copy = options[ name ];
  7336. // Prevent Object.prototype pollution
  7337. // Prevent never-ending loop
  7338. if ( name === "__proto__" || target === copy ) {
  7339. continue;
  7340. }
  7341. // Recurse if we're merging plain objects or arrays
  7342. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7343. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7344. src = target[ name ];
  7345. // Ensure proper type for the source value
  7346. if ( copyIsArray && !Array.isArray( src ) ) {
  7347. clone = [];
  7348. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7349. clone = {};
  7350. } else {
  7351. clone = src;
  7352. }
  7353. copyIsArray = false;
  7354. // Never move original objects, clone them
  7355. target[ name ] = jQuery.extend( deep, clone, copy );
  7356. // Don't bring in undefined values
  7357. } else if ( copy !== undefined ) {
  7358. target[ name ] = copy;
  7359. }
  7360. }
  7361. }
  7362. }
  7363. // Return the modified object
  7364. return target;
  7365. };
  7366. jQuery.extend( {
  7367. // Unique for each copy of jQuery on the page
  7368. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7369. // Assume jQuery is ready without the ready module
  7370. isReady: true,
  7371. error: function( msg ) {
  7372. throw new Error( msg );
  7373. },
  7374. noop: function() {},
  7375. isPlainObject: function( obj ) {
  7376. var proto, Ctor;
  7377. // Detect obvious negatives
  7378. // Use toString instead of jQuery.type to catch host objects
  7379. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7380. return false;
  7381. }
  7382. proto = getProto( obj );
  7383. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7384. if ( !proto ) {
  7385. return true;
  7386. }
  7387. // Objects with prototype are plain iff they were constructed by a global Object function
  7388. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7389. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7390. },
  7391. isEmptyObject: function( obj ) {
  7392. var name;
  7393. for ( name in obj ) {
  7394. return false;
  7395. }
  7396. return true;
  7397. },
  7398. // Evaluates a script in a global context
  7399. globalEval: function( code, options ) {
  7400. DOMEval( code, { nonce: options && options.nonce } );
  7401. },
  7402. each: function( obj, callback ) {
  7403. var length, i = 0;
  7404. if ( isArrayLike( obj ) ) {
  7405. length = obj.length;
  7406. for ( ; i < length; i++ ) {
  7407. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7408. break;
  7409. }
  7410. }
  7411. } else {
  7412. for ( i in obj ) {
  7413. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7414. break;
  7415. }
  7416. }
  7417. }
  7418. return obj;
  7419. },
  7420. // Support: Android <=4.0 only
  7421. trim: function( text ) {
  7422. return text == null ?
  7423. "" :
  7424. ( text + "" ).replace( rtrim, "" );
  7425. },
  7426. // results is for internal usage only
  7427. makeArray: function( arr, results ) {
  7428. var ret = results || [];
  7429. if ( arr != null ) {
  7430. if ( isArrayLike( Object( arr ) ) ) {
  7431. jQuery.merge( ret,
  7432. typeof arr === "string" ?
  7433. [ arr ] : arr
  7434. );
  7435. } else {
  7436. push.call( ret, arr );
  7437. }
  7438. }
  7439. return ret;
  7440. },
  7441. inArray: function( elem, arr, i ) {
  7442. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7443. },
  7444. // Support: Android <=4.0 only, PhantomJS 1 only
  7445. // push.apply(_, arraylike) throws on ancient WebKit
  7446. merge: function( first, second ) {
  7447. var len = +second.length,
  7448. j = 0,
  7449. i = first.length;
  7450. for ( ; j < len; j++ ) {
  7451. first[ i++ ] = second[ j ];
  7452. }
  7453. first.length = i;
  7454. return first;
  7455. },
  7456. grep: function( elems, callback, invert ) {
  7457. var callbackInverse,
  7458. matches = [],
  7459. i = 0,
  7460. length = elems.length,
  7461. callbackExpect = !invert;
  7462. // Go through the array, only saving the items
  7463. // that pass the validator function
  7464. for ( ; i < length; i++ ) {
  7465. callbackInverse = !callback( elems[ i ], i );
  7466. if ( callbackInverse !== callbackExpect ) {
  7467. matches.push( elems[ i ] );
  7468. }
  7469. }
  7470. return matches;
  7471. },
  7472. // arg is for internal usage only
  7473. map: function( elems, callback, arg ) {
  7474. var length, value,
  7475. i = 0,
  7476. ret = [];
  7477. // Go through the array, translating each of the items to their new values
  7478. if ( isArrayLike( elems ) ) {
  7479. length = elems.length;
  7480. for ( ; i < length; i++ ) {
  7481. value = callback( elems[ i ], i, arg );
  7482. if ( value != null ) {
  7483. ret.push( value );
  7484. }
  7485. }
  7486. // Go through every key on the object,
  7487. } else {
  7488. for ( i in elems ) {
  7489. value = callback( elems[ i ], i, arg );
  7490. if ( value != null ) {
  7491. ret.push( value );
  7492. }
  7493. }
  7494. }
  7495. // Flatten any nested arrays
  7496. return concat.apply( [], ret );
  7497. },
  7498. // A global GUID counter for objects
  7499. guid: 1,
  7500. // jQuery.support is not used in Core but other projects attach their
  7501. // properties to it so it needs to exist.
  7502. support: support
  7503. } );
  7504. if ( typeof Symbol === "function" ) {
  7505. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7506. }
  7507. // Populate the class2type map
  7508. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7509. function( i, name ) {
  7510. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7511. } );
  7512. function isArrayLike( obj ) {
  7513. // Support: real iOS 8.2 only (not reproducible in simulator)
  7514. // `in` check used to prevent JIT error (gh-2145)
  7515. // hasOwn isn't used here due to false negatives
  7516. // regarding Nodelist length in IE
  7517. var length = !!obj && "length" in obj && obj.length,
  7518. type = toType( obj );
  7519. if ( isFunction( obj ) || isWindow( obj ) ) {
  7520. return false;
  7521. }
  7522. return type === "array" || length === 0 ||
  7523. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7524. }
  7525. var Sizzle =
  7526. /*!
  7527. * Sizzle CSS Selector Engine v2.3.4
  7528. * https://sizzlejs.com/
  7529. *
  7530. * Copyright JS Foundation and other contributors
  7531. * Released under the MIT license
  7532. * https://js.foundation/
  7533. *
  7534. * Date: 2019-04-08
  7535. */
  7536. (function( window ) {
  7537. var i,
  7538. support,
  7539. Expr,
  7540. getText,
  7541. isXML,
  7542. tokenize,
  7543. compile,
  7544. select,
  7545. outermostContext,
  7546. sortInput,
  7547. hasDuplicate,
  7548. // Local document vars
  7549. setDocument,
  7550. document,
  7551. docElem,
  7552. documentIsHTML,
  7553. rbuggyQSA,
  7554. rbuggyMatches,
  7555. matches,
  7556. contains,
  7557. // Instance-specific data
  7558. expando = "sizzle" + 1 * new Date(),
  7559. preferredDoc = window.document,
  7560. dirruns = 0,
  7561. done = 0,
  7562. classCache = createCache(),
  7563. tokenCache = createCache(),
  7564. compilerCache = createCache(),
  7565. nonnativeSelectorCache = createCache(),
  7566. sortOrder = function( a, b ) {
  7567. if ( a === b ) {
  7568. hasDuplicate = true;
  7569. }
  7570. return 0;
  7571. },
  7572. // Instance methods
  7573. hasOwn = ({}).hasOwnProperty,
  7574. arr = [],
  7575. pop = arr.pop,
  7576. push_native = arr.push,
  7577. push = arr.push,
  7578. slice = arr.slice,
  7579. // Use a stripped-down indexOf as it's faster than native
  7580. // https://jsperf.com/thor-indexof-vs-for/5
  7581. indexOf = function( list, elem ) {
  7582. var i = 0,
  7583. len = list.length;
  7584. for ( ; i < len; i++ ) {
  7585. if ( list[i] === elem ) {
  7586. return i;
  7587. }
  7588. }
  7589. return -1;
  7590. },
  7591. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7592. // Regular expressions
  7593. // http://www.w3.org/TR/css3-selectors/#whitespace
  7594. whitespace = "[\\x20\\t\\r\\n\\f]",
  7595. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7596. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7597. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7598. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7599. // Operator (capture 2)
  7600. "*([*^$|!~]?=)" + whitespace +
  7601. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7602. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7603. "*\\]",
  7604. pseudos = ":(" + identifier + ")(?:\\((" +
  7605. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7606. // 1. quoted (capture 3; capture 4 or capture 5)
  7607. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7608. // 2. simple (capture 6)
  7609. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7610. // 3. anything else (capture 2)
  7611. ".*" +
  7612. ")\\)|)",
  7613. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7614. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7615. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7616. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7617. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7618. rdescend = new RegExp( whitespace + "|>" ),
  7619. rpseudo = new RegExp( pseudos ),
  7620. ridentifier = new RegExp( "^" + identifier + "$" ),
  7621. matchExpr = {
  7622. "ID": new RegExp( "^#(" + identifier + ")" ),
  7623. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7624. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7625. "ATTR": new RegExp( "^" + attributes ),
  7626. "PSEUDO": new RegExp( "^" + pseudos ),
  7627. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7628. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7629. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7630. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7631. // For use in libraries implementing .is()
  7632. // We use this for POS matching in `select`
  7633. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7634. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7635. },
  7636. rhtml = /HTML$/i,
  7637. rinputs = /^(?:input|select|textarea|button)$/i,
  7638. rheader = /^h\d$/i,
  7639. rnative = /^[^{]+\{\s*\[native \w/,
  7640. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7641. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7642. rsibling = /[+~]/,
  7643. // CSS escapes
  7644. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7645. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7646. funescape = function( _, escaped, escapedWhitespace ) {
  7647. var high = "0x" + escaped - 0x10000;
  7648. // NaN means non-codepoint
  7649. // Support: Firefox<24
  7650. // Workaround erroneous numeric interpretation of +"0x"
  7651. return high !== high || escapedWhitespace ?
  7652. escaped :
  7653. high < 0 ?
  7654. // BMP codepoint
  7655. String.fromCharCode( high + 0x10000 ) :
  7656. // Supplemental Plane codepoint (surrogate pair)
  7657. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7658. },
  7659. // CSS string/identifier serialization
  7660. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7661. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7662. fcssescape = function( ch, asCodePoint ) {
  7663. if ( asCodePoint ) {
  7664. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7665. if ( ch === "\0" ) {
  7666. return "\uFFFD";
  7667. }
  7668. // Control characters and (dependent upon position) numbers get escaped as code points
  7669. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7670. }
  7671. // Other potentially-special ASCII characters get backslash-escaped
  7672. return "\\" + ch;
  7673. },
  7674. // Used for iframes
  7675. // See setDocument()
  7676. // Removing the function wrapper causes a "Permission Denied"
  7677. // error in IE
  7678. unloadHandler = function() {
  7679. setDocument();
  7680. },
  7681. inDisabledFieldset = addCombinator(
  7682. function( elem ) {
  7683. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7684. },
  7685. { dir: "parentNode", next: "legend" }
  7686. );
  7687. // Optimize for push.apply( _, NodeList )
  7688. try {
  7689. push.apply(
  7690. (arr = slice.call( preferredDoc.childNodes )),
  7691. preferredDoc.childNodes
  7692. );
  7693. // Support: Android<4.0
  7694. // Detect silently failing push.apply
  7695. arr[ preferredDoc.childNodes.length ].nodeType;
  7696. } catch ( e ) {
  7697. push = { apply: arr.length ?
  7698. // Leverage slice if possible
  7699. function( target, els ) {
  7700. push_native.apply( target, slice.call(els) );
  7701. } :
  7702. // Support: IE<9
  7703. // Otherwise append directly
  7704. function( target, els ) {
  7705. var j = target.length,
  7706. i = 0;
  7707. // Can't trust NodeList.length
  7708. while ( (target[j++] = els[i++]) ) {}
  7709. target.length = j - 1;
  7710. }
  7711. };
  7712. }
  7713. function Sizzle( selector, context, results, seed ) {
  7714. var m, i, elem, nid, match, groups, newSelector,
  7715. newContext = context && context.ownerDocument,
  7716. // nodeType defaults to 9, since context defaults to document
  7717. nodeType = context ? context.nodeType : 9;
  7718. results = results || [];
  7719. // Return early from calls with invalid selector or context
  7720. if ( typeof selector !== "string" || !selector ||
  7721. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7722. return results;
  7723. }
  7724. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7725. if ( !seed ) {
  7726. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7727. setDocument( context );
  7728. }
  7729. context = context || document;
  7730. if ( documentIsHTML ) {
  7731. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7732. // (excepting DocumentFragment context, where the methods don't exist)
  7733. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7734. // ID selector
  7735. if ( (m = match[1]) ) {
  7736. // Document context
  7737. if ( nodeType === 9 ) {
  7738. if ( (elem = context.getElementById( m )) ) {
  7739. // Support: IE, Opera, Webkit
  7740. // TODO: identify versions
  7741. // getElementById can match elements by name instead of ID
  7742. if ( elem.id === m ) {
  7743. results.push( elem );
  7744. return results;
  7745. }
  7746. } else {
  7747. return results;
  7748. }
  7749. // Element context
  7750. } else {
  7751. // Support: IE, Opera, Webkit
  7752. // TODO: identify versions
  7753. // getElementById can match elements by name instead of ID
  7754. if ( newContext && (elem = newContext.getElementById( m )) &&
  7755. contains( context, elem ) &&
  7756. elem.id === m ) {
  7757. results.push( elem );
  7758. return results;
  7759. }
  7760. }
  7761. // Type selector
  7762. } else if ( match[2] ) {
  7763. push.apply( results, context.getElementsByTagName( selector ) );
  7764. return results;
  7765. // Class selector
  7766. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7767. context.getElementsByClassName ) {
  7768. push.apply( results, context.getElementsByClassName( m ) );
  7769. return results;
  7770. }
  7771. }
  7772. // Take advantage of querySelectorAll
  7773. if ( support.qsa &&
  7774. !nonnativeSelectorCache[ selector + " " ] &&
  7775. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7776. // Support: IE 8 only
  7777. // Exclude object elements
  7778. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7779. newSelector = selector;
  7780. newContext = context;
  7781. // qSA considers elements outside a scoping root when evaluating child or
  7782. // descendant combinators, which is not what we want.
  7783. // In such cases, we work around the behavior by prefixing every selector in the
  7784. // list with an ID selector referencing the scope context.
  7785. // Thanks to Andrew Dupont for this technique.
  7786. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7787. // Capture the context ID, setting it first if necessary
  7788. if ( (nid = context.getAttribute( "id" )) ) {
  7789. nid = nid.replace( rcssescape, fcssescape );
  7790. } else {
  7791. context.setAttribute( "id", (nid = expando) );
  7792. }
  7793. // Prefix every selector in the list
  7794. groups = tokenize( selector );
  7795. i = groups.length;
  7796. while ( i-- ) {
  7797. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7798. }
  7799. newSelector = groups.join( "," );
  7800. // Expand context for sibling selectors
  7801. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7802. context;
  7803. }
  7804. try {
  7805. push.apply( results,
  7806. newContext.querySelectorAll( newSelector )
  7807. );
  7808. return results;
  7809. } catch ( qsaError ) {
  7810. nonnativeSelectorCache( selector, true );
  7811. } finally {
  7812. if ( nid === expando ) {
  7813. context.removeAttribute( "id" );
  7814. }
  7815. }
  7816. }
  7817. }
  7818. }
  7819. // All others
  7820. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7821. }
  7822. /**
  7823. * Create key-value caches of limited size
  7824. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7825. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7826. * deleting the oldest entry
  7827. */
  7828. function createCache() {
  7829. var keys = [];
  7830. function cache( key, value ) {
  7831. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7832. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7833. // Only keep the most recent entries
  7834. delete cache[ keys.shift() ];
  7835. }
  7836. return (cache[ key + " " ] = value);
  7837. }
  7838. return cache;
  7839. }
  7840. /**
  7841. * Mark a function for special use by Sizzle
  7842. * @param {Function} fn The function to mark
  7843. */
  7844. function markFunction( fn ) {
  7845. fn[ expando ] = true;
  7846. return fn;
  7847. }
  7848. /**
  7849. * Support testing using an element
  7850. * @param {Function} fn Passed the created element and returns a boolean result
  7851. */
  7852. function assert( fn ) {
  7853. var el = document.createElement("fieldset");
  7854. try {
  7855. return !!fn( el );
  7856. } catch (e) {
  7857. return false;
  7858. } finally {
  7859. // Remove from its parent by default
  7860. if ( el.parentNode ) {
  7861. el.parentNode.removeChild( el );
  7862. }
  7863. // release memory in IE
  7864. el = null;
  7865. }
  7866. }
  7867. /**
  7868. * Adds the same handler for all of the specified attrs
  7869. * @param {String} attrs Pipe-separated list of attributes
  7870. * @param {Function} handler The method that will be applied
  7871. */
  7872. function addHandle( attrs, handler ) {
  7873. var arr = attrs.split("|"),
  7874. i = arr.length;
  7875. while ( i-- ) {
  7876. Expr.attrHandle[ arr[i] ] = handler;
  7877. }
  7878. }
  7879. /**
  7880. * Checks document order of two siblings
  7881. * @param {Element} a
  7882. * @param {Element} b
  7883. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7884. */
  7885. function siblingCheck( a, b ) {
  7886. var cur = b && a,
  7887. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7888. a.sourceIndex - b.sourceIndex;
  7889. // Use IE sourceIndex if available on both nodes
  7890. if ( diff ) {
  7891. return diff;
  7892. }
  7893. // Check if b follows a
  7894. if ( cur ) {
  7895. while ( (cur = cur.nextSibling) ) {
  7896. if ( cur === b ) {
  7897. return -1;
  7898. }
  7899. }
  7900. }
  7901. return a ? 1 : -1;
  7902. }
  7903. /**
  7904. * Returns a function to use in pseudos for input types
  7905. * @param {String} type
  7906. */
  7907. function createInputPseudo( type ) {
  7908. return function( elem ) {
  7909. var name = elem.nodeName.toLowerCase();
  7910. return name === "input" && elem.type === type;
  7911. };
  7912. }
  7913. /**
  7914. * Returns a function to use in pseudos for buttons
  7915. * @param {String} type
  7916. */
  7917. function createButtonPseudo( type ) {
  7918. return function( elem ) {
  7919. var name = elem.nodeName.toLowerCase();
  7920. return (name === "input" || name === "button") && elem.type === type;
  7921. };
  7922. }
  7923. /**
  7924. * Returns a function to use in pseudos for :enabled/:disabled
  7925. * @param {Boolean} disabled true for :disabled; false for :enabled
  7926. */
  7927. function createDisabledPseudo( disabled ) {
  7928. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7929. return function( elem ) {
  7930. // Only certain elements can match :enabled or :disabled
  7931. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7932. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7933. if ( "form" in elem ) {
  7934. // Check for inherited disabledness on relevant non-disabled elements:
  7935. // * listed form-associated elements in a disabled fieldset
  7936. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7937. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7938. // * option elements in a disabled optgroup
  7939. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7940. // All such elements have a "form" property.
  7941. if ( elem.parentNode && elem.disabled === false ) {
  7942. // Option elements defer to a parent optgroup if present
  7943. if ( "label" in elem ) {
  7944. if ( "label" in elem.parentNode ) {
  7945. return elem.parentNode.disabled === disabled;
  7946. } else {
  7947. return elem.disabled === disabled;
  7948. }
  7949. }
  7950. // Support: IE 6 - 11
  7951. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7952. return elem.isDisabled === disabled ||
  7953. // Where there is no isDisabled, check manually
  7954. /* jshint -W018 */
  7955. elem.isDisabled !== !disabled &&
  7956. inDisabledFieldset( elem ) === disabled;
  7957. }
  7958. return elem.disabled === disabled;
  7959. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7960. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7961. // even exist on them, let alone have a boolean value.
  7962. } else if ( "label" in elem ) {
  7963. return elem.disabled === disabled;
  7964. }
  7965. // Remaining elements are neither :enabled nor :disabled
  7966. return false;
  7967. };
  7968. }
  7969. /**
  7970. * Returns a function to use in pseudos for positionals
  7971. * @param {Function} fn
  7972. */
  7973. function createPositionalPseudo( fn ) {
  7974. return markFunction(function( argument ) {
  7975. argument = +argument;
  7976. return markFunction(function( seed, matches ) {
  7977. var j,
  7978. matchIndexes = fn( [], seed.length, argument ),
  7979. i = matchIndexes.length;
  7980. // Match elements found at the specified indexes
  7981. while ( i-- ) {
  7982. if ( seed[ (j = matchIndexes[i]) ] ) {
  7983. seed[j] = !(matches[j] = seed[j]);
  7984. }
  7985. }
  7986. });
  7987. });
  7988. }
  7989. /**
  7990. * Checks a node for validity as a Sizzle context
  7991. * @param {Element|Object=} context
  7992. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7993. */
  7994. function testContext( context ) {
  7995. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7996. }
  7997. // Expose support vars for convenience
  7998. support = Sizzle.support = {};
  7999. /**
  8000. * Detects XML nodes
  8001. * @param {Element|Object} elem An element or a document
  8002. * @returns {Boolean} True iff elem is a non-HTML XML node
  8003. */
  8004. isXML = Sizzle.isXML = function( elem ) {
  8005. var namespace = elem.namespaceURI,
  8006. docElem = (elem.ownerDocument || elem).documentElement;
  8007. // Support: IE <=8
  8008. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8009. // https://bugs.jquery.com/ticket/4833
  8010. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8011. };
  8012. /**
  8013. * Sets document-related variables once based on the current document
  8014. * @param {Element|Object} [doc] An element or document object to use to set the document
  8015. * @returns {Object} Returns the current document
  8016. */
  8017. setDocument = Sizzle.setDocument = function( node ) {
  8018. var hasCompare, subWindow,
  8019. doc = node ? node.ownerDocument || node : preferredDoc;
  8020. // Return early if doc is invalid or already selected
  8021. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8022. return document;
  8023. }
  8024. // Update global variables
  8025. document = doc;
  8026. docElem = document.documentElement;
  8027. documentIsHTML = !isXML( document );
  8028. // Support: IE 9-11, Edge
  8029. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8030. if ( preferredDoc !== document &&
  8031. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8032. // Support: IE 11, Edge
  8033. if ( subWindow.addEventListener ) {
  8034. subWindow.addEventListener( "unload", unloadHandler, false );
  8035. // Support: IE 9 - 10 only
  8036. } else if ( subWindow.attachEvent ) {
  8037. subWindow.attachEvent( "onunload", unloadHandler );
  8038. }
  8039. }
  8040. /* Attributes
  8041. ---------------------------------------------------------------------- */
  8042. // Support: IE<8
  8043. // Verify that getAttribute really returns attributes and not properties
  8044. // (excepting IE8 booleans)
  8045. support.attributes = assert(function( el ) {
  8046. el.className = "i";
  8047. return !el.getAttribute("className");
  8048. });
  8049. /* getElement(s)By*
  8050. ---------------------------------------------------------------------- */
  8051. // Check if getElementsByTagName("*") returns only elements
  8052. support.getElementsByTagName = assert(function( el ) {
  8053. el.appendChild( document.createComment("") );
  8054. return !el.getElementsByTagName("*").length;
  8055. });
  8056. // Support: IE<9
  8057. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8058. // Support: IE<10
  8059. // Check if getElementById returns elements by name
  8060. // The broken getElementById methods don't pick up programmatically-set names,
  8061. // so use a roundabout getElementsByName test
  8062. support.getById = assert(function( el ) {
  8063. docElem.appendChild( el ).id = expando;
  8064. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8065. });
  8066. // ID filter and find
  8067. if ( support.getById ) {
  8068. Expr.filter["ID"] = function( id ) {
  8069. var attrId = id.replace( runescape, funescape );
  8070. return function( elem ) {
  8071. return elem.getAttribute("id") === attrId;
  8072. };
  8073. };
  8074. Expr.find["ID"] = function( id, context ) {
  8075. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8076. var elem = context.getElementById( id );
  8077. return elem ? [ elem ] : [];
  8078. }
  8079. };
  8080. } else {
  8081. Expr.filter["ID"] = function( id ) {
  8082. var attrId = id.replace( runescape, funescape );
  8083. return function( elem ) {
  8084. var node = typeof elem.getAttributeNode !== "undefined" &&
  8085. elem.getAttributeNode("id");
  8086. return node && node.value === attrId;
  8087. };
  8088. };
  8089. // Support: IE 6 - 7 only
  8090. // getElementById is not reliable as a find shortcut
  8091. Expr.find["ID"] = function( id, context ) {
  8092. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8093. var node, i, elems,
  8094. elem = context.getElementById( id );
  8095. if ( elem ) {
  8096. // Verify the id attribute
  8097. node = elem.getAttributeNode("id");
  8098. if ( node && node.value === id ) {
  8099. return [ elem ];
  8100. }
  8101. // Fall back on getElementsByName
  8102. elems = context.getElementsByName( id );
  8103. i = 0;
  8104. while ( (elem = elems[i++]) ) {
  8105. node = elem.getAttributeNode("id");
  8106. if ( node && node.value === id ) {
  8107. return [ elem ];
  8108. }
  8109. }
  8110. }
  8111. return [];
  8112. }
  8113. };
  8114. }
  8115. // Tag
  8116. Expr.find["TAG"] = support.getElementsByTagName ?
  8117. function( tag, context ) {
  8118. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8119. return context.getElementsByTagName( tag );
  8120. // DocumentFragment nodes don't have gEBTN
  8121. } else if ( support.qsa ) {
  8122. return context.querySelectorAll( tag );
  8123. }
  8124. } :
  8125. function( tag, context ) {
  8126. var elem,
  8127. tmp = [],
  8128. i = 0,
  8129. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8130. results = context.getElementsByTagName( tag );
  8131. // Filter out possible comments
  8132. if ( tag === "*" ) {
  8133. while ( (elem = results[i++]) ) {
  8134. if ( elem.nodeType === 1 ) {
  8135. tmp.push( elem );
  8136. }
  8137. }
  8138. return tmp;
  8139. }
  8140. return results;
  8141. };
  8142. // Class
  8143. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8144. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8145. return context.getElementsByClassName( className );
  8146. }
  8147. };
  8148. /* QSA/matchesSelector
  8149. ---------------------------------------------------------------------- */
  8150. // QSA and matchesSelector support
  8151. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8152. rbuggyMatches = [];
  8153. // qSa(:focus) reports false when true (Chrome 21)
  8154. // We allow this because of a bug in IE8/9 that throws an error
  8155. // whenever `document.activeElement` is accessed on an iframe
  8156. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8157. // See https://bugs.jquery.com/ticket/13378
  8158. rbuggyQSA = [];
  8159. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8160. // Build QSA regex
  8161. // Regex strategy adopted from Diego Perini
  8162. assert(function( el ) {
  8163. // Select is set to empty string on purpose
  8164. // This is to test IE's treatment of not explicitly
  8165. // setting a boolean content attribute,
  8166. // since its presence should be enough
  8167. // https://bugs.jquery.com/ticket/12359
  8168. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8169. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8170. "<option selected=''></option></select>";
  8171. // Support: IE8, Opera 11-12.16
  8172. // Nothing should be selected when empty strings follow ^= or $= or *=
  8173. // The test attribute must be unknown in Opera but "safe" for WinRT
  8174. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8175. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8176. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8177. }
  8178. // Support: IE8
  8179. // Boolean attributes and "value" are not treated correctly
  8180. if ( !el.querySelectorAll("[selected]").length ) {
  8181. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8182. }
  8183. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8184. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8185. rbuggyQSA.push("~=");
  8186. }
  8187. // Webkit/Opera - :checked should return selected option elements
  8188. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8189. // IE8 throws error here and will not see later tests
  8190. if ( !el.querySelectorAll(":checked").length ) {
  8191. rbuggyQSA.push(":checked");
  8192. }
  8193. // Support: Safari 8+, iOS 8+
  8194. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8195. // In-page `selector#id sibling-combinator selector` fails
  8196. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8197. rbuggyQSA.push(".#.+[+~]");
  8198. }
  8199. });
  8200. assert(function( el ) {
  8201. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8202. "<select disabled='disabled'><option/></select>";
  8203. // Support: Windows 8 Native Apps
  8204. // The type and name attributes are restricted during .innerHTML assignment
  8205. var input = document.createElement("input");
  8206. input.setAttribute( "type", "hidden" );
  8207. el.appendChild( input ).setAttribute( "name", "D" );
  8208. // Support: IE8
  8209. // Enforce case-sensitivity of name attribute
  8210. if ( el.querySelectorAll("[name=d]").length ) {
  8211. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8212. }
  8213. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8214. // IE8 throws error here and will not see later tests
  8215. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8216. rbuggyQSA.push( ":enabled", ":disabled" );
  8217. }
  8218. // Support: IE9-11+
  8219. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8220. docElem.appendChild( el ).disabled = true;
  8221. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8222. rbuggyQSA.push( ":enabled", ":disabled" );
  8223. }
  8224. // Opera 10-11 does not throw on post-comma invalid pseudos
  8225. el.querySelectorAll("*,:x");
  8226. rbuggyQSA.push(",.*:");
  8227. });
  8228. }
  8229. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8230. docElem.webkitMatchesSelector ||
  8231. docElem.mozMatchesSelector ||
  8232. docElem.oMatchesSelector ||
  8233. docElem.msMatchesSelector) )) ) {
  8234. assert(function( el ) {
  8235. // Check to see if it's possible to do matchesSelector
  8236. // on a disconnected node (IE 9)
  8237. support.disconnectedMatch = matches.call( el, "*" );
  8238. // This should fail with an exception
  8239. // Gecko does not error, returns false instead
  8240. matches.call( el, "[s!='']:x" );
  8241. rbuggyMatches.push( "!=", pseudos );
  8242. });
  8243. }
  8244. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8245. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8246. /* Contains
  8247. ---------------------------------------------------------------------- */
  8248. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8249. // Element contains another
  8250. // Purposefully self-exclusive
  8251. // As in, an element does not contain itself
  8252. contains = hasCompare || rnative.test( docElem.contains ) ?
  8253. function( a, b ) {
  8254. var adown = a.nodeType === 9 ? a.documentElement : a,
  8255. bup = b && b.parentNode;
  8256. return a === bup || !!( bup && bup.nodeType === 1 && (
  8257. adown.contains ?
  8258. adown.contains( bup ) :
  8259. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8260. ));
  8261. } :
  8262. function( a, b ) {
  8263. if ( b ) {
  8264. while ( (b = b.parentNode) ) {
  8265. if ( b === a ) {
  8266. return true;
  8267. }
  8268. }
  8269. }
  8270. return false;
  8271. };
  8272. /* Sorting
  8273. ---------------------------------------------------------------------- */
  8274. // Document order sorting
  8275. sortOrder = hasCompare ?
  8276. function( a, b ) {
  8277. // Flag for duplicate removal
  8278. if ( a === b ) {
  8279. hasDuplicate = true;
  8280. return 0;
  8281. }
  8282. // Sort on method existence if only one input has compareDocumentPosition
  8283. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8284. if ( compare ) {
  8285. return compare;
  8286. }
  8287. // Calculate position if both inputs belong to the same document
  8288. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8289. a.compareDocumentPosition( b ) :
  8290. // Otherwise we know they are disconnected
  8291. 1;
  8292. // Disconnected nodes
  8293. if ( compare & 1 ||
  8294. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8295. // Choose the first element that is related to our preferred document
  8296. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8297. return -1;
  8298. }
  8299. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8300. return 1;
  8301. }
  8302. // Maintain original order
  8303. return sortInput ?
  8304. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8305. 0;
  8306. }
  8307. return compare & 4 ? -1 : 1;
  8308. } :
  8309. function( a, b ) {
  8310. // Exit early if the nodes are identical
  8311. if ( a === b ) {
  8312. hasDuplicate = true;
  8313. return 0;
  8314. }
  8315. var cur,
  8316. i = 0,
  8317. aup = a.parentNode,
  8318. bup = b.parentNode,
  8319. ap = [ a ],
  8320. bp = [ b ];
  8321. // Parentless nodes are either documents or disconnected
  8322. if ( !aup || !bup ) {
  8323. return a === document ? -1 :
  8324. b === document ? 1 :
  8325. aup ? -1 :
  8326. bup ? 1 :
  8327. sortInput ?
  8328. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8329. 0;
  8330. // If the nodes are siblings, we can do a quick check
  8331. } else if ( aup === bup ) {
  8332. return siblingCheck( a, b );
  8333. }
  8334. // Otherwise we need full lists of their ancestors for comparison
  8335. cur = a;
  8336. while ( (cur = cur.parentNode) ) {
  8337. ap.unshift( cur );
  8338. }
  8339. cur = b;
  8340. while ( (cur = cur.parentNode) ) {
  8341. bp.unshift( cur );
  8342. }
  8343. // Walk down the tree looking for a discrepancy
  8344. while ( ap[i] === bp[i] ) {
  8345. i++;
  8346. }
  8347. return i ?
  8348. // Do a sibling check if the nodes have a common ancestor
  8349. siblingCheck( ap[i], bp[i] ) :
  8350. // Otherwise nodes in our document sort first
  8351. ap[i] === preferredDoc ? -1 :
  8352. bp[i] === preferredDoc ? 1 :
  8353. 0;
  8354. };
  8355. return document;
  8356. };
  8357. Sizzle.matches = function( expr, elements ) {
  8358. return Sizzle( expr, null, null, elements );
  8359. };
  8360. Sizzle.matchesSelector = function( elem, expr ) {
  8361. // Set document vars if needed
  8362. if ( ( elem.ownerDocument || elem ) !== document ) {
  8363. setDocument( elem );
  8364. }
  8365. if ( support.matchesSelector && documentIsHTML &&
  8366. !nonnativeSelectorCache[ expr + " " ] &&
  8367. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8368. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8369. try {
  8370. var ret = matches.call( elem, expr );
  8371. // IE 9's matchesSelector returns false on disconnected nodes
  8372. if ( ret || support.disconnectedMatch ||
  8373. // As well, disconnected nodes are said to be in a document
  8374. // fragment in IE 9
  8375. elem.document && elem.document.nodeType !== 11 ) {
  8376. return ret;
  8377. }
  8378. } catch (e) {
  8379. nonnativeSelectorCache( expr, true );
  8380. }
  8381. }
  8382. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8383. };
  8384. Sizzle.contains = function( context, elem ) {
  8385. // Set document vars if needed
  8386. if ( ( context.ownerDocument || context ) !== document ) {
  8387. setDocument( context );
  8388. }
  8389. return contains( context, elem );
  8390. };
  8391. Sizzle.attr = function( elem, name ) {
  8392. // Set document vars if needed
  8393. if ( ( elem.ownerDocument || elem ) !== document ) {
  8394. setDocument( elem );
  8395. }
  8396. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8397. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8398. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8399. fn( elem, name, !documentIsHTML ) :
  8400. undefined;
  8401. return val !== undefined ?
  8402. val :
  8403. support.attributes || !documentIsHTML ?
  8404. elem.getAttribute( name ) :
  8405. (val = elem.getAttributeNode(name)) && val.specified ?
  8406. val.value :
  8407. null;
  8408. };
  8409. Sizzle.escape = function( sel ) {
  8410. return (sel + "").replace( rcssescape, fcssescape );
  8411. };
  8412. Sizzle.error = function( msg ) {
  8413. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8414. };
  8415. /**
  8416. * Document sorting and removing duplicates
  8417. * @param {ArrayLike} results
  8418. */
  8419. Sizzle.uniqueSort = function( results ) {
  8420. var elem,
  8421. duplicates = [],
  8422. j = 0,
  8423. i = 0;
  8424. // Unless we *know* we can detect duplicates, assume their presence
  8425. hasDuplicate = !support.detectDuplicates;
  8426. sortInput = !support.sortStable && results.slice( 0 );
  8427. results.sort( sortOrder );
  8428. if ( hasDuplicate ) {
  8429. while ( (elem = results[i++]) ) {
  8430. if ( elem === results[ i ] ) {
  8431. j = duplicates.push( i );
  8432. }
  8433. }
  8434. while ( j-- ) {
  8435. results.splice( duplicates[ j ], 1 );
  8436. }
  8437. }
  8438. // Clear input after sorting to release objects
  8439. // See https://github.com/jquery/sizzle/pull/225
  8440. sortInput = null;
  8441. return results;
  8442. };
  8443. /**
  8444. * Utility function for retrieving the text value of an array of DOM nodes
  8445. * @param {Array|Element} elem
  8446. */
  8447. getText = Sizzle.getText = function( elem ) {
  8448. var node,
  8449. ret = "",
  8450. i = 0,
  8451. nodeType = elem.nodeType;
  8452. if ( !nodeType ) {
  8453. // If no nodeType, this is expected to be an array
  8454. while ( (node = elem[i++]) ) {
  8455. // Do not traverse comment nodes
  8456. ret += getText( node );
  8457. }
  8458. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8459. // Use textContent for elements
  8460. // innerText usage removed for consistency of new lines (jQuery #11153)
  8461. if ( typeof elem.textContent === "string" ) {
  8462. return elem.textContent;
  8463. } else {
  8464. // Traverse its children
  8465. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8466. ret += getText( elem );
  8467. }
  8468. }
  8469. } else if ( nodeType === 3 || nodeType === 4 ) {
  8470. return elem.nodeValue;
  8471. }
  8472. // Do not include comment or processing instruction nodes
  8473. return ret;
  8474. };
  8475. Expr = Sizzle.selectors = {
  8476. // Can be adjusted by the user
  8477. cacheLength: 50,
  8478. createPseudo: markFunction,
  8479. match: matchExpr,
  8480. attrHandle: {},
  8481. find: {},
  8482. relative: {
  8483. ">": { dir: "parentNode", first: true },
  8484. " ": { dir: "parentNode" },
  8485. "+": { dir: "previousSibling", first: true },
  8486. "~": { dir: "previousSibling" }
  8487. },
  8488. preFilter: {
  8489. "ATTR": function( match ) {
  8490. match[1] = match[1].replace( runescape, funescape );
  8491. // Move the given value to match[3] whether quoted or unquoted
  8492. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8493. if ( match[2] === "~=" ) {
  8494. match[3] = " " + match[3] + " ";
  8495. }
  8496. return match.slice( 0, 4 );
  8497. },
  8498. "CHILD": function( match ) {
  8499. /* matches from matchExpr["CHILD"]
  8500. 1 type (only|nth|...)
  8501. 2 what (child|of-type)
  8502. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8503. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8504. 5 sign of xn-component
  8505. 6 x of xn-component
  8506. 7 sign of y-component
  8507. 8 y of y-component
  8508. */
  8509. match[1] = match[1].toLowerCase();
  8510. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8511. // nth-* requires argument
  8512. if ( !match[3] ) {
  8513. Sizzle.error( match[0] );
  8514. }
  8515. // numeric x and y parameters for Expr.filter.CHILD
  8516. // remember that false/true cast respectively to 0/1
  8517. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8518. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8519. // other types prohibit arguments
  8520. } else if ( match[3] ) {
  8521. Sizzle.error( match[0] );
  8522. }
  8523. return match;
  8524. },
  8525. "PSEUDO": function( match ) {
  8526. var excess,
  8527. unquoted = !match[6] && match[2];
  8528. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8529. return null;
  8530. }
  8531. // Accept quoted arguments as-is
  8532. if ( match[3] ) {
  8533. match[2] = match[4] || match[5] || "";
  8534. // Strip excess characters from unquoted arguments
  8535. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8536. // Get excess from tokenize (recursively)
  8537. (excess = tokenize( unquoted, true )) &&
  8538. // advance to the next closing parenthesis
  8539. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8540. // excess is a negative index
  8541. match[0] = match[0].slice( 0, excess );
  8542. match[2] = unquoted.slice( 0, excess );
  8543. }
  8544. // Return only captures needed by the pseudo filter method (type and argument)
  8545. return match.slice( 0, 3 );
  8546. }
  8547. },
  8548. filter: {
  8549. "TAG": function( nodeNameSelector ) {
  8550. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8551. return nodeNameSelector === "*" ?
  8552. function() { return true; } :
  8553. function( elem ) {
  8554. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8555. };
  8556. },
  8557. "CLASS": function( className ) {
  8558. var pattern = classCache[ className + " " ];
  8559. return pattern ||
  8560. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8561. classCache( className, function( elem ) {
  8562. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8563. });
  8564. },
  8565. "ATTR": function( name, operator, check ) {
  8566. return function( elem ) {
  8567. var result = Sizzle.attr( elem, name );
  8568. if ( result == null ) {
  8569. return operator === "!=";
  8570. }
  8571. if ( !operator ) {
  8572. return true;
  8573. }
  8574. result += "";
  8575. return operator === "=" ? result === check :
  8576. operator === "!=" ? result !== check :
  8577. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8578. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8579. operator === "$=" ? check && result.slice( -check.length ) === check :
  8580. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8581. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8582. false;
  8583. };
  8584. },
  8585. "CHILD": function( type, what, argument, first, last ) {
  8586. var simple = type.slice( 0, 3 ) !== "nth",
  8587. forward = type.slice( -4 ) !== "last",
  8588. ofType = what === "of-type";
  8589. return first === 1 && last === 0 ?
  8590. // Shortcut for :nth-*(n)
  8591. function( elem ) {
  8592. return !!elem.parentNode;
  8593. } :
  8594. function( elem, context, xml ) {
  8595. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8596. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8597. parent = elem.parentNode,
  8598. name = ofType && elem.nodeName.toLowerCase(),
  8599. useCache = !xml && !ofType,
  8600. diff = false;
  8601. if ( parent ) {
  8602. // :(first|last|only)-(child|of-type)
  8603. if ( simple ) {
  8604. while ( dir ) {
  8605. node = elem;
  8606. while ( (node = node[ dir ]) ) {
  8607. if ( ofType ?
  8608. node.nodeName.toLowerCase() === name :
  8609. node.nodeType === 1 ) {
  8610. return false;
  8611. }
  8612. }
  8613. // Reverse direction for :only-* (if we haven't yet done so)
  8614. start = dir = type === "only" && !start && "nextSibling";
  8615. }
  8616. return true;
  8617. }
  8618. start = [ forward ? parent.firstChild : parent.lastChild ];
  8619. // non-xml :nth-child(...) stores cache data on `parent`
  8620. if ( forward && useCache ) {
  8621. // Seek `elem` from a previously-cached index
  8622. // ...in a gzip-friendly way
  8623. node = parent;
  8624. outerCache = node[ expando ] || (node[ expando ] = {});
  8625. // Support: IE <9 only
  8626. // Defend against cloned attroperties (jQuery gh-1709)
  8627. uniqueCache = outerCache[ node.uniqueID ] ||
  8628. (outerCache[ node.uniqueID ] = {});
  8629. cache = uniqueCache[ type ] || [];
  8630. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8631. diff = nodeIndex && cache[ 2 ];
  8632. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8633. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8634. // Fallback to seeking `elem` from the start
  8635. (diff = nodeIndex = 0) || start.pop()) ) {
  8636. // When found, cache indexes on `parent` and break
  8637. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8638. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8639. break;
  8640. }
  8641. }
  8642. } else {
  8643. // Use previously-cached element index if available
  8644. if ( useCache ) {
  8645. // ...in a gzip-friendly way
  8646. node = elem;
  8647. outerCache = node[ expando ] || (node[ expando ] = {});
  8648. // Support: IE <9 only
  8649. // Defend against cloned attroperties (jQuery gh-1709)
  8650. uniqueCache = outerCache[ node.uniqueID ] ||
  8651. (outerCache[ node.uniqueID ] = {});
  8652. cache = uniqueCache[ type ] || [];
  8653. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8654. diff = nodeIndex;
  8655. }
  8656. // xml :nth-child(...)
  8657. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8658. if ( diff === false ) {
  8659. // Use the same loop as above to seek `elem` from the start
  8660. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8661. (diff = nodeIndex = 0) || start.pop()) ) {
  8662. if ( ( ofType ?
  8663. node.nodeName.toLowerCase() === name :
  8664. node.nodeType === 1 ) &&
  8665. ++diff ) {
  8666. // Cache the index of each encountered element
  8667. if ( useCache ) {
  8668. outerCache = node[ expando ] || (node[ expando ] = {});
  8669. // Support: IE <9 only
  8670. // Defend against cloned attroperties (jQuery gh-1709)
  8671. uniqueCache = outerCache[ node.uniqueID ] ||
  8672. (outerCache[ node.uniqueID ] = {});
  8673. uniqueCache[ type ] = [ dirruns, diff ];
  8674. }
  8675. if ( node === elem ) {
  8676. break;
  8677. }
  8678. }
  8679. }
  8680. }
  8681. }
  8682. // Incorporate the offset, then check against cycle size
  8683. diff -= last;
  8684. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8685. }
  8686. };
  8687. },
  8688. "PSEUDO": function( pseudo, argument ) {
  8689. // pseudo-class names are case-insensitive
  8690. // http://www.w3.org/TR/selectors/#pseudo-classes
  8691. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8692. // Remember that setFilters inherits from pseudos
  8693. var args,
  8694. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8695. Sizzle.error( "unsupported pseudo: " + pseudo );
  8696. // The user may use createPseudo to indicate that
  8697. // arguments are needed to create the filter function
  8698. // just as Sizzle does
  8699. if ( fn[ expando ] ) {
  8700. return fn( argument );
  8701. }
  8702. // But maintain support for old signatures
  8703. if ( fn.length > 1 ) {
  8704. args = [ pseudo, pseudo, "", argument ];
  8705. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8706. markFunction(function( seed, matches ) {
  8707. var idx,
  8708. matched = fn( seed, argument ),
  8709. i = matched.length;
  8710. while ( i-- ) {
  8711. idx = indexOf( seed, matched[i] );
  8712. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8713. }
  8714. }) :
  8715. function( elem ) {
  8716. return fn( elem, 0, args );
  8717. };
  8718. }
  8719. return fn;
  8720. }
  8721. },
  8722. pseudos: {
  8723. // Potentially complex pseudos
  8724. "not": markFunction(function( selector ) {
  8725. // Trim the selector passed to compile
  8726. // to avoid treating leading and trailing
  8727. // spaces as combinators
  8728. var input = [],
  8729. results = [],
  8730. matcher = compile( selector.replace( rtrim, "$1" ) );
  8731. return matcher[ expando ] ?
  8732. markFunction(function( seed, matches, context, xml ) {
  8733. var elem,
  8734. unmatched = matcher( seed, null, xml, [] ),
  8735. i = seed.length;
  8736. // Match elements unmatched by `matcher`
  8737. while ( i-- ) {
  8738. if ( (elem = unmatched[i]) ) {
  8739. seed[i] = !(matches[i] = elem);
  8740. }
  8741. }
  8742. }) :
  8743. function( elem, context, xml ) {
  8744. input[0] = elem;
  8745. matcher( input, null, xml, results );
  8746. // Don't keep the element (issue #299)
  8747. input[0] = null;
  8748. return !results.pop();
  8749. };
  8750. }),
  8751. "has": markFunction(function( selector ) {
  8752. return function( elem ) {
  8753. return Sizzle( selector, elem ).length > 0;
  8754. };
  8755. }),
  8756. "contains": markFunction(function( text ) {
  8757. text = text.replace( runescape, funescape );
  8758. return function( elem ) {
  8759. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8760. };
  8761. }),
  8762. // "Whether an element is represented by a :lang() selector
  8763. // is based solely on the element's language value
  8764. // being equal to the identifier C,
  8765. // or beginning with the identifier C immediately followed by "-".
  8766. // The matching of C against the element's language value is performed case-insensitively.
  8767. // The identifier C does not have to be a valid language name."
  8768. // http://www.w3.org/TR/selectors/#lang-pseudo
  8769. "lang": markFunction( function( lang ) {
  8770. // lang value must be a valid identifier
  8771. if ( !ridentifier.test(lang || "") ) {
  8772. Sizzle.error( "unsupported lang: " + lang );
  8773. }
  8774. lang = lang.replace( runescape, funescape ).toLowerCase();
  8775. return function( elem ) {
  8776. var elemLang;
  8777. do {
  8778. if ( (elemLang = documentIsHTML ?
  8779. elem.lang :
  8780. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8781. elemLang = elemLang.toLowerCase();
  8782. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8783. }
  8784. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8785. return false;
  8786. };
  8787. }),
  8788. // Miscellaneous
  8789. "target": function( elem ) {
  8790. var hash = window.location && window.location.hash;
  8791. return hash && hash.slice( 1 ) === elem.id;
  8792. },
  8793. "root": function( elem ) {
  8794. return elem === docElem;
  8795. },
  8796. "focus": function( elem ) {
  8797. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8798. },
  8799. // Boolean properties
  8800. "enabled": createDisabledPseudo( false ),
  8801. "disabled": createDisabledPseudo( true ),
  8802. "checked": function( elem ) {
  8803. // In CSS3, :checked should return both checked and selected elements
  8804. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8805. var nodeName = elem.nodeName.toLowerCase();
  8806. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8807. },
  8808. "selected": function( elem ) {
  8809. // Accessing this property makes selected-by-default
  8810. // options in Safari work properly
  8811. if ( elem.parentNode ) {
  8812. elem.parentNode.selectedIndex;
  8813. }
  8814. return elem.selected === true;
  8815. },
  8816. // Contents
  8817. "empty": function( elem ) {
  8818. // http://www.w3.org/TR/selectors/#empty-pseudo
  8819. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8820. // but not by others (comment: 8; processing instruction: 7; etc.)
  8821. // nodeType < 6 works because attributes (2) do not appear as children
  8822. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8823. if ( elem.nodeType < 6 ) {
  8824. return false;
  8825. }
  8826. }
  8827. return true;
  8828. },
  8829. "parent": function( elem ) {
  8830. return !Expr.pseudos["empty"]( elem );
  8831. },
  8832. // Element/input types
  8833. "header": function( elem ) {
  8834. return rheader.test( elem.nodeName );
  8835. },
  8836. "input": function( elem ) {
  8837. return rinputs.test( elem.nodeName );
  8838. },
  8839. "button": function( elem ) {
  8840. var name = elem.nodeName.toLowerCase();
  8841. return name === "input" && elem.type === "button" || name === "button";
  8842. },
  8843. "text": function( elem ) {
  8844. var attr;
  8845. return elem.nodeName.toLowerCase() === "input" &&
  8846. elem.type === "text" &&
  8847. // Support: IE<8
  8848. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8849. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8850. },
  8851. // Position-in-collection
  8852. "first": createPositionalPseudo(function() {
  8853. return [ 0 ];
  8854. }),
  8855. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8856. return [ length - 1 ];
  8857. }),
  8858. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8859. return [ argument < 0 ? argument + length : argument ];
  8860. }),
  8861. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8862. var i = 0;
  8863. for ( ; i < length; i += 2 ) {
  8864. matchIndexes.push( i );
  8865. }
  8866. return matchIndexes;
  8867. }),
  8868. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8869. var i = 1;
  8870. for ( ; i < length; i += 2 ) {
  8871. matchIndexes.push( i );
  8872. }
  8873. return matchIndexes;
  8874. }),
  8875. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8876. var i = argument < 0 ?
  8877. argument + length :
  8878. argument > length ?
  8879. length :
  8880. argument;
  8881. for ( ; --i >= 0; ) {
  8882. matchIndexes.push( i );
  8883. }
  8884. return matchIndexes;
  8885. }),
  8886. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8887. var i = argument < 0 ? argument + length : argument;
  8888. for ( ; ++i < length; ) {
  8889. matchIndexes.push( i );
  8890. }
  8891. return matchIndexes;
  8892. })
  8893. }
  8894. };
  8895. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8896. // Add button/input type pseudos
  8897. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8898. Expr.pseudos[ i ] = createInputPseudo( i );
  8899. }
  8900. for ( i in { submit: true, reset: true } ) {
  8901. Expr.pseudos[ i ] = createButtonPseudo( i );
  8902. }
  8903. // Easy API for creating new setFilters
  8904. function setFilters() {}
  8905. setFilters.prototype = Expr.filters = Expr.pseudos;
  8906. Expr.setFilters = new setFilters();
  8907. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8908. var matched, match, tokens, type,
  8909. soFar, groups, preFilters,
  8910. cached = tokenCache[ selector + " " ];
  8911. if ( cached ) {
  8912. return parseOnly ? 0 : cached.slice( 0 );
  8913. }
  8914. soFar = selector;
  8915. groups = [];
  8916. preFilters = Expr.preFilter;
  8917. while ( soFar ) {
  8918. // Comma and first run
  8919. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8920. if ( match ) {
  8921. // Don't consume trailing commas as valid
  8922. soFar = soFar.slice( match[0].length ) || soFar;
  8923. }
  8924. groups.push( (tokens = []) );
  8925. }
  8926. matched = false;
  8927. // Combinators
  8928. if ( (match = rcombinators.exec( soFar )) ) {
  8929. matched = match.shift();
  8930. tokens.push({
  8931. value: matched,
  8932. // Cast descendant combinators to space
  8933. type: match[0].replace( rtrim, " " )
  8934. });
  8935. soFar = soFar.slice( matched.length );
  8936. }
  8937. // Filters
  8938. for ( type in Expr.filter ) {
  8939. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8940. (match = preFilters[ type ]( match ))) ) {
  8941. matched = match.shift();
  8942. tokens.push({
  8943. value: matched,
  8944. type: type,
  8945. matches: match
  8946. });
  8947. soFar = soFar.slice( matched.length );
  8948. }
  8949. }
  8950. if ( !matched ) {
  8951. break;
  8952. }
  8953. }
  8954. // Return the length of the invalid excess
  8955. // if we're just parsing
  8956. // Otherwise, throw an error or return tokens
  8957. return parseOnly ?
  8958. soFar.length :
  8959. soFar ?
  8960. Sizzle.error( selector ) :
  8961. // Cache the tokens
  8962. tokenCache( selector, groups ).slice( 0 );
  8963. };
  8964. function toSelector( tokens ) {
  8965. var i = 0,
  8966. len = tokens.length,
  8967. selector = "";
  8968. for ( ; i < len; i++ ) {
  8969. selector += tokens[i].value;
  8970. }
  8971. return selector;
  8972. }
  8973. function addCombinator( matcher, combinator, base ) {
  8974. var dir = combinator.dir,
  8975. skip = combinator.next,
  8976. key = skip || dir,
  8977. checkNonElements = base && key === "parentNode",
  8978. doneName = done++;
  8979. return combinator.first ?
  8980. // Check against closest ancestor/preceding element
  8981. function( elem, context, xml ) {
  8982. while ( (elem = elem[ dir ]) ) {
  8983. if ( elem.nodeType === 1 || checkNonElements ) {
  8984. return matcher( elem, context, xml );
  8985. }
  8986. }
  8987. return false;
  8988. } :
  8989. // Check against all ancestor/preceding elements
  8990. function( elem, context, xml ) {
  8991. var oldCache, uniqueCache, outerCache,
  8992. newCache = [ dirruns, doneName ];
  8993. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8994. if ( xml ) {
  8995. while ( (elem = elem[ dir ]) ) {
  8996. if ( elem.nodeType === 1 || checkNonElements ) {
  8997. if ( matcher( elem, context, xml ) ) {
  8998. return true;
  8999. }
  9000. }
  9001. }
  9002. } else {
  9003. while ( (elem = elem[ dir ]) ) {
  9004. if ( elem.nodeType === 1 || checkNonElements ) {
  9005. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9006. // Support: IE <9 only
  9007. // Defend against cloned attroperties (jQuery gh-1709)
  9008. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9009. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9010. elem = elem[ dir ] || elem;
  9011. } else if ( (oldCache = uniqueCache[ key ]) &&
  9012. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9013. // Assign to newCache so results back-propagate to previous elements
  9014. return (newCache[ 2 ] = oldCache[ 2 ]);
  9015. } else {
  9016. // Reuse newcache so results back-propagate to previous elements
  9017. uniqueCache[ key ] = newCache;
  9018. // A match means we're done; a fail means we have to keep checking
  9019. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9020. return true;
  9021. }
  9022. }
  9023. }
  9024. }
  9025. }
  9026. return false;
  9027. };
  9028. }
  9029. function elementMatcher( matchers ) {
  9030. return matchers.length > 1 ?
  9031. function( elem, context, xml ) {
  9032. var i = matchers.length;
  9033. while ( i-- ) {
  9034. if ( !matchers[i]( elem, context, xml ) ) {
  9035. return false;
  9036. }
  9037. }
  9038. return true;
  9039. } :
  9040. matchers[0];
  9041. }
  9042. function multipleContexts( selector, contexts, results ) {
  9043. var i = 0,
  9044. len = contexts.length;
  9045. for ( ; i < len; i++ ) {
  9046. Sizzle( selector, contexts[i], results );
  9047. }
  9048. return results;
  9049. }
  9050. function condense( unmatched, map, filter, context, xml ) {
  9051. var elem,
  9052. newUnmatched = [],
  9053. i = 0,
  9054. len = unmatched.length,
  9055. mapped = map != null;
  9056. for ( ; i < len; i++ ) {
  9057. if ( (elem = unmatched[i]) ) {
  9058. if ( !filter || filter( elem, context, xml ) ) {
  9059. newUnmatched.push( elem );
  9060. if ( mapped ) {
  9061. map.push( i );
  9062. }
  9063. }
  9064. }
  9065. }
  9066. return newUnmatched;
  9067. }
  9068. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9069. if ( postFilter && !postFilter[ expando ] ) {
  9070. postFilter = setMatcher( postFilter );
  9071. }
  9072. if ( postFinder && !postFinder[ expando ] ) {
  9073. postFinder = setMatcher( postFinder, postSelector );
  9074. }
  9075. return markFunction(function( seed, results, context, xml ) {
  9076. var temp, i, elem,
  9077. preMap = [],
  9078. postMap = [],
  9079. preexisting = results.length,
  9080. // Get initial elements from seed or context
  9081. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9082. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9083. matcherIn = preFilter && ( seed || !selector ) ?
  9084. condense( elems, preMap, preFilter, context, xml ) :
  9085. elems,
  9086. matcherOut = matcher ?
  9087. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9088. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9089. // ...intermediate processing is necessary
  9090. [] :
  9091. // ...otherwise use results directly
  9092. results :
  9093. matcherIn;
  9094. // Find primary matches
  9095. if ( matcher ) {
  9096. matcher( matcherIn, matcherOut, context, xml );
  9097. }
  9098. // Apply postFilter
  9099. if ( postFilter ) {
  9100. temp = condense( matcherOut, postMap );
  9101. postFilter( temp, [], context, xml );
  9102. // Un-match failing elements by moving them back to matcherIn
  9103. i = temp.length;
  9104. while ( i-- ) {
  9105. if ( (elem = temp[i]) ) {
  9106. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9107. }
  9108. }
  9109. }
  9110. if ( seed ) {
  9111. if ( postFinder || preFilter ) {
  9112. if ( postFinder ) {
  9113. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9114. temp = [];
  9115. i = matcherOut.length;
  9116. while ( i-- ) {
  9117. if ( (elem = matcherOut[i]) ) {
  9118. // Restore matcherIn since elem is not yet a final match
  9119. temp.push( (matcherIn[i] = elem) );
  9120. }
  9121. }
  9122. postFinder( null, (matcherOut = []), temp, xml );
  9123. }
  9124. // Move matched elements from seed to results to keep them synchronized
  9125. i = matcherOut.length;
  9126. while ( i-- ) {
  9127. if ( (elem = matcherOut[i]) &&
  9128. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9129. seed[temp] = !(results[temp] = elem);
  9130. }
  9131. }
  9132. }
  9133. // Add elements to results, through postFinder if defined
  9134. } else {
  9135. matcherOut = condense(
  9136. matcherOut === results ?
  9137. matcherOut.splice( preexisting, matcherOut.length ) :
  9138. matcherOut
  9139. );
  9140. if ( postFinder ) {
  9141. postFinder( null, results, matcherOut, xml );
  9142. } else {
  9143. push.apply( results, matcherOut );
  9144. }
  9145. }
  9146. });
  9147. }
  9148. function matcherFromTokens( tokens ) {
  9149. var checkContext, matcher, j,
  9150. len = tokens.length,
  9151. leadingRelative = Expr.relative[ tokens[0].type ],
  9152. implicitRelative = leadingRelative || Expr.relative[" "],
  9153. i = leadingRelative ? 1 : 0,
  9154. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9155. matchContext = addCombinator( function( elem ) {
  9156. return elem === checkContext;
  9157. }, implicitRelative, true ),
  9158. matchAnyContext = addCombinator( function( elem ) {
  9159. return indexOf( checkContext, elem ) > -1;
  9160. }, implicitRelative, true ),
  9161. matchers = [ function( elem, context, xml ) {
  9162. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9163. (checkContext = context).nodeType ?
  9164. matchContext( elem, context, xml ) :
  9165. matchAnyContext( elem, context, xml ) );
  9166. // Avoid hanging onto element (issue #299)
  9167. checkContext = null;
  9168. return ret;
  9169. } ];
  9170. for ( ; i < len; i++ ) {
  9171. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9172. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9173. } else {
  9174. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9175. // Return special upon seeing a positional matcher
  9176. if ( matcher[ expando ] ) {
  9177. // Find the next relative operator (if any) for proper handling
  9178. j = ++i;
  9179. for ( ; j < len; j++ ) {
  9180. if ( Expr.relative[ tokens[j].type ] ) {
  9181. break;
  9182. }
  9183. }
  9184. return setMatcher(
  9185. i > 1 && elementMatcher( matchers ),
  9186. i > 1 && toSelector(
  9187. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9188. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9189. ).replace( rtrim, "$1" ),
  9190. matcher,
  9191. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9192. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9193. j < len && toSelector( tokens )
  9194. );
  9195. }
  9196. matchers.push( matcher );
  9197. }
  9198. }
  9199. return elementMatcher( matchers );
  9200. }
  9201. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9202. var bySet = setMatchers.length > 0,
  9203. byElement = elementMatchers.length > 0,
  9204. superMatcher = function( seed, context, xml, results, outermost ) {
  9205. var elem, j, matcher,
  9206. matchedCount = 0,
  9207. i = "0",
  9208. unmatched = seed && [],
  9209. setMatched = [],
  9210. contextBackup = outermostContext,
  9211. // We must always have either seed elements or outermost context
  9212. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9213. // Use integer dirruns iff this is the outermost matcher
  9214. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9215. len = elems.length;
  9216. if ( outermost ) {
  9217. outermostContext = context === document || context || outermost;
  9218. }
  9219. // Add elements passing elementMatchers directly to results
  9220. // Support: IE<9, Safari
  9221. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9222. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9223. if ( byElement && elem ) {
  9224. j = 0;
  9225. if ( !context && elem.ownerDocument !== document ) {
  9226. setDocument( elem );
  9227. xml = !documentIsHTML;
  9228. }
  9229. while ( (matcher = elementMatchers[j++]) ) {
  9230. if ( matcher( elem, context || document, xml) ) {
  9231. results.push( elem );
  9232. break;
  9233. }
  9234. }
  9235. if ( outermost ) {
  9236. dirruns = dirrunsUnique;
  9237. }
  9238. }
  9239. // Track unmatched elements for set filters
  9240. if ( bySet ) {
  9241. // They will have gone through all possible matchers
  9242. if ( (elem = !matcher && elem) ) {
  9243. matchedCount--;
  9244. }
  9245. // Lengthen the array for every element, matched or not
  9246. if ( seed ) {
  9247. unmatched.push( elem );
  9248. }
  9249. }
  9250. }
  9251. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9252. // makes the latter nonnegative.
  9253. matchedCount += i;
  9254. // Apply set filters to unmatched elements
  9255. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9256. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9257. // no element matchers and no seed.
  9258. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9259. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9260. // numerically zero.
  9261. if ( bySet && i !== matchedCount ) {
  9262. j = 0;
  9263. while ( (matcher = setMatchers[j++]) ) {
  9264. matcher( unmatched, setMatched, context, xml );
  9265. }
  9266. if ( seed ) {
  9267. // Reintegrate element matches to eliminate the need for sorting
  9268. if ( matchedCount > 0 ) {
  9269. while ( i-- ) {
  9270. if ( !(unmatched[i] || setMatched[i]) ) {
  9271. setMatched[i] = pop.call( results );
  9272. }
  9273. }
  9274. }
  9275. // Discard index placeholder values to get only actual matches
  9276. setMatched = condense( setMatched );
  9277. }
  9278. // Add matches to results
  9279. push.apply( results, setMatched );
  9280. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9281. if ( outermost && !seed && setMatched.length > 0 &&
  9282. ( matchedCount + setMatchers.length ) > 1 ) {
  9283. Sizzle.uniqueSort( results );
  9284. }
  9285. }
  9286. // Override manipulation of globals by nested matchers
  9287. if ( outermost ) {
  9288. dirruns = dirrunsUnique;
  9289. outermostContext = contextBackup;
  9290. }
  9291. return unmatched;
  9292. };
  9293. return bySet ?
  9294. markFunction( superMatcher ) :
  9295. superMatcher;
  9296. }
  9297. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9298. var i,
  9299. setMatchers = [],
  9300. elementMatchers = [],
  9301. cached = compilerCache[ selector + " " ];
  9302. if ( !cached ) {
  9303. // Generate a function of recursive functions that can be used to check each element
  9304. if ( !match ) {
  9305. match = tokenize( selector );
  9306. }
  9307. i = match.length;
  9308. while ( i-- ) {
  9309. cached = matcherFromTokens( match[i] );
  9310. if ( cached[ expando ] ) {
  9311. setMatchers.push( cached );
  9312. } else {
  9313. elementMatchers.push( cached );
  9314. }
  9315. }
  9316. // Cache the compiled function
  9317. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9318. // Save selector and tokenization
  9319. cached.selector = selector;
  9320. }
  9321. return cached;
  9322. };
  9323. /**
  9324. * A low-level selection function that works with Sizzle's compiled
  9325. * selector functions
  9326. * @param {String|Function} selector A selector or a pre-compiled
  9327. * selector function built with Sizzle.compile
  9328. * @param {Element} context
  9329. * @param {Array} [results]
  9330. * @param {Array} [seed] A set of elements to match against
  9331. */
  9332. select = Sizzle.select = function( selector, context, results, seed ) {
  9333. var i, tokens, token, type, find,
  9334. compiled = typeof selector === "function" && selector,
  9335. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9336. results = results || [];
  9337. // Try to minimize operations if there is only one selector in the list and no seed
  9338. // (the latter of which guarantees us context)
  9339. if ( match.length === 1 ) {
  9340. // Reduce context if the leading compound selector is an ID
  9341. tokens = match[0] = match[0].slice( 0 );
  9342. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9343. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9344. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9345. if ( !context ) {
  9346. return results;
  9347. // Precompiled matchers will still verify ancestry, so step up a level
  9348. } else if ( compiled ) {
  9349. context = context.parentNode;
  9350. }
  9351. selector = selector.slice( tokens.shift().value.length );
  9352. }
  9353. // Fetch a seed set for right-to-left matching
  9354. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9355. while ( i-- ) {
  9356. token = tokens[i];
  9357. // Abort if we hit a combinator
  9358. if ( Expr.relative[ (type = token.type) ] ) {
  9359. break;
  9360. }
  9361. if ( (find = Expr.find[ type ]) ) {
  9362. // Search, expanding context for leading sibling combinators
  9363. if ( (seed = find(
  9364. token.matches[0].replace( runescape, funescape ),
  9365. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9366. )) ) {
  9367. // If seed is empty or no tokens remain, we can return early
  9368. tokens.splice( i, 1 );
  9369. selector = seed.length && toSelector( tokens );
  9370. if ( !selector ) {
  9371. push.apply( results, seed );
  9372. return results;
  9373. }
  9374. break;
  9375. }
  9376. }
  9377. }
  9378. }
  9379. // Compile and execute a filtering function if one is not provided
  9380. // Provide `match` to avoid retokenization if we modified the selector above
  9381. ( compiled || compile( selector, match ) )(
  9382. seed,
  9383. context,
  9384. !documentIsHTML,
  9385. results,
  9386. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9387. );
  9388. return results;
  9389. };
  9390. // One-time assignments
  9391. // Sort stability
  9392. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9393. // Support: Chrome 14-35+
  9394. // Always assume duplicates if they aren't passed to the comparison function
  9395. support.detectDuplicates = !!hasDuplicate;
  9396. // Initialize against the default document
  9397. setDocument();
  9398. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9399. // Detached nodes confoundingly follow *each other*
  9400. support.sortDetached = assert(function( el ) {
  9401. // Should return 1, but returns 4 (following)
  9402. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9403. });
  9404. // Support: IE<8
  9405. // Prevent attribute/property "interpolation"
  9406. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9407. if ( !assert(function( el ) {
  9408. el.innerHTML = "<a href='#'></a>";
  9409. return el.firstChild.getAttribute("href") === "#" ;
  9410. }) ) {
  9411. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9412. if ( !isXML ) {
  9413. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9414. }
  9415. });
  9416. }
  9417. // Support: IE<9
  9418. // Use defaultValue in place of getAttribute("value")
  9419. if ( !support.attributes || !assert(function( el ) {
  9420. el.innerHTML = "<input/>";
  9421. el.firstChild.setAttribute( "value", "" );
  9422. return el.firstChild.getAttribute( "value" ) === "";
  9423. }) ) {
  9424. addHandle( "value", function( elem, name, isXML ) {
  9425. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9426. return elem.defaultValue;
  9427. }
  9428. });
  9429. }
  9430. // Support: IE<9
  9431. // Use getAttributeNode to fetch booleans when getAttribute lies
  9432. if ( !assert(function( el ) {
  9433. return el.getAttribute("disabled") == null;
  9434. }) ) {
  9435. addHandle( booleans, function( elem, name, isXML ) {
  9436. var val;
  9437. if ( !isXML ) {
  9438. return elem[ name ] === true ? name.toLowerCase() :
  9439. (val = elem.getAttributeNode( name )) && val.specified ?
  9440. val.value :
  9441. null;
  9442. }
  9443. });
  9444. }
  9445. return Sizzle;
  9446. })( window );
  9447. jQuery.find = Sizzle;
  9448. jQuery.expr = Sizzle.selectors;
  9449. // Deprecated
  9450. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9451. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9452. jQuery.text = Sizzle.getText;
  9453. jQuery.isXMLDoc = Sizzle.isXML;
  9454. jQuery.contains = Sizzle.contains;
  9455. jQuery.escapeSelector = Sizzle.escape;
  9456. var dir = function( elem, dir, until ) {
  9457. var matched = [],
  9458. truncate = until !== undefined;
  9459. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9460. if ( elem.nodeType === 1 ) {
  9461. if ( truncate && jQuery( elem ).is( until ) ) {
  9462. break;
  9463. }
  9464. matched.push( elem );
  9465. }
  9466. }
  9467. return matched;
  9468. };
  9469. var siblings = function( n, elem ) {
  9470. var matched = [];
  9471. for ( ; n; n = n.nextSibling ) {
  9472. if ( n.nodeType === 1 && n !== elem ) {
  9473. matched.push( n );
  9474. }
  9475. }
  9476. return matched;
  9477. };
  9478. var rneedsContext = jQuery.expr.match.needsContext;
  9479. function nodeName( elem, name ) {
  9480. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9481. };
  9482. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9483. // Implement the identical functionality for filter and not
  9484. function winnow( elements, qualifier, not ) {
  9485. if ( isFunction( qualifier ) ) {
  9486. return jQuery.grep( elements, function( elem, i ) {
  9487. return !!qualifier.call( elem, i, elem ) !== not;
  9488. } );
  9489. }
  9490. // Single element
  9491. if ( qualifier.nodeType ) {
  9492. return jQuery.grep( elements, function( elem ) {
  9493. return ( elem === qualifier ) !== not;
  9494. } );
  9495. }
  9496. // Arraylike of elements (jQuery, arguments, Array)
  9497. if ( typeof qualifier !== "string" ) {
  9498. return jQuery.grep( elements, function( elem ) {
  9499. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9500. } );
  9501. }
  9502. // Filtered directly for both simple and complex selectors
  9503. return jQuery.filter( qualifier, elements, not );
  9504. }
  9505. jQuery.filter = function( expr, elems, not ) {
  9506. var elem = elems[ 0 ];
  9507. if ( not ) {
  9508. expr = ":not(" + expr + ")";
  9509. }
  9510. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9511. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9512. }
  9513. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9514. return elem.nodeType === 1;
  9515. } ) );
  9516. };
  9517. jQuery.fn.extend( {
  9518. find: function( selector ) {
  9519. var i, ret,
  9520. len = this.length,
  9521. self = this;
  9522. if ( typeof selector !== "string" ) {
  9523. return this.pushStack( jQuery( selector ).filter( function() {
  9524. for ( i = 0; i < len; i++ ) {
  9525. if ( jQuery.contains( self[ i ], this ) ) {
  9526. return true;
  9527. }
  9528. }
  9529. } ) );
  9530. }
  9531. ret = this.pushStack( [] );
  9532. for ( i = 0; i < len; i++ ) {
  9533. jQuery.find( selector, self[ i ], ret );
  9534. }
  9535. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9536. },
  9537. filter: function( selector ) {
  9538. return this.pushStack( winnow( this, selector || [], false ) );
  9539. },
  9540. not: function( selector ) {
  9541. return this.pushStack( winnow( this, selector || [], true ) );
  9542. },
  9543. is: function( selector ) {
  9544. return !!winnow(
  9545. this,
  9546. // If this is a positional/relative selector, check membership in the returned set
  9547. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9548. typeof selector === "string" && rneedsContext.test( selector ) ?
  9549. jQuery( selector ) :
  9550. selector || [],
  9551. false
  9552. ).length;
  9553. }
  9554. } );
  9555. // Initialize a jQuery object
  9556. // A central reference to the root jQuery(document)
  9557. var rootjQuery,
  9558. // A simple way to check for HTML strings
  9559. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9560. // Strict HTML recognition (#11290: must start with <)
  9561. // Shortcut simple #id case for speed
  9562. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9563. init = jQuery.fn.init = function( selector, context, root ) {
  9564. var match, elem;
  9565. // HANDLE: $(""), $(null), $(undefined), $(false)
  9566. if ( !selector ) {
  9567. return this;
  9568. }
  9569. // Method init() accepts an alternate rootjQuery
  9570. // so migrate can support jQuery.sub (gh-2101)
  9571. root = root || rootjQuery;
  9572. // Handle HTML strings
  9573. if ( typeof selector === "string" ) {
  9574. if ( selector[ 0 ] === "<" &&
  9575. selector[ selector.length - 1 ] === ">" &&
  9576. selector.length >= 3 ) {
  9577. // Assume that strings that start and end with <> are HTML and skip the regex check
  9578. match = [ null, selector, null ];
  9579. } else {
  9580. match = rquickExpr.exec( selector );
  9581. }
  9582. // Match html or make sure no context is specified for #id
  9583. if ( match && ( match[ 1 ] || !context ) ) {
  9584. // HANDLE: $(html) -> $(array)
  9585. if ( match[ 1 ] ) {
  9586. context = context instanceof jQuery ? context[ 0 ] : context;
  9587. // Option to run scripts is true for back-compat
  9588. // Intentionally let the error be thrown if parseHTML is not present
  9589. jQuery.merge( this, jQuery.parseHTML(
  9590. match[ 1 ],
  9591. context && context.nodeType ? context.ownerDocument || context : document,
  9592. true
  9593. ) );
  9594. // HANDLE: $(html, props)
  9595. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9596. for ( match in context ) {
  9597. // Properties of context are called as methods if possible
  9598. if ( isFunction( this[ match ] ) ) {
  9599. this[ match ]( context[ match ] );
  9600. // ...and otherwise set as attributes
  9601. } else {
  9602. this.attr( match, context[ match ] );
  9603. }
  9604. }
  9605. }
  9606. return this;
  9607. // HANDLE: $(#id)
  9608. } else {
  9609. elem = document.getElementById( match[ 2 ] );
  9610. if ( elem ) {
  9611. // Inject the element directly into the jQuery object
  9612. this[ 0 ] = elem;
  9613. this.length = 1;
  9614. }
  9615. return this;
  9616. }
  9617. // HANDLE: $(expr, $(...))
  9618. } else if ( !context || context.jquery ) {
  9619. return ( context || root ).find( selector );
  9620. // HANDLE: $(expr, context)
  9621. // (which is just equivalent to: $(context).find(expr)
  9622. } else {
  9623. return this.constructor( context ).find( selector );
  9624. }
  9625. // HANDLE: $(DOMElement)
  9626. } else if ( selector.nodeType ) {
  9627. this[ 0 ] = selector;
  9628. this.length = 1;
  9629. return this;
  9630. // HANDLE: $(function)
  9631. // Shortcut for document ready
  9632. } else if ( isFunction( selector ) ) {
  9633. return root.ready !== undefined ?
  9634. root.ready( selector ) :
  9635. // Execute immediately if ready is not present
  9636. selector( jQuery );
  9637. }
  9638. return jQuery.makeArray( selector, this );
  9639. };
  9640. // Give the init function the jQuery prototype for later instantiation
  9641. init.prototype = jQuery.fn;
  9642. // Initialize central reference
  9643. rootjQuery = jQuery( document );
  9644. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9645. // Methods guaranteed to produce a unique set when starting from a unique set
  9646. guaranteedUnique = {
  9647. children: true,
  9648. contents: true,
  9649. next: true,
  9650. prev: true
  9651. };
  9652. jQuery.fn.extend( {
  9653. has: function( target ) {
  9654. var targets = jQuery( target, this ),
  9655. l = targets.length;
  9656. return this.filter( function() {
  9657. var i = 0;
  9658. for ( ; i < l; i++ ) {
  9659. if ( jQuery.contains( this, targets[ i ] ) ) {
  9660. return true;
  9661. }
  9662. }
  9663. } );
  9664. },
  9665. closest: function( selectors, context ) {
  9666. var cur,
  9667. i = 0,
  9668. l = this.length,
  9669. matched = [],
  9670. targets = typeof selectors !== "string" && jQuery( selectors );
  9671. // Positional selectors never match, since there's no _selection_ context
  9672. if ( !rneedsContext.test( selectors ) ) {
  9673. for ( ; i < l; i++ ) {
  9674. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9675. // Always skip document fragments
  9676. if ( cur.nodeType < 11 && ( targets ?
  9677. targets.index( cur ) > -1 :
  9678. // Don't pass non-elements to Sizzle
  9679. cur.nodeType === 1 &&
  9680. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9681. matched.push( cur );
  9682. break;
  9683. }
  9684. }
  9685. }
  9686. }
  9687. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9688. },
  9689. // Determine the position of an element within the set
  9690. index: function( elem ) {
  9691. // No argument, return index in parent
  9692. if ( !elem ) {
  9693. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9694. }
  9695. // Index in selector
  9696. if ( typeof elem === "string" ) {
  9697. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9698. }
  9699. // Locate the position of the desired element
  9700. return indexOf.call( this,
  9701. // If it receives a jQuery object, the first element is used
  9702. elem.jquery ? elem[ 0 ] : elem
  9703. );
  9704. },
  9705. add: function( selector, context ) {
  9706. return this.pushStack(
  9707. jQuery.uniqueSort(
  9708. jQuery.merge( this.get(), jQuery( selector, context ) )
  9709. )
  9710. );
  9711. },
  9712. addBack: function( selector ) {
  9713. return this.add( selector == null ?
  9714. this.prevObject : this.prevObject.filter( selector )
  9715. );
  9716. }
  9717. } );
  9718. function sibling( cur, dir ) {
  9719. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9720. return cur;
  9721. }
  9722. jQuery.each( {
  9723. parent: function( elem ) {
  9724. var parent = elem.parentNode;
  9725. return parent && parent.nodeType !== 11 ? parent : null;
  9726. },
  9727. parents: function( elem ) {
  9728. return dir( elem, "parentNode" );
  9729. },
  9730. parentsUntil: function( elem, i, until ) {
  9731. return dir( elem, "parentNode", until );
  9732. },
  9733. next: function( elem ) {
  9734. return sibling( elem, "nextSibling" );
  9735. },
  9736. prev: function( elem ) {
  9737. return sibling( elem, "previousSibling" );
  9738. },
  9739. nextAll: function( elem ) {
  9740. return dir( elem, "nextSibling" );
  9741. },
  9742. prevAll: function( elem ) {
  9743. return dir( elem, "previousSibling" );
  9744. },
  9745. nextUntil: function( elem, i, until ) {
  9746. return dir( elem, "nextSibling", until );
  9747. },
  9748. prevUntil: function( elem, i, until ) {
  9749. return dir( elem, "previousSibling", until );
  9750. },
  9751. siblings: function( elem ) {
  9752. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9753. },
  9754. children: function( elem ) {
  9755. return siblings( elem.firstChild );
  9756. },
  9757. contents: function( elem ) {
  9758. if ( typeof elem.contentDocument !== "undefined" ) {
  9759. return elem.contentDocument;
  9760. }
  9761. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9762. // Treat the template element as a regular one in browsers that
  9763. // don't support it.
  9764. if ( nodeName( elem, "template" ) ) {
  9765. elem = elem.content || elem;
  9766. }
  9767. return jQuery.merge( [], elem.childNodes );
  9768. }
  9769. }, function( name, fn ) {
  9770. jQuery.fn[ name ] = function( until, selector ) {
  9771. var matched = jQuery.map( this, fn, until );
  9772. if ( name.slice( -5 ) !== "Until" ) {
  9773. selector = until;
  9774. }
  9775. if ( selector && typeof selector === "string" ) {
  9776. matched = jQuery.filter( selector, matched );
  9777. }
  9778. if ( this.length > 1 ) {
  9779. // Remove duplicates
  9780. if ( !guaranteedUnique[ name ] ) {
  9781. jQuery.uniqueSort( matched );
  9782. }
  9783. // Reverse order for parents* and prev-derivatives
  9784. if ( rparentsprev.test( name ) ) {
  9785. matched.reverse();
  9786. }
  9787. }
  9788. return this.pushStack( matched );
  9789. };
  9790. } );
  9791. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9792. // Convert String-formatted options into Object-formatted ones
  9793. function createOptions( options ) {
  9794. var object = {};
  9795. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9796. object[ flag ] = true;
  9797. } );
  9798. return object;
  9799. }
  9800. /*
  9801. * Create a callback list using the following parameters:
  9802. *
  9803. * options: an optional list of space-separated options that will change how
  9804. * the callback list behaves or a more traditional option object
  9805. *
  9806. * By default a callback list will act like an event callback list and can be
  9807. * "fired" multiple times.
  9808. *
  9809. * Possible options:
  9810. *
  9811. * once: will ensure the callback list can only be fired once (like a Deferred)
  9812. *
  9813. * memory: will keep track of previous values and will call any callback added
  9814. * after the list has been fired right away with the latest "memorized"
  9815. * values (like a Deferred)
  9816. *
  9817. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9818. *
  9819. * stopOnFalse: interrupt callings when a callback returns false
  9820. *
  9821. */
  9822. jQuery.Callbacks = function( options ) {
  9823. // Convert options from String-formatted to Object-formatted if needed
  9824. // (we check in cache first)
  9825. options = typeof options === "string" ?
  9826. createOptions( options ) :
  9827. jQuery.extend( {}, options );
  9828. var // Flag to know if list is currently firing
  9829. firing,
  9830. // Last fire value for non-forgettable lists
  9831. memory,
  9832. // Flag to know if list was already fired
  9833. fired,
  9834. // Flag to prevent firing
  9835. locked,
  9836. // Actual callback list
  9837. list = [],
  9838. // Queue of execution data for repeatable lists
  9839. queue = [],
  9840. // Index of currently firing callback (modified by add/remove as needed)
  9841. firingIndex = -1,
  9842. // Fire callbacks
  9843. fire = function() {
  9844. // Enforce single-firing
  9845. locked = locked || options.once;
  9846. // Execute callbacks for all pending executions,
  9847. // respecting firingIndex overrides and runtime changes
  9848. fired = firing = true;
  9849. for ( ; queue.length; firingIndex = -1 ) {
  9850. memory = queue.shift();
  9851. while ( ++firingIndex < list.length ) {
  9852. // Run callback and check for early termination
  9853. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9854. options.stopOnFalse ) {
  9855. // Jump to end and forget the data so .add doesn't re-fire
  9856. firingIndex = list.length;
  9857. memory = false;
  9858. }
  9859. }
  9860. }
  9861. // Forget the data if we're done with it
  9862. if ( !options.memory ) {
  9863. memory = false;
  9864. }
  9865. firing = false;
  9866. // Clean up if we're done firing for good
  9867. if ( locked ) {
  9868. // Keep an empty list if we have data for future add calls
  9869. if ( memory ) {
  9870. list = [];
  9871. // Otherwise, this object is spent
  9872. } else {
  9873. list = "";
  9874. }
  9875. }
  9876. },
  9877. // Actual Callbacks object
  9878. self = {
  9879. // Add a callback or a collection of callbacks to the list
  9880. add: function() {
  9881. if ( list ) {
  9882. // If we have memory from a past run, we should fire after adding
  9883. if ( memory && !firing ) {
  9884. firingIndex = list.length - 1;
  9885. queue.push( memory );
  9886. }
  9887. ( function add( args ) {
  9888. jQuery.each( args, function( _, arg ) {
  9889. if ( isFunction( arg ) ) {
  9890. if ( !options.unique || !self.has( arg ) ) {
  9891. list.push( arg );
  9892. }
  9893. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9894. // Inspect recursively
  9895. add( arg );
  9896. }
  9897. } );
  9898. } )( arguments );
  9899. if ( memory && !firing ) {
  9900. fire();
  9901. }
  9902. }
  9903. return this;
  9904. },
  9905. // Remove a callback from the list
  9906. remove: function() {
  9907. jQuery.each( arguments, function( _, arg ) {
  9908. var index;
  9909. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9910. list.splice( index, 1 );
  9911. // Handle firing indexes
  9912. if ( index <= firingIndex ) {
  9913. firingIndex--;
  9914. }
  9915. }
  9916. } );
  9917. return this;
  9918. },
  9919. // Check if a given callback is in the list.
  9920. // If no argument is given, return whether or not list has callbacks attached.
  9921. has: function( fn ) {
  9922. return fn ?
  9923. jQuery.inArray( fn, list ) > -1 :
  9924. list.length > 0;
  9925. },
  9926. // Remove all callbacks from the list
  9927. empty: function() {
  9928. if ( list ) {
  9929. list = [];
  9930. }
  9931. return this;
  9932. },
  9933. // Disable .fire and .add
  9934. // Abort any current/pending executions
  9935. // Clear all callbacks and values
  9936. disable: function() {
  9937. locked = queue = [];
  9938. list = memory = "";
  9939. return this;
  9940. },
  9941. disabled: function() {
  9942. return !list;
  9943. },
  9944. // Disable .fire
  9945. // Also disable .add unless we have memory (since it would have no effect)
  9946. // Abort any pending executions
  9947. lock: function() {
  9948. locked = queue = [];
  9949. if ( !memory && !firing ) {
  9950. list = memory = "";
  9951. }
  9952. return this;
  9953. },
  9954. locked: function() {
  9955. return !!locked;
  9956. },
  9957. // Call all callbacks with the given context and arguments
  9958. fireWith: function( context, args ) {
  9959. if ( !locked ) {
  9960. args = args || [];
  9961. args = [ context, args.slice ? args.slice() : args ];
  9962. queue.push( args );
  9963. if ( !firing ) {
  9964. fire();
  9965. }
  9966. }
  9967. return this;
  9968. },
  9969. // Call all the callbacks with the given arguments
  9970. fire: function() {
  9971. self.fireWith( this, arguments );
  9972. return this;
  9973. },
  9974. // To know if the callbacks have already been called at least once
  9975. fired: function() {
  9976. return !!fired;
  9977. }
  9978. };
  9979. return self;
  9980. };
  9981. function Identity( v ) {
  9982. return v;
  9983. }
  9984. function Thrower( ex ) {
  9985. throw ex;
  9986. }
  9987. function adoptValue( value, resolve, reject, noValue ) {
  9988. var method;
  9989. try {
  9990. // Check for promise aspect first to privilege synchronous behavior
  9991. if ( value && isFunction( ( method = value.promise ) ) ) {
  9992. method.call( value ).done( resolve ).fail( reject );
  9993. // Other thenables
  9994. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9995. method.call( value, resolve, reject );
  9996. // Other non-thenables
  9997. } else {
  9998. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9999. // * false: [ value ].slice( 0 ) => resolve( value )
  10000. // * true: [ value ].slice( 1 ) => resolve()
  10001. resolve.apply( undefined, [ value ].slice( noValue ) );
  10002. }
  10003. // For Promises/A+, convert exceptions into rejections
  10004. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10005. // Deferred#then to conditionally suppress rejection.
  10006. } catch ( value ) {
  10007. // Support: Android 4.0 only
  10008. // Strict mode functions invoked without .call/.apply get global-object context
  10009. reject.apply( undefined, [ value ] );
  10010. }
  10011. }
  10012. jQuery.extend( {
  10013. Deferred: function( func ) {
  10014. var tuples = [
  10015. // action, add listener, callbacks,
  10016. // ... .then handlers, argument index, [final state]
  10017. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10018. jQuery.Callbacks( "memory" ), 2 ],
  10019. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10020. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10021. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10022. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10023. ],
  10024. state = "pending",
  10025. promise = {
  10026. state: function() {
  10027. return state;
  10028. },
  10029. always: function() {
  10030. deferred.done( arguments ).fail( arguments );
  10031. return this;
  10032. },
  10033. "catch": function( fn ) {
  10034. return promise.then( null, fn );
  10035. },
  10036. // Keep pipe for back-compat
  10037. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10038. var fns = arguments;
  10039. return jQuery.Deferred( function( newDefer ) {
  10040. jQuery.each( tuples, function( i, tuple ) {
  10041. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10042. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10043. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10044. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10045. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10046. deferred[ tuple[ 1 ] ]( function() {
  10047. var returned = fn && fn.apply( this, arguments );
  10048. if ( returned && isFunction( returned.promise ) ) {
  10049. returned.promise()
  10050. .progress( newDefer.notify )
  10051. .done( newDefer.resolve )
  10052. .fail( newDefer.reject );
  10053. } else {
  10054. newDefer[ tuple[ 0 ] + "With" ](
  10055. this,
  10056. fn ? [ returned ] : arguments
  10057. );
  10058. }
  10059. } );
  10060. } );
  10061. fns = null;
  10062. } ).promise();
  10063. },
  10064. then: function( onFulfilled, onRejected, onProgress ) {
  10065. var maxDepth = 0;
  10066. function resolve( depth, deferred, handler, special ) {
  10067. return function() {
  10068. var that = this,
  10069. args = arguments,
  10070. mightThrow = function() {
  10071. var returned, then;
  10072. // Support: Promises/A+ section 2.3.3.3.3
  10073. // https://promisesaplus.com/#point-59
  10074. // Ignore double-resolution attempts
  10075. if ( depth < maxDepth ) {
  10076. return;
  10077. }
  10078. returned = handler.apply( that, args );
  10079. // Support: Promises/A+ section 2.3.1
  10080. // https://promisesaplus.com/#point-48
  10081. if ( returned === deferred.promise() ) {
  10082. throw new TypeError( "Thenable self-resolution" );
  10083. }
  10084. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10085. // https://promisesaplus.com/#point-54
  10086. // https://promisesaplus.com/#point-75
  10087. // Retrieve `then` only once
  10088. then = returned &&
  10089. // Support: Promises/A+ section 2.3.4
  10090. // https://promisesaplus.com/#point-64
  10091. // Only check objects and functions for thenability
  10092. ( typeof returned === "object" ||
  10093. typeof returned === "function" ) &&
  10094. returned.then;
  10095. // Handle a returned thenable
  10096. if ( isFunction( then ) ) {
  10097. // Special processors (notify) just wait for resolution
  10098. if ( special ) {
  10099. then.call(
  10100. returned,
  10101. resolve( maxDepth, deferred, Identity, special ),
  10102. resolve( maxDepth, deferred, Thrower, special )
  10103. );
  10104. // Normal processors (resolve) also hook into progress
  10105. } else {
  10106. // ...and disregard older resolution values
  10107. maxDepth++;
  10108. then.call(
  10109. returned,
  10110. resolve( maxDepth, deferred, Identity, special ),
  10111. resolve( maxDepth, deferred, Thrower, special ),
  10112. resolve( maxDepth, deferred, Identity,
  10113. deferred.notifyWith )
  10114. );
  10115. }
  10116. // Handle all other returned values
  10117. } else {
  10118. // Only substitute handlers pass on context
  10119. // and multiple values (non-spec behavior)
  10120. if ( handler !== Identity ) {
  10121. that = undefined;
  10122. args = [ returned ];
  10123. }
  10124. // Process the value(s)
  10125. // Default process is resolve
  10126. ( special || deferred.resolveWith )( that, args );
  10127. }
  10128. },
  10129. // Only normal processors (resolve) catch and reject exceptions
  10130. process = special ?
  10131. mightThrow :
  10132. function() {
  10133. try {
  10134. mightThrow();
  10135. } catch ( e ) {
  10136. if ( jQuery.Deferred.exceptionHook ) {
  10137. jQuery.Deferred.exceptionHook( e,
  10138. process.stackTrace );
  10139. }
  10140. // Support: Promises/A+ section 2.3.3.3.4.1
  10141. // https://promisesaplus.com/#point-61
  10142. // Ignore post-resolution exceptions
  10143. if ( depth + 1 >= maxDepth ) {
  10144. // Only substitute handlers pass on context
  10145. // and multiple values (non-spec behavior)
  10146. if ( handler !== Thrower ) {
  10147. that = undefined;
  10148. args = [ e ];
  10149. }
  10150. deferred.rejectWith( that, args );
  10151. }
  10152. }
  10153. };
  10154. // Support: Promises/A+ section 2.3.3.3.1
  10155. // https://promisesaplus.com/#point-57
  10156. // Re-resolve promises immediately to dodge false rejection from
  10157. // subsequent errors
  10158. if ( depth ) {
  10159. process();
  10160. } else {
  10161. // Call an optional hook to record the stack, in case of exception
  10162. // since it's otherwise lost when execution goes async
  10163. if ( jQuery.Deferred.getStackHook ) {
  10164. process.stackTrace = jQuery.Deferred.getStackHook();
  10165. }
  10166. window.setTimeout( process );
  10167. }
  10168. };
  10169. }
  10170. return jQuery.Deferred( function( newDefer ) {
  10171. // progress_handlers.add( ... )
  10172. tuples[ 0 ][ 3 ].add(
  10173. resolve(
  10174. 0,
  10175. newDefer,
  10176. isFunction( onProgress ) ?
  10177. onProgress :
  10178. Identity,
  10179. newDefer.notifyWith
  10180. )
  10181. );
  10182. // fulfilled_handlers.add( ... )
  10183. tuples[ 1 ][ 3 ].add(
  10184. resolve(
  10185. 0,
  10186. newDefer,
  10187. isFunction( onFulfilled ) ?
  10188. onFulfilled :
  10189. Identity
  10190. )
  10191. );
  10192. // rejected_handlers.add( ... )
  10193. tuples[ 2 ][ 3 ].add(
  10194. resolve(
  10195. 0,
  10196. newDefer,
  10197. isFunction( onRejected ) ?
  10198. onRejected :
  10199. Thrower
  10200. )
  10201. );
  10202. } ).promise();
  10203. },
  10204. // Get a promise for this deferred
  10205. // If obj is provided, the promise aspect is added to the object
  10206. promise: function( obj ) {
  10207. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10208. }
  10209. },
  10210. deferred = {};
  10211. // Add list-specific methods
  10212. jQuery.each( tuples, function( i, tuple ) {
  10213. var list = tuple[ 2 ],
  10214. stateString = tuple[ 5 ];
  10215. // promise.progress = list.add
  10216. // promise.done = list.add
  10217. // promise.fail = list.add
  10218. promise[ tuple[ 1 ] ] = list.add;
  10219. // Handle state
  10220. if ( stateString ) {
  10221. list.add(
  10222. function() {
  10223. // state = "resolved" (i.e., fulfilled)
  10224. // state = "rejected"
  10225. state = stateString;
  10226. },
  10227. // rejected_callbacks.disable
  10228. // fulfilled_callbacks.disable
  10229. tuples[ 3 - i ][ 2 ].disable,
  10230. // rejected_handlers.disable
  10231. // fulfilled_handlers.disable
  10232. tuples[ 3 - i ][ 3 ].disable,
  10233. // progress_callbacks.lock
  10234. tuples[ 0 ][ 2 ].lock,
  10235. // progress_handlers.lock
  10236. tuples[ 0 ][ 3 ].lock
  10237. );
  10238. }
  10239. // progress_handlers.fire
  10240. // fulfilled_handlers.fire
  10241. // rejected_handlers.fire
  10242. list.add( tuple[ 3 ].fire );
  10243. // deferred.notify = function() { deferred.notifyWith(...) }
  10244. // deferred.resolve = function() { deferred.resolveWith(...) }
  10245. // deferred.reject = function() { deferred.rejectWith(...) }
  10246. deferred[ tuple[ 0 ] ] = function() {
  10247. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10248. return this;
  10249. };
  10250. // deferred.notifyWith = list.fireWith
  10251. // deferred.resolveWith = list.fireWith
  10252. // deferred.rejectWith = list.fireWith
  10253. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10254. } );
  10255. // Make the deferred a promise
  10256. promise.promise( deferred );
  10257. // Call given func if any
  10258. if ( func ) {
  10259. func.call( deferred, deferred );
  10260. }
  10261. // All done!
  10262. return deferred;
  10263. },
  10264. // Deferred helper
  10265. when: function( singleValue ) {
  10266. var
  10267. // count of uncompleted subordinates
  10268. remaining = arguments.length,
  10269. // count of unprocessed arguments
  10270. i = remaining,
  10271. // subordinate fulfillment data
  10272. resolveContexts = Array( i ),
  10273. resolveValues = slice.call( arguments ),
  10274. // the master Deferred
  10275. master = jQuery.Deferred(),
  10276. // subordinate callback factory
  10277. updateFunc = function( i ) {
  10278. return function( value ) {
  10279. resolveContexts[ i ] = this;
  10280. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10281. if ( !( --remaining ) ) {
  10282. master.resolveWith( resolveContexts, resolveValues );
  10283. }
  10284. };
  10285. };
  10286. // Single- and empty arguments are adopted like Promise.resolve
  10287. if ( remaining <= 1 ) {
  10288. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10289. !remaining );
  10290. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10291. if ( master.state() === "pending" ||
  10292. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10293. return master.then();
  10294. }
  10295. }
  10296. // Multiple arguments are aggregated like Promise.all array elements
  10297. while ( i-- ) {
  10298. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10299. }
  10300. return master.promise();
  10301. }
  10302. } );
  10303. // These usually indicate a programmer mistake during development,
  10304. // warn about them ASAP rather than swallowing them by default.
  10305. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10306. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10307. // Support: IE 8 - 9 only
  10308. // Console exists when dev tools are open, which can happen at any time
  10309. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10310. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10311. }
  10312. };
  10313. jQuery.readyException = function( error ) {
  10314. window.setTimeout( function() {
  10315. throw error;
  10316. } );
  10317. };
  10318. // The deferred used on DOM ready
  10319. var readyList = jQuery.Deferred();
  10320. jQuery.fn.ready = function( fn ) {
  10321. readyList
  10322. .then( fn )
  10323. // Wrap jQuery.readyException in a function so that the lookup
  10324. // happens at the time of error handling instead of callback
  10325. // registration.
  10326. .catch( function( error ) {
  10327. jQuery.readyException( error );
  10328. } );
  10329. return this;
  10330. };
  10331. jQuery.extend( {
  10332. // Is the DOM ready to be used? Set to true once it occurs.
  10333. isReady: false,
  10334. // A counter to track how many items to wait for before
  10335. // the ready event fires. See #6781
  10336. readyWait: 1,
  10337. // Handle when the DOM is ready
  10338. ready: function( wait ) {
  10339. // Abort if there are pending holds or we're already ready
  10340. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10341. return;
  10342. }
  10343. // Remember that the DOM is ready
  10344. jQuery.isReady = true;
  10345. // If a normal DOM Ready event fired, decrement, and wait if need be
  10346. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10347. return;
  10348. }
  10349. // If there are functions bound, to execute
  10350. readyList.resolveWith( document, [ jQuery ] );
  10351. }
  10352. } );
  10353. jQuery.ready.then = readyList.then;
  10354. // The ready event handler and self cleanup method
  10355. function completed() {
  10356. document.removeEventListener( "DOMContentLoaded", completed );
  10357. window.removeEventListener( "load", completed );
  10358. jQuery.ready();
  10359. }
  10360. // Catch cases where $(document).ready() is called
  10361. // after the browser event has already occurred.
  10362. // Support: IE <=9 - 10 only
  10363. // Older IE sometimes signals "interactive" too soon
  10364. if ( document.readyState === "complete" ||
  10365. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10366. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10367. window.setTimeout( jQuery.ready );
  10368. } else {
  10369. // Use the handy event callback
  10370. document.addEventListener( "DOMContentLoaded", completed );
  10371. // A fallback to window.onload, that will always work
  10372. window.addEventListener( "load", completed );
  10373. }
  10374. // Multifunctional method to get and set values of a collection
  10375. // The value/s can optionally be executed if it's a function
  10376. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10377. var i = 0,
  10378. len = elems.length,
  10379. bulk = key == null;
  10380. // Sets many values
  10381. if ( toType( key ) === "object" ) {
  10382. chainable = true;
  10383. for ( i in key ) {
  10384. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10385. }
  10386. // Sets one value
  10387. } else if ( value !== undefined ) {
  10388. chainable = true;
  10389. if ( !isFunction( value ) ) {
  10390. raw = true;
  10391. }
  10392. if ( bulk ) {
  10393. // Bulk operations run against the entire set
  10394. if ( raw ) {
  10395. fn.call( elems, value );
  10396. fn = null;
  10397. // ...except when executing function values
  10398. } else {
  10399. bulk = fn;
  10400. fn = function( elem, key, value ) {
  10401. return bulk.call( jQuery( elem ), value );
  10402. };
  10403. }
  10404. }
  10405. if ( fn ) {
  10406. for ( ; i < len; i++ ) {
  10407. fn(
  10408. elems[ i ], key, raw ?
  10409. value :
  10410. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10411. );
  10412. }
  10413. }
  10414. }
  10415. if ( chainable ) {
  10416. return elems;
  10417. }
  10418. // Gets
  10419. if ( bulk ) {
  10420. return fn.call( elems );
  10421. }
  10422. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10423. };
  10424. // Matches dashed string for camelizing
  10425. var rmsPrefix = /^-ms-/,
  10426. rdashAlpha = /-([a-z])/g;
  10427. // Used by camelCase as callback to replace()
  10428. function fcamelCase( all, letter ) {
  10429. return letter.toUpperCase();
  10430. }
  10431. // Convert dashed to camelCase; used by the css and data modules
  10432. // Support: IE <=9 - 11, Edge 12 - 15
  10433. // Microsoft forgot to hump their vendor prefix (#9572)
  10434. function camelCase( string ) {
  10435. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10436. }
  10437. var acceptData = function( owner ) {
  10438. // Accepts only:
  10439. // - Node
  10440. // - Node.ELEMENT_NODE
  10441. // - Node.DOCUMENT_NODE
  10442. // - Object
  10443. // - Any
  10444. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10445. };
  10446. function Data() {
  10447. this.expando = jQuery.expando + Data.uid++;
  10448. }
  10449. Data.uid = 1;
  10450. Data.prototype = {
  10451. cache: function( owner ) {
  10452. // Check if the owner object already has a cache
  10453. var value = owner[ this.expando ];
  10454. // If not, create one
  10455. if ( !value ) {
  10456. value = {};
  10457. // We can accept data for non-element nodes in modern browsers,
  10458. // but we should not, see #8335.
  10459. // Always return an empty object.
  10460. if ( acceptData( owner ) ) {
  10461. // If it is a node unlikely to be stringify-ed or looped over
  10462. // use plain assignment
  10463. if ( owner.nodeType ) {
  10464. owner[ this.expando ] = value;
  10465. // Otherwise secure it in a non-enumerable property
  10466. // configurable must be true to allow the property to be
  10467. // deleted when data is removed
  10468. } else {
  10469. Object.defineProperty( owner, this.expando, {
  10470. value: value,
  10471. configurable: true
  10472. } );
  10473. }
  10474. }
  10475. }
  10476. return value;
  10477. },
  10478. set: function( owner, data, value ) {
  10479. var prop,
  10480. cache = this.cache( owner );
  10481. // Handle: [ owner, key, value ] args
  10482. // Always use camelCase key (gh-2257)
  10483. if ( typeof data === "string" ) {
  10484. cache[ camelCase( data ) ] = value;
  10485. // Handle: [ owner, { properties } ] args
  10486. } else {
  10487. // Copy the properties one-by-one to the cache object
  10488. for ( prop in data ) {
  10489. cache[ camelCase( prop ) ] = data[ prop ];
  10490. }
  10491. }
  10492. return cache;
  10493. },
  10494. get: function( owner, key ) {
  10495. return key === undefined ?
  10496. this.cache( owner ) :
  10497. // Always use camelCase key (gh-2257)
  10498. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10499. },
  10500. access: function( owner, key, value ) {
  10501. // In cases where either:
  10502. //
  10503. // 1. No key was specified
  10504. // 2. A string key was specified, but no value provided
  10505. //
  10506. // Take the "read" path and allow the get method to determine
  10507. // which value to return, respectively either:
  10508. //
  10509. // 1. The entire cache object
  10510. // 2. The data stored at the key
  10511. //
  10512. if ( key === undefined ||
  10513. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10514. return this.get( owner, key );
  10515. }
  10516. // When the key is not a string, or both a key and value
  10517. // are specified, set or extend (existing objects) with either:
  10518. //
  10519. // 1. An object of properties
  10520. // 2. A key and value
  10521. //
  10522. this.set( owner, key, value );
  10523. // Since the "set" path can have two possible entry points
  10524. // return the expected data based on which path was taken[*]
  10525. return value !== undefined ? value : key;
  10526. },
  10527. remove: function( owner, key ) {
  10528. var i,
  10529. cache = owner[ this.expando ];
  10530. if ( cache === undefined ) {
  10531. return;
  10532. }
  10533. if ( key !== undefined ) {
  10534. // Support array or space separated string of keys
  10535. if ( Array.isArray( key ) ) {
  10536. // If key is an array of keys...
  10537. // We always set camelCase keys, so remove that.
  10538. key = key.map( camelCase );
  10539. } else {
  10540. key = camelCase( key );
  10541. // If a key with the spaces exists, use it.
  10542. // Otherwise, create an array by matching non-whitespace
  10543. key = key in cache ?
  10544. [ key ] :
  10545. ( key.match( rnothtmlwhite ) || [] );
  10546. }
  10547. i = key.length;
  10548. while ( i-- ) {
  10549. delete cache[ key[ i ] ];
  10550. }
  10551. }
  10552. // Remove the expando if there's no more data
  10553. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10554. // Support: Chrome <=35 - 45
  10555. // Webkit & Blink performance suffers when deleting properties
  10556. // from DOM nodes, so set to undefined instead
  10557. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10558. if ( owner.nodeType ) {
  10559. owner[ this.expando ] = undefined;
  10560. } else {
  10561. delete owner[ this.expando ];
  10562. }
  10563. }
  10564. },
  10565. hasData: function( owner ) {
  10566. var cache = owner[ this.expando ];
  10567. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10568. }
  10569. };
  10570. var dataPriv = new Data();
  10571. var dataUser = new Data();
  10572. // Implementation Summary
  10573. //
  10574. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10575. // 2. Improve the module's maintainability by reducing the storage
  10576. // paths to a single mechanism.
  10577. // 3. Use the same single mechanism to support "private" and "user" data.
  10578. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10579. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10580. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10581. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10582. rmultiDash = /[A-Z]/g;
  10583. function getData( data ) {
  10584. if ( data === "true" ) {
  10585. return true;
  10586. }
  10587. if ( data === "false" ) {
  10588. return false;
  10589. }
  10590. if ( data === "null" ) {
  10591. return null;
  10592. }
  10593. // Only convert to a number if it doesn't change the string
  10594. if ( data === +data + "" ) {
  10595. return +data;
  10596. }
  10597. if ( rbrace.test( data ) ) {
  10598. return JSON.parse( data );
  10599. }
  10600. return data;
  10601. }
  10602. function dataAttr( elem, key, data ) {
  10603. var name;
  10604. // If nothing was found internally, try to fetch any
  10605. // data from the HTML5 data-* attribute
  10606. if ( data === undefined && elem.nodeType === 1 ) {
  10607. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10608. data = elem.getAttribute( name );
  10609. if ( typeof data === "string" ) {
  10610. try {
  10611. data = getData( data );
  10612. } catch ( e ) {}
  10613. // Make sure we set the data so it isn't changed later
  10614. dataUser.set( elem, key, data );
  10615. } else {
  10616. data = undefined;
  10617. }
  10618. }
  10619. return data;
  10620. }
  10621. jQuery.extend( {
  10622. hasData: function( elem ) {
  10623. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10624. },
  10625. data: function( elem, name, data ) {
  10626. return dataUser.access( elem, name, data );
  10627. },
  10628. removeData: function( elem, name ) {
  10629. dataUser.remove( elem, name );
  10630. },
  10631. // TODO: Now that all calls to _data and _removeData have been replaced
  10632. // with direct calls to dataPriv methods, these can be deprecated.
  10633. _data: function( elem, name, data ) {
  10634. return dataPriv.access( elem, name, data );
  10635. },
  10636. _removeData: function( elem, name ) {
  10637. dataPriv.remove( elem, name );
  10638. }
  10639. } );
  10640. jQuery.fn.extend( {
  10641. data: function( key, value ) {
  10642. var i, name, data,
  10643. elem = this[ 0 ],
  10644. attrs = elem && elem.attributes;
  10645. // Gets all values
  10646. if ( key === undefined ) {
  10647. if ( this.length ) {
  10648. data = dataUser.get( elem );
  10649. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10650. i = attrs.length;
  10651. while ( i-- ) {
  10652. // Support: IE 11 only
  10653. // The attrs elements can be null (#14894)
  10654. if ( attrs[ i ] ) {
  10655. name = attrs[ i ].name;
  10656. if ( name.indexOf( "data-" ) === 0 ) {
  10657. name = camelCase( name.slice( 5 ) );
  10658. dataAttr( elem, name, data[ name ] );
  10659. }
  10660. }
  10661. }
  10662. dataPriv.set( elem, "hasDataAttrs", true );
  10663. }
  10664. }
  10665. return data;
  10666. }
  10667. // Sets multiple values
  10668. if ( typeof key === "object" ) {
  10669. return this.each( function() {
  10670. dataUser.set( this, key );
  10671. } );
  10672. }
  10673. return access( this, function( value ) {
  10674. var data;
  10675. // The calling jQuery object (element matches) is not empty
  10676. // (and therefore has an element appears at this[ 0 ]) and the
  10677. // `value` parameter was not undefined. An empty jQuery object
  10678. // will result in `undefined` for elem = this[ 0 ] which will
  10679. // throw an exception if an attempt to read a data cache is made.
  10680. if ( elem && value === undefined ) {
  10681. // Attempt to get data from the cache
  10682. // The key will always be camelCased in Data
  10683. data = dataUser.get( elem, key );
  10684. if ( data !== undefined ) {
  10685. return data;
  10686. }
  10687. // Attempt to "discover" the data in
  10688. // HTML5 custom data-* attrs
  10689. data = dataAttr( elem, key );
  10690. if ( data !== undefined ) {
  10691. return data;
  10692. }
  10693. // We tried really hard, but the data doesn't exist.
  10694. return;
  10695. }
  10696. // Set the data...
  10697. this.each( function() {
  10698. // We always store the camelCased key
  10699. dataUser.set( this, key, value );
  10700. } );
  10701. }, null, value, arguments.length > 1, null, true );
  10702. },
  10703. removeData: function( key ) {
  10704. return this.each( function() {
  10705. dataUser.remove( this, key );
  10706. } );
  10707. }
  10708. } );
  10709. jQuery.extend( {
  10710. queue: function( elem, type, data ) {
  10711. var queue;
  10712. if ( elem ) {
  10713. type = ( type || "fx" ) + "queue";
  10714. queue = dataPriv.get( elem, type );
  10715. // Speed up dequeue by getting out quickly if this is just a lookup
  10716. if ( data ) {
  10717. if ( !queue || Array.isArray( data ) ) {
  10718. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10719. } else {
  10720. queue.push( data );
  10721. }
  10722. }
  10723. return queue || [];
  10724. }
  10725. },
  10726. dequeue: function( elem, type ) {
  10727. type = type || "fx";
  10728. var queue = jQuery.queue( elem, type ),
  10729. startLength = queue.length,
  10730. fn = queue.shift(),
  10731. hooks = jQuery._queueHooks( elem, type ),
  10732. next = function() {
  10733. jQuery.dequeue( elem, type );
  10734. };
  10735. // If the fx queue is dequeued, always remove the progress sentinel
  10736. if ( fn === "inprogress" ) {
  10737. fn = queue.shift();
  10738. startLength--;
  10739. }
  10740. if ( fn ) {
  10741. // Add a progress sentinel to prevent the fx queue from being
  10742. // automatically dequeued
  10743. if ( type === "fx" ) {
  10744. queue.unshift( "inprogress" );
  10745. }
  10746. // Clear up the last queue stop function
  10747. delete hooks.stop;
  10748. fn.call( elem, next, hooks );
  10749. }
  10750. if ( !startLength && hooks ) {
  10751. hooks.empty.fire();
  10752. }
  10753. },
  10754. // Not public - generate a queueHooks object, or return the current one
  10755. _queueHooks: function( elem, type ) {
  10756. var key = type + "queueHooks";
  10757. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10758. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10759. dataPriv.remove( elem, [ type + "queue", key ] );
  10760. } )
  10761. } );
  10762. }
  10763. } );
  10764. jQuery.fn.extend( {
  10765. queue: function( type, data ) {
  10766. var setter = 2;
  10767. if ( typeof type !== "string" ) {
  10768. data = type;
  10769. type = "fx";
  10770. setter--;
  10771. }
  10772. if ( arguments.length < setter ) {
  10773. return jQuery.queue( this[ 0 ], type );
  10774. }
  10775. return data === undefined ?
  10776. this :
  10777. this.each( function() {
  10778. var queue = jQuery.queue( this, type, data );
  10779. // Ensure a hooks for this queue
  10780. jQuery._queueHooks( this, type );
  10781. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10782. jQuery.dequeue( this, type );
  10783. }
  10784. } );
  10785. },
  10786. dequeue: function( type ) {
  10787. return this.each( function() {
  10788. jQuery.dequeue( this, type );
  10789. } );
  10790. },
  10791. clearQueue: function( type ) {
  10792. return this.queue( type || "fx", [] );
  10793. },
  10794. // Get a promise resolved when queues of a certain type
  10795. // are emptied (fx is the type by default)
  10796. promise: function( type, obj ) {
  10797. var tmp,
  10798. count = 1,
  10799. defer = jQuery.Deferred(),
  10800. elements = this,
  10801. i = this.length,
  10802. resolve = function() {
  10803. if ( !( --count ) ) {
  10804. defer.resolveWith( elements, [ elements ] );
  10805. }
  10806. };
  10807. if ( typeof type !== "string" ) {
  10808. obj = type;
  10809. type = undefined;
  10810. }
  10811. type = type || "fx";
  10812. while ( i-- ) {
  10813. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10814. if ( tmp && tmp.empty ) {
  10815. count++;
  10816. tmp.empty.add( resolve );
  10817. }
  10818. }
  10819. resolve();
  10820. return defer.promise( obj );
  10821. }
  10822. } );
  10823. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10824. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10825. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10826. var documentElement = document.documentElement;
  10827. var isAttached = function( elem ) {
  10828. return jQuery.contains( elem.ownerDocument, elem );
  10829. },
  10830. composed = { composed: true };
  10831. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10832. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10833. // Support: iOS 10.0-10.2 only
  10834. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10835. // leading to errors. We need to check for `getRootNode`.
  10836. if ( documentElement.getRootNode ) {
  10837. isAttached = function( elem ) {
  10838. return jQuery.contains( elem.ownerDocument, elem ) ||
  10839. elem.getRootNode( composed ) === elem.ownerDocument;
  10840. };
  10841. }
  10842. var isHiddenWithinTree = function( elem, el ) {
  10843. // isHiddenWithinTree might be called from jQuery#filter function;
  10844. // in that case, element will be second argument
  10845. elem = el || elem;
  10846. // Inline style trumps all
  10847. return elem.style.display === "none" ||
  10848. elem.style.display === "" &&
  10849. // Otherwise, check computed style
  10850. // Support: Firefox <=43 - 45
  10851. // Disconnected elements can have computed display: none, so first confirm that elem is
  10852. // in the document.
  10853. isAttached( elem ) &&
  10854. jQuery.css( elem, "display" ) === "none";
  10855. };
  10856. var swap = function( elem, options, callback, args ) {
  10857. var ret, name,
  10858. old = {};
  10859. // Remember the old values, and insert the new ones
  10860. for ( name in options ) {
  10861. old[ name ] = elem.style[ name ];
  10862. elem.style[ name ] = options[ name ];
  10863. }
  10864. ret = callback.apply( elem, args || [] );
  10865. // Revert the old values
  10866. for ( name in options ) {
  10867. elem.style[ name ] = old[ name ];
  10868. }
  10869. return ret;
  10870. };
  10871. function adjustCSS( elem, prop, valueParts, tween ) {
  10872. var adjusted, scale,
  10873. maxIterations = 20,
  10874. currentValue = tween ?
  10875. function() {
  10876. return tween.cur();
  10877. } :
  10878. function() {
  10879. return jQuery.css( elem, prop, "" );
  10880. },
  10881. initial = currentValue(),
  10882. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10883. // Starting value computation is required for potential unit mismatches
  10884. initialInUnit = elem.nodeType &&
  10885. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10886. rcssNum.exec( jQuery.css( elem, prop ) );
  10887. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10888. // Support: Firefox <=54
  10889. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10890. initial = initial / 2;
  10891. // Trust units reported by jQuery.css
  10892. unit = unit || initialInUnit[ 3 ];
  10893. // Iteratively approximate from a nonzero starting point
  10894. initialInUnit = +initial || 1;
  10895. while ( maxIterations-- ) {
  10896. // Evaluate and update our best guess (doubling guesses that zero out).
  10897. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10898. jQuery.style( elem, prop, initialInUnit + unit );
  10899. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10900. maxIterations = 0;
  10901. }
  10902. initialInUnit = initialInUnit / scale;
  10903. }
  10904. initialInUnit = initialInUnit * 2;
  10905. jQuery.style( elem, prop, initialInUnit + unit );
  10906. // Make sure we update the tween properties later on
  10907. valueParts = valueParts || [];
  10908. }
  10909. if ( valueParts ) {
  10910. initialInUnit = +initialInUnit || +initial || 0;
  10911. // Apply relative offset (+=/-=) if specified
  10912. adjusted = valueParts[ 1 ] ?
  10913. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10914. +valueParts[ 2 ];
  10915. if ( tween ) {
  10916. tween.unit = unit;
  10917. tween.start = initialInUnit;
  10918. tween.end = adjusted;
  10919. }
  10920. }
  10921. return adjusted;
  10922. }
  10923. var defaultDisplayMap = {};
  10924. function getDefaultDisplay( elem ) {
  10925. var temp,
  10926. doc = elem.ownerDocument,
  10927. nodeName = elem.nodeName,
  10928. display = defaultDisplayMap[ nodeName ];
  10929. if ( display ) {
  10930. return display;
  10931. }
  10932. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10933. display = jQuery.css( temp, "display" );
  10934. temp.parentNode.removeChild( temp );
  10935. if ( display === "none" ) {
  10936. display = "block";
  10937. }
  10938. defaultDisplayMap[ nodeName ] = display;
  10939. return display;
  10940. }
  10941. function showHide( elements, show ) {
  10942. var display, elem,
  10943. values = [],
  10944. index = 0,
  10945. length = elements.length;
  10946. // Determine new display value for elements that need to change
  10947. for ( ; index < length; index++ ) {
  10948. elem = elements[ index ];
  10949. if ( !elem.style ) {
  10950. continue;
  10951. }
  10952. display = elem.style.display;
  10953. if ( show ) {
  10954. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10955. // check is required in this first loop unless we have a nonempty display value (either
  10956. // inline or about-to-be-restored)
  10957. if ( display === "none" ) {
  10958. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10959. if ( !values[ index ] ) {
  10960. elem.style.display = "";
  10961. }
  10962. }
  10963. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10964. values[ index ] = getDefaultDisplay( elem );
  10965. }
  10966. } else {
  10967. if ( display !== "none" ) {
  10968. values[ index ] = "none";
  10969. // Remember what we're overwriting
  10970. dataPriv.set( elem, "display", display );
  10971. }
  10972. }
  10973. }
  10974. // Set the display of the elements in a second loop to avoid constant reflow
  10975. for ( index = 0; index < length; index++ ) {
  10976. if ( values[ index ] != null ) {
  10977. elements[ index ].style.display = values[ index ];
  10978. }
  10979. }
  10980. return elements;
  10981. }
  10982. jQuery.fn.extend( {
  10983. show: function() {
  10984. return showHide( this, true );
  10985. },
  10986. hide: function() {
  10987. return showHide( this );
  10988. },
  10989. toggle: function( state ) {
  10990. if ( typeof state === "boolean" ) {
  10991. return state ? this.show() : this.hide();
  10992. }
  10993. return this.each( function() {
  10994. if ( isHiddenWithinTree( this ) ) {
  10995. jQuery( this ).show();
  10996. } else {
  10997. jQuery( this ).hide();
  10998. }
  10999. } );
  11000. }
  11001. } );
  11002. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11003. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11004. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11005. // We have to close these tags to support XHTML (#13200)
  11006. var wrapMap = {
  11007. // Support: IE <=9 only
  11008. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11009. // XHTML parsers do not magically insert elements in the
  11010. // same way that tag soup parsers do. So we cannot shorten
  11011. // this by omitting <tbody> or other required elements.
  11012. thead: [ 1, "<table>", "</table>" ],
  11013. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11014. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11015. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11016. _default: [ 0, "", "" ]
  11017. };
  11018. // Support: IE <=9 only
  11019. wrapMap.optgroup = wrapMap.option;
  11020. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11021. wrapMap.th = wrapMap.td;
  11022. function getAll( context, tag ) {
  11023. // Support: IE <=9 - 11 only
  11024. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11025. var ret;
  11026. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11027. ret = context.getElementsByTagName( tag || "*" );
  11028. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11029. ret = context.querySelectorAll( tag || "*" );
  11030. } else {
  11031. ret = [];
  11032. }
  11033. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11034. return jQuery.merge( [ context ], ret );
  11035. }
  11036. return ret;
  11037. }
  11038. // Mark scripts as having already been evaluated
  11039. function setGlobalEval( elems, refElements ) {
  11040. var i = 0,
  11041. l = elems.length;
  11042. for ( ; i < l; i++ ) {
  11043. dataPriv.set(
  11044. elems[ i ],
  11045. "globalEval",
  11046. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11047. );
  11048. }
  11049. }
  11050. var rhtml = /<|&#?\w+;/;
  11051. function buildFragment( elems, context, scripts, selection, ignored ) {
  11052. var elem, tmp, tag, wrap, attached, j,
  11053. fragment = context.createDocumentFragment(),
  11054. nodes = [],
  11055. i = 0,
  11056. l = elems.length;
  11057. for ( ; i < l; i++ ) {
  11058. elem = elems[ i ];
  11059. if ( elem || elem === 0 ) {
  11060. // Add nodes directly
  11061. if ( toType( elem ) === "object" ) {
  11062. // Support: Android <=4.0 only, PhantomJS 1 only
  11063. // push.apply(_, arraylike) throws on ancient WebKit
  11064. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11065. // Convert non-html into a text node
  11066. } else if ( !rhtml.test( elem ) ) {
  11067. nodes.push( context.createTextNode( elem ) );
  11068. // Convert html into DOM nodes
  11069. } else {
  11070. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11071. // Deserialize a standard representation
  11072. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11073. wrap = wrapMap[ tag ] || wrapMap._default;
  11074. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11075. // Descend through wrappers to the right content
  11076. j = wrap[ 0 ];
  11077. while ( j-- ) {
  11078. tmp = tmp.lastChild;
  11079. }
  11080. // Support: Android <=4.0 only, PhantomJS 1 only
  11081. // push.apply(_, arraylike) throws on ancient WebKit
  11082. jQuery.merge( nodes, tmp.childNodes );
  11083. // Remember the top-level container
  11084. tmp = fragment.firstChild;
  11085. // Ensure the created nodes are orphaned (#12392)
  11086. tmp.textContent = "";
  11087. }
  11088. }
  11089. }
  11090. // Remove wrapper from fragment
  11091. fragment.textContent = "";
  11092. i = 0;
  11093. while ( ( elem = nodes[ i++ ] ) ) {
  11094. // Skip elements already in the context collection (trac-4087)
  11095. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11096. if ( ignored ) {
  11097. ignored.push( elem );
  11098. }
  11099. continue;
  11100. }
  11101. attached = isAttached( elem );
  11102. // Append to fragment
  11103. tmp = getAll( fragment.appendChild( elem ), "script" );
  11104. // Preserve script evaluation history
  11105. if ( attached ) {
  11106. setGlobalEval( tmp );
  11107. }
  11108. // Capture executables
  11109. if ( scripts ) {
  11110. j = 0;
  11111. while ( ( elem = tmp[ j++ ] ) ) {
  11112. if ( rscriptType.test( elem.type || "" ) ) {
  11113. scripts.push( elem );
  11114. }
  11115. }
  11116. }
  11117. }
  11118. return fragment;
  11119. }
  11120. ( function() {
  11121. var fragment = document.createDocumentFragment(),
  11122. div = fragment.appendChild( document.createElement( "div" ) ),
  11123. input = document.createElement( "input" );
  11124. // Support: Android 4.0 - 4.3 only
  11125. // Check state lost if the name is set (#11217)
  11126. // Support: Windows Web Apps (WWA)
  11127. // `name` and `type` must use .setAttribute for WWA (#14901)
  11128. input.setAttribute( "type", "radio" );
  11129. input.setAttribute( "checked", "checked" );
  11130. input.setAttribute( "name", "t" );
  11131. div.appendChild( input );
  11132. // Support: Android <=4.1 only
  11133. // Older WebKit doesn't clone checked state correctly in fragments
  11134. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11135. // Support: IE <=11 only
  11136. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11137. div.innerHTML = "<textarea>x</textarea>";
  11138. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11139. } )();
  11140. var
  11141. rkeyEvent = /^key/,
  11142. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11143. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11144. function returnTrue() {
  11145. return true;
  11146. }
  11147. function returnFalse() {
  11148. return false;
  11149. }
  11150. // Support: IE <=9 - 11+
  11151. // focus() and blur() are asynchronous, except when they are no-op.
  11152. // So expect focus to be synchronous when the element is already active,
  11153. // and blur to be synchronous when the element is not already active.
  11154. // (focus and blur are always synchronous in other supported browsers,
  11155. // this just defines when we can count on it).
  11156. function expectSync( elem, type ) {
  11157. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11158. }
  11159. // Support: IE <=9 only
  11160. // Accessing document.activeElement can throw unexpectedly
  11161. // https://bugs.jquery.com/ticket/13393
  11162. function safeActiveElement() {
  11163. try {
  11164. return document.activeElement;
  11165. } catch ( err ) { }
  11166. }
  11167. function on( elem, types, selector, data, fn, one ) {
  11168. var origFn, type;
  11169. // Types can be a map of types/handlers
  11170. if ( typeof types === "object" ) {
  11171. // ( types-Object, selector, data )
  11172. if ( typeof selector !== "string" ) {
  11173. // ( types-Object, data )
  11174. data = data || selector;
  11175. selector = undefined;
  11176. }
  11177. for ( type in types ) {
  11178. on( elem, type, selector, data, types[ type ], one );
  11179. }
  11180. return elem;
  11181. }
  11182. if ( data == null && fn == null ) {
  11183. // ( types, fn )
  11184. fn = selector;
  11185. data = selector = undefined;
  11186. } else if ( fn == null ) {
  11187. if ( typeof selector === "string" ) {
  11188. // ( types, selector, fn )
  11189. fn = data;
  11190. data = undefined;
  11191. } else {
  11192. // ( types, data, fn )
  11193. fn = data;
  11194. data = selector;
  11195. selector = undefined;
  11196. }
  11197. }
  11198. if ( fn === false ) {
  11199. fn = returnFalse;
  11200. } else if ( !fn ) {
  11201. return elem;
  11202. }
  11203. if ( one === 1 ) {
  11204. origFn = fn;
  11205. fn = function( event ) {
  11206. // Can use an empty set, since event contains the info
  11207. jQuery().off( event );
  11208. return origFn.apply( this, arguments );
  11209. };
  11210. // Use same guid so caller can remove using origFn
  11211. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11212. }
  11213. return elem.each( function() {
  11214. jQuery.event.add( this, types, fn, data, selector );
  11215. } );
  11216. }
  11217. /*
  11218. * Helper functions for managing events -- not part of the public interface.
  11219. * Props to Dean Edwards' addEvent library for many of the ideas.
  11220. */
  11221. jQuery.event = {
  11222. global: {},
  11223. add: function( elem, types, handler, data, selector ) {
  11224. var handleObjIn, eventHandle, tmp,
  11225. events, t, handleObj,
  11226. special, handlers, type, namespaces, origType,
  11227. elemData = dataPriv.get( elem );
  11228. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11229. if ( !elemData ) {
  11230. return;
  11231. }
  11232. // Caller can pass in an object of custom data in lieu of the handler
  11233. if ( handler.handler ) {
  11234. handleObjIn = handler;
  11235. handler = handleObjIn.handler;
  11236. selector = handleObjIn.selector;
  11237. }
  11238. // Ensure that invalid selectors throw exceptions at attach time
  11239. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11240. if ( selector ) {
  11241. jQuery.find.matchesSelector( documentElement, selector );
  11242. }
  11243. // Make sure that the handler has a unique ID, used to find/remove it later
  11244. if ( !handler.guid ) {
  11245. handler.guid = jQuery.guid++;
  11246. }
  11247. // Init the element's event structure and main handler, if this is the first
  11248. if ( !( events = elemData.events ) ) {
  11249. events = elemData.events = {};
  11250. }
  11251. if ( !( eventHandle = elemData.handle ) ) {
  11252. eventHandle = elemData.handle = function( e ) {
  11253. // Discard the second event of a jQuery.event.trigger() and
  11254. // when an event is called after a page has unloaded
  11255. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11256. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11257. };
  11258. }
  11259. // Handle multiple events separated by a space
  11260. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11261. t = types.length;
  11262. while ( t-- ) {
  11263. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11264. type = origType = tmp[ 1 ];
  11265. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11266. // There *must* be a type, no attaching namespace-only handlers
  11267. if ( !type ) {
  11268. continue;
  11269. }
  11270. // If event changes its type, use the special event handlers for the changed type
  11271. special = jQuery.event.special[ type ] || {};
  11272. // If selector defined, determine special event api type, otherwise given type
  11273. type = ( selector ? special.delegateType : special.bindType ) || type;
  11274. // Update special based on newly reset type
  11275. special = jQuery.event.special[ type ] || {};
  11276. // handleObj is passed to all event handlers
  11277. handleObj = jQuery.extend( {
  11278. type: type,
  11279. origType: origType,
  11280. data: data,
  11281. handler: handler,
  11282. guid: handler.guid,
  11283. selector: selector,
  11284. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11285. namespace: namespaces.join( "." )
  11286. }, handleObjIn );
  11287. // Init the event handler queue if we're the first
  11288. if ( !( handlers = events[ type ] ) ) {
  11289. handlers = events[ type ] = [];
  11290. handlers.delegateCount = 0;
  11291. // Only use addEventListener if the special events handler returns false
  11292. if ( !special.setup ||
  11293. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11294. if ( elem.addEventListener ) {
  11295. elem.addEventListener( type, eventHandle );
  11296. }
  11297. }
  11298. }
  11299. if ( special.add ) {
  11300. special.add.call( elem, handleObj );
  11301. if ( !handleObj.handler.guid ) {
  11302. handleObj.handler.guid = handler.guid;
  11303. }
  11304. }
  11305. // Add to the element's handler list, delegates in front
  11306. if ( selector ) {
  11307. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11308. } else {
  11309. handlers.push( handleObj );
  11310. }
  11311. // Keep track of which events have ever been used, for event optimization
  11312. jQuery.event.global[ type ] = true;
  11313. }
  11314. },
  11315. // Detach an event or set of events from an element
  11316. remove: function( elem, types, handler, selector, mappedTypes ) {
  11317. var j, origCount, tmp,
  11318. events, t, handleObj,
  11319. special, handlers, type, namespaces, origType,
  11320. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11321. if ( !elemData || !( events = elemData.events ) ) {
  11322. return;
  11323. }
  11324. // Once for each type.namespace in types; type may be omitted
  11325. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11326. t = types.length;
  11327. while ( t-- ) {
  11328. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11329. type = origType = tmp[ 1 ];
  11330. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11331. // Unbind all events (on this namespace, if provided) for the element
  11332. if ( !type ) {
  11333. for ( type in events ) {
  11334. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11335. }
  11336. continue;
  11337. }
  11338. special = jQuery.event.special[ type ] || {};
  11339. type = ( selector ? special.delegateType : special.bindType ) || type;
  11340. handlers = events[ type ] || [];
  11341. tmp = tmp[ 2 ] &&
  11342. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11343. // Remove matching events
  11344. origCount = j = handlers.length;
  11345. while ( j-- ) {
  11346. handleObj = handlers[ j ];
  11347. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11348. ( !handler || handler.guid === handleObj.guid ) &&
  11349. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11350. ( !selector || selector === handleObj.selector ||
  11351. selector === "**" && handleObj.selector ) ) {
  11352. handlers.splice( j, 1 );
  11353. if ( handleObj.selector ) {
  11354. handlers.delegateCount--;
  11355. }
  11356. if ( special.remove ) {
  11357. special.remove.call( elem, handleObj );
  11358. }
  11359. }
  11360. }
  11361. // Remove generic event handler if we removed something and no more handlers exist
  11362. // (avoids potential for endless recursion during removal of special event handlers)
  11363. if ( origCount && !handlers.length ) {
  11364. if ( !special.teardown ||
  11365. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11366. jQuery.removeEvent( elem, type, elemData.handle );
  11367. }
  11368. delete events[ type ];
  11369. }
  11370. }
  11371. // Remove data and the expando if it's no longer used
  11372. if ( jQuery.isEmptyObject( events ) ) {
  11373. dataPriv.remove( elem, "handle events" );
  11374. }
  11375. },
  11376. dispatch: function( nativeEvent ) {
  11377. // Make a writable jQuery.Event from the native event object
  11378. var event = jQuery.event.fix( nativeEvent );
  11379. var i, j, ret, matched, handleObj, handlerQueue,
  11380. args = new Array( arguments.length ),
  11381. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11382. special = jQuery.event.special[ event.type ] || {};
  11383. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11384. args[ 0 ] = event;
  11385. for ( i = 1; i < arguments.length; i++ ) {
  11386. args[ i ] = arguments[ i ];
  11387. }
  11388. event.delegateTarget = this;
  11389. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11390. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11391. return;
  11392. }
  11393. // Determine handlers
  11394. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11395. // Run delegates first; they may want to stop propagation beneath us
  11396. i = 0;
  11397. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11398. event.currentTarget = matched.elem;
  11399. j = 0;
  11400. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11401. !event.isImmediatePropagationStopped() ) {
  11402. // If the event is namespaced, then each handler is only invoked if it is
  11403. // specially universal or its namespaces are a superset of the event's.
  11404. if ( !event.rnamespace || handleObj.namespace === false ||
  11405. event.rnamespace.test( handleObj.namespace ) ) {
  11406. event.handleObj = handleObj;
  11407. event.data = handleObj.data;
  11408. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11409. handleObj.handler ).apply( matched.elem, args );
  11410. if ( ret !== undefined ) {
  11411. if ( ( event.result = ret ) === false ) {
  11412. event.preventDefault();
  11413. event.stopPropagation();
  11414. }
  11415. }
  11416. }
  11417. }
  11418. }
  11419. // Call the postDispatch hook for the mapped type
  11420. if ( special.postDispatch ) {
  11421. special.postDispatch.call( this, event );
  11422. }
  11423. return event.result;
  11424. },
  11425. handlers: function( event, handlers ) {
  11426. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11427. handlerQueue = [],
  11428. delegateCount = handlers.delegateCount,
  11429. cur = event.target;
  11430. // Find delegate handlers
  11431. if ( delegateCount &&
  11432. // Support: IE <=9
  11433. // Black-hole SVG <use> instance trees (trac-13180)
  11434. cur.nodeType &&
  11435. // Support: Firefox <=42
  11436. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11437. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11438. // Support: IE 11 only
  11439. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11440. !( event.type === "click" && event.button >= 1 ) ) {
  11441. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11442. // Don't check non-elements (#13208)
  11443. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11444. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11445. matchedHandlers = [];
  11446. matchedSelectors = {};
  11447. for ( i = 0; i < delegateCount; i++ ) {
  11448. handleObj = handlers[ i ];
  11449. // Don't conflict with Object.prototype properties (#13203)
  11450. sel = handleObj.selector + " ";
  11451. if ( matchedSelectors[ sel ] === undefined ) {
  11452. matchedSelectors[ sel ] = handleObj.needsContext ?
  11453. jQuery( sel, this ).index( cur ) > -1 :
  11454. jQuery.find( sel, this, null, [ cur ] ).length;
  11455. }
  11456. if ( matchedSelectors[ sel ] ) {
  11457. matchedHandlers.push( handleObj );
  11458. }
  11459. }
  11460. if ( matchedHandlers.length ) {
  11461. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11462. }
  11463. }
  11464. }
  11465. }
  11466. // Add the remaining (directly-bound) handlers
  11467. cur = this;
  11468. if ( delegateCount < handlers.length ) {
  11469. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11470. }
  11471. return handlerQueue;
  11472. },
  11473. addProp: function( name, hook ) {
  11474. Object.defineProperty( jQuery.Event.prototype, name, {
  11475. enumerable: true,
  11476. configurable: true,
  11477. get: isFunction( hook ) ?
  11478. function() {
  11479. if ( this.originalEvent ) {
  11480. return hook( this.originalEvent );
  11481. }
  11482. } :
  11483. function() {
  11484. if ( this.originalEvent ) {
  11485. return this.originalEvent[ name ];
  11486. }
  11487. },
  11488. set: function( value ) {
  11489. Object.defineProperty( this, name, {
  11490. enumerable: true,
  11491. configurable: true,
  11492. writable: true,
  11493. value: value
  11494. } );
  11495. }
  11496. } );
  11497. },
  11498. fix: function( originalEvent ) {
  11499. return originalEvent[ jQuery.expando ] ?
  11500. originalEvent :
  11501. new jQuery.Event( originalEvent );
  11502. },
  11503. special: {
  11504. load: {
  11505. // Prevent triggered image.load events from bubbling to window.load
  11506. noBubble: true
  11507. },
  11508. click: {
  11509. // Utilize native event to ensure correct state for checkable inputs
  11510. setup: function( data ) {
  11511. // For mutual compressibility with _default, replace `this` access with a local var.
  11512. // `|| data` is dead code meant only to preserve the variable through minification.
  11513. var el = this || data;
  11514. // Claim the first handler
  11515. if ( rcheckableType.test( el.type ) &&
  11516. el.click && nodeName( el, "input" ) ) {
  11517. // dataPriv.set( el, "click", ... )
  11518. leverageNative( el, "click", returnTrue );
  11519. }
  11520. // Return false to allow normal processing in the caller
  11521. return false;
  11522. },
  11523. trigger: function( data ) {
  11524. // For mutual compressibility with _default, replace `this` access with a local var.
  11525. // `|| data` is dead code meant only to preserve the variable through minification.
  11526. var el = this || data;
  11527. // Force setup before triggering a click
  11528. if ( rcheckableType.test( el.type ) &&
  11529. el.click && nodeName( el, "input" ) ) {
  11530. leverageNative( el, "click" );
  11531. }
  11532. // Return non-false to allow normal event-path propagation
  11533. return true;
  11534. },
  11535. // For cross-browser consistency, suppress native .click() on links
  11536. // Also prevent it if we're currently inside a leveraged native-event stack
  11537. _default: function( event ) {
  11538. var target = event.target;
  11539. return rcheckableType.test( target.type ) &&
  11540. target.click && nodeName( target, "input" ) &&
  11541. dataPriv.get( target, "click" ) ||
  11542. nodeName( target, "a" );
  11543. }
  11544. },
  11545. beforeunload: {
  11546. postDispatch: function( event ) {
  11547. // Support: Firefox 20+
  11548. // Firefox doesn't alert if the returnValue field is not set.
  11549. if ( event.result !== undefined && event.originalEvent ) {
  11550. event.originalEvent.returnValue = event.result;
  11551. }
  11552. }
  11553. }
  11554. }
  11555. };
  11556. // Ensure the presence of an event listener that handles manually-triggered
  11557. // synthetic events by interrupting progress until reinvoked in response to
  11558. // *native* events that it fires directly, ensuring that state changes have
  11559. // already occurred before other listeners are invoked.
  11560. function leverageNative( el, type, expectSync ) {
  11561. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11562. if ( !expectSync ) {
  11563. if ( dataPriv.get( el, type ) === undefined ) {
  11564. jQuery.event.add( el, type, returnTrue );
  11565. }
  11566. return;
  11567. }
  11568. // Register the controller as a special universal handler for all event namespaces
  11569. dataPriv.set( el, type, false );
  11570. jQuery.event.add( el, type, {
  11571. namespace: false,
  11572. handler: function( event ) {
  11573. var notAsync, result,
  11574. saved = dataPriv.get( this, type );
  11575. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11576. // Interrupt processing of the outer synthetic .trigger()ed event
  11577. // Saved data should be false in such cases, but might be a leftover capture object
  11578. // from an async native handler (gh-4350)
  11579. if ( !saved.length ) {
  11580. // Store arguments for use when handling the inner native event
  11581. // There will always be at least one argument (an event object), so this array
  11582. // will not be confused with a leftover capture object.
  11583. saved = slice.call( arguments );
  11584. dataPriv.set( this, type, saved );
  11585. // Trigger the native event and capture its result
  11586. // Support: IE <=9 - 11+
  11587. // focus() and blur() are asynchronous
  11588. notAsync = expectSync( this, type );
  11589. this[ type ]();
  11590. result = dataPriv.get( this, type );
  11591. if ( saved !== result || notAsync ) {
  11592. dataPriv.set( this, type, false );
  11593. } else {
  11594. result = {};
  11595. }
  11596. if ( saved !== result ) {
  11597. // Cancel the outer synthetic event
  11598. event.stopImmediatePropagation();
  11599. event.preventDefault();
  11600. return result.value;
  11601. }
  11602. // If this is an inner synthetic event for an event with a bubbling surrogate
  11603. // (focus or blur), assume that the surrogate already propagated from triggering the
  11604. // native event and prevent that from happening again here.
  11605. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11606. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11607. // less bad than duplication.
  11608. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11609. event.stopPropagation();
  11610. }
  11611. // If this is a native event triggered above, everything is now in order
  11612. // Fire an inner synthetic event with the original arguments
  11613. } else if ( saved.length ) {
  11614. // ...and capture the result
  11615. dataPriv.set( this, type, {
  11616. value: jQuery.event.trigger(
  11617. // Support: IE <=9 - 11+
  11618. // Extend with the prototype to reset the above stopImmediatePropagation()
  11619. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11620. saved.slice( 1 ),
  11621. this
  11622. )
  11623. } );
  11624. // Abort handling of the native event
  11625. event.stopImmediatePropagation();
  11626. }
  11627. }
  11628. } );
  11629. }
  11630. jQuery.removeEvent = function( elem, type, handle ) {
  11631. // This "if" is needed for plain objects
  11632. if ( elem.removeEventListener ) {
  11633. elem.removeEventListener( type, handle );
  11634. }
  11635. };
  11636. jQuery.Event = function( src, props ) {
  11637. // Allow instantiation without the 'new' keyword
  11638. if ( !( this instanceof jQuery.Event ) ) {
  11639. return new jQuery.Event( src, props );
  11640. }
  11641. // Event object
  11642. if ( src && src.type ) {
  11643. this.originalEvent = src;
  11644. this.type = src.type;
  11645. // Events bubbling up the document may have been marked as prevented
  11646. // by a handler lower down the tree; reflect the correct value.
  11647. this.isDefaultPrevented = src.defaultPrevented ||
  11648. src.defaultPrevented === undefined &&
  11649. // Support: Android <=2.3 only
  11650. src.returnValue === false ?
  11651. returnTrue :
  11652. returnFalse;
  11653. // Create target properties
  11654. // Support: Safari <=6 - 7 only
  11655. // Target should not be a text node (#504, #13143)
  11656. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11657. src.target.parentNode :
  11658. src.target;
  11659. this.currentTarget = src.currentTarget;
  11660. this.relatedTarget = src.relatedTarget;
  11661. // Event type
  11662. } else {
  11663. this.type = src;
  11664. }
  11665. // Put explicitly provided properties onto the event object
  11666. if ( props ) {
  11667. jQuery.extend( this, props );
  11668. }
  11669. // Create a timestamp if incoming event doesn't have one
  11670. this.timeStamp = src && src.timeStamp || Date.now();
  11671. // Mark it as fixed
  11672. this[ jQuery.expando ] = true;
  11673. };
  11674. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11675. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11676. jQuery.Event.prototype = {
  11677. constructor: jQuery.Event,
  11678. isDefaultPrevented: returnFalse,
  11679. isPropagationStopped: returnFalse,
  11680. isImmediatePropagationStopped: returnFalse,
  11681. isSimulated: false,
  11682. preventDefault: function() {
  11683. var e = this.originalEvent;
  11684. this.isDefaultPrevented = returnTrue;
  11685. if ( e && !this.isSimulated ) {
  11686. e.preventDefault();
  11687. }
  11688. },
  11689. stopPropagation: function() {
  11690. var e = this.originalEvent;
  11691. this.isPropagationStopped = returnTrue;
  11692. if ( e && !this.isSimulated ) {
  11693. e.stopPropagation();
  11694. }
  11695. },
  11696. stopImmediatePropagation: function() {
  11697. var e = this.originalEvent;
  11698. this.isImmediatePropagationStopped = returnTrue;
  11699. if ( e && !this.isSimulated ) {
  11700. e.stopImmediatePropagation();
  11701. }
  11702. this.stopPropagation();
  11703. }
  11704. };
  11705. // Includes all common event props including KeyEvent and MouseEvent specific props
  11706. jQuery.each( {
  11707. altKey: true,
  11708. bubbles: true,
  11709. cancelable: true,
  11710. changedTouches: true,
  11711. ctrlKey: true,
  11712. detail: true,
  11713. eventPhase: true,
  11714. metaKey: true,
  11715. pageX: true,
  11716. pageY: true,
  11717. shiftKey: true,
  11718. view: true,
  11719. "char": true,
  11720. code: true,
  11721. charCode: true,
  11722. key: true,
  11723. keyCode: true,
  11724. button: true,
  11725. buttons: true,
  11726. clientX: true,
  11727. clientY: true,
  11728. offsetX: true,
  11729. offsetY: true,
  11730. pointerId: true,
  11731. pointerType: true,
  11732. screenX: true,
  11733. screenY: true,
  11734. targetTouches: true,
  11735. toElement: true,
  11736. touches: true,
  11737. which: function( event ) {
  11738. var button = event.button;
  11739. // Add which for key events
  11740. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11741. return event.charCode != null ? event.charCode : event.keyCode;
  11742. }
  11743. // Add which for click: 1 === left; 2 === middle; 3 === right
  11744. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11745. if ( button & 1 ) {
  11746. return 1;
  11747. }
  11748. if ( button & 2 ) {
  11749. return 3;
  11750. }
  11751. if ( button & 4 ) {
  11752. return 2;
  11753. }
  11754. return 0;
  11755. }
  11756. return event.which;
  11757. }
  11758. }, jQuery.event.addProp );
  11759. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11760. jQuery.event.special[ type ] = {
  11761. // Utilize native event if possible so blur/focus sequence is correct
  11762. setup: function() {
  11763. // Claim the first handler
  11764. // dataPriv.set( this, "focus", ... )
  11765. // dataPriv.set( this, "blur", ... )
  11766. leverageNative( this, type, expectSync );
  11767. // Return false to allow normal processing in the caller
  11768. return false;
  11769. },
  11770. trigger: function() {
  11771. // Force setup before trigger
  11772. leverageNative( this, type );
  11773. // Return non-false to allow normal event-path propagation
  11774. return true;
  11775. },
  11776. delegateType: delegateType
  11777. };
  11778. } );
  11779. // Create mouseenter/leave events using mouseover/out and event-time checks
  11780. // so that event delegation works in jQuery.
  11781. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11782. //
  11783. // Support: Safari 7 only
  11784. // Safari sends mouseenter too often; see:
  11785. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11786. // for the description of the bug (it existed in older Chrome versions as well).
  11787. jQuery.each( {
  11788. mouseenter: "mouseover",
  11789. mouseleave: "mouseout",
  11790. pointerenter: "pointerover",
  11791. pointerleave: "pointerout"
  11792. }, function( orig, fix ) {
  11793. jQuery.event.special[ orig ] = {
  11794. delegateType: fix,
  11795. bindType: fix,
  11796. handle: function( event ) {
  11797. var ret,
  11798. target = this,
  11799. related = event.relatedTarget,
  11800. handleObj = event.handleObj;
  11801. // For mouseenter/leave call the handler if related is outside the target.
  11802. // NB: No relatedTarget if the mouse left/entered the browser window
  11803. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11804. event.type = handleObj.origType;
  11805. ret = handleObj.handler.apply( this, arguments );
  11806. event.type = fix;
  11807. }
  11808. return ret;
  11809. }
  11810. };
  11811. } );
  11812. jQuery.fn.extend( {
  11813. on: function( types, selector, data, fn ) {
  11814. return on( this, types, selector, data, fn );
  11815. },
  11816. one: function( types, selector, data, fn ) {
  11817. return on( this, types, selector, data, fn, 1 );
  11818. },
  11819. off: function( types, selector, fn ) {
  11820. var handleObj, type;
  11821. if ( types && types.preventDefault && types.handleObj ) {
  11822. // ( event ) dispatched jQuery.Event
  11823. handleObj = types.handleObj;
  11824. jQuery( types.delegateTarget ).off(
  11825. handleObj.namespace ?
  11826. handleObj.origType + "." + handleObj.namespace :
  11827. handleObj.origType,
  11828. handleObj.selector,
  11829. handleObj.handler
  11830. );
  11831. return this;
  11832. }
  11833. if ( typeof types === "object" ) {
  11834. // ( types-object [, selector] )
  11835. for ( type in types ) {
  11836. this.off( type, selector, types[ type ] );
  11837. }
  11838. return this;
  11839. }
  11840. if ( selector === false || typeof selector === "function" ) {
  11841. // ( types [, fn] )
  11842. fn = selector;
  11843. selector = undefined;
  11844. }
  11845. if ( fn === false ) {
  11846. fn = returnFalse;
  11847. }
  11848. return this.each( function() {
  11849. jQuery.event.remove( this, types, fn, selector );
  11850. } );
  11851. }
  11852. } );
  11853. var
  11854. /* eslint-disable max-len */
  11855. // See https://github.com/eslint/eslint/issues/3229
  11856. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11857. /* eslint-enable */
  11858. // Support: IE <=10 - 11, Edge 12 - 13 only
  11859. // In IE/Edge using regex groups here causes severe slowdowns.
  11860. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11861. rnoInnerhtml = /<script|<style|<link/i,
  11862. // checked="checked" or checked
  11863. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11864. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11865. // Prefer a tbody over its parent table for containing new rows
  11866. function manipulationTarget( elem, content ) {
  11867. if ( nodeName( elem, "table" ) &&
  11868. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11869. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11870. }
  11871. return elem;
  11872. }
  11873. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11874. function disableScript( elem ) {
  11875. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11876. return elem;
  11877. }
  11878. function restoreScript( elem ) {
  11879. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11880. elem.type = elem.type.slice( 5 );
  11881. } else {
  11882. elem.removeAttribute( "type" );
  11883. }
  11884. return elem;
  11885. }
  11886. function cloneCopyEvent( src, dest ) {
  11887. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11888. if ( dest.nodeType !== 1 ) {
  11889. return;
  11890. }
  11891. // 1. Copy private data: events, handlers, etc.
  11892. if ( dataPriv.hasData( src ) ) {
  11893. pdataOld = dataPriv.access( src );
  11894. pdataCur = dataPriv.set( dest, pdataOld );
  11895. events = pdataOld.events;
  11896. if ( events ) {
  11897. delete pdataCur.handle;
  11898. pdataCur.events = {};
  11899. for ( type in events ) {
  11900. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11901. jQuery.event.add( dest, type, events[ type ][ i ] );
  11902. }
  11903. }
  11904. }
  11905. }
  11906. // 2. Copy user data
  11907. if ( dataUser.hasData( src ) ) {
  11908. udataOld = dataUser.access( src );
  11909. udataCur = jQuery.extend( {}, udataOld );
  11910. dataUser.set( dest, udataCur );
  11911. }
  11912. }
  11913. // Fix IE bugs, see support tests
  11914. function fixInput( src, dest ) {
  11915. var nodeName = dest.nodeName.toLowerCase();
  11916. // Fails to persist the checked state of a cloned checkbox or radio button.
  11917. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11918. dest.checked = src.checked;
  11919. // Fails to return the selected option to the default selected state when cloning options
  11920. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11921. dest.defaultValue = src.defaultValue;
  11922. }
  11923. }
  11924. function domManip( collection, args, callback, ignored ) {
  11925. // Flatten any nested arrays
  11926. args = concat.apply( [], args );
  11927. var fragment, first, scripts, hasScripts, node, doc,
  11928. i = 0,
  11929. l = collection.length,
  11930. iNoClone = l - 1,
  11931. value = args[ 0 ],
  11932. valueIsFunction = isFunction( value );
  11933. // We can't cloneNode fragments that contain checked, in WebKit
  11934. if ( valueIsFunction ||
  11935. ( l > 1 && typeof value === "string" &&
  11936. !support.checkClone && rchecked.test( value ) ) ) {
  11937. return collection.each( function( index ) {
  11938. var self = collection.eq( index );
  11939. if ( valueIsFunction ) {
  11940. args[ 0 ] = value.call( this, index, self.html() );
  11941. }
  11942. domManip( self, args, callback, ignored );
  11943. } );
  11944. }
  11945. if ( l ) {
  11946. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11947. first = fragment.firstChild;
  11948. if ( fragment.childNodes.length === 1 ) {
  11949. fragment = first;
  11950. }
  11951. // Require either new content or an interest in ignored elements to invoke the callback
  11952. if ( first || ignored ) {
  11953. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11954. hasScripts = scripts.length;
  11955. // Use the original fragment for the last item
  11956. // instead of the first because it can end up
  11957. // being emptied incorrectly in certain situations (#8070).
  11958. for ( ; i < l; i++ ) {
  11959. node = fragment;
  11960. if ( i !== iNoClone ) {
  11961. node = jQuery.clone( node, true, true );
  11962. // Keep references to cloned scripts for later restoration
  11963. if ( hasScripts ) {
  11964. // Support: Android <=4.0 only, PhantomJS 1 only
  11965. // push.apply(_, arraylike) throws on ancient WebKit
  11966. jQuery.merge( scripts, getAll( node, "script" ) );
  11967. }
  11968. }
  11969. callback.call( collection[ i ], node, i );
  11970. }
  11971. if ( hasScripts ) {
  11972. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11973. // Reenable scripts
  11974. jQuery.map( scripts, restoreScript );
  11975. // Evaluate executable scripts on first document insertion
  11976. for ( i = 0; i < hasScripts; i++ ) {
  11977. node = scripts[ i ];
  11978. if ( rscriptType.test( node.type || "" ) &&
  11979. !dataPriv.access( node, "globalEval" ) &&
  11980. jQuery.contains( doc, node ) ) {
  11981. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11982. // Optional AJAX dependency, but won't run scripts if not present
  11983. if ( jQuery._evalUrl && !node.noModule ) {
  11984. jQuery._evalUrl( node.src, {
  11985. nonce: node.nonce || node.getAttribute( "nonce" )
  11986. } );
  11987. }
  11988. } else {
  11989. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11990. }
  11991. }
  11992. }
  11993. }
  11994. }
  11995. }
  11996. return collection;
  11997. }
  11998. function remove( elem, selector, keepData ) {
  11999. var node,
  12000. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12001. i = 0;
  12002. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12003. if ( !keepData && node.nodeType === 1 ) {
  12004. jQuery.cleanData( getAll( node ) );
  12005. }
  12006. if ( node.parentNode ) {
  12007. if ( keepData && isAttached( node ) ) {
  12008. setGlobalEval( getAll( node, "script" ) );
  12009. }
  12010. node.parentNode.removeChild( node );
  12011. }
  12012. }
  12013. return elem;
  12014. }
  12015. jQuery.extend( {
  12016. htmlPrefilter: function( html ) {
  12017. return html.replace( rxhtmlTag, "<$1></$2>" );
  12018. },
  12019. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12020. var i, l, srcElements, destElements,
  12021. clone = elem.cloneNode( true ),
  12022. inPage = isAttached( elem );
  12023. // Fix IE cloning issues
  12024. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12025. !jQuery.isXMLDoc( elem ) ) {
  12026. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12027. destElements = getAll( clone );
  12028. srcElements = getAll( elem );
  12029. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12030. fixInput( srcElements[ i ], destElements[ i ] );
  12031. }
  12032. }
  12033. // Copy the events from the original to the clone
  12034. if ( dataAndEvents ) {
  12035. if ( deepDataAndEvents ) {
  12036. srcElements = srcElements || getAll( elem );
  12037. destElements = destElements || getAll( clone );
  12038. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12039. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12040. }
  12041. } else {
  12042. cloneCopyEvent( elem, clone );
  12043. }
  12044. }
  12045. // Preserve script evaluation history
  12046. destElements = getAll( clone, "script" );
  12047. if ( destElements.length > 0 ) {
  12048. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12049. }
  12050. // Return the cloned set
  12051. return clone;
  12052. },
  12053. cleanData: function( elems ) {
  12054. var data, elem, type,
  12055. special = jQuery.event.special,
  12056. i = 0;
  12057. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12058. if ( acceptData( elem ) ) {
  12059. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12060. if ( data.events ) {
  12061. for ( type in data.events ) {
  12062. if ( special[ type ] ) {
  12063. jQuery.event.remove( elem, type );
  12064. // This is a shortcut to avoid jQuery.event.remove's overhead
  12065. } else {
  12066. jQuery.removeEvent( elem, type, data.handle );
  12067. }
  12068. }
  12069. }
  12070. // Support: Chrome <=35 - 45+
  12071. // Assign undefined instead of using delete, see Data#remove
  12072. elem[ dataPriv.expando ] = undefined;
  12073. }
  12074. if ( elem[ dataUser.expando ] ) {
  12075. // Support: Chrome <=35 - 45+
  12076. // Assign undefined instead of using delete, see Data#remove
  12077. elem[ dataUser.expando ] = undefined;
  12078. }
  12079. }
  12080. }
  12081. }
  12082. } );
  12083. jQuery.fn.extend( {
  12084. detach: function( selector ) {
  12085. return remove( this, selector, true );
  12086. },
  12087. remove: function( selector ) {
  12088. return remove( this, selector );
  12089. },
  12090. text: function( value ) {
  12091. return access( this, function( value ) {
  12092. return value === undefined ?
  12093. jQuery.text( this ) :
  12094. this.empty().each( function() {
  12095. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12096. this.textContent = value;
  12097. }
  12098. } );
  12099. }, null, value, arguments.length );
  12100. },
  12101. append: function() {
  12102. return domManip( this, arguments, function( elem ) {
  12103. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12104. var target = manipulationTarget( this, elem );
  12105. target.appendChild( elem );
  12106. }
  12107. } );
  12108. },
  12109. prepend: function() {
  12110. return domManip( this, arguments, function( elem ) {
  12111. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12112. var target = manipulationTarget( this, elem );
  12113. target.insertBefore( elem, target.firstChild );
  12114. }
  12115. } );
  12116. },
  12117. before: function() {
  12118. return domManip( this, arguments, function( elem ) {
  12119. if ( this.parentNode ) {
  12120. this.parentNode.insertBefore( elem, this );
  12121. }
  12122. } );
  12123. },
  12124. after: function() {
  12125. return domManip( this, arguments, function( elem ) {
  12126. if ( this.parentNode ) {
  12127. this.parentNode.insertBefore( elem, this.nextSibling );
  12128. }
  12129. } );
  12130. },
  12131. empty: function() {
  12132. var elem,
  12133. i = 0;
  12134. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12135. if ( elem.nodeType === 1 ) {
  12136. // Prevent memory leaks
  12137. jQuery.cleanData( getAll( elem, false ) );
  12138. // Remove any remaining nodes
  12139. elem.textContent = "";
  12140. }
  12141. }
  12142. return this;
  12143. },
  12144. clone: function( dataAndEvents, deepDataAndEvents ) {
  12145. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12146. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12147. return this.map( function() {
  12148. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12149. } );
  12150. },
  12151. html: function( value ) {
  12152. return access( this, function( value ) {
  12153. var elem = this[ 0 ] || {},
  12154. i = 0,
  12155. l = this.length;
  12156. if ( value === undefined && elem.nodeType === 1 ) {
  12157. return elem.innerHTML;
  12158. }
  12159. // See if we can take a shortcut and just use innerHTML
  12160. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12161. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12162. value = jQuery.htmlPrefilter( value );
  12163. try {
  12164. for ( ; i < l; i++ ) {
  12165. elem = this[ i ] || {};
  12166. // Remove element nodes and prevent memory leaks
  12167. if ( elem.nodeType === 1 ) {
  12168. jQuery.cleanData( getAll( elem, false ) );
  12169. elem.innerHTML = value;
  12170. }
  12171. }
  12172. elem = 0;
  12173. // If using innerHTML throws an exception, use the fallback method
  12174. } catch ( e ) {}
  12175. }
  12176. if ( elem ) {
  12177. this.empty().append( value );
  12178. }
  12179. }, null, value, arguments.length );
  12180. },
  12181. replaceWith: function() {
  12182. var ignored = [];
  12183. // Make the changes, replacing each non-ignored context element with the new content
  12184. return domManip( this, arguments, function( elem ) {
  12185. var parent = this.parentNode;
  12186. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12187. jQuery.cleanData( getAll( this ) );
  12188. if ( parent ) {
  12189. parent.replaceChild( elem, this );
  12190. }
  12191. }
  12192. // Force callback invocation
  12193. }, ignored );
  12194. }
  12195. } );
  12196. jQuery.each( {
  12197. appendTo: "append",
  12198. prependTo: "prepend",
  12199. insertBefore: "before",
  12200. insertAfter: "after",
  12201. replaceAll: "replaceWith"
  12202. }, function( name, original ) {
  12203. jQuery.fn[ name ] = function( selector ) {
  12204. var elems,
  12205. ret = [],
  12206. insert = jQuery( selector ),
  12207. last = insert.length - 1,
  12208. i = 0;
  12209. for ( ; i <= last; i++ ) {
  12210. elems = i === last ? this : this.clone( true );
  12211. jQuery( insert[ i ] )[ original ]( elems );
  12212. // Support: Android <=4.0 only, PhantomJS 1 only
  12213. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12214. push.apply( ret, elems.get() );
  12215. }
  12216. return this.pushStack( ret );
  12217. };
  12218. } );
  12219. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12220. var getStyles = function( elem ) {
  12221. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12222. // IE throws on elements created in popups
  12223. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12224. var view = elem.ownerDocument.defaultView;
  12225. if ( !view || !view.opener ) {
  12226. view = window;
  12227. }
  12228. return view.getComputedStyle( elem );
  12229. };
  12230. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12231. ( function() {
  12232. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12233. // so they're executed at the same time to save the second computation.
  12234. function computeStyleTests() {
  12235. // This is a singleton, we need to execute it only once
  12236. if ( !div ) {
  12237. return;
  12238. }
  12239. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12240. "margin-top:1px;padding:0;border:0";
  12241. div.style.cssText =
  12242. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12243. "margin:auto;border:1px;padding:1px;" +
  12244. "width:60%;top:1%";
  12245. documentElement.appendChild( container ).appendChild( div );
  12246. var divStyle = window.getComputedStyle( div );
  12247. pixelPositionVal = divStyle.top !== "1%";
  12248. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12249. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12250. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12251. // Some styles come back with percentage values, even though they shouldn't
  12252. div.style.right = "60%";
  12253. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12254. // Support: IE 9 - 11 only
  12255. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12256. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12257. // Support: IE 9 only
  12258. // Detect overflow:scroll screwiness (gh-3699)
  12259. // Support: Chrome <=64
  12260. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12261. div.style.position = "absolute";
  12262. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12263. documentElement.removeChild( container );
  12264. // Nullify the div so it wouldn't be stored in the memory and
  12265. // it will also be a sign that checks already performed
  12266. div = null;
  12267. }
  12268. function roundPixelMeasures( measure ) {
  12269. return Math.round( parseFloat( measure ) );
  12270. }
  12271. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12272. reliableMarginLeftVal,
  12273. container = document.createElement( "div" ),
  12274. div = document.createElement( "div" );
  12275. // Finish early in limited (non-browser) environments
  12276. if ( !div.style ) {
  12277. return;
  12278. }
  12279. // Support: IE <=9 - 11 only
  12280. // Style of cloned element affects source element cloned (#8908)
  12281. div.style.backgroundClip = "content-box";
  12282. div.cloneNode( true ).style.backgroundClip = "";
  12283. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12284. jQuery.extend( support, {
  12285. boxSizingReliable: function() {
  12286. computeStyleTests();
  12287. return boxSizingReliableVal;
  12288. },
  12289. pixelBoxStyles: function() {
  12290. computeStyleTests();
  12291. return pixelBoxStylesVal;
  12292. },
  12293. pixelPosition: function() {
  12294. computeStyleTests();
  12295. return pixelPositionVal;
  12296. },
  12297. reliableMarginLeft: function() {
  12298. computeStyleTests();
  12299. return reliableMarginLeftVal;
  12300. },
  12301. scrollboxSize: function() {
  12302. computeStyleTests();
  12303. return scrollboxSizeVal;
  12304. }
  12305. } );
  12306. } )();
  12307. function curCSS( elem, name, computed ) {
  12308. var width, minWidth, maxWidth, ret,
  12309. // Support: Firefox 51+
  12310. // Retrieving style before computed somehow
  12311. // fixes an issue with getting wrong values
  12312. // on detached elements
  12313. style = elem.style;
  12314. computed = computed || getStyles( elem );
  12315. // getPropertyValue is needed for:
  12316. // .css('filter') (IE 9 only, #12537)
  12317. // .css('--customProperty) (#3144)
  12318. if ( computed ) {
  12319. ret = computed.getPropertyValue( name ) || computed[ name ];
  12320. if ( ret === "" && !isAttached( elem ) ) {
  12321. ret = jQuery.style( elem, name );
  12322. }
  12323. // A tribute to the "awesome hack by Dean Edwards"
  12324. // Android Browser returns percentage for some values,
  12325. // but width seems to be reliably pixels.
  12326. // This is against the CSSOM draft spec:
  12327. // https://drafts.csswg.org/cssom/#resolved-values
  12328. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12329. // Remember the original values
  12330. width = style.width;
  12331. minWidth = style.minWidth;
  12332. maxWidth = style.maxWidth;
  12333. // Put in the new values to get a computed value out
  12334. style.minWidth = style.maxWidth = style.width = ret;
  12335. ret = computed.width;
  12336. // Revert the changed values
  12337. style.width = width;
  12338. style.minWidth = minWidth;
  12339. style.maxWidth = maxWidth;
  12340. }
  12341. }
  12342. return ret !== undefined ?
  12343. // Support: IE <=9 - 11 only
  12344. // IE returns zIndex value as an integer.
  12345. ret + "" :
  12346. ret;
  12347. }
  12348. function addGetHookIf( conditionFn, hookFn ) {
  12349. // Define the hook, we'll check on the first run if it's really needed.
  12350. return {
  12351. get: function() {
  12352. if ( conditionFn() ) {
  12353. // Hook not needed (or it's not possible to use it due
  12354. // to missing dependency), remove it.
  12355. delete this.get;
  12356. return;
  12357. }
  12358. // Hook needed; redefine it so that the support test is not executed again.
  12359. return ( this.get = hookFn ).apply( this, arguments );
  12360. }
  12361. };
  12362. }
  12363. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12364. emptyStyle = document.createElement( "div" ).style,
  12365. vendorProps = {};
  12366. // Return a vendor-prefixed property or undefined
  12367. function vendorPropName( name ) {
  12368. // Check for vendor prefixed names
  12369. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12370. i = cssPrefixes.length;
  12371. while ( i-- ) {
  12372. name = cssPrefixes[ i ] + capName;
  12373. if ( name in emptyStyle ) {
  12374. return name;
  12375. }
  12376. }
  12377. }
  12378. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12379. function finalPropName( name ) {
  12380. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12381. if ( final ) {
  12382. return final;
  12383. }
  12384. if ( name in emptyStyle ) {
  12385. return name;
  12386. }
  12387. return vendorProps[ name ] = vendorPropName( name ) || name;
  12388. }
  12389. var
  12390. // Swappable if display is none or starts with table
  12391. // except "table", "table-cell", or "table-caption"
  12392. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12393. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12394. rcustomProp = /^--/,
  12395. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12396. cssNormalTransform = {
  12397. letterSpacing: "0",
  12398. fontWeight: "400"
  12399. };
  12400. function setPositiveNumber( elem, value, subtract ) {
  12401. // Any relative (+/-) values have already been
  12402. // normalized at this point
  12403. var matches = rcssNum.exec( value );
  12404. return matches ?
  12405. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12406. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12407. value;
  12408. }
  12409. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12410. var i = dimension === "width" ? 1 : 0,
  12411. extra = 0,
  12412. delta = 0;
  12413. // Adjustment may not be necessary
  12414. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12415. return 0;
  12416. }
  12417. for ( ; i < 4; i += 2 ) {
  12418. // Both box models exclude margin
  12419. if ( box === "margin" ) {
  12420. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12421. }
  12422. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12423. if ( !isBorderBox ) {
  12424. // Add padding
  12425. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12426. // For "border" or "margin", add border
  12427. if ( box !== "padding" ) {
  12428. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12429. // But still keep track of it otherwise
  12430. } else {
  12431. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12432. }
  12433. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12434. // "padding" or "margin"
  12435. } else {
  12436. // For "content", subtract padding
  12437. if ( box === "content" ) {
  12438. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12439. }
  12440. // For "content" or "padding", subtract border
  12441. if ( box !== "margin" ) {
  12442. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12443. }
  12444. }
  12445. }
  12446. // Account for positive content-box scroll gutter when requested by providing computedVal
  12447. if ( !isBorderBox && computedVal >= 0 ) {
  12448. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12449. // Assuming integer scroll gutter, subtract the rest and round down
  12450. delta += Math.max( 0, Math.ceil(
  12451. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12452. computedVal -
  12453. delta -
  12454. extra -
  12455. 0.5
  12456. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12457. // Use an explicit zero to avoid NaN (gh-3964)
  12458. ) ) || 0;
  12459. }
  12460. return delta;
  12461. }
  12462. function getWidthOrHeight( elem, dimension, extra ) {
  12463. // Start with computed style
  12464. var styles = getStyles( elem ),
  12465. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12466. // Fake content-box until we know it's needed to know the true value.
  12467. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12468. isBorderBox = boxSizingNeeded &&
  12469. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12470. valueIsBorderBox = isBorderBox,
  12471. val = curCSS( elem, dimension, styles ),
  12472. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12473. // Support: Firefox <=54
  12474. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12475. if ( rnumnonpx.test( val ) ) {
  12476. if ( !extra ) {
  12477. return val;
  12478. }
  12479. val = "auto";
  12480. }
  12481. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12482. // This happens for inline elements with no explicit setting (gh-3571)
  12483. // Support: Android <=4.1 - 4.3 only
  12484. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12485. // Support: IE 9-11 only
  12486. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12487. // We use getClientRects() to check for hidden/disconnected.
  12488. // In those cases, the computed value can be trusted to be border-box
  12489. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12490. val === "auto" ||
  12491. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12492. elem.getClientRects().length ) {
  12493. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12494. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12495. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12496. // retrieved value as a content box dimension.
  12497. valueIsBorderBox = offsetProp in elem;
  12498. if ( valueIsBorderBox ) {
  12499. val = elem[ offsetProp ];
  12500. }
  12501. }
  12502. // Normalize "" and auto
  12503. val = parseFloat( val ) || 0;
  12504. // Adjust for the element's box model
  12505. return ( val +
  12506. boxModelAdjustment(
  12507. elem,
  12508. dimension,
  12509. extra || ( isBorderBox ? "border" : "content" ),
  12510. valueIsBorderBox,
  12511. styles,
  12512. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12513. val
  12514. )
  12515. ) + "px";
  12516. }
  12517. jQuery.extend( {
  12518. // Add in style property hooks for overriding the default
  12519. // behavior of getting and setting a style property
  12520. cssHooks: {
  12521. opacity: {
  12522. get: function( elem, computed ) {
  12523. if ( computed ) {
  12524. // We should always get a number back from opacity
  12525. var ret = curCSS( elem, "opacity" );
  12526. return ret === "" ? "1" : ret;
  12527. }
  12528. }
  12529. }
  12530. },
  12531. // Don't automatically add "px" to these possibly-unitless properties
  12532. cssNumber: {
  12533. "animationIterationCount": true,
  12534. "columnCount": true,
  12535. "fillOpacity": true,
  12536. "flexGrow": true,
  12537. "flexShrink": true,
  12538. "fontWeight": true,
  12539. "gridArea": true,
  12540. "gridColumn": true,
  12541. "gridColumnEnd": true,
  12542. "gridColumnStart": true,
  12543. "gridRow": true,
  12544. "gridRowEnd": true,
  12545. "gridRowStart": true,
  12546. "lineHeight": true,
  12547. "opacity": true,
  12548. "order": true,
  12549. "orphans": true,
  12550. "widows": true,
  12551. "zIndex": true,
  12552. "zoom": true
  12553. },
  12554. // Add in properties whose names you wish to fix before
  12555. // setting or getting the value
  12556. cssProps: {},
  12557. // Get and set the style property on a DOM Node
  12558. style: function( elem, name, value, extra ) {
  12559. // Don't set styles on text and comment nodes
  12560. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12561. return;
  12562. }
  12563. // Make sure that we're working with the right name
  12564. var ret, type, hooks,
  12565. origName = camelCase( name ),
  12566. isCustomProp = rcustomProp.test( name ),
  12567. style = elem.style;
  12568. // Make sure that we're working with the right name. We don't
  12569. // want to query the value if it is a CSS custom property
  12570. // since they are user-defined.
  12571. if ( !isCustomProp ) {
  12572. name = finalPropName( origName );
  12573. }
  12574. // Gets hook for the prefixed version, then unprefixed version
  12575. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12576. // Check if we're setting a value
  12577. if ( value !== undefined ) {
  12578. type = typeof value;
  12579. // Convert "+=" or "-=" to relative numbers (#7345)
  12580. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12581. value = adjustCSS( elem, name, ret );
  12582. // Fixes bug #9237
  12583. type = "number";
  12584. }
  12585. // Make sure that null and NaN values aren't set (#7116)
  12586. if ( value == null || value !== value ) {
  12587. return;
  12588. }
  12589. // If a number was passed in, add the unit (except for certain CSS properties)
  12590. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12591. // "px" to a few hardcoded values.
  12592. if ( type === "number" && !isCustomProp ) {
  12593. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12594. }
  12595. // background-* props affect original clone's values
  12596. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12597. style[ name ] = "inherit";
  12598. }
  12599. // If a hook was provided, use that value, otherwise just set the specified value
  12600. if ( !hooks || !( "set" in hooks ) ||
  12601. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12602. if ( isCustomProp ) {
  12603. style.setProperty( name, value );
  12604. } else {
  12605. style[ name ] = value;
  12606. }
  12607. }
  12608. } else {
  12609. // If a hook was provided get the non-computed value from there
  12610. if ( hooks && "get" in hooks &&
  12611. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12612. return ret;
  12613. }
  12614. // Otherwise just get the value from the style object
  12615. return style[ name ];
  12616. }
  12617. },
  12618. css: function( elem, name, extra, styles ) {
  12619. var val, num, hooks,
  12620. origName = camelCase( name ),
  12621. isCustomProp = rcustomProp.test( name );
  12622. // Make sure that we're working with the right name. We don't
  12623. // want to modify the value if it is a CSS custom property
  12624. // since they are user-defined.
  12625. if ( !isCustomProp ) {
  12626. name = finalPropName( origName );
  12627. }
  12628. // Try prefixed name followed by the unprefixed name
  12629. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12630. // If a hook was provided get the computed value from there
  12631. if ( hooks && "get" in hooks ) {
  12632. val = hooks.get( elem, true, extra );
  12633. }
  12634. // Otherwise, if a way to get the computed value exists, use that
  12635. if ( val === undefined ) {
  12636. val = curCSS( elem, name, styles );
  12637. }
  12638. // Convert "normal" to computed value
  12639. if ( val === "normal" && name in cssNormalTransform ) {
  12640. val = cssNormalTransform[ name ];
  12641. }
  12642. // Make numeric if forced or a qualifier was provided and val looks numeric
  12643. if ( extra === "" || extra ) {
  12644. num = parseFloat( val );
  12645. return extra === true || isFinite( num ) ? num || 0 : val;
  12646. }
  12647. return val;
  12648. }
  12649. } );
  12650. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12651. jQuery.cssHooks[ dimension ] = {
  12652. get: function( elem, computed, extra ) {
  12653. if ( computed ) {
  12654. // Certain elements can have dimension info if we invisibly show them
  12655. // but it must have a current display style that would benefit
  12656. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12657. // Support: Safari 8+
  12658. // Table columns in Safari have non-zero offsetWidth & zero
  12659. // getBoundingClientRect().width unless display is changed.
  12660. // Support: IE <=11 only
  12661. // Running getBoundingClientRect on a disconnected node
  12662. // in IE throws an error.
  12663. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12664. swap( elem, cssShow, function() {
  12665. return getWidthOrHeight( elem, dimension, extra );
  12666. } ) :
  12667. getWidthOrHeight( elem, dimension, extra );
  12668. }
  12669. },
  12670. set: function( elem, value, extra ) {
  12671. var matches,
  12672. styles = getStyles( elem ),
  12673. // Only read styles.position if the test has a chance to fail
  12674. // to avoid forcing a reflow.
  12675. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12676. styles.position === "absolute",
  12677. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12678. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12679. isBorderBox = boxSizingNeeded &&
  12680. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12681. subtract = extra ?
  12682. boxModelAdjustment(
  12683. elem,
  12684. dimension,
  12685. extra,
  12686. isBorderBox,
  12687. styles
  12688. ) :
  12689. 0;
  12690. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12691. // faking a content-box to get border and padding (gh-3699)
  12692. if ( isBorderBox && scrollboxSizeBuggy ) {
  12693. subtract -= Math.ceil(
  12694. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12695. parseFloat( styles[ dimension ] ) -
  12696. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12697. 0.5
  12698. );
  12699. }
  12700. // Convert to pixels if value adjustment is needed
  12701. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12702. ( matches[ 3 ] || "px" ) !== "px" ) {
  12703. elem.style[ dimension ] = value;
  12704. value = jQuery.css( elem, dimension );
  12705. }
  12706. return setPositiveNumber( elem, value, subtract );
  12707. }
  12708. };
  12709. } );
  12710. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12711. function( elem, computed ) {
  12712. if ( computed ) {
  12713. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12714. elem.getBoundingClientRect().left -
  12715. swap( elem, { marginLeft: 0 }, function() {
  12716. return elem.getBoundingClientRect().left;
  12717. } )
  12718. ) + "px";
  12719. }
  12720. }
  12721. );
  12722. // These hooks are used by animate to expand properties
  12723. jQuery.each( {
  12724. margin: "",
  12725. padding: "",
  12726. border: "Width"
  12727. }, function( prefix, suffix ) {
  12728. jQuery.cssHooks[ prefix + suffix ] = {
  12729. expand: function( value ) {
  12730. var i = 0,
  12731. expanded = {},
  12732. // Assumes a single number if not a string
  12733. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12734. for ( ; i < 4; i++ ) {
  12735. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12736. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12737. }
  12738. return expanded;
  12739. }
  12740. };
  12741. if ( prefix !== "margin" ) {
  12742. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12743. }
  12744. } );
  12745. jQuery.fn.extend( {
  12746. css: function( name, value ) {
  12747. return access( this, function( elem, name, value ) {
  12748. var styles, len,
  12749. map = {},
  12750. i = 0;
  12751. if ( Array.isArray( name ) ) {
  12752. styles = getStyles( elem );
  12753. len = name.length;
  12754. for ( ; i < len; i++ ) {
  12755. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12756. }
  12757. return map;
  12758. }
  12759. return value !== undefined ?
  12760. jQuery.style( elem, name, value ) :
  12761. jQuery.css( elem, name );
  12762. }, name, value, arguments.length > 1 );
  12763. }
  12764. } );
  12765. function Tween( elem, options, prop, end, easing ) {
  12766. return new Tween.prototype.init( elem, options, prop, end, easing );
  12767. }
  12768. jQuery.Tween = Tween;
  12769. Tween.prototype = {
  12770. constructor: Tween,
  12771. init: function( elem, options, prop, end, easing, unit ) {
  12772. this.elem = elem;
  12773. this.prop = prop;
  12774. this.easing = easing || jQuery.easing._default;
  12775. this.options = options;
  12776. this.start = this.now = this.cur();
  12777. this.end = end;
  12778. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12779. },
  12780. cur: function() {
  12781. var hooks = Tween.propHooks[ this.prop ];
  12782. return hooks && hooks.get ?
  12783. hooks.get( this ) :
  12784. Tween.propHooks._default.get( this );
  12785. },
  12786. run: function( percent ) {
  12787. var eased,
  12788. hooks = Tween.propHooks[ this.prop ];
  12789. if ( this.options.duration ) {
  12790. this.pos = eased = jQuery.easing[ this.easing ](
  12791. percent, this.options.duration * percent, 0, 1, this.options.duration
  12792. );
  12793. } else {
  12794. this.pos = eased = percent;
  12795. }
  12796. this.now = ( this.end - this.start ) * eased + this.start;
  12797. if ( this.options.step ) {
  12798. this.options.step.call( this.elem, this.now, this );
  12799. }
  12800. if ( hooks && hooks.set ) {
  12801. hooks.set( this );
  12802. } else {
  12803. Tween.propHooks._default.set( this );
  12804. }
  12805. return this;
  12806. }
  12807. };
  12808. Tween.prototype.init.prototype = Tween.prototype;
  12809. Tween.propHooks = {
  12810. _default: {
  12811. get: function( tween ) {
  12812. var result;
  12813. // Use a property on the element directly when it is not a DOM element,
  12814. // or when there is no matching style property that exists.
  12815. if ( tween.elem.nodeType !== 1 ||
  12816. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12817. return tween.elem[ tween.prop ];
  12818. }
  12819. // Passing an empty string as a 3rd parameter to .css will automatically
  12820. // attempt a parseFloat and fallback to a string if the parse fails.
  12821. // Simple values such as "10px" are parsed to Float;
  12822. // complex values such as "rotate(1rad)" are returned as-is.
  12823. result = jQuery.css( tween.elem, tween.prop, "" );
  12824. // Empty strings, null, undefined and "auto" are converted to 0.
  12825. return !result || result === "auto" ? 0 : result;
  12826. },
  12827. set: function( tween ) {
  12828. // Use step hook for back compat.
  12829. // Use cssHook if its there.
  12830. // Use .style if available and use plain properties where available.
  12831. if ( jQuery.fx.step[ tween.prop ] ) {
  12832. jQuery.fx.step[ tween.prop ]( tween );
  12833. } else if ( tween.elem.nodeType === 1 && (
  12834. jQuery.cssHooks[ tween.prop ] ||
  12835. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12836. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12837. } else {
  12838. tween.elem[ tween.prop ] = tween.now;
  12839. }
  12840. }
  12841. }
  12842. };
  12843. // Support: IE <=9 only
  12844. // Panic based approach to setting things on disconnected nodes
  12845. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12846. set: function( tween ) {
  12847. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12848. tween.elem[ tween.prop ] = tween.now;
  12849. }
  12850. }
  12851. };
  12852. jQuery.easing = {
  12853. linear: function( p ) {
  12854. return p;
  12855. },
  12856. swing: function( p ) {
  12857. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12858. },
  12859. _default: "swing"
  12860. };
  12861. jQuery.fx = Tween.prototype.init;
  12862. // Back compat <1.8 extension point
  12863. jQuery.fx.step = {};
  12864. var
  12865. fxNow, inProgress,
  12866. rfxtypes = /^(?:toggle|show|hide)$/,
  12867. rrun = /queueHooks$/;
  12868. function schedule() {
  12869. if ( inProgress ) {
  12870. if ( document.hidden === false && window.requestAnimationFrame ) {
  12871. window.requestAnimationFrame( schedule );
  12872. } else {
  12873. window.setTimeout( schedule, jQuery.fx.interval );
  12874. }
  12875. jQuery.fx.tick();
  12876. }
  12877. }
  12878. // Animations created synchronously will run synchronously
  12879. function createFxNow() {
  12880. window.setTimeout( function() {
  12881. fxNow = undefined;
  12882. } );
  12883. return ( fxNow = Date.now() );
  12884. }
  12885. // Generate parameters to create a standard animation
  12886. function genFx( type, includeWidth ) {
  12887. var which,
  12888. i = 0,
  12889. attrs = { height: type };
  12890. // If we include width, step value is 1 to do all cssExpand values,
  12891. // otherwise step value is 2 to skip over Left and Right
  12892. includeWidth = includeWidth ? 1 : 0;
  12893. for ( ; i < 4; i += 2 - includeWidth ) {
  12894. which = cssExpand[ i ];
  12895. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12896. }
  12897. if ( includeWidth ) {
  12898. attrs.opacity = attrs.width = type;
  12899. }
  12900. return attrs;
  12901. }
  12902. function createTween( value, prop, animation ) {
  12903. var tween,
  12904. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12905. index = 0,
  12906. length = collection.length;
  12907. for ( ; index < length; index++ ) {
  12908. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12909. // We're done with this property
  12910. return tween;
  12911. }
  12912. }
  12913. }
  12914. function defaultPrefilter( elem, props, opts ) {
  12915. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12916. isBox = "width" in props || "height" in props,
  12917. anim = this,
  12918. orig = {},
  12919. style = elem.style,
  12920. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12921. dataShow = dataPriv.get( elem, "fxshow" );
  12922. // Queue-skipping animations hijack the fx hooks
  12923. if ( !opts.queue ) {
  12924. hooks = jQuery._queueHooks( elem, "fx" );
  12925. if ( hooks.unqueued == null ) {
  12926. hooks.unqueued = 0;
  12927. oldfire = hooks.empty.fire;
  12928. hooks.empty.fire = function() {
  12929. if ( !hooks.unqueued ) {
  12930. oldfire();
  12931. }
  12932. };
  12933. }
  12934. hooks.unqueued++;
  12935. anim.always( function() {
  12936. // Ensure the complete handler is called before this completes
  12937. anim.always( function() {
  12938. hooks.unqueued--;
  12939. if ( !jQuery.queue( elem, "fx" ).length ) {
  12940. hooks.empty.fire();
  12941. }
  12942. } );
  12943. } );
  12944. }
  12945. // Detect show/hide animations
  12946. for ( prop in props ) {
  12947. value = props[ prop ];
  12948. if ( rfxtypes.test( value ) ) {
  12949. delete props[ prop ];
  12950. toggle = toggle || value === "toggle";
  12951. if ( value === ( hidden ? "hide" : "show" ) ) {
  12952. // Pretend to be hidden if this is a "show" and
  12953. // there is still data from a stopped show/hide
  12954. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12955. hidden = true;
  12956. // Ignore all other no-op show/hide data
  12957. } else {
  12958. continue;
  12959. }
  12960. }
  12961. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12962. }
  12963. }
  12964. // Bail out if this is a no-op like .hide().hide()
  12965. propTween = !jQuery.isEmptyObject( props );
  12966. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12967. return;
  12968. }
  12969. // Restrict "overflow" and "display" styles during box animations
  12970. if ( isBox && elem.nodeType === 1 ) {
  12971. // Support: IE <=9 - 11, Edge 12 - 15
  12972. // Record all 3 overflow attributes because IE does not infer the shorthand
  12973. // from identically-valued overflowX and overflowY and Edge just mirrors
  12974. // the overflowX value there.
  12975. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12976. // Identify a display type, preferring old show/hide data over the CSS cascade
  12977. restoreDisplay = dataShow && dataShow.display;
  12978. if ( restoreDisplay == null ) {
  12979. restoreDisplay = dataPriv.get( elem, "display" );
  12980. }
  12981. display = jQuery.css( elem, "display" );
  12982. if ( display === "none" ) {
  12983. if ( restoreDisplay ) {
  12984. display = restoreDisplay;
  12985. } else {
  12986. // Get nonempty value(s) by temporarily forcing visibility
  12987. showHide( [ elem ], true );
  12988. restoreDisplay = elem.style.display || restoreDisplay;
  12989. display = jQuery.css( elem, "display" );
  12990. showHide( [ elem ] );
  12991. }
  12992. }
  12993. // Animate inline elements as inline-block
  12994. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12995. if ( jQuery.css( elem, "float" ) === "none" ) {
  12996. // Restore the original display value at the end of pure show/hide animations
  12997. if ( !propTween ) {
  12998. anim.done( function() {
  12999. style.display = restoreDisplay;
  13000. } );
  13001. if ( restoreDisplay == null ) {
  13002. display = style.display;
  13003. restoreDisplay = display === "none" ? "" : display;
  13004. }
  13005. }
  13006. style.display = "inline-block";
  13007. }
  13008. }
  13009. }
  13010. if ( opts.overflow ) {
  13011. style.overflow = "hidden";
  13012. anim.always( function() {
  13013. style.overflow = opts.overflow[ 0 ];
  13014. style.overflowX = opts.overflow[ 1 ];
  13015. style.overflowY = opts.overflow[ 2 ];
  13016. } );
  13017. }
  13018. // Implement show/hide animations
  13019. propTween = false;
  13020. for ( prop in orig ) {
  13021. // General show/hide setup for this element animation
  13022. if ( !propTween ) {
  13023. if ( dataShow ) {
  13024. if ( "hidden" in dataShow ) {
  13025. hidden = dataShow.hidden;
  13026. }
  13027. } else {
  13028. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13029. }
  13030. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13031. if ( toggle ) {
  13032. dataShow.hidden = !hidden;
  13033. }
  13034. // Show elements before animating them
  13035. if ( hidden ) {
  13036. showHide( [ elem ], true );
  13037. }
  13038. /* eslint-disable no-loop-func */
  13039. anim.done( function() {
  13040. /* eslint-enable no-loop-func */
  13041. // The final step of a "hide" animation is actually hiding the element
  13042. if ( !hidden ) {
  13043. showHide( [ elem ] );
  13044. }
  13045. dataPriv.remove( elem, "fxshow" );
  13046. for ( prop in orig ) {
  13047. jQuery.style( elem, prop, orig[ prop ] );
  13048. }
  13049. } );
  13050. }
  13051. // Per-property setup
  13052. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13053. if ( !( prop in dataShow ) ) {
  13054. dataShow[ prop ] = propTween.start;
  13055. if ( hidden ) {
  13056. propTween.end = propTween.start;
  13057. propTween.start = 0;
  13058. }
  13059. }
  13060. }
  13061. }
  13062. function propFilter( props, specialEasing ) {
  13063. var index, name, easing, value, hooks;
  13064. // camelCase, specialEasing and expand cssHook pass
  13065. for ( index in props ) {
  13066. name = camelCase( index );
  13067. easing = specialEasing[ name ];
  13068. value = props[ index ];
  13069. if ( Array.isArray( value ) ) {
  13070. easing = value[ 1 ];
  13071. value = props[ index ] = value[ 0 ];
  13072. }
  13073. if ( index !== name ) {
  13074. props[ name ] = value;
  13075. delete props[ index ];
  13076. }
  13077. hooks = jQuery.cssHooks[ name ];
  13078. if ( hooks && "expand" in hooks ) {
  13079. value = hooks.expand( value );
  13080. delete props[ name ];
  13081. // Not quite $.extend, this won't overwrite existing keys.
  13082. // Reusing 'index' because we have the correct "name"
  13083. for ( index in value ) {
  13084. if ( !( index in props ) ) {
  13085. props[ index ] = value[ index ];
  13086. specialEasing[ index ] = easing;
  13087. }
  13088. }
  13089. } else {
  13090. specialEasing[ name ] = easing;
  13091. }
  13092. }
  13093. }
  13094. function Animation( elem, properties, options ) {
  13095. var result,
  13096. stopped,
  13097. index = 0,
  13098. length = Animation.prefilters.length,
  13099. deferred = jQuery.Deferred().always( function() {
  13100. // Don't match elem in the :animated selector
  13101. delete tick.elem;
  13102. } ),
  13103. tick = function() {
  13104. if ( stopped ) {
  13105. return false;
  13106. }
  13107. var currentTime = fxNow || createFxNow(),
  13108. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13109. // Support: Android 2.3 only
  13110. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13111. temp = remaining / animation.duration || 0,
  13112. percent = 1 - temp,
  13113. index = 0,
  13114. length = animation.tweens.length;
  13115. for ( ; index < length; index++ ) {
  13116. animation.tweens[ index ].run( percent );
  13117. }
  13118. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13119. // If there's more to do, yield
  13120. if ( percent < 1 && length ) {
  13121. return remaining;
  13122. }
  13123. // If this was an empty animation, synthesize a final progress notification
  13124. if ( !length ) {
  13125. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13126. }
  13127. // Resolve the animation and report its conclusion
  13128. deferred.resolveWith( elem, [ animation ] );
  13129. return false;
  13130. },
  13131. animation = deferred.promise( {
  13132. elem: elem,
  13133. props: jQuery.extend( {}, properties ),
  13134. opts: jQuery.extend( true, {
  13135. specialEasing: {},
  13136. easing: jQuery.easing._default
  13137. }, options ),
  13138. originalProperties: properties,
  13139. originalOptions: options,
  13140. startTime: fxNow || createFxNow(),
  13141. duration: options.duration,
  13142. tweens: [],
  13143. createTween: function( prop, end ) {
  13144. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13145. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13146. animation.tweens.push( tween );
  13147. return tween;
  13148. },
  13149. stop: function( gotoEnd ) {
  13150. var index = 0,
  13151. // If we are going to the end, we want to run all the tweens
  13152. // otherwise we skip this part
  13153. length = gotoEnd ? animation.tweens.length : 0;
  13154. if ( stopped ) {
  13155. return this;
  13156. }
  13157. stopped = true;
  13158. for ( ; index < length; index++ ) {
  13159. animation.tweens[ index ].run( 1 );
  13160. }
  13161. // Resolve when we played the last frame; otherwise, reject
  13162. if ( gotoEnd ) {
  13163. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13164. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13165. } else {
  13166. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13167. }
  13168. return this;
  13169. }
  13170. } ),
  13171. props = animation.props;
  13172. propFilter( props, animation.opts.specialEasing );
  13173. for ( ; index < length; index++ ) {
  13174. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13175. if ( result ) {
  13176. if ( isFunction( result.stop ) ) {
  13177. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13178. result.stop.bind( result );
  13179. }
  13180. return result;
  13181. }
  13182. }
  13183. jQuery.map( props, createTween, animation );
  13184. if ( isFunction( animation.opts.start ) ) {
  13185. animation.opts.start.call( elem, animation );
  13186. }
  13187. // Attach callbacks from options
  13188. animation
  13189. .progress( animation.opts.progress )
  13190. .done( animation.opts.done, animation.opts.complete )
  13191. .fail( animation.opts.fail )
  13192. .always( animation.opts.always );
  13193. jQuery.fx.timer(
  13194. jQuery.extend( tick, {
  13195. elem: elem,
  13196. anim: animation,
  13197. queue: animation.opts.queue
  13198. } )
  13199. );
  13200. return animation;
  13201. }
  13202. jQuery.Animation = jQuery.extend( Animation, {
  13203. tweeners: {
  13204. "*": [ function( prop, value ) {
  13205. var tween = this.createTween( prop, value );
  13206. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13207. return tween;
  13208. } ]
  13209. },
  13210. tweener: function( props, callback ) {
  13211. if ( isFunction( props ) ) {
  13212. callback = props;
  13213. props = [ "*" ];
  13214. } else {
  13215. props = props.match( rnothtmlwhite );
  13216. }
  13217. var prop,
  13218. index = 0,
  13219. length = props.length;
  13220. for ( ; index < length; index++ ) {
  13221. prop = props[ index ];
  13222. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13223. Animation.tweeners[ prop ].unshift( callback );
  13224. }
  13225. },
  13226. prefilters: [ defaultPrefilter ],
  13227. prefilter: function( callback, prepend ) {
  13228. if ( prepend ) {
  13229. Animation.prefilters.unshift( callback );
  13230. } else {
  13231. Animation.prefilters.push( callback );
  13232. }
  13233. }
  13234. } );
  13235. jQuery.speed = function( speed, easing, fn ) {
  13236. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13237. complete: fn || !fn && easing ||
  13238. isFunction( speed ) && speed,
  13239. duration: speed,
  13240. easing: fn && easing || easing && !isFunction( easing ) && easing
  13241. };
  13242. // Go to the end state if fx are off
  13243. if ( jQuery.fx.off ) {
  13244. opt.duration = 0;
  13245. } else {
  13246. if ( typeof opt.duration !== "number" ) {
  13247. if ( opt.duration in jQuery.fx.speeds ) {
  13248. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13249. } else {
  13250. opt.duration = jQuery.fx.speeds._default;
  13251. }
  13252. }
  13253. }
  13254. // Normalize opt.queue - true/undefined/null -> "fx"
  13255. if ( opt.queue == null || opt.queue === true ) {
  13256. opt.queue = "fx";
  13257. }
  13258. // Queueing
  13259. opt.old = opt.complete;
  13260. opt.complete = function() {
  13261. if ( isFunction( opt.old ) ) {
  13262. opt.old.call( this );
  13263. }
  13264. if ( opt.queue ) {
  13265. jQuery.dequeue( this, opt.queue );
  13266. }
  13267. };
  13268. return opt;
  13269. };
  13270. jQuery.fn.extend( {
  13271. fadeTo: function( speed, to, easing, callback ) {
  13272. // Show any hidden elements after setting opacity to 0
  13273. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13274. // Animate to the value specified
  13275. .end().animate( { opacity: to }, speed, easing, callback );
  13276. },
  13277. animate: function( prop, speed, easing, callback ) {
  13278. var empty = jQuery.isEmptyObject( prop ),
  13279. optall = jQuery.speed( speed, easing, callback ),
  13280. doAnimation = function() {
  13281. // Operate on a copy of prop so per-property easing won't be lost
  13282. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13283. // Empty animations, or finishing resolves immediately
  13284. if ( empty || dataPriv.get( this, "finish" ) ) {
  13285. anim.stop( true );
  13286. }
  13287. };
  13288. doAnimation.finish = doAnimation;
  13289. return empty || optall.queue === false ?
  13290. this.each( doAnimation ) :
  13291. this.queue( optall.queue, doAnimation );
  13292. },
  13293. stop: function( type, clearQueue, gotoEnd ) {
  13294. var stopQueue = function( hooks ) {
  13295. var stop = hooks.stop;
  13296. delete hooks.stop;
  13297. stop( gotoEnd );
  13298. };
  13299. if ( typeof type !== "string" ) {
  13300. gotoEnd = clearQueue;
  13301. clearQueue = type;
  13302. type = undefined;
  13303. }
  13304. if ( clearQueue && type !== false ) {
  13305. this.queue( type || "fx", [] );
  13306. }
  13307. return this.each( function() {
  13308. var dequeue = true,
  13309. index = type != null && type + "queueHooks",
  13310. timers = jQuery.timers,
  13311. data = dataPriv.get( this );
  13312. if ( index ) {
  13313. if ( data[ index ] && data[ index ].stop ) {
  13314. stopQueue( data[ index ] );
  13315. }
  13316. } else {
  13317. for ( index in data ) {
  13318. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13319. stopQueue( data[ index ] );
  13320. }
  13321. }
  13322. }
  13323. for ( index = timers.length; index--; ) {
  13324. if ( timers[ index ].elem === this &&
  13325. ( type == null || timers[ index ].queue === type ) ) {
  13326. timers[ index ].anim.stop( gotoEnd );
  13327. dequeue = false;
  13328. timers.splice( index, 1 );
  13329. }
  13330. }
  13331. // Start the next in the queue if the last step wasn't forced.
  13332. // Timers currently will call their complete callbacks, which
  13333. // will dequeue but only if they were gotoEnd.
  13334. if ( dequeue || !gotoEnd ) {
  13335. jQuery.dequeue( this, type );
  13336. }
  13337. } );
  13338. },
  13339. finish: function( type ) {
  13340. if ( type !== false ) {
  13341. type = type || "fx";
  13342. }
  13343. return this.each( function() {
  13344. var index,
  13345. data = dataPriv.get( this ),
  13346. queue = data[ type + "queue" ],
  13347. hooks = data[ type + "queueHooks" ],
  13348. timers = jQuery.timers,
  13349. length = queue ? queue.length : 0;
  13350. // Enable finishing flag on private data
  13351. data.finish = true;
  13352. // Empty the queue first
  13353. jQuery.queue( this, type, [] );
  13354. if ( hooks && hooks.stop ) {
  13355. hooks.stop.call( this, true );
  13356. }
  13357. // Look for any active animations, and finish them
  13358. for ( index = timers.length; index--; ) {
  13359. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13360. timers[ index ].anim.stop( true );
  13361. timers.splice( index, 1 );
  13362. }
  13363. }
  13364. // Look for any animations in the old queue and finish them
  13365. for ( index = 0; index < length; index++ ) {
  13366. if ( queue[ index ] && queue[ index ].finish ) {
  13367. queue[ index ].finish.call( this );
  13368. }
  13369. }
  13370. // Turn off finishing flag
  13371. delete data.finish;
  13372. } );
  13373. }
  13374. } );
  13375. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13376. var cssFn = jQuery.fn[ name ];
  13377. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13378. return speed == null || typeof speed === "boolean" ?
  13379. cssFn.apply( this, arguments ) :
  13380. this.animate( genFx( name, true ), speed, easing, callback );
  13381. };
  13382. } );
  13383. // Generate shortcuts for custom animations
  13384. jQuery.each( {
  13385. slideDown: genFx( "show" ),
  13386. slideUp: genFx( "hide" ),
  13387. slideToggle: genFx( "toggle" ),
  13388. fadeIn: { opacity: "show" },
  13389. fadeOut: { opacity: "hide" },
  13390. fadeToggle: { opacity: "toggle" }
  13391. }, function( name, props ) {
  13392. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13393. return this.animate( props, speed, easing, callback );
  13394. };
  13395. } );
  13396. jQuery.timers = [];
  13397. jQuery.fx.tick = function() {
  13398. var timer,
  13399. i = 0,
  13400. timers = jQuery.timers;
  13401. fxNow = Date.now();
  13402. for ( ; i < timers.length; i++ ) {
  13403. timer = timers[ i ];
  13404. // Run the timer and safely remove it when done (allowing for external removal)
  13405. if ( !timer() && timers[ i ] === timer ) {
  13406. timers.splice( i--, 1 );
  13407. }
  13408. }
  13409. if ( !timers.length ) {
  13410. jQuery.fx.stop();
  13411. }
  13412. fxNow = undefined;
  13413. };
  13414. jQuery.fx.timer = function( timer ) {
  13415. jQuery.timers.push( timer );
  13416. jQuery.fx.start();
  13417. };
  13418. jQuery.fx.interval = 13;
  13419. jQuery.fx.start = function() {
  13420. if ( inProgress ) {
  13421. return;
  13422. }
  13423. inProgress = true;
  13424. schedule();
  13425. };
  13426. jQuery.fx.stop = function() {
  13427. inProgress = null;
  13428. };
  13429. jQuery.fx.speeds = {
  13430. slow: 600,
  13431. fast: 200,
  13432. // Default speed
  13433. _default: 400
  13434. };
  13435. // Based off of the plugin by Clint Helfers, with permission.
  13436. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13437. jQuery.fn.delay = function( time, type ) {
  13438. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13439. type = type || "fx";
  13440. return this.queue( type, function( next, hooks ) {
  13441. var timeout = window.setTimeout( next, time );
  13442. hooks.stop = function() {
  13443. window.clearTimeout( timeout );
  13444. };
  13445. } );
  13446. };
  13447. ( function() {
  13448. var input = document.createElement( "input" ),
  13449. select = document.createElement( "select" ),
  13450. opt = select.appendChild( document.createElement( "option" ) );
  13451. input.type = "checkbox";
  13452. // Support: Android <=4.3 only
  13453. // Default value for a checkbox should be "on"
  13454. support.checkOn = input.value !== "";
  13455. // Support: IE <=11 only
  13456. // Must access selectedIndex to make default options select
  13457. support.optSelected = opt.selected;
  13458. // Support: IE <=11 only
  13459. // An input loses its value after becoming a radio
  13460. input = document.createElement( "input" );
  13461. input.value = "t";
  13462. input.type = "radio";
  13463. support.radioValue = input.value === "t";
  13464. } )();
  13465. var boolHook,
  13466. attrHandle = jQuery.expr.attrHandle;
  13467. jQuery.fn.extend( {
  13468. attr: function( name, value ) {
  13469. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13470. },
  13471. removeAttr: function( name ) {
  13472. return this.each( function() {
  13473. jQuery.removeAttr( this, name );
  13474. } );
  13475. }
  13476. } );
  13477. jQuery.extend( {
  13478. attr: function( elem, name, value ) {
  13479. var ret, hooks,
  13480. nType = elem.nodeType;
  13481. // Don't get/set attributes on text, comment and attribute nodes
  13482. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13483. return;
  13484. }
  13485. // Fallback to prop when attributes are not supported
  13486. if ( typeof elem.getAttribute === "undefined" ) {
  13487. return jQuery.prop( elem, name, value );
  13488. }
  13489. // Attribute hooks are determined by the lowercase version
  13490. // Grab necessary hook if one is defined
  13491. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13492. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13493. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13494. }
  13495. if ( value !== undefined ) {
  13496. if ( value === null ) {
  13497. jQuery.removeAttr( elem, name );
  13498. return;
  13499. }
  13500. if ( hooks && "set" in hooks &&
  13501. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13502. return ret;
  13503. }
  13504. elem.setAttribute( name, value + "" );
  13505. return value;
  13506. }
  13507. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13508. return ret;
  13509. }
  13510. ret = jQuery.find.attr( elem, name );
  13511. // Non-existent attributes return null, we normalize to undefined
  13512. return ret == null ? undefined : ret;
  13513. },
  13514. attrHooks: {
  13515. type: {
  13516. set: function( elem, value ) {
  13517. if ( !support.radioValue && value === "radio" &&
  13518. nodeName( elem, "input" ) ) {
  13519. var val = elem.value;
  13520. elem.setAttribute( "type", value );
  13521. if ( val ) {
  13522. elem.value = val;
  13523. }
  13524. return value;
  13525. }
  13526. }
  13527. }
  13528. },
  13529. removeAttr: function( elem, value ) {
  13530. var name,
  13531. i = 0,
  13532. // Attribute names can contain non-HTML whitespace characters
  13533. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13534. attrNames = value && value.match( rnothtmlwhite );
  13535. if ( attrNames && elem.nodeType === 1 ) {
  13536. while ( ( name = attrNames[ i++ ] ) ) {
  13537. elem.removeAttribute( name );
  13538. }
  13539. }
  13540. }
  13541. } );
  13542. // Hooks for boolean attributes
  13543. boolHook = {
  13544. set: function( elem, value, name ) {
  13545. if ( value === false ) {
  13546. // Remove boolean attributes when set to false
  13547. jQuery.removeAttr( elem, name );
  13548. } else {
  13549. elem.setAttribute( name, name );
  13550. }
  13551. return name;
  13552. }
  13553. };
  13554. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13555. var getter = attrHandle[ name ] || jQuery.find.attr;
  13556. attrHandle[ name ] = function( elem, name, isXML ) {
  13557. var ret, handle,
  13558. lowercaseName = name.toLowerCase();
  13559. if ( !isXML ) {
  13560. // Avoid an infinite loop by temporarily removing this function from the getter
  13561. handle = attrHandle[ lowercaseName ];
  13562. attrHandle[ lowercaseName ] = ret;
  13563. ret = getter( elem, name, isXML ) != null ?
  13564. lowercaseName :
  13565. null;
  13566. attrHandle[ lowercaseName ] = handle;
  13567. }
  13568. return ret;
  13569. };
  13570. } );
  13571. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13572. rclickable = /^(?:a|area)$/i;
  13573. jQuery.fn.extend( {
  13574. prop: function( name, value ) {
  13575. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13576. },
  13577. removeProp: function( name ) {
  13578. return this.each( function() {
  13579. delete this[ jQuery.propFix[ name ] || name ];
  13580. } );
  13581. }
  13582. } );
  13583. jQuery.extend( {
  13584. prop: function( elem, name, value ) {
  13585. var ret, hooks,
  13586. nType = elem.nodeType;
  13587. // Don't get/set properties on text, comment and attribute nodes
  13588. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13589. return;
  13590. }
  13591. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13592. // Fix name and attach hooks
  13593. name = jQuery.propFix[ name ] || name;
  13594. hooks = jQuery.propHooks[ name ];
  13595. }
  13596. if ( value !== undefined ) {
  13597. if ( hooks && "set" in hooks &&
  13598. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13599. return ret;
  13600. }
  13601. return ( elem[ name ] = value );
  13602. }
  13603. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13604. return ret;
  13605. }
  13606. return elem[ name ];
  13607. },
  13608. propHooks: {
  13609. tabIndex: {
  13610. get: function( elem ) {
  13611. // Support: IE <=9 - 11 only
  13612. // elem.tabIndex doesn't always return the
  13613. // correct value when it hasn't been explicitly set
  13614. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13615. // Use proper attribute retrieval(#12072)
  13616. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13617. if ( tabindex ) {
  13618. return parseInt( tabindex, 10 );
  13619. }
  13620. if (
  13621. rfocusable.test( elem.nodeName ) ||
  13622. rclickable.test( elem.nodeName ) &&
  13623. elem.href
  13624. ) {
  13625. return 0;
  13626. }
  13627. return -1;
  13628. }
  13629. }
  13630. },
  13631. propFix: {
  13632. "for": "htmlFor",
  13633. "class": "className"
  13634. }
  13635. } );
  13636. // Support: IE <=11 only
  13637. // Accessing the selectedIndex property
  13638. // forces the browser to respect setting selected
  13639. // on the option
  13640. // The getter ensures a default option is selected
  13641. // when in an optgroup
  13642. // eslint rule "no-unused-expressions" is disabled for this code
  13643. // since it considers such accessions noop
  13644. if ( !support.optSelected ) {
  13645. jQuery.propHooks.selected = {
  13646. get: function( elem ) {
  13647. /* eslint no-unused-expressions: "off" */
  13648. var parent = elem.parentNode;
  13649. if ( parent && parent.parentNode ) {
  13650. parent.parentNode.selectedIndex;
  13651. }
  13652. return null;
  13653. },
  13654. set: function( elem ) {
  13655. /* eslint no-unused-expressions: "off" */
  13656. var parent = elem.parentNode;
  13657. if ( parent ) {
  13658. parent.selectedIndex;
  13659. if ( parent.parentNode ) {
  13660. parent.parentNode.selectedIndex;
  13661. }
  13662. }
  13663. }
  13664. };
  13665. }
  13666. jQuery.each( [
  13667. "tabIndex",
  13668. "readOnly",
  13669. "maxLength",
  13670. "cellSpacing",
  13671. "cellPadding",
  13672. "rowSpan",
  13673. "colSpan",
  13674. "useMap",
  13675. "frameBorder",
  13676. "contentEditable"
  13677. ], function() {
  13678. jQuery.propFix[ this.toLowerCase() ] = this;
  13679. } );
  13680. // Strip and collapse whitespace according to HTML spec
  13681. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13682. function stripAndCollapse( value ) {
  13683. var tokens = value.match( rnothtmlwhite ) || [];
  13684. return tokens.join( " " );
  13685. }
  13686. function getClass( elem ) {
  13687. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13688. }
  13689. function classesToArray( value ) {
  13690. if ( Array.isArray( value ) ) {
  13691. return value;
  13692. }
  13693. if ( typeof value === "string" ) {
  13694. return value.match( rnothtmlwhite ) || [];
  13695. }
  13696. return [];
  13697. }
  13698. jQuery.fn.extend( {
  13699. addClass: function( value ) {
  13700. var classes, elem, cur, curValue, clazz, j, finalValue,
  13701. i = 0;
  13702. if ( isFunction( value ) ) {
  13703. return this.each( function( j ) {
  13704. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13705. } );
  13706. }
  13707. classes = classesToArray( value );
  13708. if ( classes.length ) {
  13709. while ( ( elem = this[ i++ ] ) ) {
  13710. curValue = getClass( elem );
  13711. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13712. if ( cur ) {
  13713. j = 0;
  13714. while ( ( clazz = classes[ j++ ] ) ) {
  13715. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13716. cur += clazz + " ";
  13717. }
  13718. }
  13719. // Only assign if different to avoid unneeded rendering.
  13720. finalValue = stripAndCollapse( cur );
  13721. if ( curValue !== finalValue ) {
  13722. elem.setAttribute( "class", finalValue );
  13723. }
  13724. }
  13725. }
  13726. }
  13727. return this;
  13728. },
  13729. removeClass: function( value ) {
  13730. var classes, elem, cur, curValue, clazz, j, finalValue,
  13731. i = 0;
  13732. if ( isFunction( value ) ) {
  13733. return this.each( function( j ) {
  13734. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13735. } );
  13736. }
  13737. if ( !arguments.length ) {
  13738. return this.attr( "class", "" );
  13739. }
  13740. classes = classesToArray( value );
  13741. if ( classes.length ) {
  13742. while ( ( elem = this[ i++ ] ) ) {
  13743. curValue = getClass( elem );
  13744. // This expression is here for better compressibility (see addClass)
  13745. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13746. if ( cur ) {
  13747. j = 0;
  13748. while ( ( clazz = classes[ j++ ] ) ) {
  13749. // Remove *all* instances
  13750. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13751. cur = cur.replace( " " + clazz + " ", " " );
  13752. }
  13753. }
  13754. // Only assign if different to avoid unneeded rendering.
  13755. finalValue = stripAndCollapse( cur );
  13756. if ( curValue !== finalValue ) {
  13757. elem.setAttribute( "class", finalValue );
  13758. }
  13759. }
  13760. }
  13761. }
  13762. return this;
  13763. },
  13764. toggleClass: function( value, stateVal ) {
  13765. var type = typeof value,
  13766. isValidValue = type === "string" || Array.isArray( value );
  13767. if ( typeof stateVal === "boolean" && isValidValue ) {
  13768. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13769. }
  13770. if ( isFunction( value ) ) {
  13771. return this.each( function( i ) {
  13772. jQuery( this ).toggleClass(
  13773. value.call( this, i, getClass( this ), stateVal ),
  13774. stateVal
  13775. );
  13776. } );
  13777. }
  13778. return this.each( function() {
  13779. var className, i, self, classNames;
  13780. if ( isValidValue ) {
  13781. // Toggle individual class names
  13782. i = 0;
  13783. self = jQuery( this );
  13784. classNames = classesToArray( value );
  13785. while ( ( className = classNames[ i++ ] ) ) {
  13786. // Check each className given, space separated list
  13787. if ( self.hasClass( className ) ) {
  13788. self.removeClass( className );
  13789. } else {
  13790. self.addClass( className );
  13791. }
  13792. }
  13793. // Toggle whole class name
  13794. } else if ( value === undefined || type === "boolean" ) {
  13795. className = getClass( this );
  13796. if ( className ) {
  13797. // Store className if set
  13798. dataPriv.set( this, "__className__", className );
  13799. }
  13800. // If the element has a class name or if we're passed `false`,
  13801. // then remove the whole classname (if there was one, the above saved it).
  13802. // Otherwise bring back whatever was previously saved (if anything),
  13803. // falling back to the empty string if nothing was stored.
  13804. if ( this.setAttribute ) {
  13805. this.setAttribute( "class",
  13806. className || value === false ?
  13807. "" :
  13808. dataPriv.get( this, "__className__" ) || ""
  13809. );
  13810. }
  13811. }
  13812. } );
  13813. },
  13814. hasClass: function( selector ) {
  13815. var className, elem,
  13816. i = 0;
  13817. className = " " + selector + " ";
  13818. while ( ( elem = this[ i++ ] ) ) {
  13819. if ( elem.nodeType === 1 &&
  13820. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13821. return true;
  13822. }
  13823. }
  13824. return false;
  13825. }
  13826. } );
  13827. var rreturn = /\r/g;
  13828. jQuery.fn.extend( {
  13829. val: function( value ) {
  13830. var hooks, ret, valueIsFunction,
  13831. elem = this[ 0 ];
  13832. if ( !arguments.length ) {
  13833. if ( elem ) {
  13834. hooks = jQuery.valHooks[ elem.type ] ||
  13835. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13836. if ( hooks &&
  13837. "get" in hooks &&
  13838. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13839. ) {
  13840. return ret;
  13841. }
  13842. ret = elem.value;
  13843. // Handle most common string cases
  13844. if ( typeof ret === "string" ) {
  13845. return ret.replace( rreturn, "" );
  13846. }
  13847. // Handle cases where value is null/undef or number
  13848. return ret == null ? "" : ret;
  13849. }
  13850. return;
  13851. }
  13852. valueIsFunction = isFunction( value );
  13853. return this.each( function( i ) {
  13854. var val;
  13855. if ( this.nodeType !== 1 ) {
  13856. return;
  13857. }
  13858. if ( valueIsFunction ) {
  13859. val = value.call( this, i, jQuery( this ).val() );
  13860. } else {
  13861. val = value;
  13862. }
  13863. // Treat null/undefined as ""; convert numbers to string
  13864. if ( val == null ) {
  13865. val = "";
  13866. } else if ( typeof val === "number" ) {
  13867. val += "";
  13868. } else if ( Array.isArray( val ) ) {
  13869. val = jQuery.map( val, function( value ) {
  13870. return value == null ? "" : value + "";
  13871. } );
  13872. }
  13873. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13874. // If set returns undefined, fall back to normal setting
  13875. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13876. this.value = val;
  13877. }
  13878. } );
  13879. }
  13880. } );
  13881. jQuery.extend( {
  13882. valHooks: {
  13883. option: {
  13884. get: function( elem ) {
  13885. var val = jQuery.find.attr( elem, "value" );
  13886. return val != null ?
  13887. val :
  13888. // Support: IE <=10 - 11 only
  13889. // option.text throws exceptions (#14686, #14858)
  13890. // Strip and collapse whitespace
  13891. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13892. stripAndCollapse( jQuery.text( elem ) );
  13893. }
  13894. },
  13895. select: {
  13896. get: function( elem ) {
  13897. var value, option, i,
  13898. options = elem.options,
  13899. index = elem.selectedIndex,
  13900. one = elem.type === "select-one",
  13901. values = one ? null : [],
  13902. max = one ? index + 1 : options.length;
  13903. if ( index < 0 ) {
  13904. i = max;
  13905. } else {
  13906. i = one ? index : 0;
  13907. }
  13908. // Loop through all the selected options
  13909. for ( ; i < max; i++ ) {
  13910. option = options[ i ];
  13911. // Support: IE <=9 only
  13912. // IE8-9 doesn't update selected after form reset (#2551)
  13913. if ( ( option.selected || i === index ) &&
  13914. // Don't return options that are disabled or in a disabled optgroup
  13915. !option.disabled &&
  13916. ( !option.parentNode.disabled ||
  13917. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13918. // Get the specific value for the option
  13919. value = jQuery( option ).val();
  13920. // We don't need an array for one selects
  13921. if ( one ) {
  13922. return value;
  13923. }
  13924. // Multi-Selects return an array
  13925. values.push( value );
  13926. }
  13927. }
  13928. return values;
  13929. },
  13930. set: function( elem, value ) {
  13931. var optionSet, option,
  13932. options = elem.options,
  13933. values = jQuery.makeArray( value ),
  13934. i = options.length;
  13935. while ( i-- ) {
  13936. option = options[ i ];
  13937. /* eslint-disable no-cond-assign */
  13938. if ( option.selected =
  13939. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13940. ) {
  13941. optionSet = true;
  13942. }
  13943. /* eslint-enable no-cond-assign */
  13944. }
  13945. // Force browsers to behave consistently when non-matching value is set
  13946. if ( !optionSet ) {
  13947. elem.selectedIndex = -1;
  13948. }
  13949. return values;
  13950. }
  13951. }
  13952. }
  13953. } );
  13954. // Radios and checkboxes getter/setter
  13955. jQuery.each( [ "radio", "checkbox" ], function() {
  13956. jQuery.valHooks[ this ] = {
  13957. set: function( elem, value ) {
  13958. if ( Array.isArray( value ) ) {
  13959. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13960. }
  13961. }
  13962. };
  13963. if ( !support.checkOn ) {
  13964. jQuery.valHooks[ this ].get = function( elem ) {
  13965. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13966. };
  13967. }
  13968. } );
  13969. // Return jQuery for attributes-only inclusion
  13970. support.focusin = "onfocusin" in window;
  13971. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13972. stopPropagationCallback = function( e ) {
  13973. e.stopPropagation();
  13974. };
  13975. jQuery.extend( jQuery.event, {
  13976. trigger: function( event, data, elem, onlyHandlers ) {
  13977. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13978. eventPath = [ elem || document ],
  13979. type = hasOwn.call( event, "type" ) ? event.type : event,
  13980. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13981. cur = lastElement = tmp = elem = elem || document;
  13982. // Don't do events on text and comment nodes
  13983. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13984. return;
  13985. }
  13986. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13987. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13988. return;
  13989. }
  13990. if ( type.indexOf( "." ) > -1 ) {
  13991. // Namespaced trigger; create a regexp to match event type in handle()
  13992. namespaces = type.split( "." );
  13993. type = namespaces.shift();
  13994. namespaces.sort();
  13995. }
  13996. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13997. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13998. event = event[ jQuery.expando ] ?
  13999. event :
  14000. new jQuery.Event( type, typeof event === "object" && event );
  14001. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14002. event.isTrigger = onlyHandlers ? 2 : 3;
  14003. event.namespace = namespaces.join( "." );
  14004. event.rnamespace = event.namespace ?
  14005. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14006. null;
  14007. // Clean up the event in case it is being reused
  14008. event.result = undefined;
  14009. if ( !event.target ) {
  14010. event.target = elem;
  14011. }
  14012. // Clone any incoming data and prepend the event, creating the handler arg list
  14013. data = data == null ?
  14014. [ event ] :
  14015. jQuery.makeArray( data, [ event ] );
  14016. // Allow special events to draw outside the lines
  14017. special = jQuery.event.special[ type ] || {};
  14018. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14019. return;
  14020. }
  14021. // Determine event propagation path in advance, per W3C events spec (#9951)
  14022. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14023. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14024. bubbleType = special.delegateType || type;
  14025. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14026. cur = cur.parentNode;
  14027. }
  14028. for ( ; cur; cur = cur.parentNode ) {
  14029. eventPath.push( cur );
  14030. tmp = cur;
  14031. }
  14032. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14033. if ( tmp === ( elem.ownerDocument || document ) ) {
  14034. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14035. }
  14036. }
  14037. // Fire handlers on the event path
  14038. i = 0;
  14039. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14040. lastElement = cur;
  14041. event.type = i > 1 ?
  14042. bubbleType :
  14043. special.bindType || type;
  14044. // jQuery handler
  14045. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14046. dataPriv.get( cur, "handle" );
  14047. if ( handle ) {
  14048. handle.apply( cur, data );
  14049. }
  14050. // Native handler
  14051. handle = ontype && cur[ ontype ];
  14052. if ( handle && handle.apply && acceptData( cur ) ) {
  14053. event.result = handle.apply( cur, data );
  14054. if ( event.result === false ) {
  14055. event.preventDefault();
  14056. }
  14057. }
  14058. }
  14059. event.type = type;
  14060. // If nobody prevented the default action, do it now
  14061. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14062. if ( ( !special._default ||
  14063. special._default.apply( eventPath.pop(), data ) === false ) &&
  14064. acceptData( elem ) ) {
  14065. // Call a native DOM method on the target with the same name as the event.
  14066. // Don't do default actions on window, that's where global variables be (#6170)
  14067. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14068. // Don't re-trigger an onFOO event when we call its FOO() method
  14069. tmp = elem[ ontype ];
  14070. if ( tmp ) {
  14071. elem[ ontype ] = null;
  14072. }
  14073. // Prevent re-triggering of the same event, since we already bubbled it above
  14074. jQuery.event.triggered = type;
  14075. if ( event.isPropagationStopped() ) {
  14076. lastElement.addEventListener( type, stopPropagationCallback );
  14077. }
  14078. elem[ type ]();
  14079. if ( event.isPropagationStopped() ) {
  14080. lastElement.removeEventListener( type, stopPropagationCallback );
  14081. }
  14082. jQuery.event.triggered = undefined;
  14083. if ( tmp ) {
  14084. elem[ ontype ] = tmp;
  14085. }
  14086. }
  14087. }
  14088. }
  14089. return event.result;
  14090. },
  14091. // Piggyback on a donor event to simulate a different one
  14092. // Used only for `focus(in | out)` events
  14093. simulate: function( type, elem, event ) {
  14094. var e = jQuery.extend(
  14095. new jQuery.Event(),
  14096. event,
  14097. {
  14098. type: type,
  14099. isSimulated: true
  14100. }
  14101. );
  14102. jQuery.event.trigger( e, null, elem );
  14103. }
  14104. } );
  14105. jQuery.fn.extend( {
  14106. trigger: function( type, data ) {
  14107. return this.each( function() {
  14108. jQuery.event.trigger( type, data, this );
  14109. } );
  14110. },
  14111. triggerHandler: function( type, data ) {
  14112. var elem = this[ 0 ];
  14113. if ( elem ) {
  14114. return jQuery.event.trigger( type, data, elem, true );
  14115. }
  14116. }
  14117. } );
  14118. // Support: Firefox <=44
  14119. // Firefox doesn't have focus(in | out) events
  14120. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14121. //
  14122. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14123. // focus(in | out) events fire after focus & blur events,
  14124. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14125. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14126. if ( !support.focusin ) {
  14127. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14128. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14129. var handler = function( event ) {
  14130. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14131. };
  14132. jQuery.event.special[ fix ] = {
  14133. setup: function() {
  14134. var doc = this.ownerDocument || this,
  14135. attaches = dataPriv.access( doc, fix );
  14136. if ( !attaches ) {
  14137. doc.addEventListener( orig, handler, true );
  14138. }
  14139. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14140. },
  14141. teardown: function() {
  14142. var doc = this.ownerDocument || this,
  14143. attaches = dataPriv.access( doc, fix ) - 1;
  14144. if ( !attaches ) {
  14145. doc.removeEventListener( orig, handler, true );
  14146. dataPriv.remove( doc, fix );
  14147. } else {
  14148. dataPriv.access( doc, fix, attaches );
  14149. }
  14150. }
  14151. };
  14152. } );
  14153. }
  14154. var location = window.location;
  14155. var nonce = Date.now();
  14156. var rquery = ( /\?/ );
  14157. // Cross-browser xml parsing
  14158. jQuery.parseXML = function( data ) {
  14159. var xml;
  14160. if ( !data || typeof data !== "string" ) {
  14161. return null;
  14162. }
  14163. // Support: IE 9 - 11 only
  14164. // IE throws on parseFromString with invalid input.
  14165. try {
  14166. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14167. } catch ( e ) {
  14168. xml = undefined;
  14169. }
  14170. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14171. jQuery.error( "Invalid XML: " + data );
  14172. }
  14173. return xml;
  14174. };
  14175. var
  14176. rbracket = /\[\]$/,
  14177. rCRLF = /\r?\n/g,
  14178. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14179. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14180. function buildParams( prefix, obj, traditional, add ) {
  14181. var name;
  14182. if ( Array.isArray( obj ) ) {
  14183. // Serialize array item.
  14184. jQuery.each( obj, function( i, v ) {
  14185. if ( traditional || rbracket.test( prefix ) ) {
  14186. // Treat each array item as a scalar.
  14187. add( prefix, v );
  14188. } else {
  14189. // Item is non-scalar (array or object), encode its numeric index.
  14190. buildParams(
  14191. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14192. v,
  14193. traditional,
  14194. add
  14195. );
  14196. }
  14197. } );
  14198. } else if ( !traditional && toType( obj ) === "object" ) {
  14199. // Serialize object item.
  14200. for ( name in obj ) {
  14201. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14202. }
  14203. } else {
  14204. // Serialize scalar item.
  14205. add( prefix, obj );
  14206. }
  14207. }
  14208. // Serialize an array of form elements or a set of
  14209. // key/values into a query string
  14210. jQuery.param = function( a, traditional ) {
  14211. var prefix,
  14212. s = [],
  14213. add = function( key, valueOrFunction ) {
  14214. // If value is a function, invoke it and use its return value
  14215. var value = isFunction( valueOrFunction ) ?
  14216. valueOrFunction() :
  14217. valueOrFunction;
  14218. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14219. encodeURIComponent( value == null ? "" : value );
  14220. };
  14221. if ( a == null ) {
  14222. return "";
  14223. }
  14224. // If an array was passed in, assume that it is an array of form elements.
  14225. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14226. // Serialize the form elements
  14227. jQuery.each( a, function() {
  14228. add( this.name, this.value );
  14229. } );
  14230. } else {
  14231. // If traditional, encode the "old" way (the way 1.3.2 or older
  14232. // did it), otherwise encode params recursively.
  14233. for ( prefix in a ) {
  14234. buildParams( prefix, a[ prefix ], traditional, add );
  14235. }
  14236. }
  14237. // Return the resulting serialization
  14238. return s.join( "&" );
  14239. };
  14240. jQuery.fn.extend( {
  14241. serialize: function() {
  14242. return jQuery.param( this.serializeArray() );
  14243. },
  14244. serializeArray: function() {
  14245. return this.map( function() {
  14246. // Can add propHook for "elements" to filter or add form elements
  14247. var elements = jQuery.prop( this, "elements" );
  14248. return elements ? jQuery.makeArray( elements ) : this;
  14249. } )
  14250. .filter( function() {
  14251. var type = this.type;
  14252. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14253. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14254. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14255. ( this.checked || !rcheckableType.test( type ) );
  14256. } )
  14257. .map( function( i, elem ) {
  14258. var val = jQuery( this ).val();
  14259. if ( val == null ) {
  14260. return null;
  14261. }
  14262. if ( Array.isArray( val ) ) {
  14263. return jQuery.map( val, function( val ) {
  14264. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14265. } );
  14266. }
  14267. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14268. } ).get();
  14269. }
  14270. } );
  14271. var
  14272. r20 = /%20/g,
  14273. rhash = /#.*$/,
  14274. rantiCache = /([?&])_=[^&]*/,
  14275. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14276. // #7653, #8125, #8152: local protocol detection
  14277. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14278. rnoContent = /^(?:GET|HEAD)$/,
  14279. rprotocol = /^\/\//,
  14280. /* Prefilters
  14281. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14282. * 2) These are called:
  14283. * - BEFORE asking for a transport
  14284. * - AFTER param serialization (s.data is a string if s.processData is true)
  14285. * 3) key is the dataType
  14286. * 4) the catchall symbol "*" can be used
  14287. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14288. */
  14289. prefilters = {},
  14290. /* Transports bindings
  14291. * 1) key is the dataType
  14292. * 2) the catchall symbol "*" can be used
  14293. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14294. */
  14295. transports = {},
  14296. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14297. allTypes = "*/".concat( "*" ),
  14298. // Anchor tag for parsing the document origin
  14299. originAnchor = document.createElement( "a" );
  14300. originAnchor.href = location.href;
  14301. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14302. function addToPrefiltersOrTransports( structure ) {
  14303. // dataTypeExpression is optional and defaults to "*"
  14304. return function( dataTypeExpression, func ) {
  14305. if ( typeof dataTypeExpression !== "string" ) {
  14306. func = dataTypeExpression;
  14307. dataTypeExpression = "*";
  14308. }
  14309. var dataType,
  14310. i = 0,
  14311. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14312. if ( isFunction( func ) ) {
  14313. // For each dataType in the dataTypeExpression
  14314. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14315. // Prepend if requested
  14316. if ( dataType[ 0 ] === "+" ) {
  14317. dataType = dataType.slice( 1 ) || "*";
  14318. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14319. // Otherwise append
  14320. } else {
  14321. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14322. }
  14323. }
  14324. }
  14325. };
  14326. }
  14327. // Base inspection function for prefilters and transports
  14328. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14329. var inspected = {},
  14330. seekingTransport = ( structure === transports );
  14331. function inspect( dataType ) {
  14332. var selected;
  14333. inspected[ dataType ] = true;
  14334. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14335. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14336. if ( typeof dataTypeOrTransport === "string" &&
  14337. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14338. options.dataTypes.unshift( dataTypeOrTransport );
  14339. inspect( dataTypeOrTransport );
  14340. return false;
  14341. } else if ( seekingTransport ) {
  14342. return !( selected = dataTypeOrTransport );
  14343. }
  14344. } );
  14345. return selected;
  14346. }
  14347. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14348. }
  14349. // A special extend for ajax options
  14350. // that takes "flat" options (not to be deep extended)
  14351. // Fixes #9887
  14352. function ajaxExtend( target, src ) {
  14353. var key, deep,
  14354. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14355. for ( key in src ) {
  14356. if ( src[ key ] !== undefined ) {
  14357. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14358. }
  14359. }
  14360. if ( deep ) {
  14361. jQuery.extend( true, target, deep );
  14362. }
  14363. return target;
  14364. }
  14365. /* Handles responses to an ajax request:
  14366. * - finds the right dataType (mediates between content-type and expected dataType)
  14367. * - returns the corresponding response
  14368. */
  14369. function ajaxHandleResponses( s, jqXHR, responses ) {
  14370. var ct, type, finalDataType, firstDataType,
  14371. contents = s.contents,
  14372. dataTypes = s.dataTypes;
  14373. // Remove auto dataType and get content-type in the process
  14374. while ( dataTypes[ 0 ] === "*" ) {
  14375. dataTypes.shift();
  14376. if ( ct === undefined ) {
  14377. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14378. }
  14379. }
  14380. // Check if we're dealing with a known content-type
  14381. if ( ct ) {
  14382. for ( type in contents ) {
  14383. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14384. dataTypes.unshift( type );
  14385. break;
  14386. }
  14387. }
  14388. }
  14389. // Check to see if we have a response for the expected dataType
  14390. if ( dataTypes[ 0 ] in responses ) {
  14391. finalDataType = dataTypes[ 0 ];
  14392. } else {
  14393. // Try convertible dataTypes
  14394. for ( type in responses ) {
  14395. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14396. finalDataType = type;
  14397. break;
  14398. }
  14399. if ( !firstDataType ) {
  14400. firstDataType = type;
  14401. }
  14402. }
  14403. // Or just use first one
  14404. finalDataType = finalDataType || firstDataType;
  14405. }
  14406. // If we found a dataType
  14407. // We add the dataType to the list if needed
  14408. // and return the corresponding response
  14409. if ( finalDataType ) {
  14410. if ( finalDataType !== dataTypes[ 0 ] ) {
  14411. dataTypes.unshift( finalDataType );
  14412. }
  14413. return responses[ finalDataType ];
  14414. }
  14415. }
  14416. /* Chain conversions given the request and the original response
  14417. * Also sets the responseXXX fields on the jqXHR instance
  14418. */
  14419. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14420. var conv2, current, conv, tmp, prev,
  14421. converters = {},
  14422. // Work with a copy of dataTypes in case we need to modify it for conversion
  14423. dataTypes = s.dataTypes.slice();
  14424. // Create converters map with lowercased keys
  14425. if ( dataTypes[ 1 ] ) {
  14426. for ( conv in s.converters ) {
  14427. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14428. }
  14429. }
  14430. current = dataTypes.shift();
  14431. // Convert to each sequential dataType
  14432. while ( current ) {
  14433. if ( s.responseFields[ current ] ) {
  14434. jqXHR[ s.responseFields[ current ] ] = response;
  14435. }
  14436. // Apply the dataFilter if provided
  14437. if ( !prev && isSuccess && s.dataFilter ) {
  14438. response = s.dataFilter( response, s.dataType );
  14439. }
  14440. prev = current;
  14441. current = dataTypes.shift();
  14442. if ( current ) {
  14443. // There's only work to do if current dataType is non-auto
  14444. if ( current === "*" ) {
  14445. current = prev;
  14446. // Convert response if prev dataType is non-auto and differs from current
  14447. } else if ( prev !== "*" && prev !== current ) {
  14448. // Seek a direct converter
  14449. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14450. // If none found, seek a pair
  14451. if ( !conv ) {
  14452. for ( conv2 in converters ) {
  14453. // If conv2 outputs current
  14454. tmp = conv2.split( " " );
  14455. if ( tmp[ 1 ] === current ) {
  14456. // If prev can be converted to accepted input
  14457. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14458. converters[ "* " + tmp[ 0 ] ];
  14459. if ( conv ) {
  14460. // Condense equivalence converters
  14461. if ( conv === true ) {
  14462. conv = converters[ conv2 ];
  14463. // Otherwise, insert the intermediate dataType
  14464. } else if ( converters[ conv2 ] !== true ) {
  14465. current = tmp[ 0 ];
  14466. dataTypes.unshift( tmp[ 1 ] );
  14467. }
  14468. break;
  14469. }
  14470. }
  14471. }
  14472. }
  14473. // Apply converter (if not an equivalence)
  14474. if ( conv !== true ) {
  14475. // Unless errors are allowed to bubble, catch and return them
  14476. if ( conv && s.throws ) {
  14477. response = conv( response );
  14478. } else {
  14479. try {
  14480. response = conv( response );
  14481. } catch ( e ) {
  14482. return {
  14483. state: "parsererror",
  14484. error: conv ? e : "No conversion from " + prev + " to " + current
  14485. };
  14486. }
  14487. }
  14488. }
  14489. }
  14490. }
  14491. }
  14492. return { state: "success", data: response };
  14493. }
  14494. jQuery.extend( {
  14495. // Counter for holding the number of active queries
  14496. active: 0,
  14497. // Last-Modified header cache for next request
  14498. lastModified: {},
  14499. etag: {},
  14500. ajaxSettings: {
  14501. url: location.href,
  14502. type: "GET",
  14503. isLocal: rlocalProtocol.test( location.protocol ),
  14504. global: true,
  14505. processData: true,
  14506. async: true,
  14507. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14508. /*
  14509. timeout: 0,
  14510. data: null,
  14511. dataType: null,
  14512. username: null,
  14513. password: null,
  14514. cache: null,
  14515. throws: false,
  14516. traditional: false,
  14517. headers: {},
  14518. */
  14519. accepts: {
  14520. "*": allTypes,
  14521. text: "text/plain",
  14522. html: "text/html",
  14523. xml: "application/xml, text/xml",
  14524. json: "application/json, text/javascript"
  14525. },
  14526. contents: {
  14527. xml: /\bxml\b/,
  14528. html: /\bhtml/,
  14529. json: /\bjson\b/
  14530. },
  14531. responseFields: {
  14532. xml: "responseXML",
  14533. text: "responseText",
  14534. json: "responseJSON"
  14535. },
  14536. // Data converters
  14537. // Keys separate source (or catchall "*") and destination types with a single space
  14538. converters: {
  14539. // Convert anything to text
  14540. "* text": String,
  14541. // Text to html (true = no transformation)
  14542. "text html": true,
  14543. // Evaluate text as a json expression
  14544. "text json": JSON.parse,
  14545. // Parse text as xml
  14546. "text xml": jQuery.parseXML
  14547. },
  14548. // For options that shouldn't be deep extended:
  14549. // you can add your own custom options here if
  14550. // and when you create one that shouldn't be
  14551. // deep extended (see ajaxExtend)
  14552. flatOptions: {
  14553. url: true,
  14554. context: true
  14555. }
  14556. },
  14557. // Creates a full fledged settings object into target
  14558. // with both ajaxSettings and settings fields.
  14559. // If target is omitted, writes into ajaxSettings.
  14560. ajaxSetup: function( target, settings ) {
  14561. return settings ?
  14562. // Building a settings object
  14563. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14564. // Extending ajaxSettings
  14565. ajaxExtend( jQuery.ajaxSettings, target );
  14566. },
  14567. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14568. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14569. // Main method
  14570. ajax: function( url, options ) {
  14571. // If url is an object, simulate pre-1.5 signature
  14572. if ( typeof url === "object" ) {
  14573. options = url;
  14574. url = undefined;
  14575. }
  14576. // Force options to be an object
  14577. options = options || {};
  14578. var transport,
  14579. // URL without anti-cache param
  14580. cacheURL,
  14581. // Response headers
  14582. responseHeadersString,
  14583. responseHeaders,
  14584. // timeout handle
  14585. timeoutTimer,
  14586. // Url cleanup var
  14587. urlAnchor,
  14588. // Request state (becomes false upon send and true upon completion)
  14589. completed,
  14590. // To know if global events are to be dispatched
  14591. fireGlobals,
  14592. // Loop variable
  14593. i,
  14594. // uncached part of the url
  14595. uncached,
  14596. // Create the final options object
  14597. s = jQuery.ajaxSetup( {}, options ),
  14598. // Callbacks context
  14599. callbackContext = s.context || s,
  14600. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14601. globalEventContext = s.context &&
  14602. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14603. jQuery( callbackContext ) :
  14604. jQuery.event,
  14605. // Deferreds
  14606. deferred = jQuery.Deferred(),
  14607. completeDeferred = jQuery.Callbacks( "once memory" ),
  14608. // Status-dependent callbacks
  14609. statusCode = s.statusCode || {},
  14610. // Headers (they are sent all at once)
  14611. requestHeaders = {},
  14612. requestHeadersNames = {},
  14613. // Default abort message
  14614. strAbort = "canceled",
  14615. // Fake xhr
  14616. jqXHR = {
  14617. readyState: 0,
  14618. // Builds headers hashtable if needed
  14619. getResponseHeader: function( key ) {
  14620. var match;
  14621. if ( completed ) {
  14622. if ( !responseHeaders ) {
  14623. responseHeaders = {};
  14624. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14625. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14626. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14627. .concat( match[ 2 ] );
  14628. }
  14629. }
  14630. match = responseHeaders[ key.toLowerCase() + " " ];
  14631. }
  14632. return match == null ? null : match.join( ", " );
  14633. },
  14634. // Raw string
  14635. getAllResponseHeaders: function() {
  14636. return completed ? responseHeadersString : null;
  14637. },
  14638. // Caches the header
  14639. setRequestHeader: function( name, value ) {
  14640. if ( completed == null ) {
  14641. name = requestHeadersNames[ name.toLowerCase() ] =
  14642. requestHeadersNames[ name.toLowerCase() ] || name;
  14643. requestHeaders[ name ] = value;
  14644. }
  14645. return this;
  14646. },
  14647. // Overrides response content-type header
  14648. overrideMimeType: function( type ) {
  14649. if ( completed == null ) {
  14650. s.mimeType = type;
  14651. }
  14652. return this;
  14653. },
  14654. // Status-dependent callbacks
  14655. statusCode: function( map ) {
  14656. var code;
  14657. if ( map ) {
  14658. if ( completed ) {
  14659. // Execute the appropriate callbacks
  14660. jqXHR.always( map[ jqXHR.status ] );
  14661. } else {
  14662. // Lazy-add the new callbacks in a way that preserves old ones
  14663. for ( code in map ) {
  14664. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14665. }
  14666. }
  14667. }
  14668. return this;
  14669. },
  14670. // Cancel the request
  14671. abort: function( statusText ) {
  14672. var finalText = statusText || strAbort;
  14673. if ( transport ) {
  14674. transport.abort( finalText );
  14675. }
  14676. done( 0, finalText );
  14677. return this;
  14678. }
  14679. };
  14680. // Attach deferreds
  14681. deferred.promise( jqXHR );
  14682. // Add protocol if not provided (prefilters might expect it)
  14683. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14684. // We also use the url parameter if available
  14685. s.url = ( ( url || s.url || location.href ) + "" )
  14686. .replace( rprotocol, location.protocol + "//" );
  14687. // Alias method option to type as per ticket #12004
  14688. s.type = options.method || options.type || s.method || s.type;
  14689. // Extract dataTypes list
  14690. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14691. // A cross-domain request is in order when the origin doesn't match the current origin.
  14692. if ( s.crossDomain == null ) {
  14693. urlAnchor = document.createElement( "a" );
  14694. // Support: IE <=8 - 11, Edge 12 - 15
  14695. // IE throws exception on accessing the href property if url is malformed,
  14696. // e.g. http://example.com:80x/
  14697. try {
  14698. urlAnchor.href = s.url;
  14699. // Support: IE <=8 - 11 only
  14700. // Anchor's host property isn't correctly set when s.url is relative
  14701. urlAnchor.href = urlAnchor.href;
  14702. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14703. urlAnchor.protocol + "//" + urlAnchor.host;
  14704. } catch ( e ) {
  14705. // If there is an error parsing the URL, assume it is crossDomain,
  14706. // it can be rejected by the transport if it is invalid
  14707. s.crossDomain = true;
  14708. }
  14709. }
  14710. // Convert data if not already a string
  14711. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14712. s.data = jQuery.param( s.data, s.traditional );
  14713. }
  14714. // Apply prefilters
  14715. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14716. // If request was aborted inside a prefilter, stop there
  14717. if ( completed ) {
  14718. return jqXHR;
  14719. }
  14720. // We can fire global events as of now if asked to
  14721. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14722. fireGlobals = jQuery.event && s.global;
  14723. // Watch for a new set of requests
  14724. if ( fireGlobals && jQuery.active++ === 0 ) {
  14725. jQuery.event.trigger( "ajaxStart" );
  14726. }
  14727. // Uppercase the type
  14728. s.type = s.type.toUpperCase();
  14729. // Determine if request has content
  14730. s.hasContent = !rnoContent.test( s.type );
  14731. // Save the URL in case we're toying with the If-Modified-Since
  14732. // and/or If-None-Match header later on
  14733. // Remove hash to simplify url manipulation
  14734. cacheURL = s.url.replace( rhash, "" );
  14735. // More options handling for requests with no content
  14736. if ( !s.hasContent ) {
  14737. // Remember the hash so we can put it back
  14738. uncached = s.url.slice( cacheURL.length );
  14739. // If data is available and should be processed, append data to url
  14740. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14741. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14742. // #9682: remove data so that it's not used in an eventual retry
  14743. delete s.data;
  14744. }
  14745. // Add or update anti-cache param if needed
  14746. if ( s.cache === false ) {
  14747. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14748. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14749. }
  14750. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14751. s.url = cacheURL + uncached;
  14752. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14753. } else if ( s.data && s.processData &&
  14754. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14755. s.data = s.data.replace( r20, "+" );
  14756. }
  14757. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14758. if ( s.ifModified ) {
  14759. if ( jQuery.lastModified[ cacheURL ] ) {
  14760. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14761. }
  14762. if ( jQuery.etag[ cacheURL ] ) {
  14763. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14764. }
  14765. }
  14766. // Set the correct header, if data is being sent
  14767. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14768. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14769. }
  14770. // Set the Accepts header for the server, depending on the dataType
  14771. jqXHR.setRequestHeader(
  14772. "Accept",
  14773. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14774. s.accepts[ s.dataTypes[ 0 ] ] +
  14775. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14776. s.accepts[ "*" ]
  14777. );
  14778. // Check for headers option
  14779. for ( i in s.headers ) {
  14780. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14781. }
  14782. // Allow custom headers/mimetypes and early abort
  14783. if ( s.beforeSend &&
  14784. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14785. // Abort if not done already and return
  14786. return jqXHR.abort();
  14787. }
  14788. // Aborting is no longer a cancellation
  14789. strAbort = "abort";
  14790. // Install callbacks on deferreds
  14791. completeDeferred.add( s.complete );
  14792. jqXHR.done( s.success );
  14793. jqXHR.fail( s.error );
  14794. // Get transport
  14795. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14796. // If no transport, we auto-abort
  14797. if ( !transport ) {
  14798. done( -1, "No Transport" );
  14799. } else {
  14800. jqXHR.readyState = 1;
  14801. // Send global event
  14802. if ( fireGlobals ) {
  14803. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14804. }
  14805. // If request was aborted inside ajaxSend, stop there
  14806. if ( completed ) {
  14807. return jqXHR;
  14808. }
  14809. // Timeout
  14810. if ( s.async && s.timeout > 0 ) {
  14811. timeoutTimer = window.setTimeout( function() {
  14812. jqXHR.abort( "timeout" );
  14813. }, s.timeout );
  14814. }
  14815. try {
  14816. completed = false;
  14817. transport.send( requestHeaders, done );
  14818. } catch ( e ) {
  14819. // Rethrow post-completion exceptions
  14820. if ( completed ) {
  14821. throw e;
  14822. }
  14823. // Propagate others as results
  14824. done( -1, e );
  14825. }
  14826. }
  14827. // Callback for when everything is done
  14828. function done( status, nativeStatusText, responses, headers ) {
  14829. var isSuccess, success, error, response, modified,
  14830. statusText = nativeStatusText;
  14831. // Ignore repeat invocations
  14832. if ( completed ) {
  14833. return;
  14834. }
  14835. completed = true;
  14836. // Clear timeout if it exists
  14837. if ( timeoutTimer ) {
  14838. window.clearTimeout( timeoutTimer );
  14839. }
  14840. // Dereference transport for early garbage collection
  14841. // (no matter how long the jqXHR object will be used)
  14842. transport = undefined;
  14843. // Cache response headers
  14844. responseHeadersString = headers || "";
  14845. // Set readyState
  14846. jqXHR.readyState = status > 0 ? 4 : 0;
  14847. // Determine if successful
  14848. isSuccess = status >= 200 && status < 300 || status === 304;
  14849. // Get response data
  14850. if ( responses ) {
  14851. response = ajaxHandleResponses( s, jqXHR, responses );
  14852. }
  14853. // Convert no matter what (that way responseXXX fields are always set)
  14854. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14855. // If successful, handle type chaining
  14856. if ( isSuccess ) {
  14857. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14858. if ( s.ifModified ) {
  14859. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14860. if ( modified ) {
  14861. jQuery.lastModified[ cacheURL ] = modified;
  14862. }
  14863. modified = jqXHR.getResponseHeader( "etag" );
  14864. if ( modified ) {
  14865. jQuery.etag[ cacheURL ] = modified;
  14866. }
  14867. }
  14868. // if no content
  14869. if ( status === 204 || s.type === "HEAD" ) {
  14870. statusText = "nocontent";
  14871. // if not modified
  14872. } else if ( status === 304 ) {
  14873. statusText = "notmodified";
  14874. // If we have data, let's convert it
  14875. } else {
  14876. statusText = response.state;
  14877. success = response.data;
  14878. error = response.error;
  14879. isSuccess = !error;
  14880. }
  14881. } else {
  14882. // Extract error from statusText and normalize for non-aborts
  14883. error = statusText;
  14884. if ( status || !statusText ) {
  14885. statusText = "error";
  14886. if ( status < 0 ) {
  14887. status = 0;
  14888. }
  14889. }
  14890. }
  14891. // Set data for the fake xhr object
  14892. jqXHR.status = status;
  14893. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14894. // Success/Error
  14895. if ( isSuccess ) {
  14896. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14897. } else {
  14898. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14899. }
  14900. // Status-dependent callbacks
  14901. jqXHR.statusCode( statusCode );
  14902. statusCode = undefined;
  14903. if ( fireGlobals ) {
  14904. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14905. [ jqXHR, s, isSuccess ? success : error ] );
  14906. }
  14907. // Complete
  14908. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14909. if ( fireGlobals ) {
  14910. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14911. // Handle the global AJAX counter
  14912. if ( !( --jQuery.active ) ) {
  14913. jQuery.event.trigger( "ajaxStop" );
  14914. }
  14915. }
  14916. }
  14917. return jqXHR;
  14918. },
  14919. getJSON: function( url, data, callback ) {
  14920. return jQuery.get( url, data, callback, "json" );
  14921. },
  14922. getScript: function( url, callback ) {
  14923. return jQuery.get( url, undefined, callback, "script" );
  14924. }
  14925. } );
  14926. jQuery.each( [ "get", "post" ], function( i, method ) {
  14927. jQuery[ method ] = function( url, data, callback, type ) {
  14928. // Shift arguments if data argument was omitted
  14929. if ( isFunction( data ) ) {
  14930. type = type || callback;
  14931. callback = data;
  14932. data = undefined;
  14933. }
  14934. // The url can be an options object (which then must have .url)
  14935. return jQuery.ajax( jQuery.extend( {
  14936. url: url,
  14937. type: method,
  14938. dataType: type,
  14939. data: data,
  14940. success: callback
  14941. }, jQuery.isPlainObject( url ) && url ) );
  14942. };
  14943. } );
  14944. jQuery._evalUrl = function( url, options ) {
  14945. return jQuery.ajax( {
  14946. url: url,
  14947. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14948. type: "GET",
  14949. dataType: "script",
  14950. cache: true,
  14951. async: false,
  14952. global: false,
  14953. // Only evaluate the response if it is successful (gh-4126)
  14954. // dataFilter is not invoked for failure responses, so using it instead
  14955. // of the default converter is kludgy but it works.
  14956. converters: {
  14957. "text script": function() {}
  14958. },
  14959. dataFilter: function( response ) {
  14960. jQuery.globalEval( response, options );
  14961. }
  14962. } );
  14963. };
  14964. jQuery.fn.extend( {
  14965. wrapAll: function( html ) {
  14966. var wrap;
  14967. if ( this[ 0 ] ) {
  14968. if ( isFunction( html ) ) {
  14969. html = html.call( this[ 0 ] );
  14970. }
  14971. // The elements to wrap the target around
  14972. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14973. if ( this[ 0 ].parentNode ) {
  14974. wrap.insertBefore( this[ 0 ] );
  14975. }
  14976. wrap.map( function() {
  14977. var elem = this;
  14978. while ( elem.firstElementChild ) {
  14979. elem = elem.firstElementChild;
  14980. }
  14981. return elem;
  14982. } ).append( this );
  14983. }
  14984. return this;
  14985. },
  14986. wrapInner: function( html ) {
  14987. if ( isFunction( html ) ) {
  14988. return this.each( function( i ) {
  14989. jQuery( this ).wrapInner( html.call( this, i ) );
  14990. } );
  14991. }
  14992. return this.each( function() {
  14993. var self = jQuery( this ),
  14994. contents = self.contents();
  14995. if ( contents.length ) {
  14996. contents.wrapAll( html );
  14997. } else {
  14998. self.append( html );
  14999. }
  15000. } );
  15001. },
  15002. wrap: function( html ) {
  15003. var htmlIsFunction = isFunction( html );
  15004. return this.each( function( i ) {
  15005. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15006. } );
  15007. },
  15008. unwrap: function( selector ) {
  15009. this.parent( selector ).not( "body" ).each( function() {
  15010. jQuery( this ).replaceWith( this.childNodes );
  15011. } );
  15012. return this;
  15013. }
  15014. } );
  15015. jQuery.expr.pseudos.hidden = function( elem ) {
  15016. return !jQuery.expr.pseudos.visible( elem );
  15017. };
  15018. jQuery.expr.pseudos.visible = function( elem ) {
  15019. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15020. };
  15021. jQuery.ajaxSettings.xhr = function() {
  15022. try {
  15023. return new window.XMLHttpRequest();
  15024. } catch ( e ) {}
  15025. };
  15026. var xhrSuccessStatus = {
  15027. // File protocol always yields status code 0, assume 200
  15028. 0: 200,
  15029. // Support: IE <=9 only
  15030. // #1450: sometimes IE returns 1223 when it should be 204
  15031. 1223: 204
  15032. },
  15033. xhrSupported = jQuery.ajaxSettings.xhr();
  15034. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15035. support.ajax = xhrSupported = !!xhrSupported;
  15036. jQuery.ajaxTransport( function( options ) {
  15037. var callback, errorCallback;
  15038. // Cross domain only allowed if supported through XMLHttpRequest
  15039. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15040. return {
  15041. send: function( headers, complete ) {
  15042. var i,
  15043. xhr = options.xhr();
  15044. xhr.open(
  15045. options.type,
  15046. options.url,
  15047. options.async,
  15048. options.username,
  15049. options.password
  15050. );
  15051. // Apply custom fields if provided
  15052. if ( options.xhrFields ) {
  15053. for ( i in options.xhrFields ) {
  15054. xhr[ i ] = options.xhrFields[ i ];
  15055. }
  15056. }
  15057. // Override mime type if needed
  15058. if ( options.mimeType && xhr.overrideMimeType ) {
  15059. xhr.overrideMimeType( options.mimeType );
  15060. }
  15061. // X-Requested-With header
  15062. // For cross-domain requests, seeing as conditions for a preflight are
  15063. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15064. // (it can always be set on a per-request basis or even using ajaxSetup)
  15065. // For same-domain requests, won't change header if already provided.
  15066. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15067. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15068. }
  15069. // Set headers
  15070. for ( i in headers ) {
  15071. xhr.setRequestHeader( i, headers[ i ] );
  15072. }
  15073. // Callback
  15074. callback = function( type ) {
  15075. return function() {
  15076. if ( callback ) {
  15077. callback = errorCallback = xhr.onload =
  15078. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15079. xhr.onreadystatechange = null;
  15080. if ( type === "abort" ) {
  15081. xhr.abort();
  15082. } else if ( type === "error" ) {
  15083. // Support: IE <=9 only
  15084. // On a manual native abort, IE9 throws
  15085. // errors on any property access that is not readyState
  15086. if ( typeof xhr.status !== "number" ) {
  15087. complete( 0, "error" );
  15088. } else {
  15089. complete(
  15090. // File: protocol always yields status 0; see #8605, #14207
  15091. xhr.status,
  15092. xhr.statusText
  15093. );
  15094. }
  15095. } else {
  15096. complete(
  15097. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15098. xhr.statusText,
  15099. // Support: IE <=9 only
  15100. // IE9 has no XHR2 but throws on binary (trac-11426)
  15101. // For XHR2 non-text, let the caller handle it (gh-2498)
  15102. ( xhr.responseType || "text" ) !== "text" ||
  15103. typeof xhr.responseText !== "string" ?
  15104. { binary: xhr.response } :
  15105. { text: xhr.responseText },
  15106. xhr.getAllResponseHeaders()
  15107. );
  15108. }
  15109. }
  15110. };
  15111. };
  15112. // Listen to events
  15113. xhr.onload = callback();
  15114. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15115. // Support: IE 9 only
  15116. // Use onreadystatechange to replace onabort
  15117. // to handle uncaught aborts
  15118. if ( xhr.onabort !== undefined ) {
  15119. xhr.onabort = errorCallback;
  15120. } else {
  15121. xhr.onreadystatechange = function() {
  15122. // Check readyState before timeout as it changes
  15123. if ( xhr.readyState === 4 ) {
  15124. // Allow onerror to be called first,
  15125. // but that will not handle a native abort
  15126. // Also, save errorCallback to a variable
  15127. // as xhr.onerror cannot be accessed
  15128. window.setTimeout( function() {
  15129. if ( callback ) {
  15130. errorCallback();
  15131. }
  15132. } );
  15133. }
  15134. };
  15135. }
  15136. // Create the abort callback
  15137. callback = callback( "abort" );
  15138. try {
  15139. // Do send the request (this may raise an exception)
  15140. xhr.send( options.hasContent && options.data || null );
  15141. } catch ( e ) {
  15142. // #14683: Only rethrow if this hasn't been notified as an error yet
  15143. if ( callback ) {
  15144. throw e;
  15145. }
  15146. }
  15147. },
  15148. abort: function() {
  15149. if ( callback ) {
  15150. callback();
  15151. }
  15152. }
  15153. };
  15154. }
  15155. } );
  15156. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15157. jQuery.ajaxPrefilter( function( s ) {
  15158. if ( s.crossDomain ) {
  15159. s.contents.script = false;
  15160. }
  15161. } );
  15162. // Install script dataType
  15163. jQuery.ajaxSetup( {
  15164. accepts: {
  15165. script: "text/javascript, application/javascript, " +
  15166. "application/ecmascript, application/x-ecmascript"
  15167. },
  15168. contents: {
  15169. script: /\b(?:java|ecma)script\b/
  15170. },
  15171. converters: {
  15172. "text script": function( text ) {
  15173. jQuery.globalEval( text );
  15174. return text;
  15175. }
  15176. }
  15177. } );
  15178. // Handle cache's special case and crossDomain
  15179. jQuery.ajaxPrefilter( "script", function( s ) {
  15180. if ( s.cache === undefined ) {
  15181. s.cache = false;
  15182. }
  15183. if ( s.crossDomain ) {
  15184. s.type = "GET";
  15185. }
  15186. } );
  15187. // Bind script tag hack transport
  15188. jQuery.ajaxTransport( "script", function( s ) {
  15189. // This transport only deals with cross domain or forced-by-attrs requests
  15190. if ( s.crossDomain || s.scriptAttrs ) {
  15191. var script, callback;
  15192. return {
  15193. send: function( _, complete ) {
  15194. script = jQuery( "<script>" )
  15195. .attr( s.scriptAttrs || {} )
  15196. .prop( { charset: s.scriptCharset, src: s.url } )
  15197. .on( "load error", callback = function( evt ) {
  15198. script.remove();
  15199. callback = null;
  15200. if ( evt ) {
  15201. complete( evt.type === "error" ? 404 : 200, evt.type );
  15202. }
  15203. } );
  15204. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15205. document.head.appendChild( script[ 0 ] );
  15206. },
  15207. abort: function() {
  15208. if ( callback ) {
  15209. callback();
  15210. }
  15211. }
  15212. };
  15213. }
  15214. } );
  15215. var oldCallbacks = [],
  15216. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15217. // Default jsonp settings
  15218. jQuery.ajaxSetup( {
  15219. jsonp: "callback",
  15220. jsonpCallback: function() {
  15221. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15222. this[ callback ] = true;
  15223. return callback;
  15224. }
  15225. } );
  15226. // Detect, normalize options and install callbacks for jsonp requests
  15227. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15228. var callbackName, overwritten, responseContainer,
  15229. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15230. "url" :
  15231. typeof s.data === "string" &&
  15232. ( s.contentType || "" )
  15233. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15234. rjsonp.test( s.data ) && "data"
  15235. );
  15236. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15237. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15238. // Get callback name, remembering preexisting value associated with it
  15239. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15240. s.jsonpCallback() :
  15241. s.jsonpCallback;
  15242. // Insert callback into url or form data
  15243. if ( jsonProp ) {
  15244. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15245. } else if ( s.jsonp !== false ) {
  15246. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15247. }
  15248. // Use data converter to retrieve json after script execution
  15249. s.converters[ "script json" ] = function() {
  15250. if ( !responseContainer ) {
  15251. jQuery.error( callbackName + " was not called" );
  15252. }
  15253. return responseContainer[ 0 ];
  15254. };
  15255. // Force json dataType
  15256. s.dataTypes[ 0 ] = "json";
  15257. // Install callback
  15258. overwritten = window[ callbackName ];
  15259. window[ callbackName ] = function() {
  15260. responseContainer = arguments;
  15261. };
  15262. // Clean-up function (fires after converters)
  15263. jqXHR.always( function() {
  15264. // If previous value didn't exist - remove it
  15265. if ( overwritten === undefined ) {
  15266. jQuery( window ).removeProp( callbackName );
  15267. // Otherwise restore preexisting value
  15268. } else {
  15269. window[ callbackName ] = overwritten;
  15270. }
  15271. // Save back as free
  15272. if ( s[ callbackName ] ) {
  15273. // Make sure that re-using the options doesn't screw things around
  15274. s.jsonpCallback = originalSettings.jsonpCallback;
  15275. // Save the callback name for future use
  15276. oldCallbacks.push( callbackName );
  15277. }
  15278. // Call if it was a function and we have a response
  15279. if ( responseContainer && isFunction( overwritten ) ) {
  15280. overwritten( responseContainer[ 0 ] );
  15281. }
  15282. responseContainer = overwritten = undefined;
  15283. } );
  15284. // Delegate to script
  15285. return "script";
  15286. }
  15287. } );
  15288. // Support: Safari 8 only
  15289. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15290. // collapse sibling forms: the second one becomes a child of the first one.
  15291. // Because of that, this security measure has to be disabled in Safari 8.
  15292. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15293. support.createHTMLDocument = ( function() {
  15294. var body = document.implementation.createHTMLDocument( "" ).body;
  15295. body.innerHTML = "<form></form><form></form>";
  15296. return body.childNodes.length === 2;
  15297. } )();
  15298. // Argument "data" should be string of html
  15299. // context (optional): If specified, the fragment will be created in this context,
  15300. // defaults to document
  15301. // keepScripts (optional): If true, will include scripts passed in the html string
  15302. jQuery.parseHTML = function( data, context, keepScripts ) {
  15303. if ( typeof data !== "string" ) {
  15304. return [];
  15305. }
  15306. if ( typeof context === "boolean" ) {
  15307. keepScripts = context;
  15308. context = false;
  15309. }
  15310. var base, parsed, scripts;
  15311. if ( !context ) {
  15312. // Stop scripts or inline event handlers from being executed immediately
  15313. // by using document.implementation
  15314. if ( support.createHTMLDocument ) {
  15315. context = document.implementation.createHTMLDocument( "" );
  15316. // Set the base href for the created document
  15317. // so any parsed elements with URLs
  15318. // are based on the document's URL (gh-2965)
  15319. base = context.createElement( "base" );
  15320. base.href = document.location.href;
  15321. context.head.appendChild( base );
  15322. } else {
  15323. context = document;
  15324. }
  15325. }
  15326. parsed = rsingleTag.exec( data );
  15327. scripts = !keepScripts && [];
  15328. // Single tag
  15329. if ( parsed ) {
  15330. return [ context.createElement( parsed[ 1 ] ) ];
  15331. }
  15332. parsed = buildFragment( [ data ], context, scripts );
  15333. if ( scripts && scripts.length ) {
  15334. jQuery( scripts ).remove();
  15335. }
  15336. return jQuery.merge( [], parsed.childNodes );
  15337. };
  15338. /**
  15339. * Load a url into a page
  15340. */
  15341. jQuery.fn.load = function( url, params, callback ) {
  15342. var selector, type, response,
  15343. self = this,
  15344. off = url.indexOf( " " );
  15345. if ( off > -1 ) {
  15346. selector = stripAndCollapse( url.slice( off ) );
  15347. url = url.slice( 0, off );
  15348. }
  15349. // If it's a function
  15350. if ( isFunction( params ) ) {
  15351. // We assume that it's the callback
  15352. callback = params;
  15353. params = undefined;
  15354. // Otherwise, build a param string
  15355. } else if ( params && typeof params === "object" ) {
  15356. type = "POST";
  15357. }
  15358. // If we have elements to modify, make the request
  15359. if ( self.length > 0 ) {
  15360. jQuery.ajax( {
  15361. url: url,
  15362. // If "type" variable is undefined, then "GET" method will be used.
  15363. // Make value of this field explicit since
  15364. // user can override it through ajaxSetup method
  15365. type: type || "GET",
  15366. dataType: "html",
  15367. data: params
  15368. } ).done( function( responseText ) {
  15369. // Save response for use in complete callback
  15370. response = arguments;
  15371. self.html( selector ?
  15372. // If a selector was specified, locate the right elements in a dummy div
  15373. // Exclude scripts to avoid IE 'Permission Denied' errors
  15374. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15375. // Otherwise use the full result
  15376. responseText );
  15377. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15378. // but they are ignored because response was set above.
  15379. // If it fails, this function gets "jqXHR", "status", "error"
  15380. } ).always( callback && function( jqXHR, status ) {
  15381. self.each( function() {
  15382. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15383. } );
  15384. } );
  15385. }
  15386. return this;
  15387. };
  15388. // Attach a bunch of functions for handling common AJAX events
  15389. jQuery.each( [
  15390. "ajaxStart",
  15391. "ajaxStop",
  15392. "ajaxComplete",
  15393. "ajaxError",
  15394. "ajaxSuccess",
  15395. "ajaxSend"
  15396. ], function( i, type ) {
  15397. jQuery.fn[ type ] = function( fn ) {
  15398. return this.on( type, fn );
  15399. };
  15400. } );
  15401. jQuery.expr.pseudos.animated = function( elem ) {
  15402. return jQuery.grep( jQuery.timers, function( fn ) {
  15403. return elem === fn.elem;
  15404. } ).length;
  15405. };
  15406. jQuery.offset = {
  15407. setOffset: function( elem, options, i ) {
  15408. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15409. position = jQuery.css( elem, "position" ),
  15410. curElem = jQuery( elem ),
  15411. props = {};
  15412. // Set position first, in-case top/left are set even on static elem
  15413. if ( position === "static" ) {
  15414. elem.style.position = "relative";
  15415. }
  15416. curOffset = curElem.offset();
  15417. curCSSTop = jQuery.css( elem, "top" );
  15418. curCSSLeft = jQuery.css( elem, "left" );
  15419. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15420. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15421. // Need to be able to calculate position if either
  15422. // top or left is auto and position is either absolute or fixed
  15423. if ( calculatePosition ) {
  15424. curPosition = curElem.position();
  15425. curTop = curPosition.top;
  15426. curLeft = curPosition.left;
  15427. } else {
  15428. curTop = parseFloat( curCSSTop ) || 0;
  15429. curLeft = parseFloat( curCSSLeft ) || 0;
  15430. }
  15431. if ( isFunction( options ) ) {
  15432. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15433. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15434. }
  15435. if ( options.top != null ) {
  15436. props.top = ( options.top - curOffset.top ) + curTop;
  15437. }
  15438. if ( options.left != null ) {
  15439. props.left = ( options.left - curOffset.left ) + curLeft;
  15440. }
  15441. if ( "using" in options ) {
  15442. options.using.call( elem, props );
  15443. } else {
  15444. curElem.css( props );
  15445. }
  15446. }
  15447. };
  15448. jQuery.fn.extend( {
  15449. // offset() relates an element's border box to the document origin
  15450. offset: function( options ) {
  15451. // Preserve chaining for setter
  15452. if ( arguments.length ) {
  15453. return options === undefined ?
  15454. this :
  15455. this.each( function( i ) {
  15456. jQuery.offset.setOffset( this, options, i );
  15457. } );
  15458. }
  15459. var rect, win,
  15460. elem = this[ 0 ];
  15461. if ( !elem ) {
  15462. return;
  15463. }
  15464. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15465. // Support: IE <=11 only
  15466. // Running getBoundingClientRect on a
  15467. // disconnected node in IE throws an error
  15468. if ( !elem.getClientRects().length ) {
  15469. return { top: 0, left: 0 };
  15470. }
  15471. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15472. rect = elem.getBoundingClientRect();
  15473. win = elem.ownerDocument.defaultView;
  15474. return {
  15475. top: rect.top + win.pageYOffset,
  15476. left: rect.left + win.pageXOffset
  15477. };
  15478. },
  15479. // position() relates an element's margin box to its offset parent's padding box
  15480. // This corresponds to the behavior of CSS absolute positioning
  15481. position: function() {
  15482. if ( !this[ 0 ] ) {
  15483. return;
  15484. }
  15485. var offsetParent, offset, doc,
  15486. elem = this[ 0 ],
  15487. parentOffset = { top: 0, left: 0 };
  15488. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15489. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15490. // Assume position:fixed implies availability of getBoundingClientRect
  15491. offset = elem.getBoundingClientRect();
  15492. } else {
  15493. offset = this.offset();
  15494. // Account for the *real* offset parent, which can be the document or its root element
  15495. // when a statically positioned element is identified
  15496. doc = elem.ownerDocument;
  15497. offsetParent = elem.offsetParent || doc.documentElement;
  15498. while ( offsetParent &&
  15499. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15500. jQuery.css( offsetParent, "position" ) === "static" ) {
  15501. offsetParent = offsetParent.parentNode;
  15502. }
  15503. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15504. // Incorporate borders into its offset, since they are outside its content origin
  15505. parentOffset = jQuery( offsetParent ).offset();
  15506. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15507. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15508. }
  15509. }
  15510. // Subtract parent offsets and element margins
  15511. return {
  15512. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15513. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15514. };
  15515. },
  15516. // This method will return documentElement in the following cases:
  15517. // 1) For the element inside the iframe without offsetParent, this method will return
  15518. // documentElement of the parent window
  15519. // 2) For the hidden or detached element
  15520. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15521. //
  15522. // but those exceptions were never presented as a real life use-cases
  15523. // and might be considered as more preferable results.
  15524. //
  15525. // This logic, however, is not guaranteed and can change at any point in the future
  15526. offsetParent: function() {
  15527. return this.map( function() {
  15528. var offsetParent = this.offsetParent;
  15529. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15530. offsetParent = offsetParent.offsetParent;
  15531. }
  15532. return offsetParent || documentElement;
  15533. } );
  15534. }
  15535. } );
  15536. // Create scrollLeft and scrollTop methods
  15537. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15538. var top = "pageYOffset" === prop;
  15539. jQuery.fn[ method ] = function( val ) {
  15540. return access( this, function( elem, method, val ) {
  15541. // Coalesce documents and windows
  15542. var win;
  15543. if ( isWindow( elem ) ) {
  15544. win = elem;
  15545. } else if ( elem.nodeType === 9 ) {
  15546. win = elem.defaultView;
  15547. }
  15548. if ( val === undefined ) {
  15549. return win ? win[ prop ] : elem[ method ];
  15550. }
  15551. if ( win ) {
  15552. win.scrollTo(
  15553. !top ? val : win.pageXOffset,
  15554. top ? val : win.pageYOffset
  15555. );
  15556. } else {
  15557. elem[ method ] = val;
  15558. }
  15559. }, method, val, arguments.length );
  15560. };
  15561. } );
  15562. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15563. // Add the top/left cssHooks using jQuery.fn.position
  15564. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15565. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15566. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15567. // rather than make the css module depend on the offset module, just check for it here
  15568. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15569. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15570. function( elem, computed ) {
  15571. if ( computed ) {
  15572. computed = curCSS( elem, prop );
  15573. // If curCSS returns percentage, fallback to offset
  15574. return rnumnonpx.test( computed ) ?
  15575. jQuery( elem ).position()[ prop ] + "px" :
  15576. computed;
  15577. }
  15578. }
  15579. );
  15580. } );
  15581. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15582. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15583. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15584. function( defaultExtra, funcName ) {
  15585. // Margin is only for outerHeight, outerWidth
  15586. jQuery.fn[ funcName ] = function( margin, value ) {
  15587. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15588. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15589. return access( this, function( elem, type, value ) {
  15590. var doc;
  15591. if ( isWindow( elem ) ) {
  15592. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15593. return funcName.indexOf( "outer" ) === 0 ?
  15594. elem[ "inner" + name ] :
  15595. elem.document.documentElement[ "client" + name ];
  15596. }
  15597. // Get document width or height
  15598. if ( elem.nodeType === 9 ) {
  15599. doc = elem.documentElement;
  15600. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15601. // whichever is greatest
  15602. return Math.max(
  15603. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15604. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15605. doc[ "client" + name ]
  15606. );
  15607. }
  15608. return value === undefined ?
  15609. // Get width or height on the element, requesting but not forcing parseFloat
  15610. jQuery.css( elem, type, extra ) :
  15611. // Set width or height on the element
  15612. jQuery.style( elem, type, value, extra );
  15613. }, type, chainable ? margin : undefined, chainable );
  15614. };
  15615. } );
  15616. } );
  15617. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15618. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15619. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15620. function( i, name ) {
  15621. // Handle event binding
  15622. jQuery.fn[ name ] = function( data, fn ) {
  15623. return arguments.length > 0 ?
  15624. this.on( name, null, data, fn ) :
  15625. this.trigger( name );
  15626. };
  15627. } );
  15628. jQuery.fn.extend( {
  15629. hover: function( fnOver, fnOut ) {
  15630. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15631. }
  15632. } );
  15633. jQuery.fn.extend( {
  15634. bind: function( types, data, fn ) {
  15635. return this.on( types, null, data, fn );
  15636. },
  15637. unbind: function( types, fn ) {
  15638. return this.off( types, null, fn );
  15639. },
  15640. delegate: function( selector, types, data, fn ) {
  15641. return this.on( types, selector, data, fn );
  15642. },
  15643. undelegate: function( selector, types, fn ) {
  15644. // ( namespace ) or ( selector, types [, fn] )
  15645. return arguments.length === 1 ?
  15646. this.off( selector, "**" ) :
  15647. this.off( types, selector || "**", fn );
  15648. }
  15649. } );
  15650. // Bind a function to a context, optionally partially applying any
  15651. // arguments.
  15652. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15653. // However, it is not slated for removal any time soon
  15654. jQuery.proxy = function( fn, context ) {
  15655. var tmp, args, proxy;
  15656. if ( typeof context === "string" ) {
  15657. tmp = fn[ context ];
  15658. context = fn;
  15659. fn = tmp;
  15660. }
  15661. // Quick check to determine if target is callable, in the spec
  15662. // this throws a TypeError, but we will just return undefined.
  15663. if ( !isFunction( fn ) ) {
  15664. return undefined;
  15665. }
  15666. // Simulated bind
  15667. args = slice.call( arguments, 2 );
  15668. proxy = function() {
  15669. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15670. };
  15671. // Set the guid of unique handler to the same of original handler, so it can be removed
  15672. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15673. return proxy;
  15674. };
  15675. jQuery.holdReady = function( hold ) {
  15676. if ( hold ) {
  15677. jQuery.readyWait++;
  15678. } else {
  15679. jQuery.ready( true );
  15680. }
  15681. };
  15682. jQuery.isArray = Array.isArray;
  15683. jQuery.parseJSON = JSON.parse;
  15684. jQuery.nodeName = nodeName;
  15685. jQuery.isFunction = isFunction;
  15686. jQuery.isWindow = isWindow;
  15687. jQuery.camelCase = camelCase;
  15688. jQuery.type = toType;
  15689. jQuery.now = Date.now;
  15690. jQuery.isNumeric = function( obj ) {
  15691. // As of jQuery 3.0, isNumeric is limited to
  15692. // strings and numbers (primitives or objects)
  15693. // that can be coerced to finite numbers (gh-2662)
  15694. var type = jQuery.type( obj );
  15695. return ( type === "number" || type === "string" ) &&
  15696. // parseFloat NaNs numeric-cast false positives ("")
  15697. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15698. // subtraction forces infinities to NaN
  15699. !isNaN( obj - parseFloat( obj ) );
  15700. };
  15701. // Register as a named AMD module, since jQuery can be concatenated with other
  15702. // files that may use define, but not via a proper concatenation script that
  15703. // understands anonymous AMD modules. A named AMD is safest and most robust
  15704. // way to register. Lowercase jquery is used because AMD module names are
  15705. // derived from file names, and jQuery is normally delivered in a lowercase
  15706. // file name. Do this after creating the global so that if an AMD module wants
  15707. // to call noConflict to hide this version of jQuery, it will work.
  15708. // Note that for maximum portability, libraries that are not jQuery should
  15709. // declare themselves as anonymous modules, and avoid setting a global if an
  15710. // AMD loader is present. jQuery is a special case. For more information, see
  15711. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15712. if ( true ) {
  15713. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15714. return jQuery;
  15715. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15716. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15717. }
  15718. var
  15719. // Map over jQuery in case of overwrite
  15720. _jQuery = window.jQuery,
  15721. // Map over the $ in case of overwrite
  15722. _$ = window.$;
  15723. jQuery.noConflict = function( deep ) {
  15724. if ( window.$ === jQuery ) {
  15725. window.$ = _$;
  15726. }
  15727. if ( deep && window.jQuery === jQuery ) {
  15728. window.jQuery = _jQuery;
  15729. }
  15730. return jQuery;
  15731. };
  15732. // Expose jQuery and $ identifiers, even in AMD
  15733. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15734. // and CommonJS for browser emulators (#13566)
  15735. if ( !noGlobal ) {
  15736. window.jQuery = window.$ = jQuery;
  15737. }
  15738. return jQuery;
  15739. } );
  15740. /***/ }),
  15741. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15742. /*!************************************************!*\
  15743. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15744. \************************************************/
  15745. /*! exports provided: default */
  15746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15747. "use strict";
  15748. __webpack_require__.r(__webpack_exports__);
  15749. var classCallCheck = function (instance, Constructor) {
  15750. if (!(instance instanceof Constructor)) {
  15751. throw new TypeError("Cannot call a class as a function");
  15752. }
  15753. };
  15754. var createClass = function () {
  15755. function defineProperties(target, props) {
  15756. for (var i = 0; i < props.length; i++) {
  15757. var descriptor = props[i];
  15758. descriptor.enumerable = descriptor.enumerable || false;
  15759. descriptor.configurable = true;
  15760. if ("value" in descriptor) descriptor.writable = true;
  15761. Object.defineProperty(target, descriptor.key, descriptor);
  15762. }
  15763. }
  15764. return function (Constructor, protoProps, staticProps) {
  15765. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15766. if (staticProps) defineProperties(Constructor, staticProps);
  15767. return Constructor;
  15768. };
  15769. }();
  15770. var _extends = Object.assign || function (target) {
  15771. for (var i = 1; i < arguments.length; i++) {
  15772. var source = arguments[i];
  15773. for (var key in source) {
  15774. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15775. target[key] = source[key];
  15776. }
  15777. }
  15778. }
  15779. return target;
  15780. };
  15781. var inherits = function (subClass, superClass) {
  15782. if (typeof superClass !== "function" && superClass !== null) {
  15783. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15784. }
  15785. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15786. constructor: {
  15787. value: subClass,
  15788. enumerable: false,
  15789. writable: true,
  15790. configurable: true
  15791. }
  15792. });
  15793. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15794. };
  15795. var possibleConstructorReturn = function (self, call) {
  15796. if (!self) {
  15797. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15798. }
  15799. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15800. };
  15801. var Connector = function () {
  15802. /**
  15803. * Create a new class instance.
  15804. */
  15805. function Connector(options) {
  15806. classCallCheck(this, Connector);
  15807. /**
  15808. * Default connector options.
  15809. */
  15810. this._defaultOptions = {
  15811. auth: {
  15812. headers: {}
  15813. },
  15814. authEndpoint: '/broadcasting/auth',
  15815. broadcaster: 'pusher',
  15816. csrfToken: null,
  15817. host: null,
  15818. key: null,
  15819. namespace: 'App.Events'
  15820. };
  15821. this.setOptions(options);
  15822. this.connect();
  15823. }
  15824. /**
  15825. * Merge the custom options with the defaults.
  15826. */
  15827. createClass(Connector, [{
  15828. key: 'setOptions',
  15829. value: function setOptions(options) {
  15830. this.options = _extends(this._defaultOptions, options);
  15831. if (this.csrfToken()) {
  15832. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15833. }
  15834. return options;
  15835. }
  15836. /**
  15837. * Extract the CSRF token from the page.
  15838. */
  15839. }, {
  15840. key: 'csrfToken',
  15841. value: function csrfToken() {
  15842. var selector = void 0;
  15843. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15844. return window['Laravel'].csrfToken;
  15845. } else if (this.options.csrfToken) {
  15846. return this.options.csrfToken;
  15847. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15848. return selector.getAttribute('content');
  15849. }
  15850. return null;
  15851. }
  15852. }]);
  15853. return Connector;
  15854. }();
  15855. /**
  15856. * This class represents a basic channel.
  15857. */
  15858. var Channel = function () {
  15859. function Channel() {
  15860. classCallCheck(this, Channel);
  15861. }
  15862. createClass(Channel, [{
  15863. key: 'listenForWhisper',
  15864. /**
  15865. * Listen for a whisper event on the channel instance.
  15866. */
  15867. value: function listenForWhisper(event, callback) {
  15868. return this.listen('.client-' + event, callback);
  15869. }
  15870. /**
  15871. * Listen for an event on the channel instance.
  15872. */
  15873. }, {
  15874. key: 'notification',
  15875. value: function notification(callback) {
  15876. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15877. }
  15878. /**
  15879. * Stop listening for a whispser event on the channel instance.
  15880. */
  15881. }, {
  15882. key: 'stopListeningForWhisper',
  15883. value: function stopListeningForWhisper(event) {
  15884. return this.stopListening('.client-' + event);
  15885. }
  15886. }]);
  15887. return Channel;
  15888. }();
  15889. /**
  15890. * Event name formatter
  15891. */
  15892. var EventFormatter = function () {
  15893. /**
  15894. * Create a new class instance.
  15895. */
  15896. function EventFormatter(namespace) {
  15897. classCallCheck(this, EventFormatter);
  15898. this.setNamespace(namespace);
  15899. }
  15900. /**
  15901. * Format the given event name.
  15902. */
  15903. createClass(EventFormatter, [{
  15904. key: 'format',
  15905. value: function format(event) {
  15906. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15907. return event.substr(1);
  15908. } else if (this.namespace) {
  15909. event = this.namespace + '.' + event;
  15910. }
  15911. return event.replace(/\./g, '\\');
  15912. }
  15913. /**
  15914. * Set the event namespace.
  15915. */
  15916. }, {
  15917. key: 'setNamespace',
  15918. value: function setNamespace(value) {
  15919. this.namespace = value;
  15920. }
  15921. }]);
  15922. return EventFormatter;
  15923. }();
  15924. /**
  15925. * This class represents a Pusher channel.
  15926. */
  15927. var PusherChannel = function (_Channel) {
  15928. inherits(PusherChannel, _Channel);
  15929. /**
  15930. * Create a new class instance.
  15931. */
  15932. function PusherChannel(pusher, name, options) {
  15933. classCallCheck(this, PusherChannel);
  15934. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15935. _this.name = name;
  15936. _this.pusher = pusher;
  15937. _this.options = options;
  15938. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15939. _this.subscribe();
  15940. return _this;
  15941. }
  15942. /**
  15943. * Subscribe to a Pusher channel.
  15944. */
  15945. createClass(PusherChannel, [{
  15946. key: 'subscribe',
  15947. value: function subscribe() {
  15948. this.subscription = this.pusher.subscribe(this.name);
  15949. }
  15950. /**
  15951. * Unsubscribe from a Pusher channel.
  15952. */
  15953. }, {
  15954. key: 'unsubscribe',
  15955. value: function unsubscribe() {
  15956. this.pusher.unsubscribe(this.name);
  15957. }
  15958. /**
  15959. * Listen for an event on the channel instance.
  15960. */
  15961. }, {
  15962. key: 'listen',
  15963. value: function listen(event, callback) {
  15964. this.on(this.eventFormatter.format(event), callback);
  15965. return this;
  15966. }
  15967. /**
  15968. * Stop listening for an event on the channel instance.
  15969. */
  15970. }, {
  15971. key: 'stopListening',
  15972. value: function stopListening(event) {
  15973. this.subscription.unbind(this.eventFormatter.format(event));
  15974. return this;
  15975. }
  15976. /**
  15977. * Bind a channel to an event.
  15978. */
  15979. }, {
  15980. key: 'on',
  15981. value: function on(event, callback) {
  15982. this.subscription.bind(event, callback);
  15983. return this;
  15984. }
  15985. }]);
  15986. return PusherChannel;
  15987. }(Channel);
  15988. /**
  15989. * This class represents a Pusher private channel.
  15990. */
  15991. var PusherPrivateChannel = function (_PusherChannel) {
  15992. inherits(PusherPrivateChannel, _PusherChannel);
  15993. function PusherPrivateChannel() {
  15994. classCallCheck(this, PusherPrivateChannel);
  15995. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15996. }
  15997. createClass(PusherPrivateChannel, [{
  15998. key: 'whisper',
  15999. /**
  16000. * Trigger client event on the channel.
  16001. */
  16002. value: function whisper(eventName, data) {
  16003. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16004. return this;
  16005. }
  16006. }]);
  16007. return PusherPrivateChannel;
  16008. }(PusherChannel);
  16009. /**
  16010. * This class represents a Pusher presence channel.
  16011. */
  16012. var PusherPresenceChannel = function (_PusherChannel) {
  16013. inherits(PusherPresenceChannel, _PusherChannel);
  16014. function PusherPresenceChannel() {
  16015. classCallCheck(this, PusherPresenceChannel);
  16016. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16017. }
  16018. createClass(PusherPresenceChannel, [{
  16019. key: 'here',
  16020. /**
  16021. * Register a callback to be called anytime the member list changes.
  16022. */
  16023. value: function here(callback) {
  16024. this.on('pusher:subscription_succeeded', function (data) {
  16025. callback(Object.keys(data.members).map(function (k) {
  16026. return data.members[k];
  16027. }));
  16028. });
  16029. return this;
  16030. }
  16031. /**
  16032. * Listen for someone joining the channel.
  16033. */
  16034. }, {
  16035. key: 'joining',
  16036. value: function joining(callback) {
  16037. this.on('pusher:member_added', function (member) {
  16038. callback(member.info);
  16039. });
  16040. return this;
  16041. }
  16042. /**
  16043. * Listen for someone leaving the channel.
  16044. */
  16045. }, {
  16046. key: 'leaving',
  16047. value: function leaving(callback) {
  16048. this.on('pusher:member_removed', function (member) {
  16049. callback(member.info);
  16050. });
  16051. return this;
  16052. }
  16053. /**
  16054. * Trigger client event on the channel.
  16055. */
  16056. }, {
  16057. key: 'whisper',
  16058. value: function whisper(eventName, data) {
  16059. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16060. return this;
  16061. }
  16062. }]);
  16063. return PusherPresenceChannel;
  16064. }(PusherChannel);
  16065. /**
  16066. * This class represents a Socket.io channel.
  16067. */
  16068. var SocketIoChannel = function (_Channel) {
  16069. inherits(SocketIoChannel, _Channel);
  16070. /**
  16071. * Create a new class instance.
  16072. */
  16073. function SocketIoChannel(socket, name, options) {
  16074. classCallCheck(this, SocketIoChannel);
  16075. /**
  16076. * The event callbacks applied to the channel.
  16077. */
  16078. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16079. _this.events = {};
  16080. _this.name = name;
  16081. _this.socket = socket;
  16082. _this.options = options;
  16083. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16084. _this.subscribe();
  16085. _this.configureReconnector();
  16086. return _this;
  16087. }
  16088. /**
  16089. * Subscribe to a Socket.io channel.
  16090. */
  16091. createClass(SocketIoChannel, [{
  16092. key: 'subscribe',
  16093. value: function subscribe() {
  16094. this.socket.emit('subscribe', {
  16095. channel: this.name,
  16096. auth: this.options.auth || {}
  16097. });
  16098. }
  16099. /**
  16100. * Unsubscribe from channel and ubind event callbacks.
  16101. */
  16102. }, {
  16103. key: 'unsubscribe',
  16104. value: function unsubscribe() {
  16105. this.unbind();
  16106. this.socket.emit('unsubscribe', {
  16107. channel: this.name,
  16108. auth: this.options.auth || {}
  16109. });
  16110. }
  16111. /**
  16112. * Listen for an event on the channel instance.
  16113. */
  16114. }, {
  16115. key: 'listen',
  16116. value: function listen(event, callback) {
  16117. this.on(this.eventFormatter.format(event), callback);
  16118. return this;
  16119. }
  16120. /**
  16121. * Stop listening for an event on the channel instance.
  16122. */
  16123. }, {
  16124. key: 'stopListening',
  16125. value: function stopListening(event) {
  16126. var name = this.eventFormatter.format(event);
  16127. this.socket.removeListener(name);
  16128. delete this.events[name];
  16129. return this;
  16130. }
  16131. /**
  16132. * Bind the channel's socket to an event and store the callback.
  16133. */
  16134. }, {
  16135. key: 'on',
  16136. value: function on(event, callback) {
  16137. var _this2 = this;
  16138. var listener = function listener(channel, data) {
  16139. if (_this2.name == channel) {
  16140. callback(data);
  16141. }
  16142. };
  16143. this.socket.on(event, listener);
  16144. this.bind(event, listener);
  16145. }
  16146. /**
  16147. * Attach a 'reconnect' listener and bind the event.
  16148. */
  16149. }, {
  16150. key: 'configureReconnector',
  16151. value: function configureReconnector() {
  16152. var _this3 = this;
  16153. var listener = function listener() {
  16154. _this3.subscribe();
  16155. };
  16156. this.socket.on('reconnect', listener);
  16157. this.bind('reconnect', listener);
  16158. }
  16159. /**
  16160. * Bind the channel's socket to an event and store the callback.
  16161. */
  16162. }, {
  16163. key: 'bind',
  16164. value: function bind(event, callback) {
  16165. this.events[event] = this.events[event] || [];
  16166. this.events[event].push(callback);
  16167. }
  16168. /**
  16169. * Unbind the channel's socket from all stored event callbacks.
  16170. */
  16171. }, {
  16172. key: 'unbind',
  16173. value: function unbind() {
  16174. var _this4 = this;
  16175. Object.keys(this.events).forEach(function (event) {
  16176. _this4.events[event].forEach(function (callback) {
  16177. _this4.socket.removeListener(event, callback);
  16178. });
  16179. delete _this4.events[event];
  16180. });
  16181. }
  16182. }]);
  16183. return SocketIoChannel;
  16184. }(Channel);
  16185. /**
  16186. * This class represents a Socket.io presence channel.
  16187. */
  16188. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16189. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16190. function SocketIoPrivateChannel() {
  16191. classCallCheck(this, SocketIoPrivateChannel);
  16192. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16193. }
  16194. createClass(SocketIoPrivateChannel, [{
  16195. key: 'whisper',
  16196. /**
  16197. * Trigger client event on the channel.
  16198. */
  16199. value: function whisper(eventName, data) {
  16200. this.socket.emit('client event', {
  16201. channel: this.name,
  16202. event: 'client-' + eventName,
  16203. data: data
  16204. });
  16205. return this;
  16206. }
  16207. }]);
  16208. return SocketIoPrivateChannel;
  16209. }(SocketIoChannel);
  16210. /**
  16211. * This class represents a Socket.io presence channel.
  16212. */
  16213. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16214. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16215. function SocketIoPresenceChannel() {
  16216. classCallCheck(this, SocketIoPresenceChannel);
  16217. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16218. }
  16219. createClass(SocketIoPresenceChannel, [{
  16220. key: 'here',
  16221. /**
  16222. * Register a callback to be called anytime the member list changes.
  16223. */
  16224. value: function here(callback) {
  16225. this.on('presence:subscribed', function (members) {
  16226. callback(members.map(function (m) {
  16227. return m.user_info;
  16228. }));
  16229. });
  16230. return this;
  16231. }
  16232. /**
  16233. * Listen for someone joining the channel.
  16234. */
  16235. }, {
  16236. key: 'joining',
  16237. value: function joining(callback) {
  16238. this.on('presence:joining', function (member) {
  16239. return callback(member.user_info);
  16240. });
  16241. return this;
  16242. }
  16243. /**
  16244. * Listen for someone leaving the channel.
  16245. */
  16246. }, {
  16247. key: 'leaving',
  16248. value: function leaving(callback) {
  16249. this.on('presence:leaving', function (member) {
  16250. return callback(member.user_info);
  16251. });
  16252. return this;
  16253. }
  16254. }]);
  16255. return SocketIoPresenceChannel;
  16256. }(SocketIoPrivateChannel);
  16257. /**
  16258. * This class represents a null channel.
  16259. */
  16260. var NullChannel = function (_Channel) {
  16261. inherits(NullChannel, _Channel);
  16262. function NullChannel() {
  16263. classCallCheck(this, NullChannel);
  16264. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16265. }
  16266. createClass(NullChannel, [{
  16267. key: 'subscribe',
  16268. /**
  16269. * Subscribe to a channel.
  16270. */
  16271. value: function subscribe() {}
  16272. //
  16273. /**
  16274. * Unsubscribe from a channel.
  16275. */
  16276. }, {
  16277. key: 'unsubscribe',
  16278. value: function unsubscribe() {}
  16279. //
  16280. /**
  16281. * Listen for an event on the channel instance.
  16282. */
  16283. }, {
  16284. key: 'listen',
  16285. value: function listen(event, callback) {
  16286. return this;
  16287. }
  16288. /**
  16289. * Stop listening for an event on the channel instance.
  16290. */
  16291. }, {
  16292. key: 'stopListening',
  16293. value: function stopListening(event) {
  16294. return this;
  16295. }
  16296. /**
  16297. * Bind a channel to an event.
  16298. */
  16299. }, {
  16300. key: 'on',
  16301. value: function on(event, callback) {
  16302. return this;
  16303. }
  16304. }]);
  16305. return NullChannel;
  16306. }(Channel);
  16307. /**
  16308. * This class represents a null private channel.
  16309. */
  16310. var NullPrivateChannel = function (_NullChannel) {
  16311. inherits(NullPrivateChannel, _NullChannel);
  16312. function NullPrivateChannel() {
  16313. classCallCheck(this, NullPrivateChannel);
  16314. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16315. }
  16316. createClass(NullPrivateChannel, [{
  16317. key: 'whisper',
  16318. /**
  16319. * Trigger client event on the channel.
  16320. */
  16321. value: function whisper(eventName, data) {
  16322. return this;
  16323. }
  16324. }]);
  16325. return NullPrivateChannel;
  16326. }(NullChannel);
  16327. /**
  16328. * This class represents a null presence channel.
  16329. */
  16330. var NullPresenceChannel = function (_NullChannel) {
  16331. inherits(NullPresenceChannel, _NullChannel);
  16332. function NullPresenceChannel() {
  16333. classCallCheck(this, NullPresenceChannel);
  16334. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16335. }
  16336. createClass(NullPresenceChannel, [{
  16337. key: 'here',
  16338. /**
  16339. * Register a callback to be called anytime the member list changes.
  16340. */
  16341. value: function here(callback) {
  16342. return this;
  16343. }
  16344. /**
  16345. * Listen for someone joining the channel.
  16346. */
  16347. }, {
  16348. key: 'joining',
  16349. value: function joining(callback) {
  16350. return this;
  16351. }
  16352. /**
  16353. * Listen for someone leaving the channel.
  16354. */
  16355. }, {
  16356. key: 'leaving',
  16357. value: function leaving(callback) {
  16358. return this;
  16359. }
  16360. /**
  16361. * Trigger client event on the channel.
  16362. */
  16363. }, {
  16364. key: 'whisper',
  16365. value: function whisper(eventName, data) {
  16366. return this;
  16367. }
  16368. }]);
  16369. return NullPresenceChannel;
  16370. }(NullChannel);
  16371. /**
  16372. * This class creates a connector to Pusher.
  16373. */
  16374. var PusherConnector = function (_Connector) {
  16375. inherits(PusherConnector, _Connector);
  16376. function PusherConnector() {
  16377. classCallCheck(this, PusherConnector);
  16378. /**
  16379. * All of the subscribed channel names.
  16380. */
  16381. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16382. _this.channels = {};
  16383. return _this;
  16384. }
  16385. /**
  16386. * Create a fresh Pusher connection.
  16387. */
  16388. createClass(PusherConnector, [{
  16389. key: 'connect',
  16390. value: function connect() {
  16391. if (typeof this.options.client !== 'undefined') {
  16392. this.pusher = this.options.client;
  16393. } else {
  16394. this.pusher = new Pusher(this.options.key, this.options);
  16395. }
  16396. }
  16397. /**
  16398. * Listen for an event on a channel instance.
  16399. */
  16400. }, {
  16401. key: 'listen',
  16402. value: function listen(name, event, callback) {
  16403. return this.channel(name).listen(event, callback);
  16404. }
  16405. /**
  16406. * Get a channel instance by name.
  16407. */
  16408. }, {
  16409. key: 'channel',
  16410. value: function channel(name) {
  16411. if (!this.channels[name]) {
  16412. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16413. }
  16414. return this.channels[name];
  16415. }
  16416. /**
  16417. * Get a private channel instance by name.
  16418. */
  16419. }, {
  16420. key: 'privateChannel',
  16421. value: function privateChannel(name) {
  16422. if (!this.channels['private-' + name]) {
  16423. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16424. }
  16425. return this.channels['private-' + name];
  16426. }
  16427. /**
  16428. * Get a presence channel instance by name.
  16429. */
  16430. }, {
  16431. key: 'presenceChannel',
  16432. value: function presenceChannel(name) {
  16433. if (!this.channels['presence-' + name]) {
  16434. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16435. }
  16436. return this.channels['presence-' + name];
  16437. }
  16438. /**
  16439. * Leave the given channel, as well as its private and presence variants.
  16440. */
  16441. }, {
  16442. key: 'leave',
  16443. value: function leave(name) {
  16444. var _this2 = this;
  16445. var channels = [name, 'private-' + name, 'presence-' + name];
  16446. channels.forEach(function (name, index) {
  16447. _this2.leaveChannel(name);
  16448. });
  16449. }
  16450. /**
  16451. * Leave the given channel.
  16452. */
  16453. }, {
  16454. key: 'leaveChannel',
  16455. value: function leaveChannel(name) {
  16456. if (this.channels[name]) {
  16457. this.channels[name].unsubscribe();
  16458. delete this.channels[name];
  16459. }
  16460. }
  16461. /**
  16462. * Get the socket ID for the connection.
  16463. */
  16464. }, {
  16465. key: 'socketId',
  16466. value: function socketId() {
  16467. return this.pusher.connection.socket_id;
  16468. }
  16469. /**
  16470. * Disconnect Pusher connection.
  16471. */
  16472. }, {
  16473. key: 'disconnect',
  16474. value: function disconnect() {
  16475. this.pusher.disconnect();
  16476. }
  16477. }]);
  16478. return PusherConnector;
  16479. }(Connector);
  16480. /**
  16481. * This class creates a connnector to a Socket.io server.
  16482. */
  16483. var SocketIoConnector = function (_Connector) {
  16484. inherits(SocketIoConnector, _Connector);
  16485. function SocketIoConnector() {
  16486. classCallCheck(this, SocketIoConnector);
  16487. /**
  16488. * All of the subscribed channel names.
  16489. */
  16490. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16491. _this.channels = {};
  16492. return _this;
  16493. }
  16494. /**
  16495. * Create a fresh Socket.io connection.
  16496. */
  16497. createClass(SocketIoConnector, [{
  16498. key: 'connect',
  16499. value: function connect() {
  16500. var io = this.getSocketIO();
  16501. this.socket = io(this.options.host, this.options);
  16502. return this.socket;
  16503. }
  16504. /**
  16505. * Get socket.io module from global scope or options.
  16506. */
  16507. }, {
  16508. key: 'getSocketIO',
  16509. value: function getSocketIO() {
  16510. if (typeof this.options.client !== 'undefined') {
  16511. return this.options.client;
  16512. }
  16513. if (typeof io !== 'undefined') {
  16514. return io;
  16515. }
  16516. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16517. }
  16518. /**
  16519. * Listen for an event on a channel instance.
  16520. */
  16521. }, {
  16522. key: 'listen',
  16523. value: function listen(name, event, callback) {
  16524. return this.channel(name).listen(event, callback);
  16525. }
  16526. /**
  16527. * Get a channel instance by name.
  16528. */
  16529. }, {
  16530. key: 'channel',
  16531. value: function channel(name) {
  16532. if (!this.channels[name]) {
  16533. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16534. }
  16535. return this.channels[name];
  16536. }
  16537. /**
  16538. * Get a private channel instance by name.
  16539. */
  16540. }, {
  16541. key: 'privateChannel',
  16542. value: function privateChannel(name) {
  16543. if (!this.channels['private-' + name]) {
  16544. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16545. }
  16546. return this.channels['private-' + name];
  16547. }
  16548. /**
  16549. * Get a presence channel instance by name.
  16550. */
  16551. }, {
  16552. key: 'presenceChannel',
  16553. value: function presenceChannel(name) {
  16554. if (!this.channels['presence-' + name]) {
  16555. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16556. }
  16557. return this.channels['presence-' + name];
  16558. }
  16559. /**
  16560. * Leave the given channel, as well as its private and presence variants.
  16561. */
  16562. }, {
  16563. key: 'leave',
  16564. value: function leave(name) {
  16565. var _this2 = this;
  16566. var channels = [name, 'private-' + name, 'presence-' + name];
  16567. channels.forEach(function (name) {
  16568. _this2.leaveChannel(name);
  16569. });
  16570. }
  16571. /**
  16572. * Leave the given channel.
  16573. */
  16574. }, {
  16575. key: 'leaveChannel',
  16576. value: function leaveChannel(name) {
  16577. if (this.channels[name]) {
  16578. this.channels[name].unsubscribe();
  16579. delete this.channels[name];
  16580. }
  16581. }
  16582. /**
  16583. * Get the socket ID for the connection.
  16584. */
  16585. }, {
  16586. key: 'socketId',
  16587. value: function socketId() {
  16588. return this.socket.id;
  16589. }
  16590. /**
  16591. * Disconnect Socketio connection.
  16592. */
  16593. }, {
  16594. key: 'disconnect',
  16595. value: function disconnect() {
  16596. this.socket.disconnect();
  16597. }
  16598. }]);
  16599. return SocketIoConnector;
  16600. }(Connector);
  16601. /**
  16602. * This class creates a null connector.
  16603. */
  16604. var NullConnector = function (_Connector) {
  16605. inherits(NullConnector, _Connector);
  16606. function NullConnector() {
  16607. classCallCheck(this, NullConnector);
  16608. /**
  16609. * All of the subscribed channel names.
  16610. */
  16611. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16612. _this.channels = {};
  16613. return _this;
  16614. }
  16615. /**
  16616. * Create a fresh connection.
  16617. */
  16618. createClass(NullConnector, [{
  16619. key: 'connect',
  16620. value: function connect() {}
  16621. //
  16622. /**
  16623. * Listen for an event on a channel instance.
  16624. */
  16625. }, {
  16626. key: 'listen',
  16627. value: function listen(name, event, callback) {
  16628. return new NullChannel();
  16629. }
  16630. /**
  16631. * Get a channel instance by name.
  16632. */
  16633. }, {
  16634. key: 'channel',
  16635. value: function channel(name) {
  16636. return new NullChannel();
  16637. }
  16638. /**
  16639. * Get a private channel instance by name.
  16640. */
  16641. }, {
  16642. key: 'privateChannel',
  16643. value: function privateChannel(name) {
  16644. return new NullPrivateChannel();
  16645. }
  16646. /**
  16647. * Get a presence channel instance by name.
  16648. */
  16649. }, {
  16650. key: 'presenceChannel',
  16651. value: function presenceChannel(name) {
  16652. return new NullPresenceChannel();
  16653. }
  16654. /**
  16655. * Leave the given channel, as well as its private and presence variants.
  16656. */
  16657. }, {
  16658. key: 'leave',
  16659. value: function leave(name) {}
  16660. //
  16661. /**
  16662. * Leave the given channel.
  16663. */
  16664. }, {
  16665. key: 'leaveChannel',
  16666. value: function leaveChannel(name) {}
  16667. //
  16668. /**
  16669. * Get the socket ID for the connection.
  16670. */
  16671. }, {
  16672. key: 'socketId',
  16673. value: function socketId() {
  16674. return 'fake-socket-id';
  16675. }
  16676. /**
  16677. * Disconnect the connection.
  16678. */
  16679. }, {
  16680. key: 'disconnect',
  16681. value: function disconnect() {
  16682. //
  16683. }
  16684. }]);
  16685. return NullConnector;
  16686. }(Connector);
  16687. /**
  16688. * This class is the primary API for interacting with broadcasting.
  16689. */
  16690. var Echo = function () {
  16691. /**
  16692. * Create a new class instance.
  16693. */
  16694. function Echo(options) {
  16695. classCallCheck(this, Echo);
  16696. this.options = options;
  16697. this.connect();
  16698. if (!this.options.withoutInterceptors) {
  16699. this.registerInterceptors();
  16700. }
  16701. }
  16702. /**
  16703. * Get a channel instance by name.
  16704. */
  16705. createClass(Echo, [{
  16706. key: 'channel',
  16707. value: function channel(_channel) {
  16708. return this.connector.channel(_channel);
  16709. }
  16710. /**
  16711. * Create a new connection.
  16712. */
  16713. }, {
  16714. key: 'connect',
  16715. value: function connect() {
  16716. if (this.options.broadcaster == 'pusher') {
  16717. this.connector = new PusherConnector(this.options);
  16718. } else if (this.options.broadcaster == 'socket.io') {
  16719. this.connector = new SocketIoConnector(this.options);
  16720. } else if (this.options.broadcaster == 'null') {
  16721. this.connector = new NullConnector(this.options);
  16722. } else if (typeof this.options.broadcaster == 'function') {
  16723. this.connector = new this.options.broadcaster(this.options);
  16724. }
  16725. }
  16726. /**
  16727. * Disconnect from the Echo server.
  16728. */
  16729. }, {
  16730. key: 'disconnect',
  16731. value: function disconnect() {
  16732. this.connector.disconnect();
  16733. }
  16734. /**
  16735. * Get a presence channel instance by name.
  16736. */
  16737. }, {
  16738. key: 'join',
  16739. value: function join(channel) {
  16740. return this.connector.presenceChannel(channel);
  16741. }
  16742. /**
  16743. * Leave the given channel, as well as its private and presence variants.
  16744. */
  16745. }, {
  16746. key: 'leave',
  16747. value: function leave(channel) {
  16748. this.connector.leave(channel);
  16749. }
  16750. /**
  16751. * Leave the given channel.
  16752. */
  16753. }, {
  16754. key: 'leaveChannel',
  16755. value: function leaveChannel(channel) {
  16756. this.connector.leaveChannel(channel);
  16757. }
  16758. /**
  16759. * Listen for an event on a channel instance.
  16760. */
  16761. }, {
  16762. key: 'listen',
  16763. value: function listen(channel, event, callback) {
  16764. return this.connector.listen(channel, event, callback);
  16765. }
  16766. /**
  16767. * Get a private channel instance by name.
  16768. */
  16769. }, {
  16770. key: 'private',
  16771. value: function _private(channel) {
  16772. return this.connector.privateChannel(channel);
  16773. }
  16774. /**
  16775. * Get the Socket ID for the connection.
  16776. */
  16777. }, {
  16778. key: 'socketId',
  16779. value: function socketId() {
  16780. return this.connector.socketId();
  16781. }
  16782. /**
  16783. * Register 3rd party request interceptiors. These are used to automatically
  16784. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16785. */
  16786. }, {
  16787. key: 'registerInterceptors',
  16788. value: function registerInterceptors() {
  16789. if (typeof Vue === 'function' && Vue.http) {
  16790. this.registerVueRequestInterceptor();
  16791. }
  16792. if (typeof axios === 'function') {
  16793. this.registerAxiosRequestInterceptor();
  16794. }
  16795. if (typeof jQuery === 'function') {
  16796. this.registerjQueryAjaxSetup();
  16797. }
  16798. }
  16799. /**
  16800. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16801. */
  16802. }, {
  16803. key: 'registerVueRequestInterceptor',
  16804. value: function registerVueRequestInterceptor() {
  16805. var _this = this;
  16806. Vue.http.interceptors.push(function (request, next) {
  16807. if (_this.socketId()) {
  16808. request.headers.set('X-Socket-ID', _this.socketId());
  16809. }
  16810. next();
  16811. });
  16812. }
  16813. /**
  16814. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16815. */
  16816. }, {
  16817. key: 'registerAxiosRequestInterceptor',
  16818. value: function registerAxiosRequestInterceptor() {
  16819. var _this2 = this;
  16820. axios.interceptors.request.use(function (config) {
  16821. if (_this2.socketId()) {
  16822. config.headers['X-Socket-Id'] = _this2.socketId();
  16823. }
  16824. return config;
  16825. });
  16826. }
  16827. /**
  16828. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16829. */
  16830. }, {
  16831. key: 'registerjQueryAjaxSetup',
  16832. value: function registerjQueryAjaxSetup() {
  16833. var _this3 = this;
  16834. if (typeof jQuery.ajax != 'undefined') {
  16835. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16836. if (_this3.socketId()) {
  16837. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16838. }
  16839. });
  16840. }
  16841. }
  16842. }]);
  16843. return Echo;
  16844. }();
  16845. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16846. /***/ }),
  16847. /***/ "./node_modules/lodash/lodash.js":
  16848. /*!***************************************!*\
  16849. !*** ./node_modules/lodash/lodash.js ***!
  16850. \***************************************/
  16851. /*! no static exports found */
  16852. /***/ (function(module, exports, __webpack_require__) {
  16853. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16854. * @license
  16855. * Lodash <https://lodash.com/>
  16856. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16857. * Released under MIT license <https://lodash.com/license>
  16858. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16859. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16860. */
  16861. ;(function() {
  16862. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16863. var undefined;
  16864. /** Used as the semantic version number. */
  16865. var VERSION = '4.17.15';
  16866. /** Used as the size to enable large array optimizations. */
  16867. var LARGE_ARRAY_SIZE = 200;
  16868. /** Error message constants. */
  16869. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16870. FUNC_ERROR_TEXT = 'Expected a function';
  16871. /** Used to stand-in for `undefined` hash values. */
  16872. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16873. /** Used as the maximum memoize cache size. */
  16874. var MAX_MEMOIZE_SIZE = 500;
  16875. /** Used as the internal argument placeholder. */
  16876. var PLACEHOLDER = '__lodash_placeholder__';
  16877. /** Used to compose bitmasks for cloning. */
  16878. var CLONE_DEEP_FLAG = 1,
  16879. CLONE_FLAT_FLAG = 2,
  16880. CLONE_SYMBOLS_FLAG = 4;
  16881. /** Used to compose bitmasks for value comparisons. */
  16882. var COMPARE_PARTIAL_FLAG = 1,
  16883. COMPARE_UNORDERED_FLAG = 2;
  16884. /** Used to compose bitmasks for function metadata. */
  16885. var WRAP_BIND_FLAG = 1,
  16886. WRAP_BIND_KEY_FLAG = 2,
  16887. WRAP_CURRY_BOUND_FLAG = 4,
  16888. WRAP_CURRY_FLAG = 8,
  16889. WRAP_CURRY_RIGHT_FLAG = 16,
  16890. WRAP_PARTIAL_FLAG = 32,
  16891. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16892. WRAP_ARY_FLAG = 128,
  16893. WRAP_REARG_FLAG = 256,
  16894. WRAP_FLIP_FLAG = 512;
  16895. /** Used as default options for `_.truncate`. */
  16896. var DEFAULT_TRUNC_LENGTH = 30,
  16897. DEFAULT_TRUNC_OMISSION = '...';
  16898. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16899. var HOT_COUNT = 800,
  16900. HOT_SPAN = 16;
  16901. /** Used to indicate the type of lazy iteratees. */
  16902. var LAZY_FILTER_FLAG = 1,
  16903. LAZY_MAP_FLAG = 2,
  16904. LAZY_WHILE_FLAG = 3;
  16905. /** Used as references for various `Number` constants. */
  16906. var INFINITY = 1 / 0,
  16907. MAX_SAFE_INTEGER = 9007199254740991,
  16908. MAX_INTEGER = 1.7976931348623157e+308,
  16909. NAN = 0 / 0;
  16910. /** Used as references for the maximum length and index of an array. */
  16911. var MAX_ARRAY_LENGTH = 4294967295,
  16912. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16913. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16914. /** Used to associate wrap methods with their bit flags. */
  16915. var wrapFlags = [
  16916. ['ary', WRAP_ARY_FLAG],
  16917. ['bind', WRAP_BIND_FLAG],
  16918. ['bindKey', WRAP_BIND_KEY_FLAG],
  16919. ['curry', WRAP_CURRY_FLAG],
  16920. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16921. ['flip', WRAP_FLIP_FLAG],
  16922. ['partial', WRAP_PARTIAL_FLAG],
  16923. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16924. ['rearg', WRAP_REARG_FLAG]
  16925. ];
  16926. /** `Object#toString` result references. */
  16927. var argsTag = '[object Arguments]',
  16928. arrayTag = '[object Array]',
  16929. asyncTag = '[object AsyncFunction]',
  16930. boolTag = '[object Boolean]',
  16931. dateTag = '[object Date]',
  16932. domExcTag = '[object DOMException]',
  16933. errorTag = '[object Error]',
  16934. funcTag = '[object Function]',
  16935. genTag = '[object GeneratorFunction]',
  16936. mapTag = '[object Map]',
  16937. numberTag = '[object Number]',
  16938. nullTag = '[object Null]',
  16939. objectTag = '[object Object]',
  16940. promiseTag = '[object Promise]',
  16941. proxyTag = '[object Proxy]',
  16942. regexpTag = '[object RegExp]',
  16943. setTag = '[object Set]',
  16944. stringTag = '[object String]',
  16945. symbolTag = '[object Symbol]',
  16946. undefinedTag = '[object Undefined]',
  16947. weakMapTag = '[object WeakMap]',
  16948. weakSetTag = '[object WeakSet]';
  16949. var arrayBufferTag = '[object ArrayBuffer]',
  16950. dataViewTag = '[object DataView]',
  16951. float32Tag = '[object Float32Array]',
  16952. float64Tag = '[object Float64Array]',
  16953. int8Tag = '[object Int8Array]',
  16954. int16Tag = '[object Int16Array]',
  16955. int32Tag = '[object Int32Array]',
  16956. uint8Tag = '[object Uint8Array]',
  16957. uint8ClampedTag = '[object Uint8ClampedArray]',
  16958. uint16Tag = '[object Uint16Array]',
  16959. uint32Tag = '[object Uint32Array]';
  16960. /** Used to match empty string literals in compiled template source. */
  16961. var reEmptyStringLeading = /\b__p \+= '';/g,
  16962. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16963. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16964. /** Used to match HTML entities and HTML characters. */
  16965. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16966. reUnescapedHtml = /[&<>"']/g,
  16967. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16968. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16969. /** Used to match template delimiters. */
  16970. var reEscape = /<%-([\s\S]+?)%>/g,
  16971. reEvaluate = /<%([\s\S]+?)%>/g,
  16972. reInterpolate = /<%=([\s\S]+?)%>/g;
  16973. /** Used to match property names within property paths. */
  16974. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16975. reIsPlainProp = /^\w*$/,
  16976. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16977. /**
  16978. * Used to match `RegExp`
  16979. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16980. */
  16981. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16982. reHasRegExpChar = RegExp(reRegExpChar.source);
  16983. /** Used to match leading and trailing whitespace. */
  16984. var reTrim = /^\s+|\s+$/g,
  16985. reTrimStart = /^\s+/,
  16986. reTrimEnd = /\s+$/;
  16987. /** Used to match wrap detail comments. */
  16988. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16989. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16990. reSplitDetails = /,? & /;
  16991. /** Used to match words composed of alphanumeric characters. */
  16992. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16993. /** Used to match backslashes in property paths. */
  16994. var reEscapeChar = /\\(\\)?/g;
  16995. /**
  16996. * Used to match
  16997. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16998. */
  16999. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17000. /** Used to match `RegExp` flags from their coerced string values. */
  17001. var reFlags = /\w*$/;
  17002. /** Used to detect bad signed hexadecimal string values. */
  17003. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17004. /** Used to detect binary string values. */
  17005. var reIsBinary = /^0b[01]+$/i;
  17006. /** Used to detect host constructors (Safari). */
  17007. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17008. /** Used to detect octal string values. */
  17009. var reIsOctal = /^0o[0-7]+$/i;
  17010. /** Used to detect unsigned integer values. */
  17011. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17012. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17013. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17014. /** Used to ensure capturing order of template delimiters. */
  17015. var reNoMatch = /($^)/;
  17016. /** Used to match unescaped characters in compiled string literals. */
  17017. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17018. /** Used to compose unicode character classes. */
  17019. var rsAstralRange = '\\ud800-\\udfff',
  17020. rsComboMarksRange = '\\u0300-\\u036f',
  17021. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17022. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17023. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17024. rsDingbatRange = '\\u2700-\\u27bf',
  17025. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17026. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17027. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17028. rsPunctuationRange = '\\u2000-\\u206f',
  17029. 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',
  17030. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17031. rsVarRange = '\\ufe0e\\ufe0f',
  17032. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17033. /** Used to compose unicode capture groups. */
  17034. var rsApos = "['\u2019]",
  17035. rsAstral = '[' + rsAstralRange + ']',
  17036. rsBreak = '[' + rsBreakRange + ']',
  17037. rsCombo = '[' + rsComboRange + ']',
  17038. rsDigits = '\\d+',
  17039. rsDingbat = '[' + rsDingbatRange + ']',
  17040. rsLower = '[' + rsLowerRange + ']',
  17041. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17042. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17043. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17044. rsNonAstral = '[^' + rsAstralRange + ']',
  17045. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17046. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17047. rsUpper = '[' + rsUpperRange + ']',
  17048. rsZWJ = '\\u200d';
  17049. /** Used to compose unicode regexes. */
  17050. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17051. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17052. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17053. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17054. reOptMod = rsModifier + '?',
  17055. rsOptVar = '[' + rsVarRange + ']?',
  17056. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17057. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17058. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17059. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17060. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17061. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17062. /** Used to match apostrophes. */
  17063. var reApos = RegExp(rsApos, 'g');
  17064. /**
  17065. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17066. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17067. */
  17068. var reComboMark = RegExp(rsCombo, 'g');
  17069. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17070. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17071. /** Used to match complex or compound words. */
  17072. var reUnicodeWord = RegExp([
  17073. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17074. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17075. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17076. rsUpper + '+' + rsOptContrUpper,
  17077. rsOrdUpper,
  17078. rsOrdLower,
  17079. rsDigits,
  17080. rsEmoji
  17081. ].join('|'), 'g');
  17082. /** 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/). */
  17083. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17084. /** Used to detect strings that need a more robust regexp to match words. */
  17085. 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 ]/;
  17086. /** Used to assign default `context` object properties. */
  17087. var contextProps = [
  17088. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17089. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17090. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17091. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17092. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17093. ];
  17094. /** Used to make template sourceURLs easier to identify. */
  17095. var templateCounter = -1;
  17096. /** Used to identify `toStringTag` values of typed arrays. */
  17097. var typedArrayTags = {};
  17098. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17099. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17100. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17101. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17102. typedArrayTags[uint32Tag] = true;
  17103. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17104. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17105. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17106. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17107. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17108. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17109. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17110. typedArrayTags[weakMapTag] = false;
  17111. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17112. var cloneableTags = {};
  17113. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17114. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17115. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17116. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17117. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17118. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17119. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17120. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17121. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17122. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17123. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17124. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17125. cloneableTags[weakMapTag] = false;
  17126. /** Used to map Latin Unicode letters to basic Latin letters. */
  17127. var deburredLetters = {
  17128. // Latin-1 Supplement block.
  17129. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17130. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17131. '\xc7': 'C', '\xe7': 'c',
  17132. '\xd0': 'D', '\xf0': 'd',
  17133. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17134. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17135. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17136. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17137. '\xd1': 'N', '\xf1': 'n',
  17138. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17139. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17140. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17141. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17142. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17143. '\xc6': 'Ae', '\xe6': 'ae',
  17144. '\xde': 'Th', '\xfe': 'th',
  17145. '\xdf': 'ss',
  17146. // Latin Extended-A block.
  17147. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17148. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17149. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17150. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17151. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17152. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17153. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17154. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17155. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17156. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17157. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17158. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17159. '\u0134': 'J', '\u0135': 'j',
  17160. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17161. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17162. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17163. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17164. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17165. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17166. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17167. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17168. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17169. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17170. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17171. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17172. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17173. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17174. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17175. '\u0174': 'W', '\u0175': 'w',
  17176. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17177. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17178. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17179. '\u0132': 'IJ', '\u0133': 'ij',
  17180. '\u0152': 'Oe', '\u0153': 'oe',
  17181. '\u0149': "'n", '\u017f': 's'
  17182. };
  17183. /** Used to map characters to HTML entities. */
  17184. var htmlEscapes = {
  17185. '&': '&amp;',
  17186. '<': '&lt;',
  17187. '>': '&gt;',
  17188. '"': '&quot;',
  17189. "'": '&#39;'
  17190. };
  17191. /** Used to map HTML entities to characters. */
  17192. var htmlUnescapes = {
  17193. '&amp;': '&',
  17194. '&lt;': '<',
  17195. '&gt;': '>',
  17196. '&quot;': '"',
  17197. '&#39;': "'"
  17198. };
  17199. /** Used to escape characters for inclusion in compiled string literals. */
  17200. var stringEscapes = {
  17201. '\\': '\\',
  17202. "'": "'",
  17203. '\n': 'n',
  17204. '\r': 'r',
  17205. '\u2028': 'u2028',
  17206. '\u2029': 'u2029'
  17207. };
  17208. /** Built-in method references without a dependency on `root`. */
  17209. var freeParseFloat = parseFloat,
  17210. freeParseInt = parseInt;
  17211. /** Detect free variable `global` from Node.js. */
  17212. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17213. /** Detect free variable `self`. */
  17214. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17215. /** Used as a reference to the global object. */
  17216. var root = freeGlobal || freeSelf || Function('return this')();
  17217. /** Detect free variable `exports`. */
  17218. var freeExports = true && exports && !exports.nodeType && exports;
  17219. /** Detect free variable `module`. */
  17220. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17221. /** Detect the popular CommonJS extension `module.exports`. */
  17222. var moduleExports = freeModule && freeModule.exports === freeExports;
  17223. /** Detect free variable `process` from Node.js. */
  17224. var freeProcess = moduleExports && freeGlobal.process;
  17225. /** Used to access faster Node.js helpers. */
  17226. var nodeUtil = (function() {
  17227. try {
  17228. // Use `util.types` for Node.js 10+.
  17229. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17230. if (types) {
  17231. return types;
  17232. }
  17233. // Legacy `process.binding('util')` for Node.js < 10.
  17234. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17235. } catch (e) {}
  17236. }());
  17237. /* Node.js helper references. */
  17238. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17239. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17240. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17241. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17242. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17243. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17244. /*--------------------------------------------------------------------------*/
  17245. /**
  17246. * A faster alternative to `Function#apply`, this function invokes `func`
  17247. * with the `this` binding of `thisArg` and the arguments of `args`.
  17248. *
  17249. * @private
  17250. * @param {Function} func The function to invoke.
  17251. * @param {*} thisArg The `this` binding of `func`.
  17252. * @param {Array} args The arguments to invoke `func` with.
  17253. * @returns {*} Returns the result of `func`.
  17254. */
  17255. function apply(func, thisArg, args) {
  17256. switch (args.length) {
  17257. case 0: return func.call(thisArg);
  17258. case 1: return func.call(thisArg, args[0]);
  17259. case 2: return func.call(thisArg, args[0], args[1]);
  17260. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17261. }
  17262. return func.apply(thisArg, args);
  17263. }
  17264. /**
  17265. * A specialized version of `baseAggregator` for arrays.
  17266. *
  17267. * @private
  17268. * @param {Array} [array] The array to iterate over.
  17269. * @param {Function} setter The function to set `accumulator` values.
  17270. * @param {Function} iteratee The iteratee to transform keys.
  17271. * @param {Object} accumulator The initial aggregated object.
  17272. * @returns {Function} Returns `accumulator`.
  17273. */
  17274. function arrayAggregator(array, setter, iteratee, accumulator) {
  17275. var index = -1,
  17276. length = array == null ? 0 : array.length;
  17277. while (++index < length) {
  17278. var value = array[index];
  17279. setter(accumulator, value, iteratee(value), array);
  17280. }
  17281. return accumulator;
  17282. }
  17283. /**
  17284. * A specialized version of `_.forEach` for arrays without support for
  17285. * iteratee shorthands.
  17286. *
  17287. * @private
  17288. * @param {Array} [array] The array to iterate over.
  17289. * @param {Function} iteratee The function invoked per iteration.
  17290. * @returns {Array} Returns `array`.
  17291. */
  17292. function arrayEach(array, iteratee) {
  17293. var index = -1,
  17294. length = array == null ? 0 : array.length;
  17295. while (++index < length) {
  17296. if (iteratee(array[index], index, array) === false) {
  17297. break;
  17298. }
  17299. }
  17300. return array;
  17301. }
  17302. /**
  17303. * A specialized version of `_.forEachRight` for arrays without support for
  17304. * iteratee shorthands.
  17305. *
  17306. * @private
  17307. * @param {Array} [array] The array to iterate over.
  17308. * @param {Function} iteratee The function invoked per iteration.
  17309. * @returns {Array} Returns `array`.
  17310. */
  17311. function arrayEachRight(array, iteratee) {
  17312. var length = array == null ? 0 : array.length;
  17313. while (length--) {
  17314. if (iteratee(array[length], length, array) === false) {
  17315. break;
  17316. }
  17317. }
  17318. return array;
  17319. }
  17320. /**
  17321. * A specialized version of `_.every` for arrays without support for
  17322. * iteratee shorthands.
  17323. *
  17324. * @private
  17325. * @param {Array} [array] The array to iterate over.
  17326. * @param {Function} predicate The function invoked per iteration.
  17327. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17328. * else `false`.
  17329. */
  17330. function arrayEvery(array, predicate) {
  17331. var index = -1,
  17332. length = array == null ? 0 : array.length;
  17333. while (++index < length) {
  17334. if (!predicate(array[index], index, array)) {
  17335. return false;
  17336. }
  17337. }
  17338. return true;
  17339. }
  17340. /**
  17341. * A specialized version of `_.filter` for arrays without support for
  17342. * iteratee shorthands.
  17343. *
  17344. * @private
  17345. * @param {Array} [array] The array to iterate over.
  17346. * @param {Function} predicate The function invoked per iteration.
  17347. * @returns {Array} Returns the new filtered array.
  17348. */
  17349. function arrayFilter(array, predicate) {
  17350. var index = -1,
  17351. length = array == null ? 0 : array.length,
  17352. resIndex = 0,
  17353. result = [];
  17354. while (++index < length) {
  17355. var value = array[index];
  17356. if (predicate(value, index, array)) {
  17357. result[resIndex++] = value;
  17358. }
  17359. }
  17360. return result;
  17361. }
  17362. /**
  17363. * A specialized version of `_.includes` for arrays without support for
  17364. * specifying an index to search from.
  17365. *
  17366. * @private
  17367. * @param {Array} [array] The array to inspect.
  17368. * @param {*} target The value to search for.
  17369. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17370. */
  17371. function arrayIncludes(array, value) {
  17372. var length = array == null ? 0 : array.length;
  17373. return !!length && baseIndexOf(array, value, 0) > -1;
  17374. }
  17375. /**
  17376. * This function is like `arrayIncludes` except that it accepts a comparator.
  17377. *
  17378. * @private
  17379. * @param {Array} [array] The array to inspect.
  17380. * @param {*} target The value to search for.
  17381. * @param {Function} comparator The comparator invoked per element.
  17382. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17383. */
  17384. function arrayIncludesWith(array, value, comparator) {
  17385. var index = -1,
  17386. length = array == null ? 0 : array.length;
  17387. while (++index < length) {
  17388. if (comparator(value, array[index])) {
  17389. return true;
  17390. }
  17391. }
  17392. return false;
  17393. }
  17394. /**
  17395. * A specialized version of `_.map` for arrays without support for iteratee
  17396. * shorthands.
  17397. *
  17398. * @private
  17399. * @param {Array} [array] The array to iterate over.
  17400. * @param {Function} iteratee The function invoked per iteration.
  17401. * @returns {Array} Returns the new mapped array.
  17402. */
  17403. function arrayMap(array, iteratee) {
  17404. var index = -1,
  17405. length = array == null ? 0 : array.length,
  17406. result = Array(length);
  17407. while (++index < length) {
  17408. result[index] = iteratee(array[index], index, array);
  17409. }
  17410. return result;
  17411. }
  17412. /**
  17413. * Appends the elements of `values` to `array`.
  17414. *
  17415. * @private
  17416. * @param {Array} array The array to modify.
  17417. * @param {Array} values The values to append.
  17418. * @returns {Array} Returns `array`.
  17419. */
  17420. function arrayPush(array, values) {
  17421. var index = -1,
  17422. length = values.length,
  17423. offset = array.length;
  17424. while (++index < length) {
  17425. array[offset + index] = values[index];
  17426. }
  17427. return array;
  17428. }
  17429. /**
  17430. * A specialized version of `_.reduce` for arrays without support for
  17431. * iteratee shorthands.
  17432. *
  17433. * @private
  17434. * @param {Array} [array] The array to iterate over.
  17435. * @param {Function} iteratee The function invoked per iteration.
  17436. * @param {*} [accumulator] The initial value.
  17437. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17438. * the initial value.
  17439. * @returns {*} Returns the accumulated value.
  17440. */
  17441. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17442. var index = -1,
  17443. length = array == null ? 0 : array.length;
  17444. if (initAccum && length) {
  17445. accumulator = array[++index];
  17446. }
  17447. while (++index < length) {
  17448. accumulator = iteratee(accumulator, array[index], index, array);
  17449. }
  17450. return accumulator;
  17451. }
  17452. /**
  17453. * A specialized version of `_.reduceRight` for arrays without support for
  17454. * iteratee shorthands.
  17455. *
  17456. * @private
  17457. * @param {Array} [array] The array to iterate over.
  17458. * @param {Function} iteratee The function invoked per iteration.
  17459. * @param {*} [accumulator] The initial value.
  17460. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17461. * the initial value.
  17462. * @returns {*} Returns the accumulated value.
  17463. */
  17464. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17465. var length = array == null ? 0 : array.length;
  17466. if (initAccum && length) {
  17467. accumulator = array[--length];
  17468. }
  17469. while (length--) {
  17470. accumulator = iteratee(accumulator, array[length], length, array);
  17471. }
  17472. return accumulator;
  17473. }
  17474. /**
  17475. * A specialized version of `_.some` for arrays without support for iteratee
  17476. * shorthands.
  17477. *
  17478. * @private
  17479. * @param {Array} [array] The array to iterate over.
  17480. * @param {Function} predicate The function invoked per iteration.
  17481. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17482. * else `false`.
  17483. */
  17484. function arraySome(array, predicate) {
  17485. var index = -1,
  17486. length = array == null ? 0 : array.length;
  17487. while (++index < length) {
  17488. if (predicate(array[index], index, array)) {
  17489. return true;
  17490. }
  17491. }
  17492. return false;
  17493. }
  17494. /**
  17495. * Gets the size of an ASCII `string`.
  17496. *
  17497. * @private
  17498. * @param {string} string The string inspect.
  17499. * @returns {number} Returns the string size.
  17500. */
  17501. var asciiSize = baseProperty('length');
  17502. /**
  17503. * Converts an ASCII `string` to an array.
  17504. *
  17505. * @private
  17506. * @param {string} string The string to convert.
  17507. * @returns {Array} Returns the converted array.
  17508. */
  17509. function asciiToArray(string) {
  17510. return string.split('');
  17511. }
  17512. /**
  17513. * Splits an ASCII `string` into an array of its words.
  17514. *
  17515. * @private
  17516. * @param {string} The string to inspect.
  17517. * @returns {Array} Returns the words of `string`.
  17518. */
  17519. function asciiWords(string) {
  17520. return string.match(reAsciiWord) || [];
  17521. }
  17522. /**
  17523. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17524. * without support for iteratee shorthands, which iterates over `collection`
  17525. * using `eachFunc`.
  17526. *
  17527. * @private
  17528. * @param {Array|Object} collection The collection to inspect.
  17529. * @param {Function} predicate The function invoked per iteration.
  17530. * @param {Function} eachFunc The function to iterate over `collection`.
  17531. * @returns {*} Returns the found element or its key, else `undefined`.
  17532. */
  17533. function baseFindKey(collection, predicate, eachFunc) {
  17534. var result;
  17535. eachFunc(collection, function(value, key, collection) {
  17536. if (predicate(value, key, collection)) {
  17537. result = key;
  17538. return false;
  17539. }
  17540. });
  17541. return result;
  17542. }
  17543. /**
  17544. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17545. * support for iteratee shorthands.
  17546. *
  17547. * @private
  17548. * @param {Array} array The array to inspect.
  17549. * @param {Function} predicate The function invoked per iteration.
  17550. * @param {number} fromIndex The index to search from.
  17551. * @param {boolean} [fromRight] Specify iterating from right to left.
  17552. * @returns {number} Returns the index of the matched value, else `-1`.
  17553. */
  17554. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17555. var length = array.length,
  17556. index = fromIndex + (fromRight ? 1 : -1);
  17557. while ((fromRight ? index-- : ++index < length)) {
  17558. if (predicate(array[index], index, array)) {
  17559. return index;
  17560. }
  17561. }
  17562. return -1;
  17563. }
  17564. /**
  17565. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17566. *
  17567. * @private
  17568. * @param {Array} array The array to inspect.
  17569. * @param {*} value The value to search for.
  17570. * @param {number} fromIndex The index to search from.
  17571. * @returns {number} Returns the index of the matched value, else `-1`.
  17572. */
  17573. function baseIndexOf(array, value, fromIndex) {
  17574. return value === value
  17575. ? strictIndexOf(array, value, fromIndex)
  17576. : baseFindIndex(array, baseIsNaN, fromIndex);
  17577. }
  17578. /**
  17579. * This function is like `baseIndexOf` except that it accepts a comparator.
  17580. *
  17581. * @private
  17582. * @param {Array} array The array to inspect.
  17583. * @param {*} value The value to search for.
  17584. * @param {number} fromIndex The index to search from.
  17585. * @param {Function} comparator The comparator invoked per element.
  17586. * @returns {number} Returns the index of the matched value, else `-1`.
  17587. */
  17588. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17589. var index = fromIndex - 1,
  17590. length = array.length;
  17591. while (++index < length) {
  17592. if (comparator(array[index], value)) {
  17593. return index;
  17594. }
  17595. }
  17596. return -1;
  17597. }
  17598. /**
  17599. * The base implementation of `_.isNaN` without support for number objects.
  17600. *
  17601. * @private
  17602. * @param {*} value The value to check.
  17603. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17604. */
  17605. function baseIsNaN(value) {
  17606. return value !== value;
  17607. }
  17608. /**
  17609. * The base implementation of `_.mean` and `_.meanBy` without support for
  17610. * iteratee shorthands.
  17611. *
  17612. * @private
  17613. * @param {Array} array The array to iterate over.
  17614. * @param {Function} iteratee The function invoked per iteration.
  17615. * @returns {number} Returns the mean.
  17616. */
  17617. function baseMean(array, iteratee) {
  17618. var length = array == null ? 0 : array.length;
  17619. return length ? (baseSum(array, iteratee) / length) : NAN;
  17620. }
  17621. /**
  17622. * The base implementation of `_.property` without support for deep paths.
  17623. *
  17624. * @private
  17625. * @param {string} key The key of the property to get.
  17626. * @returns {Function} Returns the new accessor function.
  17627. */
  17628. function baseProperty(key) {
  17629. return function(object) {
  17630. return object == null ? undefined : object[key];
  17631. };
  17632. }
  17633. /**
  17634. * The base implementation of `_.propertyOf` without support for deep paths.
  17635. *
  17636. * @private
  17637. * @param {Object} object The object to query.
  17638. * @returns {Function} Returns the new accessor function.
  17639. */
  17640. function basePropertyOf(object) {
  17641. return function(key) {
  17642. return object == null ? undefined : object[key];
  17643. };
  17644. }
  17645. /**
  17646. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17647. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17648. *
  17649. * @private
  17650. * @param {Array|Object} collection The collection to iterate over.
  17651. * @param {Function} iteratee The function invoked per iteration.
  17652. * @param {*} accumulator The initial value.
  17653. * @param {boolean} initAccum Specify using the first or last element of
  17654. * `collection` as the initial value.
  17655. * @param {Function} eachFunc The function to iterate over `collection`.
  17656. * @returns {*} Returns the accumulated value.
  17657. */
  17658. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17659. eachFunc(collection, function(value, index, collection) {
  17660. accumulator = initAccum
  17661. ? (initAccum = false, value)
  17662. : iteratee(accumulator, value, index, collection);
  17663. });
  17664. return accumulator;
  17665. }
  17666. /**
  17667. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17668. * sort order of `array` and replaces criteria objects with their corresponding
  17669. * values.
  17670. *
  17671. * @private
  17672. * @param {Array} array The array to sort.
  17673. * @param {Function} comparer The function to define sort order.
  17674. * @returns {Array} Returns `array`.
  17675. */
  17676. function baseSortBy(array, comparer) {
  17677. var length = array.length;
  17678. array.sort(comparer);
  17679. while (length--) {
  17680. array[length] = array[length].value;
  17681. }
  17682. return array;
  17683. }
  17684. /**
  17685. * The base implementation of `_.sum` and `_.sumBy` without support for
  17686. * iteratee shorthands.
  17687. *
  17688. * @private
  17689. * @param {Array} array The array to iterate over.
  17690. * @param {Function} iteratee The function invoked per iteration.
  17691. * @returns {number} Returns the sum.
  17692. */
  17693. function baseSum(array, iteratee) {
  17694. var result,
  17695. index = -1,
  17696. length = array.length;
  17697. while (++index < length) {
  17698. var current = iteratee(array[index]);
  17699. if (current !== undefined) {
  17700. result = result === undefined ? current : (result + current);
  17701. }
  17702. }
  17703. return result;
  17704. }
  17705. /**
  17706. * The base implementation of `_.times` without support for iteratee shorthands
  17707. * or max array length checks.
  17708. *
  17709. * @private
  17710. * @param {number} n The number of times to invoke `iteratee`.
  17711. * @param {Function} iteratee The function invoked per iteration.
  17712. * @returns {Array} Returns the array of results.
  17713. */
  17714. function baseTimes(n, iteratee) {
  17715. var index = -1,
  17716. result = Array(n);
  17717. while (++index < n) {
  17718. result[index] = iteratee(index);
  17719. }
  17720. return result;
  17721. }
  17722. /**
  17723. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17724. * of key-value pairs for `object` corresponding to the property names of `props`.
  17725. *
  17726. * @private
  17727. * @param {Object} object The object to query.
  17728. * @param {Array} props The property names to get values for.
  17729. * @returns {Object} Returns the key-value pairs.
  17730. */
  17731. function baseToPairs(object, props) {
  17732. return arrayMap(props, function(key) {
  17733. return [key, object[key]];
  17734. });
  17735. }
  17736. /**
  17737. * The base implementation of `_.unary` without support for storing metadata.
  17738. *
  17739. * @private
  17740. * @param {Function} func The function to cap arguments for.
  17741. * @returns {Function} Returns the new capped function.
  17742. */
  17743. function baseUnary(func) {
  17744. return function(value) {
  17745. return func(value);
  17746. };
  17747. }
  17748. /**
  17749. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17750. * array of `object` property values corresponding to the property names
  17751. * of `props`.
  17752. *
  17753. * @private
  17754. * @param {Object} object The object to query.
  17755. * @param {Array} props The property names to get values for.
  17756. * @returns {Object} Returns the array of property values.
  17757. */
  17758. function baseValues(object, props) {
  17759. return arrayMap(props, function(key) {
  17760. return object[key];
  17761. });
  17762. }
  17763. /**
  17764. * Checks if a `cache` value for `key` exists.
  17765. *
  17766. * @private
  17767. * @param {Object} cache The cache to query.
  17768. * @param {string} key The key of the entry to check.
  17769. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17770. */
  17771. function cacheHas(cache, key) {
  17772. return cache.has(key);
  17773. }
  17774. /**
  17775. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17776. * that is not found in the character symbols.
  17777. *
  17778. * @private
  17779. * @param {Array} strSymbols The string symbols to inspect.
  17780. * @param {Array} chrSymbols The character symbols to find.
  17781. * @returns {number} Returns the index of the first unmatched string symbol.
  17782. */
  17783. function charsStartIndex(strSymbols, chrSymbols) {
  17784. var index = -1,
  17785. length = strSymbols.length;
  17786. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17787. return index;
  17788. }
  17789. /**
  17790. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17791. * that is not found in the character symbols.
  17792. *
  17793. * @private
  17794. * @param {Array} strSymbols The string symbols to inspect.
  17795. * @param {Array} chrSymbols The character symbols to find.
  17796. * @returns {number} Returns the index of the last unmatched string symbol.
  17797. */
  17798. function charsEndIndex(strSymbols, chrSymbols) {
  17799. var index = strSymbols.length;
  17800. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17801. return index;
  17802. }
  17803. /**
  17804. * Gets the number of `placeholder` occurrences in `array`.
  17805. *
  17806. * @private
  17807. * @param {Array} array The array to inspect.
  17808. * @param {*} placeholder The placeholder to search for.
  17809. * @returns {number} Returns the placeholder count.
  17810. */
  17811. function countHolders(array, placeholder) {
  17812. var length = array.length,
  17813. result = 0;
  17814. while (length--) {
  17815. if (array[length] === placeholder) {
  17816. ++result;
  17817. }
  17818. }
  17819. return result;
  17820. }
  17821. /**
  17822. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17823. * letters to basic Latin letters.
  17824. *
  17825. * @private
  17826. * @param {string} letter The matched letter to deburr.
  17827. * @returns {string} Returns the deburred letter.
  17828. */
  17829. var deburrLetter = basePropertyOf(deburredLetters);
  17830. /**
  17831. * Used by `_.escape` to convert characters to HTML entities.
  17832. *
  17833. * @private
  17834. * @param {string} chr The matched character to escape.
  17835. * @returns {string} Returns the escaped character.
  17836. */
  17837. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17838. /**
  17839. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17840. *
  17841. * @private
  17842. * @param {string} chr The matched character to escape.
  17843. * @returns {string} Returns the escaped character.
  17844. */
  17845. function escapeStringChar(chr) {
  17846. return '\\' + stringEscapes[chr];
  17847. }
  17848. /**
  17849. * Gets the value at `key` of `object`.
  17850. *
  17851. * @private
  17852. * @param {Object} [object] The object to query.
  17853. * @param {string} key The key of the property to get.
  17854. * @returns {*} Returns the property value.
  17855. */
  17856. function getValue(object, key) {
  17857. return object == null ? undefined : object[key];
  17858. }
  17859. /**
  17860. * Checks if `string` contains Unicode symbols.
  17861. *
  17862. * @private
  17863. * @param {string} string The string to inspect.
  17864. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17865. */
  17866. function hasUnicode(string) {
  17867. return reHasUnicode.test(string);
  17868. }
  17869. /**
  17870. * Checks if `string` contains a word composed of Unicode symbols.
  17871. *
  17872. * @private
  17873. * @param {string} string The string to inspect.
  17874. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17875. */
  17876. function hasUnicodeWord(string) {
  17877. return reHasUnicodeWord.test(string);
  17878. }
  17879. /**
  17880. * Converts `iterator` to an array.
  17881. *
  17882. * @private
  17883. * @param {Object} iterator The iterator to convert.
  17884. * @returns {Array} Returns the converted array.
  17885. */
  17886. function iteratorToArray(iterator) {
  17887. var data,
  17888. result = [];
  17889. while (!(data = iterator.next()).done) {
  17890. result.push(data.value);
  17891. }
  17892. return result;
  17893. }
  17894. /**
  17895. * Converts `map` to its key-value pairs.
  17896. *
  17897. * @private
  17898. * @param {Object} map The map to convert.
  17899. * @returns {Array} Returns the key-value pairs.
  17900. */
  17901. function mapToArray(map) {
  17902. var index = -1,
  17903. result = Array(map.size);
  17904. map.forEach(function(value, key) {
  17905. result[++index] = [key, value];
  17906. });
  17907. return result;
  17908. }
  17909. /**
  17910. * Creates a unary function that invokes `func` with its argument transformed.
  17911. *
  17912. * @private
  17913. * @param {Function} func The function to wrap.
  17914. * @param {Function} transform The argument transform.
  17915. * @returns {Function} Returns the new function.
  17916. */
  17917. function overArg(func, transform) {
  17918. return function(arg) {
  17919. return func(transform(arg));
  17920. };
  17921. }
  17922. /**
  17923. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17924. * and returns an array of their indexes.
  17925. *
  17926. * @private
  17927. * @param {Array} array The array to modify.
  17928. * @param {*} placeholder The placeholder to replace.
  17929. * @returns {Array} Returns the new array of placeholder indexes.
  17930. */
  17931. function replaceHolders(array, placeholder) {
  17932. var index = -1,
  17933. length = array.length,
  17934. resIndex = 0,
  17935. result = [];
  17936. while (++index < length) {
  17937. var value = array[index];
  17938. if (value === placeholder || value === PLACEHOLDER) {
  17939. array[index] = PLACEHOLDER;
  17940. result[resIndex++] = index;
  17941. }
  17942. }
  17943. return result;
  17944. }
  17945. /**
  17946. * Converts `set` to an array of its values.
  17947. *
  17948. * @private
  17949. * @param {Object} set The set to convert.
  17950. * @returns {Array} Returns the values.
  17951. */
  17952. function setToArray(set) {
  17953. var index = -1,
  17954. result = Array(set.size);
  17955. set.forEach(function(value) {
  17956. result[++index] = value;
  17957. });
  17958. return result;
  17959. }
  17960. /**
  17961. * Converts `set` to its value-value pairs.
  17962. *
  17963. * @private
  17964. * @param {Object} set The set to convert.
  17965. * @returns {Array} Returns the value-value pairs.
  17966. */
  17967. function setToPairs(set) {
  17968. var index = -1,
  17969. result = Array(set.size);
  17970. set.forEach(function(value) {
  17971. result[++index] = [value, value];
  17972. });
  17973. return result;
  17974. }
  17975. /**
  17976. * A specialized version of `_.indexOf` which performs strict equality
  17977. * comparisons of values, i.e. `===`.
  17978. *
  17979. * @private
  17980. * @param {Array} array The array to inspect.
  17981. * @param {*} value The value to search for.
  17982. * @param {number} fromIndex The index to search from.
  17983. * @returns {number} Returns the index of the matched value, else `-1`.
  17984. */
  17985. function strictIndexOf(array, value, fromIndex) {
  17986. var index = fromIndex - 1,
  17987. length = array.length;
  17988. while (++index < length) {
  17989. if (array[index] === value) {
  17990. return index;
  17991. }
  17992. }
  17993. return -1;
  17994. }
  17995. /**
  17996. * A specialized version of `_.lastIndexOf` which performs strict equality
  17997. * comparisons of values, i.e. `===`.
  17998. *
  17999. * @private
  18000. * @param {Array} array The array to inspect.
  18001. * @param {*} value The value to search for.
  18002. * @param {number} fromIndex The index to search from.
  18003. * @returns {number} Returns the index of the matched value, else `-1`.
  18004. */
  18005. function strictLastIndexOf(array, value, fromIndex) {
  18006. var index = fromIndex + 1;
  18007. while (index--) {
  18008. if (array[index] === value) {
  18009. return index;
  18010. }
  18011. }
  18012. return index;
  18013. }
  18014. /**
  18015. * Gets the number of symbols in `string`.
  18016. *
  18017. * @private
  18018. * @param {string} string The string to inspect.
  18019. * @returns {number} Returns the string size.
  18020. */
  18021. function stringSize(string) {
  18022. return hasUnicode(string)
  18023. ? unicodeSize(string)
  18024. : asciiSize(string);
  18025. }
  18026. /**
  18027. * Converts `string` to an array.
  18028. *
  18029. * @private
  18030. * @param {string} string The string to convert.
  18031. * @returns {Array} Returns the converted array.
  18032. */
  18033. function stringToArray(string) {
  18034. return hasUnicode(string)
  18035. ? unicodeToArray(string)
  18036. : asciiToArray(string);
  18037. }
  18038. /**
  18039. * Used by `_.unescape` to convert HTML entities to characters.
  18040. *
  18041. * @private
  18042. * @param {string} chr The matched character to unescape.
  18043. * @returns {string} Returns the unescaped character.
  18044. */
  18045. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18046. /**
  18047. * Gets the size of a Unicode `string`.
  18048. *
  18049. * @private
  18050. * @param {string} string The string inspect.
  18051. * @returns {number} Returns the string size.
  18052. */
  18053. function unicodeSize(string) {
  18054. var result = reUnicode.lastIndex = 0;
  18055. while (reUnicode.test(string)) {
  18056. ++result;
  18057. }
  18058. return result;
  18059. }
  18060. /**
  18061. * Converts a Unicode `string` to an array.
  18062. *
  18063. * @private
  18064. * @param {string} string The string to convert.
  18065. * @returns {Array} Returns the converted array.
  18066. */
  18067. function unicodeToArray(string) {
  18068. return string.match(reUnicode) || [];
  18069. }
  18070. /**
  18071. * Splits a Unicode `string` into an array of its words.
  18072. *
  18073. * @private
  18074. * @param {string} The string to inspect.
  18075. * @returns {Array} Returns the words of `string`.
  18076. */
  18077. function unicodeWords(string) {
  18078. return string.match(reUnicodeWord) || [];
  18079. }
  18080. /*--------------------------------------------------------------------------*/
  18081. /**
  18082. * Create a new pristine `lodash` function using the `context` object.
  18083. *
  18084. * @static
  18085. * @memberOf _
  18086. * @since 1.1.0
  18087. * @category Util
  18088. * @param {Object} [context=root] The context object.
  18089. * @returns {Function} Returns a new `lodash` function.
  18090. * @example
  18091. *
  18092. * _.mixin({ 'foo': _.constant('foo') });
  18093. *
  18094. * var lodash = _.runInContext();
  18095. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18096. *
  18097. * _.isFunction(_.foo);
  18098. * // => true
  18099. * _.isFunction(_.bar);
  18100. * // => false
  18101. *
  18102. * lodash.isFunction(lodash.foo);
  18103. * // => false
  18104. * lodash.isFunction(lodash.bar);
  18105. * // => true
  18106. *
  18107. * // Create a suped-up `defer` in Node.js.
  18108. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18109. */
  18110. var runInContext = (function runInContext(context) {
  18111. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18112. /** Built-in constructor references. */
  18113. var Array = context.Array,
  18114. Date = context.Date,
  18115. Error = context.Error,
  18116. Function = context.Function,
  18117. Math = context.Math,
  18118. Object = context.Object,
  18119. RegExp = context.RegExp,
  18120. String = context.String,
  18121. TypeError = context.TypeError;
  18122. /** Used for built-in method references. */
  18123. var arrayProto = Array.prototype,
  18124. funcProto = Function.prototype,
  18125. objectProto = Object.prototype;
  18126. /** Used to detect overreaching core-js shims. */
  18127. var coreJsData = context['__core-js_shared__'];
  18128. /** Used to resolve the decompiled source of functions. */
  18129. var funcToString = funcProto.toString;
  18130. /** Used to check objects for own properties. */
  18131. var hasOwnProperty = objectProto.hasOwnProperty;
  18132. /** Used to generate unique IDs. */
  18133. var idCounter = 0;
  18134. /** Used to detect methods masquerading as native. */
  18135. var maskSrcKey = (function() {
  18136. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18137. return uid ? ('Symbol(src)_1.' + uid) : '';
  18138. }());
  18139. /**
  18140. * Used to resolve the
  18141. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18142. * of values.
  18143. */
  18144. var nativeObjectToString = objectProto.toString;
  18145. /** Used to infer the `Object` constructor. */
  18146. var objectCtorString = funcToString.call(Object);
  18147. /** Used to restore the original `_` reference in `_.noConflict`. */
  18148. var oldDash = root._;
  18149. /** Used to detect if a method is native. */
  18150. var reIsNative = RegExp('^' +
  18151. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18152. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18153. );
  18154. /** Built-in value references. */
  18155. var Buffer = moduleExports ? context.Buffer : undefined,
  18156. Symbol = context.Symbol,
  18157. Uint8Array = context.Uint8Array,
  18158. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18159. getPrototype = overArg(Object.getPrototypeOf, Object),
  18160. objectCreate = Object.create,
  18161. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18162. splice = arrayProto.splice,
  18163. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18164. symIterator = Symbol ? Symbol.iterator : undefined,
  18165. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18166. var defineProperty = (function() {
  18167. try {
  18168. var func = getNative(Object, 'defineProperty');
  18169. func({}, '', {});
  18170. return func;
  18171. } catch (e) {}
  18172. }());
  18173. /** Mocked built-ins. */
  18174. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18175. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18176. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18177. /* Built-in method references for those with the same name as other `lodash` methods. */
  18178. var nativeCeil = Math.ceil,
  18179. nativeFloor = Math.floor,
  18180. nativeGetSymbols = Object.getOwnPropertySymbols,
  18181. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18182. nativeIsFinite = context.isFinite,
  18183. nativeJoin = arrayProto.join,
  18184. nativeKeys = overArg(Object.keys, Object),
  18185. nativeMax = Math.max,
  18186. nativeMin = Math.min,
  18187. nativeNow = Date.now,
  18188. nativeParseInt = context.parseInt,
  18189. nativeRandom = Math.random,
  18190. nativeReverse = arrayProto.reverse;
  18191. /* Built-in method references that are verified to be native. */
  18192. var DataView = getNative(context, 'DataView'),
  18193. Map = getNative(context, 'Map'),
  18194. Promise = getNative(context, 'Promise'),
  18195. Set = getNative(context, 'Set'),
  18196. WeakMap = getNative(context, 'WeakMap'),
  18197. nativeCreate = getNative(Object, 'create');
  18198. /** Used to store function metadata. */
  18199. var metaMap = WeakMap && new WeakMap;
  18200. /** Used to lookup unminified function names. */
  18201. var realNames = {};
  18202. /** Used to detect maps, sets, and weakmaps. */
  18203. var dataViewCtorString = toSource(DataView),
  18204. mapCtorString = toSource(Map),
  18205. promiseCtorString = toSource(Promise),
  18206. setCtorString = toSource(Set),
  18207. weakMapCtorString = toSource(WeakMap);
  18208. /** Used to convert symbols to primitives and strings. */
  18209. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18210. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18211. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18212. /*------------------------------------------------------------------------*/
  18213. /**
  18214. * Creates a `lodash` object which wraps `value` to enable implicit method
  18215. * chain sequences. Methods that operate on and return arrays, collections,
  18216. * and functions can be chained together. Methods that retrieve a single value
  18217. * or may return a primitive value will automatically end the chain sequence
  18218. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18219. * with `_#value`.
  18220. *
  18221. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18222. * enabled using `_.chain`.
  18223. *
  18224. * The execution of chained methods is lazy, that is, it's deferred until
  18225. * `_#value` is implicitly or explicitly called.
  18226. *
  18227. * Lazy evaluation allows several methods to support shortcut fusion.
  18228. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18229. * the creation of intermediate arrays and can greatly reduce the number of
  18230. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18231. * fusion if the section is applied to an array and iteratees accept only
  18232. * one argument. The heuristic for whether a section qualifies for shortcut
  18233. * fusion is subject to change.
  18234. *
  18235. * Chaining is supported in custom builds as long as the `_#value` method is
  18236. * directly or indirectly included in the build.
  18237. *
  18238. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18239. *
  18240. * The wrapper `Array` methods are:
  18241. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18242. *
  18243. * The wrapper `String` methods are:
  18244. * `replace` and `split`
  18245. *
  18246. * The wrapper methods that support shortcut fusion are:
  18247. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18248. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18249. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18250. *
  18251. * The chainable wrapper methods are:
  18252. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18253. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18254. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18255. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18256. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18257. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18258. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18259. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18260. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18261. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18262. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18263. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18264. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18265. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18266. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18267. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18268. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18269. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18270. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18271. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18272. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18273. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18274. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18275. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18276. *
  18277. * The wrapper methods that are **not** chainable by default are:
  18278. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18279. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18280. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18281. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18282. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18283. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18284. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18285. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18286. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18287. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18288. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18289. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18290. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18291. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18292. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18293. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18294. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18295. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18296. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18297. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18298. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18299. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18300. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18301. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18302. * `upperFirst`, `value`, and `words`
  18303. *
  18304. * @name _
  18305. * @constructor
  18306. * @category Seq
  18307. * @param {*} value The value to wrap in a `lodash` instance.
  18308. * @returns {Object} Returns the new `lodash` wrapper instance.
  18309. * @example
  18310. *
  18311. * function square(n) {
  18312. * return n * n;
  18313. * }
  18314. *
  18315. * var wrapped = _([1, 2, 3]);
  18316. *
  18317. * // Returns an unwrapped value.
  18318. * wrapped.reduce(_.add);
  18319. * // => 6
  18320. *
  18321. * // Returns a wrapped value.
  18322. * var squares = wrapped.map(square);
  18323. *
  18324. * _.isArray(squares);
  18325. * // => false
  18326. *
  18327. * _.isArray(squares.value());
  18328. * // => true
  18329. */
  18330. function lodash(value) {
  18331. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18332. if (value instanceof LodashWrapper) {
  18333. return value;
  18334. }
  18335. if (hasOwnProperty.call(value, '__wrapped__')) {
  18336. return wrapperClone(value);
  18337. }
  18338. }
  18339. return new LodashWrapper(value);
  18340. }
  18341. /**
  18342. * The base implementation of `_.create` without support for assigning
  18343. * properties to the created object.
  18344. *
  18345. * @private
  18346. * @param {Object} proto The object to inherit from.
  18347. * @returns {Object} Returns the new object.
  18348. */
  18349. var baseCreate = (function() {
  18350. function object() {}
  18351. return function(proto) {
  18352. if (!isObject(proto)) {
  18353. return {};
  18354. }
  18355. if (objectCreate) {
  18356. return objectCreate(proto);
  18357. }
  18358. object.prototype = proto;
  18359. var result = new object;
  18360. object.prototype = undefined;
  18361. return result;
  18362. };
  18363. }());
  18364. /**
  18365. * The function whose prototype chain sequence wrappers inherit from.
  18366. *
  18367. * @private
  18368. */
  18369. function baseLodash() {
  18370. // No operation performed.
  18371. }
  18372. /**
  18373. * The base constructor for creating `lodash` wrapper objects.
  18374. *
  18375. * @private
  18376. * @param {*} value The value to wrap.
  18377. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18378. */
  18379. function LodashWrapper(value, chainAll) {
  18380. this.__wrapped__ = value;
  18381. this.__actions__ = [];
  18382. this.__chain__ = !!chainAll;
  18383. this.__index__ = 0;
  18384. this.__values__ = undefined;
  18385. }
  18386. /**
  18387. * By default, the template delimiters used by lodash are like those in
  18388. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18389. * following template settings to use alternative delimiters.
  18390. *
  18391. * @static
  18392. * @memberOf _
  18393. * @type {Object}
  18394. */
  18395. lodash.templateSettings = {
  18396. /**
  18397. * Used to detect `data` property values to be HTML-escaped.
  18398. *
  18399. * @memberOf _.templateSettings
  18400. * @type {RegExp}
  18401. */
  18402. 'escape': reEscape,
  18403. /**
  18404. * Used to detect code to be evaluated.
  18405. *
  18406. * @memberOf _.templateSettings
  18407. * @type {RegExp}
  18408. */
  18409. 'evaluate': reEvaluate,
  18410. /**
  18411. * Used to detect `data` property values to inject.
  18412. *
  18413. * @memberOf _.templateSettings
  18414. * @type {RegExp}
  18415. */
  18416. 'interpolate': reInterpolate,
  18417. /**
  18418. * Used to reference the data object in the template text.
  18419. *
  18420. * @memberOf _.templateSettings
  18421. * @type {string}
  18422. */
  18423. 'variable': '',
  18424. /**
  18425. * Used to import variables into the compiled template.
  18426. *
  18427. * @memberOf _.templateSettings
  18428. * @type {Object}
  18429. */
  18430. 'imports': {
  18431. /**
  18432. * A reference to the `lodash` function.
  18433. *
  18434. * @memberOf _.templateSettings.imports
  18435. * @type {Function}
  18436. */
  18437. '_': lodash
  18438. }
  18439. };
  18440. // Ensure wrappers are instances of `baseLodash`.
  18441. lodash.prototype = baseLodash.prototype;
  18442. lodash.prototype.constructor = lodash;
  18443. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18444. LodashWrapper.prototype.constructor = LodashWrapper;
  18445. /*------------------------------------------------------------------------*/
  18446. /**
  18447. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18448. *
  18449. * @private
  18450. * @constructor
  18451. * @param {*} value The value to wrap.
  18452. */
  18453. function LazyWrapper(value) {
  18454. this.__wrapped__ = value;
  18455. this.__actions__ = [];
  18456. this.__dir__ = 1;
  18457. this.__filtered__ = false;
  18458. this.__iteratees__ = [];
  18459. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18460. this.__views__ = [];
  18461. }
  18462. /**
  18463. * Creates a clone of the lazy wrapper object.
  18464. *
  18465. * @private
  18466. * @name clone
  18467. * @memberOf LazyWrapper
  18468. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18469. */
  18470. function lazyClone() {
  18471. var result = new LazyWrapper(this.__wrapped__);
  18472. result.__actions__ = copyArray(this.__actions__);
  18473. result.__dir__ = this.__dir__;
  18474. result.__filtered__ = this.__filtered__;
  18475. result.__iteratees__ = copyArray(this.__iteratees__);
  18476. result.__takeCount__ = this.__takeCount__;
  18477. result.__views__ = copyArray(this.__views__);
  18478. return result;
  18479. }
  18480. /**
  18481. * Reverses the direction of lazy iteration.
  18482. *
  18483. * @private
  18484. * @name reverse
  18485. * @memberOf LazyWrapper
  18486. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18487. */
  18488. function lazyReverse() {
  18489. if (this.__filtered__) {
  18490. var result = new LazyWrapper(this);
  18491. result.__dir__ = -1;
  18492. result.__filtered__ = true;
  18493. } else {
  18494. result = this.clone();
  18495. result.__dir__ *= -1;
  18496. }
  18497. return result;
  18498. }
  18499. /**
  18500. * Extracts the unwrapped value from its lazy wrapper.
  18501. *
  18502. * @private
  18503. * @name value
  18504. * @memberOf LazyWrapper
  18505. * @returns {*} Returns the unwrapped value.
  18506. */
  18507. function lazyValue() {
  18508. var array = this.__wrapped__.value(),
  18509. dir = this.__dir__,
  18510. isArr = isArray(array),
  18511. isRight = dir < 0,
  18512. arrLength = isArr ? array.length : 0,
  18513. view = getView(0, arrLength, this.__views__),
  18514. start = view.start,
  18515. end = view.end,
  18516. length = end - start,
  18517. index = isRight ? end : (start - 1),
  18518. iteratees = this.__iteratees__,
  18519. iterLength = iteratees.length,
  18520. resIndex = 0,
  18521. takeCount = nativeMin(length, this.__takeCount__);
  18522. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18523. return baseWrapperValue(array, this.__actions__);
  18524. }
  18525. var result = [];
  18526. outer:
  18527. while (length-- && resIndex < takeCount) {
  18528. index += dir;
  18529. var iterIndex = -1,
  18530. value = array[index];
  18531. while (++iterIndex < iterLength) {
  18532. var data = iteratees[iterIndex],
  18533. iteratee = data.iteratee,
  18534. type = data.type,
  18535. computed = iteratee(value);
  18536. if (type == LAZY_MAP_FLAG) {
  18537. value = computed;
  18538. } else if (!computed) {
  18539. if (type == LAZY_FILTER_FLAG) {
  18540. continue outer;
  18541. } else {
  18542. break outer;
  18543. }
  18544. }
  18545. }
  18546. result[resIndex++] = value;
  18547. }
  18548. return result;
  18549. }
  18550. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18551. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18552. LazyWrapper.prototype.constructor = LazyWrapper;
  18553. /*------------------------------------------------------------------------*/
  18554. /**
  18555. * Creates a hash object.
  18556. *
  18557. * @private
  18558. * @constructor
  18559. * @param {Array} [entries] The key-value pairs to cache.
  18560. */
  18561. function Hash(entries) {
  18562. var index = -1,
  18563. length = entries == null ? 0 : entries.length;
  18564. this.clear();
  18565. while (++index < length) {
  18566. var entry = entries[index];
  18567. this.set(entry[0], entry[1]);
  18568. }
  18569. }
  18570. /**
  18571. * Removes all key-value entries from the hash.
  18572. *
  18573. * @private
  18574. * @name clear
  18575. * @memberOf Hash
  18576. */
  18577. function hashClear() {
  18578. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18579. this.size = 0;
  18580. }
  18581. /**
  18582. * Removes `key` and its value from the hash.
  18583. *
  18584. * @private
  18585. * @name delete
  18586. * @memberOf Hash
  18587. * @param {Object} hash The hash to modify.
  18588. * @param {string} key The key of the value to remove.
  18589. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18590. */
  18591. function hashDelete(key) {
  18592. var result = this.has(key) && delete this.__data__[key];
  18593. this.size -= result ? 1 : 0;
  18594. return result;
  18595. }
  18596. /**
  18597. * Gets the hash value for `key`.
  18598. *
  18599. * @private
  18600. * @name get
  18601. * @memberOf Hash
  18602. * @param {string} key The key of the value to get.
  18603. * @returns {*} Returns the entry value.
  18604. */
  18605. function hashGet(key) {
  18606. var data = this.__data__;
  18607. if (nativeCreate) {
  18608. var result = data[key];
  18609. return result === HASH_UNDEFINED ? undefined : result;
  18610. }
  18611. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18612. }
  18613. /**
  18614. * Checks if a hash value for `key` exists.
  18615. *
  18616. * @private
  18617. * @name has
  18618. * @memberOf Hash
  18619. * @param {string} key The key of the entry to check.
  18620. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18621. */
  18622. function hashHas(key) {
  18623. var data = this.__data__;
  18624. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18625. }
  18626. /**
  18627. * Sets the hash `key` to `value`.
  18628. *
  18629. * @private
  18630. * @name set
  18631. * @memberOf Hash
  18632. * @param {string} key The key of the value to set.
  18633. * @param {*} value The value to set.
  18634. * @returns {Object} Returns the hash instance.
  18635. */
  18636. function hashSet(key, value) {
  18637. var data = this.__data__;
  18638. this.size += this.has(key) ? 0 : 1;
  18639. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18640. return this;
  18641. }
  18642. // Add methods to `Hash`.
  18643. Hash.prototype.clear = hashClear;
  18644. Hash.prototype['delete'] = hashDelete;
  18645. Hash.prototype.get = hashGet;
  18646. Hash.prototype.has = hashHas;
  18647. Hash.prototype.set = hashSet;
  18648. /*------------------------------------------------------------------------*/
  18649. /**
  18650. * Creates an list cache object.
  18651. *
  18652. * @private
  18653. * @constructor
  18654. * @param {Array} [entries] The key-value pairs to cache.
  18655. */
  18656. function ListCache(entries) {
  18657. var index = -1,
  18658. length = entries == null ? 0 : entries.length;
  18659. this.clear();
  18660. while (++index < length) {
  18661. var entry = entries[index];
  18662. this.set(entry[0], entry[1]);
  18663. }
  18664. }
  18665. /**
  18666. * Removes all key-value entries from the list cache.
  18667. *
  18668. * @private
  18669. * @name clear
  18670. * @memberOf ListCache
  18671. */
  18672. function listCacheClear() {
  18673. this.__data__ = [];
  18674. this.size = 0;
  18675. }
  18676. /**
  18677. * Removes `key` and its value from the list cache.
  18678. *
  18679. * @private
  18680. * @name delete
  18681. * @memberOf ListCache
  18682. * @param {string} key The key of the value to remove.
  18683. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18684. */
  18685. function listCacheDelete(key) {
  18686. var data = this.__data__,
  18687. index = assocIndexOf(data, key);
  18688. if (index < 0) {
  18689. return false;
  18690. }
  18691. var lastIndex = data.length - 1;
  18692. if (index == lastIndex) {
  18693. data.pop();
  18694. } else {
  18695. splice.call(data, index, 1);
  18696. }
  18697. --this.size;
  18698. return true;
  18699. }
  18700. /**
  18701. * Gets the list cache value for `key`.
  18702. *
  18703. * @private
  18704. * @name get
  18705. * @memberOf ListCache
  18706. * @param {string} key The key of the value to get.
  18707. * @returns {*} Returns the entry value.
  18708. */
  18709. function listCacheGet(key) {
  18710. var data = this.__data__,
  18711. index = assocIndexOf(data, key);
  18712. return index < 0 ? undefined : data[index][1];
  18713. }
  18714. /**
  18715. * Checks if a list cache value for `key` exists.
  18716. *
  18717. * @private
  18718. * @name has
  18719. * @memberOf ListCache
  18720. * @param {string} key The key of the entry to check.
  18721. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18722. */
  18723. function listCacheHas(key) {
  18724. return assocIndexOf(this.__data__, key) > -1;
  18725. }
  18726. /**
  18727. * Sets the list cache `key` to `value`.
  18728. *
  18729. * @private
  18730. * @name set
  18731. * @memberOf ListCache
  18732. * @param {string} key The key of the value to set.
  18733. * @param {*} value The value to set.
  18734. * @returns {Object} Returns the list cache instance.
  18735. */
  18736. function listCacheSet(key, value) {
  18737. var data = this.__data__,
  18738. index = assocIndexOf(data, key);
  18739. if (index < 0) {
  18740. ++this.size;
  18741. data.push([key, value]);
  18742. } else {
  18743. data[index][1] = value;
  18744. }
  18745. return this;
  18746. }
  18747. // Add methods to `ListCache`.
  18748. ListCache.prototype.clear = listCacheClear;
  18749. ListCache.prototype['delete'] = listCacheDelete;
  18750. ListCache.prototype.get = listCacheGet;
  18751. ListCache.prototype.has = listCacheHas;
  18752. ListCache.prototype.set = listCacheSet;
  18753. /*------------------------------------------------------------------------*/
  18754. /**
  18755. * Creates a map cache object to store key-value pairs.
  18756. *
  18757. * @private
  18758. * @constructor
  18759. * @param {Array} [entries] The key-value pairs to cache.
  18760. */
  18761. function MapCache(entries) {
  18762. var index = -1,
  18763. length = entries == null ? 0 : entries.length;
  18764. this.clear();
  18765. while (++index < length) {
  18766. var entry = entries[index];
  18767. this.set(entry[0], entry[1]);
  18768. }
  18769. }
  18770. /**
  18771. * Removes all key-value entries from the map.
  18772. *
  18773. * @private
  18774. * @name clear
  18775. * @memberOf MapCache
  18776. */
  18777. function mapCacheClear() {
  18778. this.size = 0;
  18779. this.__data__ = {
  18780. 'hash': new Hash,
  18781. 'map': new (Map || ListCache),
  18782. 'string': new Hash
  18783. };
  18784. }
  18785. /**
  18786. * Removes `key` and its value from the map.
  18787. *
  18788. * @private
  18789. * @name delete
  18790. * @memberOf MapCache
  18791. * @param {string} key The key of the value to remove.
  18792. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18793. */
  18794. function mapCacheDelete(key) {
  18795. var result = getMapData(this, key)['delete'](key);
  18796. this.size -= result ? 1 : 0;
  18797. return result;
  18798. }
  18799. /**
  18800. * Gets the map value for `key`.
  18801. *
  18802. * @private
  18803. * @name get
  18804. * @memberOf MapCache
  18805. * @param {string} key The key of the value to get.
  18806. * @returns {*} Returns the entry value.
  18807. */
  18808. function mapCacheGet(key) {
  18809. return getMapData(this, key).get(key);
  18810. }
  18811. /**
  18812. * Checks if a map value for `key` exists.
  18813. *
  18814. * @private
  18815. * @name has
  18816. * @memberOf MapCache
  18817. * @param {string} key The key of the entry to check.
  18818. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18819. */
  18820. function mapCacheHas(key) {
  18821. return getMapData(this, key).has(key);
  18822. }
  18823. /**
  18824. * Sets the map `key` to `value`.
  18825. *
  18826. * @private
  18827. * @name set
  18828. * @memberOf MapCache
  18829. * @param {string} key The key of the value to set.
  18830. * @param {*} value The value to set.
  18831. * @returns {Object} Returns the map cache instance.
  18832. */
  18833. function mapCacheSet(key, value) {
  18834. var data = getMapData(this, key),
  18835. size = data.size;
  18836. data.set(key, value);
  18837. this.size += data.size == size ? 0 : 1;
  18838. return this;
  18839. }
  18840. // Add methods to `MapCache`.
  18841. MapCache.prototype.clear = mapCacheClear;
  18842. MapCache.prototype['delete'] = mapCacheDelete;
  18843. MapCache.prototype.get = mapCacheGet;
  18844. MapCache.prototype.has = mapCacheHas;
  18845. MapCache.prototype.set = mapCacheSet;
  18846. /*------------------------------------------------------------------------*/
  18847. /**
  18848. *
  18849. * Creates an array cache object to store unique values.
  18850. *
  18851. * @private
  18852. * @constructor
  18853. * @param {Array} [values] The values to cache.
  18854. */
  18855. function SetCache(values) {
  18856. var index = -1,
  18857. length = values == null ? 0 : values.length;
  18858. this.__data__ = new MapCache;
  18859. while (++index < length) {
  18860. this.add(values[index]);
  18861. }
  18862. }
  18863. /**
  18864. * Adds `value` to the array cache.
  18865. *
  18866. * @private
  18867. * @name add
  18868. * @memberOf SetCache
  18869. * @alias push
  18870. * @param {*} value The value to cache.
  18871. * @returns {Object} Returns the cache instance.
  18872. */
  18873. function setCacheAdd(value) {
  18874. this.__data__.set(value, HASH_UNDEFINED);
  18875. return this;
  18876. }
  18877. /**
  18878. * Checks if `value` is in the array cache.
  18879. *
  18880. * @private
  18881. * @name has
  18882. * @memberOf SetCache
  18883. * @param {*} value The value to search for.
  18884. * @returns {number} Returns `true` if `value` is found, else `false`.
  18885. */
  18886. function setCacheHas(value) {
  18887. return this.__data__.has(value);
  18888. }
  18889. // Add methods to `SetCache`.
  18890. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18891. SetCache.prototype.has = setCacheHas;
  18892. /*------------------------------------------------------------------------*/
  18893. /**
  18894. * Creates a stack cache object to store key-value pairs.
  18895. *
  18896. * @private
  18897. * @constructor
  18898. * @param {Array} [entries] The key-value pairs to cache.
  18899. */
  18900. function Stack(entries) {
  18901. var data = this.__data__ = new ListCache(entries);
  18902. this.size = data.size;
  18903. }
  18904. /**
  18905. * Removes all key-value entries from the stack.
  18906. *
  18907. * @private
  18908. * @name clear
  18909. * @memberOf Stack
  18910. */
  18911. function stackClear() {
  18912. this.__data__ = new ListCache;
  18913. this.size = 0;
  18914. }
  18915. /**
  18916. * Removes `key` and its value from the stack.
  18917. *
  18918. * @private
  18919. * @name delete
  18920. * @memberOf Stack
  18921. * @param {string} key The key of the value to remove.
  18922. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18923. */
  18924. function stackDelete(key) {
  18925. var data = this.__data__,
  18926. result = data['delete'](key);
  18927. this.size = data.size;
  18928. return result;
  18929. }
  18930. /**
  18931. * Gets the stack value for `key`.
  18932. *
  18933. * @private
  18934. * @name get
  18935. * @memberOf Stack
  18936. * @param {string} key The key of the value to get.
  18937. * @returns {*} Returns the entry value.
  18938. */
  18939. function stackGet(key) {
  18940. return this.__data__.get(key);
  18941. }
  18942. /**
  18943. * Checks if a stack value for `key` exists.
  18944. *
  18945. * @private
  18946. * @name has
  18947. * @memberOf Stack
  18948. * @param {string} key The key of the entry to check.
  18949. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18950. */
  18951. function stackHas(key) {
  18952. return this.__data__.has(key);
  18953. }
  18954. /**
  18955. * Sets the stack `key` to `value`.
  18956. *
  18957. * @private
  18958. * @name set
  18959. * @memberOf Stack
  18960. * @param {string} key The key of the value to set.
  18961. * @param {*} value The value to set.
  18962. * @returns {Object} Returns the stack cache instance.
  18963. */
  18964. function stackSet(key, value) {
  18965. var data = this.__data__;
  18966. if (data instanceof ListCache) {
  18967. var pairs = data.__data__;
  18968. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18969. pairs.push([key, value]);
  18970. this.size = ++data.size;
  18971. return this;
  18972. }
  18973. data = this.__data__ = new MapCache(pairs);
  18974. }
  18975. data.set(key, value);
  18976. this.size = data.size;
  18977. return this;
  18978. }
  18979. // Add methods to `Stack`.
  18980. Stack.prototype.clear = stackClear;
  18981. Stack.prototype['delete'] = stackDelete;
  18982. Stack.prototype.get = stackGet;
  18983. Stack.prototype.has = stackHas;
  18984. Stack.prototype.set = stackSet;
  18985. /*------------------------------------------------------------------------*/
  18986. /**
  18987. * Creates an array of the enumerable property names of the array-like `value`.
  18988. *
  18989. * @private
  18990. * @param {*} value The value to query.
  18991. * @param {boolean} inherited Specify returning inherited property names.
  18992. * @returns {Array} Returns the array of property names.
  18993. */
  18994. function arrayLikeKeys(value, inherited) {
  18995. var isArr = isArray(value),
  18996. isArg = !isArr && isArguments(value),
  18997. isBuff = !isArr && !isArg && isBuffer(value),
  18998. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18999. skipIndexes = isArr || isArg || isBuff || isType,
  19000. result = skipIndexes ? baseTimes(value.length, String) : [],
  19001. length = result.length;
  19002. for (var key in value) {
  19003. if ((inherited || hasOwnProperty.call(value, key)) &&
  19004. !(skipIndexes && (
  19005. // Safari 9 has enumerable `arguments.length` in strict mode.
  19006. key == 'length' ||
  19007. // Node.js 0.10 has enumerable non-index properties on buffers.
  19008. (isBuff && (key == 'offset' || key == 'parent')) ||
  19009. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19010. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19011. // Skip index properties.
  19012. isIndex(key, length)
  19013. ))) {
  19014. result.push(key);
  19015. }
  19016. }
  19017. return result;
  19018. }
  19019. /**
  19020. * A specialized version of `_.sample` for arrays.
  19021. *
  19022. * @private
  19023. * @param {Array} array The array to sample.
  19024. * @returns {*} Returns the random element.
  19025. */
  19026. function arraySample(array) {
  19027. var length = array.length;
  19028. return length ? array[baseRandom(0, length - 1)] : undefined;
  19029. }
  19030. /**
  19031. * A specialized version of `_.sampleSize` for arrays.
  19032. *
  19033. * @private
  19034. * @param {Array} array The array to sample.
  19035. * @param {number} n The number of elements to sample.
  19036. * @returns {Array} Returns the random elements.
  19037. */
  19038. function arraySampleSize(array, n) {
  19039. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19040. }
  19041. /**
  19042. * A specialized version of `_.shuffle` for arrays.
  19043. *
  19044. * @private
  19045. * @param {Array} array The array to shuffle.
  19046. * @returns {Array} Returns the new shuffled array.
  19047. */
  19048. function arrayShuffle(array) {
  19049. return shuffleSelf(copyArray(array));
  19050. }
  19051. /**
  19052. * This function is like `assignValue` except that it doesn't assign
  19053. * `undefined` values.
  19054. *
  19055. * @private
  19056. * @param {Object} object The object to modify.
  19057. * @param {string} key The key of the property to assign.
  19058. * @param {*} value The value to assign.
  19059. */
  19060. function assignMergeValue(object, key, value) {
  19061. if ((value !== undefined && !eq(object[key], value)) ||
  19062. (value === undefined && !(key in object))) {
  19063. baseAssignValue(object, key, value);
  19064. }
  19065. }
  19066. /**
  19067. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19068. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19069. * for equality comparisons.
  19070. *
  19071. * @private
  19072. * @param {Object} object The object to modify.
  19073. * @param {string} key The key of the property to assign.
  19074. * @param {*} value The value to assign.
  19075. */
  19076. function assignValue(object, key, value) {
  19077. var objValue = object[key];
  19078. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19079. (value === undefined && !(key in object))) {
  19080. baseAssignValue(object, key, value);
  19081. }
  19082. }
  19083. /**
  19084. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19085. *
  19086. * @private
  19087. * @param {Array} array The array to inspect.
  19088. * @param {*} key The key to search for.
  19089. * @returns {number} Returns the index of the matched value, else `-1`.
  19090. */
  19091. function assocIndexOf(array, key) {
  19092. var length = array.length;
  19093. while (length--) {
  19094. if (eq(array[length][0], key)) {
  19095. return length;
  19096. }
  19097. }
  19098. return -1;
  19099. }
  19100. /**
  19101. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19102. * by `iteratee` and values set by `setter`.
  19103. *
  19104. * @private
  19105. * @param {Array|Object} collection The collection to iterate over.
  19106. * @param {Function} setter The function to set `accumulator` values.
  19107. * @param {Function} iteratee The iteratee to transform keys.
  19108. * @param {Object} accumulator The initial aggregated object.
  19109. * @returns {Function} Returns `accumulator`.
  19110. */
  19111. function baseAggregator(collection, setter, iteratee, accumulator) {
  19112. baseEach(collection, function(value, key, collection) {
  19113. setter(accumulator, value, iteratee(value), collection);
  19114. });
  19115. return accumulator;
  19116. }
  19117. /**
  19118. * The base implementation of `_.assign` without support for multiple sources
  19119. * or `customizer` functions.
  19120. *
  19121. * @private
  19122. * @param {Object} object The destination object.
  19123. * @param {Object} source The source object.
  19124. * @returns {Object} Returns `object`.
  19125. */
  19126. function baseAssign(object, source) {
  19127. return object && copyObject(source, keys(source), object);
  19128. }
  19129. /**
  19130. * The base implementation of `_.assignIn` without support for multiple sources
  19131. * or `customizer` functions.
  19132. *
  19133. * @private
  19134. * @param {Object} object The destination object.
  19135. * @param {Object} source The source object.
  19136. * @returns {Object} Returns `object`.
  19137. */
  19138. function baseAssignIn(object, source) {
  19139. return object && copyObject(source, keysIn(source), object);
  19140. }
  19141. /**
  19142. * The base implementation of `assignValue` and `assignMergeValue` without
  19143. * value checks.
  19144. *
  19145. * @private
  19146. * @param {Object} object The object to modify.
  19147. * @param {string} key The key of the property to assign.
  19148. * @param {*} value The value to assign.
  19149. */
  19150. function baseAssignValue(object, key, value) {
  19151. if (key == '__proto__' && defineProperty) {
  19152. defineProperty(object, key, {
  19153. 'configurable': true,
  19154. 'enumerable': true,
  19155. 'value': value,
  19156. 'writable': true
  19157. });
  19158. } else {
  19159. object[key] = value;
  19160. }
  19161. }
  19162. /**
  19163. * The base implementation of `_.at` without support for individual paths.
  19164. *
  19165. * @private
  19166. * @param {Object} object The object to iterate over.
  19167. * @param {string[]} paths The property paths to pick.
  19168. * @returns {Array} Returns the picked elements.
  19169. */
  19170. function baseAt(object, paths) {
  19171. var index = -1,
  19172. length = paths.length,
  19173. result = Array(length),
  19174. skip = object == null;
  19175. while (++index < length) {
  19176. result[index] = skip ? undefined : get(object, paths[index]);
  19177. }
  19178. return result;
  19179. }
  19180. /**
  19181. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19182. *
  19183. * @private
  19184. * @param {number} number The number to clamp.
  19185. * @param {number} [lower] The lower bound.
  19186. * @param {number} upper The upper bound.
  19187. * @returns {number} Returns the clamped number.
  19188. */
  19189. function baseClamp(number, lower, upper) {
  19190. if (number === number) {
  19191. if (upper !== undefined) {
  19192. number = number <= upper ? number : upper;
  19193. }
  19194. if (lower !== undefined) {
  19195. number = number >= lower ? number : lower;
  19196. }
  19197. }
  19198. return number;
  19199. }
  19200. /**
  19201. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19202. * traversed objects.
  19203. *
  19204. * @private
  19205. * @param {*} value The value to clone.
  19206. * @param {boolean} bitmask The bitmask flags.
  19207. * 1 - Deep clone
  19208. * 2 - Flatten inherited properties
  19209. * 4 - Clone symbols
  19210. * @param {Function} [customizer] The function to customize cloning.
  19211. * @param {string} [key] The key of `value`.
  19212. * @param {Object} [object] The parent object of `value`.
  19213. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19214. * @returns {*} Returns the cloned value.
  19215. */
  19216. function baseClone(value, bitmask, customizer, key, object, stack) {
  19217. var result,
  19218. isDeep = bitmask & CLONE_DEEP_FLAG,
  19219. isFlat = bitmask & CLONE_FLAT_FLAG,
  19220. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19221. if (customizer) {
  19222. result = object ? customizer(value, key, object, stack) : customizer(value);
  19223. }
  19224. if (result !== undefined) {
  19225. return result;
  19226. }
  19227. if (!isObject(value)) {
  19228. return value;
  19229. }
  19230. var isArr = isArray(value);
  19231. if (isArr) {
  19232. result = initCloneArray(value);
  19233. if (!isDeep) {
  19234. return copyArray(value, result);
  19235. }
  19236. } else {
  19237. var tag = getTag(value),
  19238. isFunc = tag == funcTag || tag == genTag;
  19239. if (isBuffer(value)) {
  19240. return cloneBuffer(value, isDeep);
  19241. }
  19242. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19243. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19244. if (!isDeep) {
  19245. return isFlat
  19246. ? copySymbolsIn(value, baseAssignIn(result, value))
  19247. : copySymbols(value, baseAssign(result, value));
  19248. }
  19249. } else {
  19250. if (!cloneableTags[tag]) {
  19251. return object ? value : {};
  19252. }
  19253. result = initCloneByTag(value, tag, isDeep);
  19254. }
  19255. }
  19256. // Check for circular references and return its corresponding clone.
  19257. stack || (stack = new Stack);
  19258. var stacked = stack.get(value);
  19259. if (stacked) {
  19260. return stacked;
  19261. }
  19262. stack.set(value, result);
  19263. if (isSet(value)) {
  19264. value.forEach(function(subValue) {
  19265. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19266. });
  19267. } else if (isMap(value)) {
  19268. value.forEach(function(subValue, key) {
  19269. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19270. });
  19271. }
  19272. var keysFunc = isFull
  19273. ? (isFlat ? getAllKeysIn : getAllKeys)
  19274. : (isFlat ? keysIn : keys);
  19275. var props = isArr ? undefined : keysFunc(value);
  19276. arrayEach(props || value, function(subValue, key) {
  19277. if (props) {
  19278. key = subValue;
  19279. subValue = value[key];
  19280. }
  19281. // Recursively populate clone (susceptible to call stack limits).
  19282. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19283. });
  19284. return result;
  19285. }
  19286. /**
  19287. * The base implementation of `_.conforms` which doesn't clone `source`.
  19288. *
  19289. * @private
  19290. * @param {Object} source The object of property predicates to conform to.
  19291. * @returns {Function} Returns the new spec function.
  19292. */
  19293. function baseConforms(source) {
  19294. var props = keys(source);
  19295. return function(object) {
  19296. return baseConformsTo(object, source, props);
  19297. };
  19298. }
  19299. /**
  19300. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19301. *
  19302. * @private
  19303. * @param {Object} object The object to inspect.
  19304. * @param {Object} source The object of property predicates to conform to.
  19305. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19306. */
  19307. function baseConformsTo(object, source, props) {
  19308. var length = props.length;
  19309. if (object == null) {
  19310. return !length;
  19311. }
  19312. object = Object(object);
  19313. while (length--) {
  19314. var key = props[length],
  19315. predicate = source[key],
  19316. value = object[key];
  19317. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19318. return false;
  19319. }
  19320. }
  19321. return true;
  19322. }
  19323. /**
  19324. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19325. * to provide to `func`.
  19326. *
  19327. * @private
  19328. * @param {Function} func The function to delay.
  19329. * @param {number} wait The number of milliseconds to delay invocation.
  19330. * @param {Array} args The arguments to provide to `func`.
  19331. * @returns {number|Object} Returns the timer id or timeout object.
  19332. */
  19333. function baseDelay(func, wait, args) {
  19334. if (typeof func != 'function') {
  19335. throw new TypeError(FUNC_ERROR_TEXT);
  19336. }
  19337. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19338. }
  19339. /**
  19340. * The base implementation of methods like `_.difference` without support
  19341. * for excluding multiple arrays or iteratee shorthands.
  19342. *
  19343. * @private
  19344. * @param {Array} array The array to inspect.
  19345. * @param {Array} values The values to exclude.
  19346. * @param {Function} [iteratee] The iteratee invoked per element.
  19347. * @param {Function} [comparator] The comparator invoked per element.
  19348. * @returns {Array} Returns the new array of filtered values.
  19349. */
  19350. function baseDifference(array, values, iteratee, comparator) {
  19351. var index = -1,
  19352. includes = arrayIncludes,
  19353. isCommon = true,
  19354. length = array.length,
  19355. result = [],
  19356. valuesLength = values.length;
  19357. if (!length) {
  19358. return result;
  19359. }
  19360. if (iteratee) {
  19361. values = arrayMap(values, baseUnary(iteratee));
  19362. }
  19363. if (comparator) {
  19364. includes = arrayIncludesWith;
  19365. isCommon = false;
  19366. }
  19367. else if (values.length >= LARGE_ARRAY_SIZE) {
  19368. includes = cacheHas;
  19369. isCommon = false;
  19370. values = new SetCache(values);
  19371. }
  19372. outer:
  19373. while (++index < length) {
  19374. var value = array[index],
  19375. computed = iteratee == null ? value : iteratee(value);
  19376. value = (comparator || value !== 0) ? value : 0;
  19377. if (isCommon && computed === computed) {
  19378. var valuesIndex = valuesLength;
  19379. while (valuesIndex--) {
  19380. if (values[valuesIndex] === computed) {
  19381. continue outer;
  19382. }
  19383. }
  19384. result.push(value);
  19385. }
  19386. else if (!includes(values, computed, comparator)) {
  19387. result.push(value);
  19388. }
  19389. }
  19390. return result;
  19391. }
  19392. /**
  19393. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19394. *
  19395. * @private
  19396. * @param {Array|Object} collection The collection to iterate over.
  19397. * @param {Function} iteratee The function invoked per iteration.
  19398. * @returns {Array|Object} Returns `collection`.
  19399. */
  19400. var baseEach = createBaseEach(baseForOwn);
  19401. /**
  19402. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19403. *
  19404. * @private
  19405. * @param {Array|Object} collection The collection to iterate over.
  19406. * @param {Function} iteratee The function invoked per iteration.
  19407. * @returns {Array|Object} Returns `collection`.
  19408. */
  19409. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19410. /**
  19411. * The base implementation of `_.every` without support for iteratee shorthands.
  19412. *
  19413. * @private
  19414. * @param {Array|Object} collection The collection to iterate over.
  19415. * @param {Function} predicate The function invoked per iteration.
  19416. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19417. * else `false`
  19418. */
  19419. function baseEvery(collection, predicate) {
  19420. var result = true;
  19421. baseEach(collection, function(value, index, collection) {
  19422. result = !!predicate(value, index, collection);
  19423. return result;
  19424. });
  19425. return result;
  19426. }
  19427. /**
  19428. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19429. * `comparator` to determine the extremum value.
  19430. *
  19431. * @private
  19432. * @param {Array} array The array to iterate over.
  19433. * @param {Function} iteratee The iteratee invoked per iteration.
  19434. * @param {Function} comparator The comparator used to compare values.
  19435. * @returns {*} Returns the extremum value.
  19436. */
  19437. function baseExtremum(array, iteratee, comparator) {
  19438. var index = -1,
  19439. length = array.length;
  19440. while (++index < length) {
  19441. var value = array[index],
  19442. current = iteratee(value);
  19443. if (current != null && (computed === undefined
  19444. ? (current === current && !isSymbol(current))
  19445. : comparator(current, computed)
  19446. )) {
  19447. var computed = current,
  19448. result = value;
  19449. }
  19450. }
  19451. return result;
  19452. }
  19453. /**
  19454. * The base implementation of `_.fill` without an iteratee call guard.
  19455. *
  19456. * @private
  19457. * @param {Array} array The array to fill.
  19458. * @param {*} value The value to fill `array` with.
  19459. * @param {number} [start=0] The start position.
  19460. * @param {number} [end=array.length] The end position.
  19461. * @returns {Array} Returns `array`.
  19462. */
  19463. function baseFill(array, value, start, end) {
  19464. var length = array.length;
  19465. start = toInteger(start);
  19466. if (start < 0) {
  19467. start = -start > length ? 0 : (length + start);
  19468. }
  19469. end = (end === undefined || end > length) ? length : toInteger(end);
  19470. if (end < 0) {
  19471. end += length;
  19472. }
  19473. end = start > end ? 0 : toLength(end);
  19474. while (start < end) {
  19475. array[start++] = value;
  19476. }
  19477. return array;
  19478. }
  19479. /**
  19480. * The base implementation of `_.filter` without support for iteratee shorthands.
  19481. *
  19482. * @private
  19483. * @param {Array|Object} collection The collection to iterate over.
  19484. * @param {Function} predicate The function invoked per iteration.
  19485. * @returns {Array} Returns the new filtered array.
  19486. */
  19487. function baseFilter(collection, predicate) {
  19488. var result = [];
  19489. baseEach(collection, function(value, index, collection) {
  19490. if (predicate(value, index, collection)) {
  19491. result.push(value);
  19492. }
  19493. });
  19494. return result;
  19495. }
  19496. /**
  19497. * The base implementation of `_.flatten` with support for restricting flattening.
  19498. *
  19499. * @private
  19500. * @param {Array} array The array to flatten.
  19501. * @param {number} depth The maximum recursion depth.
  19502. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19503. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19504. * @param {Array} [result=[]] The initial result value.
  19505. * @returns {Array} Returns the new flattened array.
  19506. */
  19507. function baseFlatten(array, depth, predicate, isStrict, result) {
  19508. var index = -1,
  19509. length = array.length;
  19510. predicate || (predicate = isFlattenable);
  19511. result || (result = []);
  19512. while (++index < length) {
  19513. var value = array[index];
  19514. if (depth > 0 && predicate(value)) {
  19515. if (depth > 1) {
  19516. // Recursively flatten arrays (susceptible to call stack limits).
  19517. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19518. } else {
  19519. arrayPush(result, value);
  19520. }
  19521. } else if (!isStrict) {
  19522. result[result.length] = value;
  19523. }
  19524. }
  19525. return result;
  19526. }
  19527. /**
  19528. * The base implementation of `baseForOwn` which iterates over `object`
  19529. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19530. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19531. *
  19532. * @private
  19533. * @param {Object} object The object to iterate over.
  19534. * @param {Function} iteratee The function invoked per iteration.
  19535. * @param {Function} keysFunc The function to get the keys of `object`.
  19536. * @returns {Object} Returns `object`.
  19537. */
  19538. var baseFor = createBaseFor();
  19539. /**
  19540. * This function is like `baseFor` except that it iterates over properties
  19541. * in the opposite order.
  19542. *
  19543. * @private
  19544. * @param {Object} object The object to iterate over.
  19545. * @param {Function} iteratee The function invoked per iteration.
  19546. * @param {Function} keysFunc The function to get the keys of `object`.
  19547. * @returns {Object} Returns `object`.
  19548. */
  19549. var baseForRight = createBaseFor(true);
  19550. /**
  19551. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19552. *
  19553. * @private
  19554. * @param {Object} object The object to iterate over.
  19555. * @param {Function} iteratee The function invoked per iteration.
  19556. * @returns {Object} Returns `object`.
  19557. */
  19558. function baseForOwn(object, iteratee) {
  19559. return object && baseFor(object, iteratee, keys);
  19560. }
  19561. /**
  19562. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19563. *
  19564. * @private
  19565. * @param {Object} object The object to iterate over.
  19566. * @param {Function} iteratee The function invoked per iteration.
  19567. * @returns {Object} Returns `object`.
  19568. */
  19569. function baseForOwnRight(object, iteratee) {
  19570. return object && baseForRight(object, iteratee, keys);
  19571. }
  19572. /**
  19573. * The base implementation of `_.functions` which creates an array of
  19574. * `object` function property names filtered from `props`.
  19575. *
  19576. * @private
  19577. * @param {Object} object The object to inspect.
  19578. * @param {Array} props The property names to filter.
  19579. * @returns {Array} Returns the function names.
  19580. */
  19581. function baseFunctions(object, props) {
  19582. return arrayFilter(props, function(key) {
  19583. return isFunction(object[key]);
  19584. });
  19585. }
  19586. /**
  19587. * The base implementation of `_.get` without support for default values.
  19588. *
  19589. * @private
  19590. * @param {Object} object The object to query.
  19591. * @param {Array|string} path The path of the property to get.
  19592. * @returns {*} Returns the resolved value.
  19593. */
  19594. function baseGet(object, path) {
  19595. path = castPath(path, object);
  19596. var index = 0,
  19597. length = path.length;
  19598. while (object != null && index < length) {
  19599. object = object[toKey(path[index++])];
  19600. }
  19601. return (index && index == length) ? object : undefined;
  19602. }
  19603. /**
  19604. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19605. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19606. * symbols of `object`.
  19607. *
  19608. * @private
  19609. * @param {Object} object The object to query.
  19610. * @param {Function} keysFunc The function to get the keys of `object`.
  19611. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19612. * @returns {Array} Returns the array of property names and symbols.
  19613. */
  19614. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19615. var result = keysFunc(object);
  19616. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19617. }
  19618. /**
  19619. * The base implementation of `getTag` without fallbacks for buggy environments.
  19620. *
  19621. * @private
  19622. * @param {*} value The value to query.
  19623. * @returns {string} Returns the `toStringTag`.
  19624. */
  19625. function baseGetTag(value) {
  19626. if (value == null) {
  19627. return value === undefined ? undefinedTag : nullTag;
  19628. }
  19629. return (symToStringTag && symToStringTag in Object(value))
  19630. ? getRawTag(value)
  19631. : objectToString(value);
  19632. }
  19633. /**
  19634. * The base implementation of `_.gt` which doesn't coerce arguments.
  19635. *
  19636. * @private
  19637. * @param {*} value The value to compare.
  19638. * @param {*} other The other value to compare.
  19639. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19640. * else `false`.
  19641. */
  19642. function baseGt(value, other) {
  19643. return value > other;
  19644. }
  19645. /**
  19646. * The base implementation of `_.has` without support for deep paths.
  19647. *
  19648. * @private
  19649. * @param {Object} [object] The object to query.
  19650. * @param {Array|string} key The key to check.
  19651. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19652. */
  19653. function baseHas(object, key) {
  19654. return object != null && hasOwnProperty.call(object, key);
  19655. }
  19656. /**
  19657. * The base implementation of `_.hasIn` without support for deep paths.
  19658. *
  19659. * @private
  19660. * @param {Object} [object] The object to query.
  19661. * @param {Array|string} key The key to check.
  19662. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19663. */
  19664. function baseHasIn(object, key) {
  19665. return object != null && key in Object(object);
  19666. }
  19667. /**
  19668. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19669. *
  19670. * @private
  19671. * @param {number} number The number to check.
  19672. * @param {number} start The start of the range.
  19673. * @param {number} end The end of the range.
  19674. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19675. */
  19676. function baseInRange(number, start, end) {
  19677. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19678. }
  19679. /**
  19680. * The base implementation of methods like `_.intersection`, without support
  19681. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19682. *
  19683. * @private
  19684. * @param {Array} arrays The arrays to inspect.
  19685. * @param {Function} [iteratee] The iteratee invoked per element.
  19686. * @param {Function} [comparator] The comparator invoked per element.
  19687. * @returns {Array} Returns the new array of shared values.
  19688. */
  19689. function baseIntersection(arrays, iteratee, comparator) {
  19690. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19691. length = arrays[0].length,
  19692. othLength = arrays.length,
  19693. othIndex = othLength,
  19694. caches = Array(othLength),
  19695. maxLength = Infinity,
  19696. result = [];
  19697. while (othIndex--) {
  19698. var array = arrays[othIndex];
  19699. if (othIndex && iteratee) {
  19700. array = arrayMap(array, baseUnary(iteratee));
  19701. }
  19702. maxLength = nativeMin(array.length, maxLength);
  19703. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19704. ? new SetCache(othIndex && array)
  19705. : undefined;
  19706. }
  19707. array = arrays[0];
  19708. var index = -1,
  19709. seen = caches[0];
  19710. outer:
  19711. while (++index < length && result.length < maxLength) {
  19712. var value = array[index],
  19713. computed = iteratee ? iteratee(value) : value;
  19714. value = (comparator || value !== 0) ? value : 0;
  19715. if (!(seen
  19716. ? cacheHas(seen, computed)
  19717. : includes(result, computed, comparator)
  19718. )) {
  19719. othIndex = othLength;
  19720. while (--othIndex) {
  19721. var cache = caches[othIndex];
  19722. if (!(cache
  19723. ? cacheHas(cache, computed)
  19724. : includes(arrays[othIndex], computed, comparator))
  19725. ) {
  19726. continue outer;
  19727. }
  19728. }
  19729. if (seen) {
  19730. seen.push(computed);
  19731. }
  19732. result.push(value);
  19733. }
  19734. }
  19735. return result;
  19736. }
  19737. /**
  19738. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19739. * `object` with values transformed by `iteratee` and set by `setter`.
  19740. *
  19741. * @private
  19742. * @param {Object} object The object to iterate over.
  19743. * @param {Function} setter The function to set `accumulator` values.
  19744. * @param {Function} iteratee The iteratee to transform values.
  19745. * @param {Object} accumulator The initial inverted object.
  19746. * @returns {Function} Returns `accumulator`.
  19747. */
  19748. function baseInverter(object, setter, iteratee, accumulator) {
  19749. baseForOwn(object, function(value, key, object) {
  19750. setter(accumulator, iteratee(value), key, object);
  19751. });
  19752. return accumulator;
  19753. }
  19754. /**
  19755. * The base implementation of `_.invoke` without support for individual
  19756. * method arguments.
  19757. *
  19758. * @private
  19759. * @param {Object} object The object to query.
  19760. * @param {Array|string} path The path of the method to invoke.
  19761. * @param {Array} args The arguments to invoke the method with.
  19762. * @returns {*} Returns the result of the invoked method.
  19763. */
  19764. function baseInvoke(object, path, args) {
  19765. path = castPath(path, object);
  19766. object = parent(object, path);
  19767. var func = object == null ? object : object[toKey(last(path))];
  19768. return func == null ? undefined : apply(func, object, args);
  19769. }
  19770. /**
  19771. * The base implementation of `_.isArguments`.
  19772. *
  19773. * @private
  19774. * @param {*} value The value to check.
  19775. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19776. */
  19777. function baseIsArguments(value) {
  19778. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19779. }
  19780. /**
  19781. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19782. *
  19783. * @private
  19784. * @param {*} value The value to check.
  19785. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19786. */
  19787. function baseIsArrayBuffer(value) {
  19788. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19789. }
  19790. /**
  19791. * The base implementation of `_.isDate` without Node.js optimizations.
  19792. *
  19793. * @private
  19794. * @param {*} value The value to check.
  19795. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19796. */
  19797. function baseIsDate(value) {
  19798. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19799. }
  19800. /**
  19801. * The base implementation of `_.isEqual` which supports partial comparisons
  19802. * and tracks traversed objects.
  19803. *
  19804. * @private
  19805. * @param {*} value The value to compare.
  19806. * @param {*} other The other value to compare.
  19807. * @param {boolean} bitmask The bitmask flags.
  19808. * 1 - Unordered comparison
  19809. * 2 - Partial comparison
  19810. * @param {Function} [customizer] The function to customize comparisons.
  19811. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19812. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19813. */
  19814. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19815. if (value === other) {
  19816. return true;
  19817. }
  19818. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19819. return value !== value && other !== other;
  19820. }
  19821. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19822. }
  19823. /**
  19824. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19825. * deep comparisons and tracks traversed objects enabling objects with circular
  19826. * references to be compared.
  19827. *
  19828. * @private
  19829. * @param {Object} object The object to compare.
  19830. * @param {Object} other The other object to compare.
  19831. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19832. * @param {Function} customizer The function to customize comparisons.
  19833. * @param {Function} equalFunc The function to determine equivalents of values.
  19834. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19835. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19836. */
  19837. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19838. var objIsArr = isArray(object),
  19839. othIsArr = isArray(other),
  19840. objTag = objIsArr ? arrayTag : getTag(object),
  19841. othTag = othIsArr ? arrayTag : getTag(other);
  19842. objTag = objTag == argsTag ? objectTag : objTag;
  19843. othTag = othTag == argsTag ? objectTag : othTag;
  19844. var objIsObj = objTag == objectTag,
  19845. othIsObj = othTag == objectTag,
  19846. isSameTag = objTag == othTag;
  19847. if (isSameTag && isBuffer(object)) {
  19848. if (!isBuffer(other)) {
  19849. return false;
  19850. }
  19851. objIsArr = true;
  19852. objIsObj = false;
  19853. }
  19854. if (isSameTag && !objIsObj) {
  19855. stack || (stack = new Stack);
  19856. return (objIsArr || isTypedArray(object))
  19857. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19858. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19859. }
  19860. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19861. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19862. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19863. if (objIsWrapped || othIsWrapped) {
  19864. var objUnwrapped = objIsWrapped ? object.value() : object,
  19865. othUnwrapped = othIsWrapped ? other.value() : other;
  19866. stack || (stack = new Stack);
  19867. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19868. }
  19869. }
  19870. if (!isSameTag) {
  19871. return false;
  19872. }
  19873. stack || (stack = new Stack);
  19874. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19875. }
  19876. /**
  19877. * The base implementation of `_.isMap` without Node.js optimizations.
  19878. *
  19879. * @private
  19880. * @param {*} value The value to check.
  19881. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19882. */
  19883. function baseIsMap(value) {
  19884. return isObjectLike(value) && getTag(value) == mapTag;
  19885. }
  19886. /**
  19887. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19888. *
  19889. * @private
  19890. * @param {Object} object The object to inspect.
  19891. * @param {Object} source The object of property values to match.
  19892. * @param {Array} matchData The property names, values, and compare flags to match.
  19893. * @param {Function} [customizer] The function to customize comparisons.
  19894. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19895. */
  19896. function baseIsMatch(object, source, matchData, customizer) {
  19897. var index = matchData.length,
  19898. length = index,
  19899. noCustomizer = !customizer;
  19900. if (object == null) {
  19901. return !length;
  19902. }
  19903. object = Object(object);
  19904. while (index--) {
  19905. var data = matchData[index];
  19906. if ((noCustomizer && data[2])
  19907. ? data[1] !== object[data[0]]
  19908. : !(data[0] in object)
  19909. ) {
  19910. return false;
  19911. }
  19912. }
  19913. while (++index < length) {
  19914. data = matchData[index];
  19915. var key = data[0],
  19916. objValue = object[key],
  19917. srcValue = data[1];
  19918. if (noCustomizer && data[2]) {
  19919. if (objValue === undefined && !(key in object)) {
  19920. return false;
  19921. }
  19922. } else {
  19923. var stack = new Stack;
  19924. if (customizer) {
  19925. var result = customizer(objValue, srcValue, key, object, source, stack);
  19926. }
  19927. if (!(result === undefined
  19928. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19929. : result
  19930. )) {
  19931. return false;
  19932. }
  19933. }
  19934. }
  19935. return true;
  19936. }
  19937. /**
  19938. * The base implementation of `_.isNative` without bad shim checks.
  19939. *
  19940. * @private
  19941. * @param {*} value The value to check.
  19942. * @returns {boolean} Returns `true` if `value` is a native function,
  19943. * else `false`.
  19944. */
  19945. function baseIsNative(value) {
  19946. if (!isObject(value) || isMasked(value)) {
  19947. return false;
  19948. }
  19949. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19950. return pattern.test(toSource(value));
  19951. }
  19952. /**
  19953. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19954. *
  19955. * @private
  19956. * @param {*} value The value to check.
  19957. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19958. */
  19959. function baseIsRegExp(value) {
  19960. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19961. }
  19962. /**
  19963. * The base implementation of `_.isSet` without Node.js optimizations.
  19964. *
  19965. * @private
  19966. * @param {*} value The value to check.
  19967. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19968. */
  19969. function baseIsSet(value) {
  19970. return isObjectLike(value) && getTag(value) == setTag;
  19971. }
  19972. /**
  19973. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19974. *
  19975. * @private
  19976. * @param {*} value The value to check.
  19977. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19978. */
  19979. function baseIsTypedArray(value) {
  19980. return isObjectLike(value) &&
  19981. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19982. }
  19983. /**
  19984. * The base implementation of `_.iteratee`.
  19985. *
  19986. * @private
  19987. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19988. * @returns {Function} Returns the iteratee.
  19989. */
  19990. function baseIteratee(value) {
  19991. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19992. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19993. if (typeof value == 'function') {
  19994. return value;
  19995. }
  19996. if (value == null) {
  19997. return identity;
  19998. }
  19999. if (typeof value == 'object') {
  20000. return isArray(value)
  20001. ? baseMatchesProperty(value[0], value[1])
  20002. : baseMatches(value);
  20003. }
  20004. return property(value);
  20005. }
  20006. /**
  20007. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20008. *
  20009. * @private
  20010. * @param {Object} object The object to query.
  20011. * @returns {Array} Returns the array of property names.
  20012. */
  20013. function baseKeys(object) {
  20014. if (!isPrototype(object)) {
  20015. return nativeKeys(object);
  20016. }
  20017. var result = [];
  20018. for (var key in Object(object)) {
  20019. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20020. result.push(key);
  20021. }
  20022. }
  20023. return result;
  20024. }
  20025. /**
  20026. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20027. *
  20028. * @private
  20029. * @param {Object} object The object to query.
  20030. * @returns {Array} Returns the array of property names.
  20031. */
  20032. function baseKeysIn(object) {
  20033. if (!isObject(object)) {
  20034. return nativeKeysIn(object);
  20035. }
  20036. var isProto = isPrototype(object),
  20037. result = [];
  20038. for (var key in object) {
  20039. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20040. result.push(key);
  20041. }
  20042. }
  20043. return result;
  20044. }
  20045. /**
  20046. * The base implementation of `_.lt` which doesn't coerce arguments.
  20047. *
  20048. * @private
  20049. * @param {*} value The value to compare.
  20050. * @param {*} other The other value to compare.
  20051. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20052. * else `false`.
  20053. */
  20054. function baseLt(value, other) {
  20055. return value < other;
  20056. }
  20057. /**
  20058. * The base implementation of `_.map` without support for iteratee shorthands.
  20059. *
  20060. * @private
  20061. * @param {Array|Object} collection The collection to iterate over.
  20062. * @param {Function} iteratee The function invoked per iteration.
  20063. * @returns {Array} Returns the new mapped array.
  20064. */
  20065. function baseMap(collection, iteratee) {
  20066. var index = -1,
  20067. result = isArrayLike(collection) ? Array(collection.length) : [];
  20068. baseEach(collection, function(value, key, collection) {
  20069. result[++index] = iteratee(value, key, collection);
  20070. });
  20071. return result;
  20072. }
  20073. /**
  20074. * The base implementation of `_.matches` which doesn't clone `source`.
  20075. *
  20076. * @private
  20077. * @param {Object} source The object of property values to match.
  20078. * @returns {Function} Returns the new spec function.
  20079. */
  20080. function baseMatches(source) {
  20081. var matchData = getMatchData(source);
  20082. if (matchData.length == 1 && matchData[0][2]) {
  20083. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20084. }
  20085. return function(object) {
  20086. return object === source || baseIsMatch(object, source, matchData);
  20087. };
  20088. }
  20089. /**
  20090. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20091. *
  20092. * @private
  20093. * @param {string} path The path of the property to get.
  20094. * @param {*} srcValue The value to match.
  20095. * @returns {Function} Returns the new spec function.
  20096. */
  20097. function baseMatchesProperty(path, srcValue) {
  20098. if (isKey(path) && isStrictComparable(srcValue)) {
  20099. return matchesStrictComparable(toKey(path), srcValue);
  20100. }
  20101. return function(object) {
  20102. var objValue = get(object, path);
  20103. return (objValue === undefined && objValue === srcValue)
  20104. ? hasIn(object, path)
  20105. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20106. };
  20107. }
  20108. /**
  20109. * The base implementation of `_.merge` without support for multiple sources.
  20110. *
  20111. * @private
  20112. * @param {Object} object The destination object.
  20113. * @param {Object} source The source object.
  20114. * @param {number} srcIndex The index of `source`.
  20115. * @param {Function} [customizer] The function to customize merged values.
  20116. * @param {Object} [stack] Tracks traversed source values and their merged
  20117. * counterparts.
  20118. */
  20119. function baseMerge(object, source, srcIndex, customizer, stack) {
  20120. if (object === source) {
  20121. return;
  20122. }
  20123. baseFor(source, function(srcValue, key) {
  20124. stack || (stack = new Stack);
  20125. if (isObject(srcValue)) {
  20126. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20127. }
  20128. else {
  20129. var newValue = customizer
  20130. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20131. : undefined;
  20132. if (newValue === undefined) {
  20133. newValue = srcValue;
  20134. }
  20135. assignMergeValue(object, key, newValue);
  20136. }
  20137. }, keysIn);
  20138. }
  20139. /**
  20140. * A specialized version of `baseMerge` for arrays and objects which performs
  20141. * deep merges and tracks traversed objects enabling objects with circular
  20142. * references to be merged.
  20143. *
  20144. * @private
  20145. * @param {Object} object The destination object.
  20146. * @param {Object} source The source object.
  20147. * @param {string} key The key of the value to merge.
  20148. * @param {number} srcIndex The index of `source`.
  20149. * @param {Function} mergeFunc The function to merge values.
  20150. * @param {Function} [customizer] The function to customize assigned values.
  20151. * @param {Object} [stack] Tracks traversed source values and their merged
  20152. * counterparts.
  20153. */
  20154. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20155. var objValue = safeGet(object, key),
  20156. srcValue = safeGet(source, key),
  20157. stacked = stack.get(srcValue);
  20158. if (stacked) {
  20159. assignMergeValue(object, key, stacked);
  20160. return;
  20161. }
  20162. var newValue = customizer
  20163. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20164. : undefined;
  20165. var isCommon = newValue === undefined;
  20166. if (isCommon) {
  20167. var isArr = isArray(srcValue),
  20168. isBuff = !isArr && isBuffer(srcValue),
  20169. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20170. newValue = srcValue;
  20171. if (isArr || isBuff || isTyped) {
  20172. if (isArray(objValue)) {
  20173. newValue = objValue;
  20174. }
  20175. else if (isArrayLikeObject(objValue)) {
  20176. newValue = copyArray(objValue);
  20177. }
  20178. else if (isBuff) {
  20179. isCommon = false;
  20180. newValue = cloneBuffer(srcValue, true);
  20181. }
  20182. else if (isTyped) {
  20183. isCommon = false;
  20184. newValue = cloneTypedArray(srcValue, true);
  20185. }
  20186. else {
  20187. newValue = [];
  20188. }
  20189. }
  20190. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20191. newValue = objValue;
  20192. if (isArguments(objValue)) {
  20193. newValue = toPlainObject(objValue);
  20194. }
  20195. else if (!isObject(objValue) || isFunction(objValue)) {
  20196. newValue = initCloneObject(srcValue);
  20197. }
  20198. }
  20199. else {
  20200. isCommon = false;
  20201. }
  20202. }
  20203. if (isCommon) {
  20204. // Recursively merge objects and arrays (susceptible to call stack limits).
  20205. stack.set(srcValue, newValue);
  20206. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20207. stack['delete'](srcValue);
  20208. }
  20209. assignMergeValue(object, key, newValue);
  20210. }
  20211. /**
  20212. * The base implementation of `_.nth` which doesn't coerce arguments.
  20213. *
  20214. * @private
  20215. * @param {Array} array The array to query.
  20216. * @param {number} n The index of the element to return.
  20217. * @returns {*} Returns the nth element of `array`.
  20218. */
  20219. function baseNth(array, n) {
  20220. var length = array.length;
  20221. if (!length) {
  20222. return;
  20223. }
  20224. n += n < 0 ? length : 0;
  20225. return isIndex(n, length) ? array[n] : undefined;
  20226. }
  20227. /**
  20228. * The base implementation of `_.orderBy` without param guards.
  20229. *
  20230. * @private
  20231. * @param {Array|Object} collection The collection to iterate over.
  20232. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20233. * @param {string[]} orders The sort orders of `iteratees`.
  20234. * @returns {Array} Returns the new sorted array.
  20235. */
  20236. function baseOrderBy(collection, iteratees, orders) {
  20237. var index = -1;
  20238. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20239. var result = baseMap(collection, function(value, key, collection) {
  20240. var criteria = arrayMap(iteratees, function(iteratee) {
  20241. return iteratee(value);
  20242. });
  20243. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20244. });
  20245. return baseSortBy(result, function(object, other) {
  20246. return compareMultiple(object, other, orders);
  20247. });
  20248. }
  20249. /**
  20250. * The base implementation of `_.pick` without support for individual
  20251. * property identifiers.
  20252. *
  20253. * @private
  20254. * @param {Object} object The source object.
  20255. * @param {string[]} paths The property paths to pick.
  20256. * @returns {Object} Returns the new object.
  20257. */
  20258. function basePick(object, paths) {
  20259. return basePickBy(object, paths, function(value, path) {
  20260. return hasIn(object, path);
  20261. });
  20262. }
  20263. /**
  20264. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20265. *
  20266. * @private
  20267. * @param {Object} object The source object.
  20268. * @param {string[]} paths The property paths to pick.
  20269. * @param {Function} predicate The function invoked per property.
  20270. * @returns {Object} Returns the new object.
  20271. */
  20272. function basePickBy(object, paths, predicate) {
  20273. var index = -1,
  20274. length = paths.length,
  20275. result = {};
  20276. while (++index < length) {
  20277. var path = paths[index],
  20278. value = baseGet(object, path);
  20279. if (predicate(value, path)) {
  20280. baseSet(result, castPath(path, object), value);
  20281. }
  20282. }
  20283. return result;
  20284. }
  20285. /**
  20286. * A specialized version of `baseProperty` which supports deep paths.
  20287. *
  20288. * @private
  20289. * @param {Array|string} path The path of the property to get.
  20290. * @returns {Function} Returns the new accessor function.
  20291. */
  20292. function basePropertyDeep(path) {
  20293. return function(object) {
  20294. return baseGet(object, path);
  20295. };
  20296. }
  20297. /**
  20298. * The base implementation of `_.pullAllBy` without support for iteratee
  20299. * shorthands.
  20300. *
  20301. * @private
  20302. * @param {Array} array The array to modify.
  20303. * @param {Array} values The values to remove.
  20304. * @param {Function} [iteratee] The iteratee invoked per element.
  20305. * @param {Function} [comparator] The comparator invoked per element.
  20306. * @returns {Array} Returns `array`.
  20307. */
  20308. function basePullAll(array, values, iteratee, comparator) {
  20309. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20310. index = -1,
  20311. length = values.length,
  20312. seen = array;
  20313. if (array === values) {
  20314. values = copyArray(values);
  20315. }
  20316. if (iteratee) {
  20317. seen = arrayMap(array, baseUnary(iteratee));
  20318. }
  20319. while (++index < length) {
  20320. var fromIndex = 0,
  20321. value = values[index],
  20322. computed = iteratee ? iteratee(value) : value;
  20323. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20324. if (seen !== array) {
  20325. splice.call(seen, fromIndex, 1);
  20326. }
  20327. splice.call(array, fromIndex, 1);
  20328. }
  20329. }
  20330. return array;
  20331. }
  20332. /**
  20333. * The base implementation of `_.pullAt` without support for individual
  20334. * indexes or capturing the removed elements.
  20335. *
  20336. * @private
  20337. * @param {Array} array The array to modify.
  20338. * @param {number[]} indexes The indexes of elements to remove.
  20339. * @returns {Array} Returns `array`.
  20340. */
  20341. function basePullAt(array, indexes) {
  20342. var length = array ? indexes.length : 0,
  20343. lastIndex = length - 1;
  20344. while (length--) {
  20345. var index = indexes[length];
  20346. if (length == lastIndex || index !== previous) {
  20347. var previous = index;
  20348. if (isIndex(index)) {
  20349. splice.call(array, index, 1);
  20350. } else {
  20351. baseUnset(array, index);
  20352. }
  20353. }
  20354. }
  20355. return array;
  20356. }
  20357. /**
  20358. * The base implementation of `_.random` without support for returning
  20359. * floating-point numbers.
  20360. *
  20361. * @private
  20362. * @param {number} lower The lower bound.
  20363. * @param {number} upper The upper bound.
  20364. * @returns {number} Returns the random number.
  20365. */
  20366. function baseRandom(lower, upper) {
  20367. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20368. }
  20369. /**
  20370. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20371. * coerce arguments.
  20372. *
  20373. * @private
  20374. * @param {number} start The start of the range.
  20375. * @param {number} end The end of the range.
  20376. * @param {number} step The value to increment or decrement by.
  20377. * @param {boolean} [fromRight] Specify iterating from right to left.
  20378. * @returns {Array} Returns the range of numbers.
  20379. */
  20380. function baseRange(start, end, step, fromRight) {
  20381. var index = -1,
  20382. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20383. result = Array(length);
  20384. while (length--) {
  20385. result[fromRight ? length : ++index] = start;
  20386. start += step;
  20387. }
  20388. return result;
  20389. }
  20390. /**
  20391. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20392. *
  20393. * @private
  20394. * @param {string} string The string to repeat.
  20395. * @param {number} n The number of times to repeat the string.
  20396. * @returns {string} Returns the repeated string.
  20397. */
  20398. function baseRepeat(string, n) {
  20399. var result = '';
  20400. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20401. return result;
  20402. }
  20403. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20404. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20405. do {
  20406. if (n % 2) {
  20407. result += string;
  20408. }
  20409. n = nativeFloor(n / 2);
  20410. if (n) {
  20411. string += string;
  20412. }
  20413. } while (n);
  20414. return result;
  20415. }
  20416. /**
  20417. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20418. *
  20419. * @private
  20420. * @param {Function} func The function to apply a rest parameter to.
  20421. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20422. * @returns {Function} Returns the new function.
  20423. */
  20424. function baseRest(func, start) {
  20425. return setToString(overRest(func, start, identity), func + '');
  20426. }
  20427. /**
  20428. * The base implementation of `_.sample`.
  20429. *
  20430. * @private
  20431. * @param {Array|Object} collection The collection to sample.
  20432. * @returns {*} Returns the random element.
  20433. */
  20434. function baseSample(collection) {
  20435. return arraySample(values(collection));
  20436. }
  20437. /**
  20438. * The base implementation of `_.sampleSize` without param guards.
  20439. *
  20440. * @private
  20441. * @param {Array|Object} collection The collection to sample.
  20442. * @param {number} n The number of elements to sample.
  20443. * @returns {Array} Returns the random elements.
  20444. */
  20445. function baseSampleSize(collection, n) {
  20446. var array = values(collection);
  20447. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20448. }
  20449. /**
  20450. * The base implementation of `_.set`.
  20451. *
  20452. * @private
  20453. * @param {Object} object The object to modify.
  20454. * @param {Array|string} path The path of the property to set.
  20455. * @param {*} value The value to set.
  20456. * @param {Function} [customizer] The function to customize path creation.
  20457. * @returns {Object} Returns `object`.
  20458. */
  20459. function baseSet(object, path, value, customizer) {
  20460. if (!isObject(object)) {
  20461. return object;
  20462. }
  20463. path = castPath(path, object);
  20464. var index = -1,
  20465. length = path.length,
  20466. lastIndex = length - 1,
  20467. nested = object;
  20468. while (nested != null && ++index < length) {
  20469. var key = toKey(path[index]),
  20470. newValue = value;
  20471. if (index != lastIndex) {
  20472. var objValue = nested[key];
  20473. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20474. if (newValue === undefined) {
  20475. newValue = isObject(objValue)
  20476. ? objValue
  20477. : (isIndex(path[index + 1]) ? [] : {});
  20478. }
  20479. }
  20480. assignValue(nested, key, newValue);
  20481. nested = nested[key];
  20482. }
  20483. return object;
  20484. }
  20485. /**
  20486. * The base implementation of `setData` without support for hot loop shorting.
  20487. *
  20488. * @private
  20489. * @param {Function} func The function to associate metadata with.
  20490. * @param {*} data The metadata.
  20491. * @returns {Function} Returns `func`.
  20492. */
  20493. var baseSetData = !metaMap ? identity : function(func, data) {
  20494. metaMap.set(func, data);
  20495. return func;
  20496. };
  20497. /**
  20498. * The base implementation of `setToString` without support for hot loop shorting.
  20499. *
  20500. * @private
  20501. * @param {Function} func The function to modify.
  20502. * @param {Function} string The `toString` result.
  20503. * @returns {Function} Returns `func`.
  20504. */
  20505. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20506. return defineProperty(func, 'toString', {
  20507. 'configurable': true,
  20508. 'enumerable': false,
  20509. 'value': constant(string),
  20510. 'writable': true
  20511. });
  20512. };
  20513. /**
  20514. * The base implementation of `_.shuffle`.
  20515. *
  20516. * @private
  20517. * @param {Array|Object} collection The collection to shuffle.
  20518. * @returns {Array} Returns the new shuffled array.
  20519. */
  20520. function baseShuffle(collection) {
  20521. return shuffleSelf(values(collection));
  20522. }
  20523. /**
  20524. * The base implementation of `_.slice` without an iteratee call guard.
  20525. *
  20526. * @private
  20527. * @param {Array} array The array to slice.
  20528. * @param {number} [start=0] The start position.
  20529. * @param {number} [end=array.length] The end position.
  20530. * @returns {Array} Returns the slice of `array`.
  20531. */
  20532. function baseSlice(array, start, end) {
  20533. var index = -1,
  20534. length = array.length;
  20535. if (start < 0) {
  20536. start = -start > length ? 0 : (length + start);
  20537. }
  20538. end = end > length ? length : end;
  20539. if (end < 0) {
  20540. end += length;
  20541. }
  20542. length = start > end ? 0 : ((end - start) >>> 0);
  20543. start >>>= 0;
  20544. var result = Array(length);
  20545. while (++index < length) {
  20546. result[index] = array[index + start];
  20547. }
  20548. return result;
  20549. }
  20550. /**
  20551. * The base implementation of `_.some` without support for iteratee shorthands.
  20552. *
  20553. * @private
  20554. * @param {Array|Object} collection The collection to iterate over.
  20555. * @param {Function} predicate The function invoked per iteration.
  20556. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20557. * else `false`.
  20558. */
  20559. function baseSome(collection, predicate) {
  20560. var result;
  20561. baseEach(collection, function(value, index, collection) {
  20562. result = predicate(value, index, collection);
  20563. return !result;
  20564. });
  20565. return !!result;
  20566. }
  20567. /**
  20568. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20569. * performs a binary search of `array` to determine the index at which `value`
  20570. * should be inserted into `array` in order to maintain its sort order.
  20571. *
  20572. * @private
  20573. * @param {Array} array The sorted array to inspect.
  20574. * @param {*} value The value to evaluate.
  20575. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20576. * @returns {number} Returns the index at which `value` should be inserted
  20577. * into `array`.
  20578. */
  20579. function baseSortedIndex(array, value, retHighest) {
  20580. var low = 0,
  20581. high = array == null ? low : array.length;
  20582. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20583. while (low < high) {
  20584. var mid = (low + high) >>> 1,
  20585. computed = array[mid];
  20586. if (computed !== null && !isSymbol(computed) &&
  20587. (retHighest ? (computed <= value) : (computed < value))) {
  20588. low = mid + 1;
  20589. } else {
  20590. high = mid;
  20591. }
  20592. }
  20593. return high;
  20594. }
  20595. return baseSortedIndexBy(array, value, identity, retHighest);
  20596. }
  20597. /**
  20598. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20599. * which invokes `iteratee` for `value` and each element of `array` to compute
  20600. * their sort ranking. The iteratee is invoked with one argument; (value).
  20601. *
  20602. * @private
  20603. * @param {Array} array The sorted array to inspect.
  20604. * @param {*} value The value to evaluate.
  20605. * @param {Function} iteratee The iteratee invoked per element.
  20606. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20607. * @returns {number} Returns the index at which `value` should be inserted
  20608. * into `array`.
  20609. */
  20610. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20611. value = iteratee(value);
  20612. var low = 0,
  20613. high = array == null ? 0 : array.length,
  20614. valIsNaN = value !== value,
  20615. valIsNull = value === null,
  20616. valIsSymbol = isSymbol(value),
  20617. valIsUndefined = value === undefined;
  20618. while (low < high) {
  20619. var mid = nativeFloor((low + high) / 2),
  20620. computed = iteratee(array[mid]),
  20621. othIsDefined = computed !== undefined,
  20622. othIsNull = computed === null,
  20623. othIsReflexive = computed === computed,
  20624. othIsSymbol = isSymbol(computed);
  20625. if (valIsNaN) {
  20626. var setLow = retHighest || othIsReflexive;
  20627. } else if (valIsUndefined) {
  20628. setLow = othIsReflexive && (retHighest || othIsDefined);
  20629. } else if (valIsNull) {
  20630. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20631. } else if (valIsSymbol) {
  20632. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20633. } else if (othIsNull || othIsSymbol) {
  20634. setLow = false;
  20635. } else {
  20636. setLow = retHighest ? (computed <= value) : (computed < value);
  20637. }
  20638. if (setLow) {
  20639. low = mid + 1;
  20640. } else {
  20641. high = mid;
  20642. }
  20643. }
  20644. return nativeMin(high, MAX_ARRAY_INDEX);
  20645. }
  20646. /**
  20647. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20648. * support for iteratee shorthands.
  20649. *
  20650. * @private
  20651. * @param {Array} array The array to inspect.
  20652. * @param {Function} [iteratee] The iteratee invoked per element.
  20653. * @returns {Array} Returns the new duplicate free array.
  20654. */
  20655. function baseSortedUniq(array, iteratee) {
  20656. var index = -1,
  20657. length = array.length,
  20658. resIndex = 0,
  20659. result = [];
  20660. while (++index < length) {
  20661. var value = array[index],
  20662. computed = iteratee ? iteratee(value) : value;
  20663. if (!index || !eq(computed, seen)) {
  20664. var seen = computed;
  20665. result[resIndex++] = value === 0 ? 0 : value;
  20666. }
  20667. }
  20668. return result;
  20669. }
  20670. /**
  20671. * The base implementation of `_.toNumber` which doesn't ensure correct
  20672. * conversions of binary, hexadecimal, or octal string values.
  20673. *
  20674. * @private
  20675. * @param {*} value The value to process.
  20676. * @returns {number} Returns the number.
  20677. */
  20678. function baseToNumber(value) {
  20679. if (typeof value == 'number') {
  20680. return value;
  20681. }
  20682. if (isSymbol(value)) {
  20683. return NAN;
  20684. }
  20685. return +value;
  20686. }
  20687. /**
  20688. * The base implementation of `_.toString` which doesn't convert nullish
  20689. * values to empty strings.
  20690. *
  20691. * @private
  20692. * @param {*} value The value to process.
  20693. * @returns {string} Returns the string.
  20694. */
  20695. function baseToString(value) {
  20696. // Exit early for strings to avoid a performance hit in some environments.
  20697. if (typeof value == 'string') {
  20698. return value;
  20699. }
  20700. if (isArray(value)) {
  20701. // Recursively convert values (susceptible to call stack limits).
  20702. return arrayMap(value, baseToString) + '';
  20703. }
  20704. if (isSymbol(value)) {
  20705. return symbolToString ? symbolToString.call(value) : '';
  20706. }
  20707. var result = (value + '');
  20708. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20709. }
  20710. /**
  20711. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20712. *
  20713. * @private
  20714. * @param {Array} array The array to inspect.
  20715. * @param {Function} [iteratee] The iteratee invoked per element.
  20716. * @param {Function} [comparator] The comparator invoked per element.
  20717. * @returns {Array} Returns the new duplicate free array.
  20718. */
  20719. function baseUniq(array, iteratee, comparator) {
  20720. var index = -1,
  20721. includes = arrayIncludes,
  20722. length = array.length,
  20723. isCommon = true,
  20724. result = [],
  20725. seen = result;
  20726. if (comparator) {
  20727. isCommon = false;
  20728. includes = arrayIncludesWith;
  20729. }
  20730. else if (length >= LARGE_ARRAY_SIZE) {
  20731. var set = iteratee ? null : createSet(array);
  20732. if (set) {
  20733. return setToArray(set);
  20734. }
  20735. isCommon = false;
  20736. includes = cacheHas;
  20737. seen = new SetCache;
  20738. }
  20739. else {
  20740. seen = iteratee ? [] : result;
  20741. }
  20742. outer:
  20743. while (++index < length) {
  20744. var value = array[index],
  20745. computed = iteratee ? iteratee(value) : value;
  20746. value = (comparator || value !== 0) ? value : 0;
  20747. if (isCommon && computed === computed) {
  20748. var seenIndex = seen.length;
  20749. while (seenIndex--) {
  20750. if (seen[seenIndex] === computed) {
  20751. continue outer;
  20752. }
  20753. }
  20754. if (iteratee) {
  20755. seen.push(computed);
  20756. }
  20757. result.push(value);
  20758. }
  20759. else if (!includes(seen, computed, comparator)) {
  20760. if (seen !== result) {
  20761. seen.push(computed);
  20762. }
  20763. result.push(value);
  20764. }
  20765. }
  20766. return result;
  20767. }
  20768. /**
  20769. * The base implementation of `_.unset`.
  20770. *
  20771. * @private
  20772. * @param {Object} object The object to modify.
  20773. * @param {Array|string} path The property path to unset.
  20774. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20775. */
  20776. function baseUnset(object, path) {
  20777. path = castPath(path, object);
  20778. object = parent(object, path);
  20779. return object == null || delete object[toKey(last(path))];
  20780. }
  20781. /**
  20782. * The base implementation of `_.update`.
  20783. *
  20784. * @private
  20785. * @param {Object} object The object to modify.
  20786. * @param {Array|string} path The path of the property to update.
  20787. * @param {Function} updater The function to produce the updated value.
  20788. * @param {Function} [customizer] The function to customize path creation.
  20789. * @returns {Object} Returns `object`.
  20790. */
  20791. function baseUpdate(object, path, updater, customizer) {
  20792. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20793. }
  20794. /**
  20795. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20796. * without support for iteratee shorthands.
  20797. *
  20798. * @private
  20799. * @param {Array} array The array to query.
  20800. * @param {Function} predicate The function invoked per iteration.
  20801. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20802. * @param {boolean} [fromRight] Specify iterating from right to left.
  20803. * @returns {Array} Returns the slice of `array`.
  20804. */
  20805. function baseWhile(array, predicate, isDrop, fromRight) {
  20806. var length = array.length,
  20807. index = fromRight ? length : -1;
  20808. while ((fromRight ? index-- : ++index < length) &&
  20809. predicate(array[index], index, array)) {}
  20810. return isDrop
  20811. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20812. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20813. }
  20814. /**
  20815. * The base implementation of `wrapperValue` which returns the result of
  20816. * performing a sequence of actions on the unwrapped `value`, where each
  20817. * successive action is supplied the return value of the previous.
  20818. *
  20819. * @private
  20820. * @param {*} value The unwrapped value.
  20821. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20822. * @returns {*} Returns the resolved value.
  20823. */
  20824. function baseWrapperValue(value, actions) {
  20825. var result = value;
  20826. if (result instanceof LazyWrapper) {
  20827. result = result.value();
  20828. }
  20829. return arrayReduce(actions, function(result, action) {
  20830. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20831. }, result);
  20832. }
  20833. /**
  20834. * The base implementation of methods like `_.xor`, without support for
  20835. * iteratee shorthands, that accepts an array of arrays to inspect.
  20836. *
  20837. * @private
  20838. * @param {Array} arrays The arrays to inspect.
  20839. * @param {Function} [iteratee] The iteratee invoked per element.
  20840. * @param {Function} [comparator] The comparator invoked per element.
  20841. * @returns {Array} Returns the new array of values.
  20842. */
  20843. function baseXor(arrays, iteratee, comparator) {
  20844. var length = arrays.length;
  20845. if (length < 2) {
  20846. return length ? baseUniq(arrays[0]) : [];
  20847. }
  20848. var index = -1,
  20849. result = Array(length);
  20850. while (++index < length) {
  20851. var array = arrays[index],
  20852. othIndex = -1;
  20853. while (++othIndex < length) {
  20854. if (othIndex != index) {
  20855. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20856. }
  20857. }
  20858. }
  20859. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20860. }
  20861. /**
  20862. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20863. *
  20864. * @private
  20865. * @param {Array} props The property identifiers.
  20866. * @param {Array} values The property values.
  20867. * @param {Function} assignFunc The function to assign values.
  20868. * @returns {Object} Returns the new object.
  20869. */
  20870. function baseZipObject(props, values, assignFunc) {
  20871. var index = -1,
  20872. length = props.length,
  20873. valsLength = values.length,
  20874. result = {};
  20875. while (++index < length) {
  20876. var value = index < valsLength ? values[index] : undefined;
  20877. assignFunc(result, props[index], value);
  20878. }
  20879. return result;
  20880. }
  20881. /**
  20882. * Casts `value` to an empty array if it's not an array like object.
  20883. *
  20884. * @private
  20885. * @param {*} value The value to inspect.
  20886. * @returns {Array|Object} Returns the cast array-like object.
  20887. */
  20888. function castArrayLikeObject(value) {
  20889. return isArrayLikeObject(value) ? value : [];
  20890. }
  20891. /**
  20892. * Casts `value` to `identity` if it's not a function.
  20893. *
  20894. * @private
  20895. * @param {*} value The value to inspect.
  20896. * @returns {Function} Returns cast function.
  20897. */
  20898. function castFunction(value) {
  20899. return typeof value == 'function' ? value : identity;
  20900. }
  20901. /**
  20902. * Casts `value` to a path array if it's not one.
  20903. *
  20904. * @private
  20905. * @param {*} value The value to inspect.
  20906. * @param {Object} [object] The object to query keys on.
  20907. * @returns {Array} Returns the cast property path array.
  20908. */
  20909. function castPath(value, object) {
  20910. if (isArray(value)) {
  20911. return value;
  20912. }
  20913. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20914. }
  20915. /**
  20916. * A `baseRest` alias which can be replaced with `identity` by module
  20917. * replacement plugins.
  20918. *
  20919. * @private
  20920. * @type {Function}
  20921. * @param {Function} func The function to apply a rest parameter to.
  20922. * @returns {Function} Returns the new function.
  20923. */
  20924. var castRest = baseRest;
  20925. /**
  20926. * Casts `array` to a slice if it's needed.
  20927. *
  20928. * @private
  20929. * @param {Array} array The array to inspect.
  20930. * @param {number} start The start position.
  20931. * @param {number} [end=array.length] The end position.
  20932. * @returns {Array} Returns the cast slice.
  20933. */
  20934. function castSlice(array, start, end) {
  20935. var length = array.length;
  20936. end = end === undefined ? length : end;
  20937. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20938. }
  20939. /**
  20940. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20941. *
  20942. * @private
  20943. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20944. */
  20945. var clearTimeout = ctxClearTimeout || function(id) {
  20946. return root.clearTimeout(id);
  20947. };
  20948. /**
  20949. * Creates a clone of `buffer`.
  20950. *
  20951. * @private
  20952. * @param {Buffer} buffer The buffer to clone.
  20953. * @param {boolean} [isDeep] Specify a deep clone.
  20954. * @returns {Buffer} Returns the cloned buffer.
  20955. */
  20956. function cloneBuffer(buffer, isDeep) {
  20957. if (isDeep) {
  20958. return buffer.slice();
  20959. }
  20960. var length = buffer.length,
  20961. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20962. buffer.copy(result);
  20963. return result;
  20964. }
  20965. /**
  20966. * Creates a clone of `arrayBuffer`.
  20967. *
  20968. * @private
  20969. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20970. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20971. */
  20972. function cloneArrayBuffer(arrayBuffer) {
  20973. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20974. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20975. return result;
  20976. }
  20977. /**
  20978. * Creates a clone of `dataView`.
  20979. *
  20980. * @private
  20981. * @param {Object} dataView The data view to clone.
  20982. * @param {boolean} [isDeep] Specify a deep clone.
  20983. * @returns {Object} Returns the cloned data view.
  20984. */
  20985. function cloneDataView(dataView, isDeep) {
  20986. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20987. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20988. }
  20989. /**
  20990. * Creates a clone of `regexp`.
  20991. *
  20992. * @private
  20993. * @param {Object} regexp The regexp to clone.
  20994. * @returns {Object} Returns the cloned regexp.
  20995. */
  20996. function cloneRegExp(regexp) {
  20997. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20998. result.lastIndex = regexp.lastIndex;
  20999. return result;
  21000. }
  21001. /**
  21002. * Creates a clone of the `symbol` object.
  21003. *
  21004. * @private
  21005. * @param {Object} symbol The symbol object to clone.
  21006. * @returns {Object} Returns the cloned symbol object.
  21007. */
  21008. function cloneSymbol(symbol) {
  21009. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21010. }
  21011. /**
  21012. * Creates a clone of `typedArray`.
  21013. *
  21014. * @private
  21015. * @param {Object} typedArray The typed array to clone.
  21016. * @param {boolean} [isDeep] Specify a deep clone.
  21017. * @returns {Object} Returns the cloned typed array.
  21018. */
  21019. function cloneTypedArray(typedArray, isDeep) {
  21020. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21021. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21022. }
  21023. /**
  21024. * Compares values to sort them in ascending order.
  21025. *
  21026. * @private
  21027. * @param {*} value The value to compare.
  21028. * @param {*} other The other value to compare.
  21029. * @returns {number} Returns the sort order indicator for `value`.
  21030. */
  21031. function compareAscending(value, other) {
  21032. if (value !== other) {
  21033. var valIsDefined = value !== undefined,
  21034. valIsNull = value === null,
  21035. valIsReflexive = value === value,
  21036. valIsSymbol = isSymbol(value);
  21037. var othIsDefined = other !== undefined,
  21038. othIsNull = other === null,
  21039. othIsReflexive = other === other,
  21040. othIsSymbol = isSymbol(other);
  21041. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21042. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21043. (valIsNull && othIsDefined && othIsReflexive) ||
  21044. (!valIsDefined && othIsReflexive) ||
  21045. !valIsReflexive) {
  21046. return 1;
  21047. }
  21048. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21049. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21050. (othIsNull && valIsDefined && valIsReflexive) ||
  21051. (!othIsDefined && valIsReflexive) ||
  21052. !othIsReflexive) {
  21053. return -1;
  21054. }
  21055. }
  21056. return 0;
  21057. }
  21058. /**
  21059. * Used by `_.orderBy` to compare multiple properties of a value to another
  21060. * and stable sort them.
  21061. *
  21062. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21063. * specify an order of "desc" for descending or "asc" for ascending sort order
  21064. * of corresponding values.
  21065. *
  21066. * @private
  21067. * @param {Object} object The object to compare.
  21068. * @param {Object} other The other object to compare.
  21069. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21070. * @returns {number} Returns the sort order indicator for `object`.
  21071. */
  21072. function compareMultiple(object, other, orders) {
  21073. var index = -1,
  21074. objCriteria = object.criteria,
  21075. othCriteria = other.criteria,
  21076. length = objCriteria.length,
  21077. ordersLength = orders.length;
  21078. while (++index < length) {
  21079. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21080. if (result) {
  21081. if (index >= ordersLength) {
  21082. return result;
  21083. }
  21084. var order = orders[index];
  21085. return result * (order == 'desc' ? -1 : 1);
  21086. }
  21087. }
  21088. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21089. // that causes it, under certain circumstances, to provide the same value for
  21090. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21091. // for more details.
  21092. //
  21093. // This also ensures a stable sort in V8 and other engines.
  21094. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21095. return object.index - other.index;
  21096. }
  21097. /**
  21098. * Creates an array that is the composition of partially applied arguments,
  21099. * placeholders, and provided arguments into a single array of arguments.
  21100. *
  21101. * @private
  21102. * @param {Array} args The provided arguments.
  21103. * @param {Array} partials The arguments to prepend to those provided.
  21104. * @param {Array} holders The `partials` placeholder indexes.
  21105. * @params {boolean} [isCurried] Specify composing for a curried function.
  21106. * @returns {Array} Returns the new array of composed arguments.
  21107. */
  21108. function composeArgs(args, partials, holders, isCurried) {
  21109. var argsIndex = -1,
  21110. argsLength = args.length,
  21111. holdersLength = holders.length,
  21112. leftIndex = -1,
  21113. leftLength = partials.length,
  21114. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21115. result = Array(leftLength + rangeLength),
  21116. isUncurried = !isCurried;
  21117. while (++leftIndex < leftLength) {
  21118. result[leftIndex] = partials[leftIndex];
  21119. }
  21120. while (++argsIndex < holdersLength) {
  21121. if (isUncurried || argsIndex < argsLength) {
  21122. result[holders[argsIndex]] = args[argsIndex];
  21123. }
  21124. }
  21125. while (rangeLength--) {
  21126. result[leftIndex++] = args[argsIndex++];
  21127. }
  21128. return result;
  21129. }
  21130. /**
  21131. * This function is like `composeArgs` except that the arguments composition
  21132. * is tailored for `_.partialRight`.
  21133. *
  21134. * @private
  21135. * @param {Array} args The provided arguments.
  21136. * @param {Array} partials The arguments to append to those provided.
  21137. * @param {Array} holders The `partials` placeholder indexes.
  21138. * @params {boolean} [isCurried] Specify composing for a curried function.
  21139. * @returns {Array} Returns the new array of composed arguments.
  21140. */
  21141. function composeArgsRight(args, partials, holders, isCurried) {
  21142. var argsIndex = -1,
  21143. argsLength = args.length,
  21144. holdersIndex = -1,
  21145. holdersLength = holders.length,
  21146. rightIndex = -1,
  21147. rightLength = partials.length,
  21148. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21149. result = Array(rangeLength + rightLength),
  21150. isUncurried = !isCurried;
  21151. while (++argsIndex < rangeLength) {
  21152. result[argsIndex] = args[argsIndex];
  21153. }
  21154. var offset = argsIndex;
  21155. while (++rightIndex < rightLength) {
  21156. result[offset + rightIndex] = partials[rightIndex];
  21157. }
  21158. while (++holdersIndex < holdersLength) {
  21159. if (isUncurried || argsIndex < argsLength) {
  21160. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21161. }
  21162. }
  21163. return result;
  21164. }
  21165. /**
  21166. * Copies the values of `source` to `array`.
  21167. *
  21168. * @private
  21169. * @param {Array} source The array to copy values from.
  21170. * @param {Array} [array=[]] The array to copy values to.
  21171. * @returns {Array} Returns `array`.
  21172. */
  21173. function copyArray(source, array) {
  21174. var index = -1,
  21175. length = source.length;
  21176. array || (array = Array(length));
  21177. while (++index < length) {
  21178. array[index] = source[index];
  21179. }
  21180. return array;
  21181. }
  21182. /**
  21183. * Copies properties of `source` to `object`.
  21184. *
  21185. * @private
  21186. * @param {Object} source The object to copy properties from.
  21187. * @param {Array} props The property identifiers to copy.
  21188. * @param {Object} [object={}] The object to copy properties to.
  21189. * @param {Function} [customizer] The function to customize copied values.
  21190. * @returns {Object} Returns `object`.
  21191. */
  21192. function copyObject(source, props, object, customizer) {
  21193. var isNew = !object;
  21194. object || (object = {});
  21195. var index = -1,
  21196. length = props.length;
  21197. while (++index < length) {
  21198. var key = props[index];
  21199. var newValue = customizer
  21200. ? customizer(object[key], source[key], key, object, source)
  21201. : undefined;
  21202. if (newValue === undefined) {
  21203. newValue = source[key];
  21204. }
  21205. if (isNew) {
  21206. baseAssignValue(object, key, newValue);
  21207. } else {
  21208. assignValue(object, key, newValue);
  21209. }
  21210. }
  21211. return object;
  21212. }
  21213. /**
  21214. * Copies own symbols of `source` to `object`.
  21215. *
  21216. * @private
  21217. * @param {Object} source The object to copy symbols from.
  21218. * @param {Object} [object={}] The object to copy symbols to.
  21219. * @returns {Object} Returns `object`.
  21220. */
  21221. function copySymbols(source, object) {
  21222. return copyObject(source, getSymbols(source), object);
  21223. }
  21224. /**
  21225. * Copies own and inherited symbols of `source` to `object`.
  21226. *
  21227. * @private
  21228. * @param {Object} source The object to copy symbols from.
  21229. * @param {Object} [object={}] The object to copy symbols to.
  21230. * @returns {Object} Returns `object`.
  21231. */
  21232. function copySymbolsIn(source, object) {
  21233. return copyObject(source, getSymbolsIn(source), object);
  21234. }
  21235. /**
  21236. * Creates a function like `_.groupBy`.
  21237. *
  21238. * @private
  21239. * @param {Function} setter The function to set accumulator values.
  21240. * @param {Function} [initializer] The accumulator object initializer.
  21241. * @returns {Function} Returns the new aggregator function.
  21242. */
  21243. function createAggregator(setter, initializer) {
  21244. return function(collection, iteratee) {
  21245. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21246. accumulator = initializer ? initializer() : {};
  21247. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21248. };
  21249. }
  21250. /**
  21251. * Creates a function like `_.assign`.
  21252. *
  21253. * @private
  21254. * @param {Function} assigner The function to assign values.
  21255. * @returns {Function} Returns the new assigner function.
  21256. */
  21257. function createAssigner(assigner) {
  21258. return baseRest(function(object, sources) {
  21259. var index = -1,
  21260. length = sources.length,
  21261. customizer = length > 1 ? sources[length - 1] : undefined,
  21262. guard = length > 2 ? sources[2] : undefined;
  21263. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21264. ? (length--, customizer)
  21265. : undefined;
  21266. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21267. customizer = length < 3 ? undefined : customizer;
  21268. length = 1;
  21269. }
  21270. object = Object(object);
  21271. while (++index < length) {
  21272. var source = sources[index];
  21273. if (source) {
  21274. assigner(object, source, index, customizer);
  21275. }
  21276. }
  21277. return object;
  21278. });
  21279. }
  21280. /**
  21281. * Creates a `baseEach` or `baseEachRight` function.
  21282. *
  21283. * @private
  21284. * @param {Function} eachFunc The function to iterate over a collection.
  21285. * @param {boolean} [fromRight] Specify iterating from right to left.
  21286. * @returns {Function} Returns the new base function.
  21287. */
  21288. function createBaseEach(eachFunc, fromRight) {
  21289. return function(collection, iteratee) {
  21290. if (collection == null) {
  21291. return collection;
  21292. }
  21293. if (!isArrayLike(collection)) {
  21294. return eachFunc(collection, iteratee);
  21295. }
  21296. var length = collection.length,
  21297. index = fromRight ? length : -1,
  21298. iterable = Object(collection);
  21299. while ((fromRight ? index-- : ++index < length)) {
  21300. if (iteratee(iterable[index], index, iterable) === false) {
  21301. break;
  21302. }
  21303. }
  21304. return collection;
  21305. };
  21306. }
  21307. /**
  21308. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21309. *
  21310. * @private
  21311. * @param {boolean} [fromRight] Specify iterating from right to left.
  21312. * @returns {Function} Returns the new base function.
  21313. */
  21314. function createBaseFor(fromRight) {
  21315. return function(object, iteratee, keysFunc) {
  21316. var index = -1,
  21317. iterable = Object(object),
  21318. props = keysFunc(object),
  21319. length = props.length;
  21320. while (length--) {
  21321. var key = props[fromRight ? length : ++index];
  21322. if (iteratee(iterable[key], key, iterable) === false) {
  21323. break;
  21324. }
  21325. }
  21326. return object;
  21327. };
  21328. }
  21329. /**
  21330. * Creates a function that wraps `func` to invoke it with the optional `this`
  21331. * binding of `thisArg`.
  21332. *
  21333. * @private
  21334. * @param {Function} func The function to wrap.
  21335. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21336. * @param {*} [thisArg] The `this` binding of `func`.
  21337. * @returns {Function} Returns the new wrapped function.
  21338. */
  21339. function createBind(func, bitmask, thisArg) {
  21340. var isBind = bitmask & WRAP_BIND_FLAG,
  21341. Ctor = createCtor(func);
  21342. function wrapper() {
  21343. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21344. return fn.apply(isBind ? thisArg : this, arguments);
  21345. }
  21346. return wrapper;
  21347. }
  21348. /**
  21349. * Creates a function like `_.lowerFirst`.
  21350. *
  21351. * @private
  21352. * @param {string} methodName The name of the `String` case method to use.
  21353. * @returns {Function} Returns the new case function.
  21354. */
  21355. function createCaseFirst(methodName) {
  21356. return function(string) {
  21357. string = toString(string);
  21358. var strSymbols = hasUnicode(string)
  21359. ? stringToArray(string)
  21360. : undefined;
  21361. var chr = strSymbols
  21362. ? strSymbols[0]
  21363. : string.charAt(0);
  21364. var trailing = strSymbols
  21365. ? castSlice(strSymbols, 1).join('')
  21366. : string.slice(1);
  21367. return chr[methodName]() + trailing;
  21368. };
  21369. }
  21370. /**
  21371. * Creates a function like `_.camelCase`.
  21372. *
  21373. * @private
  21374. * @param {Function} callback The function to combine each word.
  21375. * @returns {Function} Returns the new compounder function.
  21376. */
  21377. function createCompounder(callback) {
  21378. return function(string) {
  21379. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21380. };
  21381. }
  21382. /**
  21383. * Creates a function that produces an instance of `Ctor` regardless of
  21384. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21385. *
  21386. * @private
  21387. * @param {Function} Ctor The constructor to wrap.
  21388. * @returns {Function} Returns the new wrapped function.
  21389. */
  21390. function createCtor(Ctor) {
  21391. return function() {
  21392. // Use a `switch` statement to work with class constructors. See
  21393. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21394. // for more details.
  21395. var args = arguments;
  21396. switch (args.length) {
  21397. case 0: return new Ctor;
  21398. case 1: return new Ctor(args[0]);
  21399. case 2: return new Ctor(args[0], args[1]);
  21400. case 3: return new Ctor(args[0], args[1], args[2]);
  21401. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21402. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21403. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21404. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21405. }
  21406. var thisBinding = baseCreate(Ctor.prototype),
  21407. result = Ctor.apply(thisBinding, args);
  21408. // Mimic the constructor's `return` behavior.
  21409. // See https://es5.github.io/#x13.2.2 for more details.
  21410. return isObject(result) ? result : thisBinding;
  21411. };
  21412. }
  21413. /**
  21414. * Creates a function that wraps `func` to enable currying.
  21415. *
  21416. * @private
  21417. * @param {Function} func The function to wrap.
  21418. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21419. * @param {number} arity The arity of `func`.
  21420. * @returns {Function} Returns the new wrapped function.
  21421. */
  21422. function createCurry(func, bitmask, arity) {
  21423. var Ctor = createCtor(func);
  21424. function wrapper() {
  21425. var length = arguments.length,
  21426. args = Array(length),
  21427. index = length,
  21428. placeholder = getHolder(wrapper);
  21429. while (index--) {
  21430. args[index] = arguments[index];
  21431. }
  21432. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21433. ? []
  21434. : replaceHolders(args, placeholder);
  21435. length -= holders.length;
  21436. if (length < arity) {
  21437. return createRecurry(
  21438. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21439. args, holders, undefined, undefined, arity - length);
  21440. }
  21441. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21442. return apply(fn, this, args);
  21443. }
  21444. return wrapper;
  21445. }
  21446. /**
  21447. * Creates a `_.find` or `_.findLast` function.
  21448. *
  21449. * @private
  21450. * @param {Function} findIndexFunc The function to find the collection index.
  21451. * @returns {Function} Returns the new find function.
  21452. */
  21453. function createFind(findIndexFunc) {
  21454. return function(collection, predicate, fromIndex) {
  21455. var iterable = Object(collection);
  21456. if (!isArrayLike(collection)) {
  21457. var iteratee = getIteratee(predicate, 3);
  21458. collection = keys(collection);
  21459. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21460. }
  21461. var index = findIndexFunc(collection, predicate, fromIndex);
  21462. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21463. };
  21464. }
  21465. /**
  21466. * Creates a `_.flow` or `_.flowRight` function.
  21467. *
  21468. * @private
  21469. * @param {boolean} [fromRight] Specify iterating from right to left.
  21470. * @returns {Function} Returns the new flow function.
  21471. */
  21472. function createFlow(fromRight) {
  21473. return flatRest(function(funcs) {
  21474. var length = funcs.length,
  21475. index = length,
  21476. prereq = LodashWrapper.prototype.thru;
  21477. if (fromRight) {
  21478. funcs.reverse();
  21479. }
  21480. while (index--) {
  21481. var func = funcs[index];
  21482. if (typeof func != 'function') {
  21483. throw new TypeError(FUNC_ERROR_TEXT);
  21484. }
  21485. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21486. var wrapper = new LodashWrapper([], true);
  21487. }
  21488. }
  21489. index = wrapper ? index : length;
  21490. while (++index < length) {
  21491. func = funcs[index];
  21492. var funcName = getFuncName(func),
  21493. data = funcName == 'wrapper' ? getData(func) : undefined;
  21494. if (data && isLaziable(data[0]) &&
  21495. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21496. !data[4].length && data[9] == 1
  21497. ) {
  21498. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21499. } else {
  21500. wrapper = (func.length == 1 && isLaziable(func))
  21501. ? wrapper[funcName]()
  21502. : wrapper.thru(func);
  21503. }
  21504. }
  21505. return function() {
  21506. var args = arguments,
  21507. value = args[0];
  21508. if (wrapper && args.length == 1 && isArray(value)) {
  21509. return wrapper.plant(value).value();
  21510. }
  21511. var index = 0,
  21512. result = length ? funcs[index].apply(this, args) : value;
  21513. while (++index < length) {
  21514. result = funcs[index].call(this, result);
  21515. }
  21516. return result;
  21517. };
  21518. });
  21519. }
  21520. /**
  21521. * Creates a function that wraps `func` to invoke it with optional `this`
  21522. * binding of `thisArg`, partial application, and currying.
  21523. *
  21524. * @private
  21525. * @param {Function|string} func The function or method name to wrap.
  21526. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21527. * @param {*} [thisArg] The `this` binding of `func`.
  21528. * @param {Array} [partials] The arguments to prepend to those provided to
  21529. * the new function.
  21530. * @param {Array} [holders] The `partials` placeholder indexes.
  21531. * @param {Array} [partialsRight] The arguments to append to those provided
  21532. * to the new function.
  21533. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21534. * @param {Array} [argPos] The argument positions of the new function.
  21535. * @param {number} [ary] The arity cap of `func`.
  21536. * @param {number} [arity] The arity of `func`.
  21537. * @returns {Function} Returns the new wrapped function.
  21538. */
  21539. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21540. var isAry = bitmask & WRAP_ARY_FLAG,
  21541. isBind = bitmask & WRAP_BIND_FLAG,
  21542. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21543. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21544. isFlip = bitmask & WRAP_FLIP_FLAG,
  21545. Ctor = isBindKey ? undefined : createCtor(func);
  21546. function wrapper() {
  21547. var length = arguments.length,
  21548. args = Array(length),
  21549. index = length;
  21550. while (index--) {
  21551. args[index] = arguments[index];
  21552. }
  21553. if (isCurried) {
  21554. var placeholder = getHolder(wrapper),
  21555. holdersCount = countHolders(args, placeholder);
  21556. }
  21557. if (partials) {
  21558. args = composeArgs(args, partials, holders, isCurried);
  21559. }
  21560. if (partialsRight) {
  21561. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21562. }
  21563. length -= holdersCount;
  21564. if (isCurried && length < arity) {
  21565. var newHolders = replaceHolders(args, placeholder);
  21566. return createRecurry(
  21567. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21568. args, newHolders, argPos, ary, arity - length
  21569. );
  21570. }
  21571. var thisBinding = isBind ? thisArg : this,
  21572. fn = isBindKey ? thisBinding[func] : func;
  21573. length = args.length;
  21574. if (argPos) {
  21575. args = reorder(args, argPos);
  21576. } else if (isFlip && length > 1) {
  21577. args.reverse();
  21578. }
  21579. if (isAry && ary < length) {
  21580. args.length = ary;
  21581. }
  21582. if (this && this !== root && this instanceof wrapper) {
  21583. fn = Ctor || createCtor(fn);
  21584. }
  21585. return fn.apply(thisBinding, args);
  21586. }
  21587. return wrapper;
  21588. }
  21589. /**
  21590. * Creates a function like `_.invertBy`.
  21591. *
  21592. * @private
  21593. * @param {Function} setter The function to set accumulator values.
  21594. * @param {Function} toIteratee The function to resolve iteratees.
  21595. * @returns {Function} Returns the new inverter function.
  21596. */
  21597. function createInverter(setter, toIteratee) {
  21598. return function(object, iteratee) {
  21599. return baseInverter(object, setter, toIteratee(iteratee), {});
  21600. };
  21601. }
  21602. /**
  21603. * Creates a function that performs a mathematical operation on two values.
  21604. *
  21605. * @private
  21606. * @param {Function} operator The function to perform the operation.
  21607. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21608. * @returns {Function} Returns the new mathematical operation function.
  21609. */
  21610. function createMathOperation(operator, defaultValue) {
  21611. return function(value, other) {
  21612. var result;
  21613. if (value === undefined && other === undefined) {
  21614. return defaultValue;
  21615. }
  21616. if (value !== undefined) {
  21617. result = value;
  21618. }
  21619. if (other !== undefined) {
  21620. if (result === undefined) {
  21621. return other;
  21622. }
  21623. if (typeof value == 'string' || typeof other == 'string') {
  21624. value = baseToString(value);
  21625. other = baseToString(other);
  21626. } else {
  21627. value = baseToNumber(value);
  21628. other = baseToNumber(other);
  21629. }
  21630. result = operator(value, other);
  21631. }
  21632. return result;
  21633. };
  21634. }
  21635. /**
  21636. * Creates a function like `_.over`.
  21637. *
  21638. * @private
  21639. * @param {Function} arrayFunc The function to iterate over iteratees.
  21640. * @returns {Function} Returns the new over function.
  21641. */
  21642. function createOver(arrayFunc) {
  21643. return flatRest(function(iteratees) {
  21644. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21645. return baseRest(function(args) {
  21646. var thisArg = this;
  21647. return arrayFunc(iteratees, function(iteratee) {
  21648. return apply(iteratee, thisArg, args);
  21649. });
  21650. });
  21651. });
  21652. }
  21653. /**
  21654. * Creates the padding for `string` based on `length`. The `chars` string
  21655. * is truncated if the number of characters exceeds `length`.
  21656. *
  21657. * @private
  21658. * @param {number} length The padding length.
  21659. * @param {string} [chars=' '] The string used as padding.
  21660. * @returns {string} Returns the padding for `string`.
  21661. */
  21662. function createPadding(length, chars) {
  21663. chars = chars === undefined ? ' ' : baseToString(chars);
  21664. var charsLength = chars.length;
  21665. if (charsLength < 2) {
  21666. return charsLength ? baseRepeat(chars, length) : chars;
  21667. }
  21668. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21669. return hasUnicode(chars)
  21670. ? castSlice(stringToArray(result), 0, length).join('')
  21671. : result.slice(0, length);
  21672. }
  21673. /**
  21674. * Creates a function that wraps `func` to invoke it with the `this` binding
  21675. * of `thisArg` and `partials` prepended to the arguments it receives.
  21676. *
  21677. * @private
  21678. * @param {Function} func The function to wrap.
  21679. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21680. * @param {*} thisArg The `this` binding of `func`.
  21681. * @param {Array} partials The arguments to prepend to those provided to
  21682. * the new function.
  21683. * @returns {Function} Returns the new wrapped function.
  21684. */
  21685. function createPartial(func, bitmask, thisArg, partials) {
  21686. var isBind = bitmask & WRAP_BIND_FLAG,
  21687. Ctor = createCtor(func);
  21688. function wrapper() {
  21689. var argsIndex = -1,
  21690. argsLength = arguments.length,
  21691. leftIndex = -1,
  21692. leftLength = partials.length,
  21693. args = Array(leftLength + argsLength),
  21694. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21695. while (++leftIndex < leftLength) {
  21696. args[leftIndex] = partials[leftIndex];
  21697. }
  21698. while (argsLength--) {
  21699. args[leftIndex++] = arguments[++argsIndex];
  21700. }
  21701. return apply(fn, isBind ? thisArg : this, args);
  21702. }
  21703. return wrapper;
  21704. }
  21705. /**
  21706. * Creates a `_.range` or `_.rangeRight` function.
  21707. *
  21708. * @private
  21709. * @param {boolean} [fromRight] Specify iterating from right to left.
  21710. * @returns {Function} Returns the new range function.
  21711. */
  21712. function createRange(fromRight) {
  21713. return function(start, end, step) {
  21714. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21715. end = step = undefined;
  21716. }
  21717. // Ensure the sign of `-0` is preserved.
  21718. start = toFinite(start);
  21719. if (end === undefined) {
  21720. end = start;
  21721. start = 0;
  21722. } else {
  21723. end = toFinite(end);
  21724. }
  21725. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21726. return baseRange(start, end, step, fromRight);
  21727. };
  21728. }
  21729. /**
  21730. * Creates a function that performs a relational operation on two values.
  21731. *
  21732. * @private
  21733. * @param {Function} operator The function to perform the operation.
  21734. * @returns {Function} Returns the new relational operation function.
  21735. */
  21736. function createRelationalOperation(operator) {
  21737. return function(value, other) {
  21738. if (!(typeof value == 'string' && typeof other == 'string')) {
  21739. value = toNumber(value);
  21740. other = toNumber(other);
  21741. }
  21742. return operator(value, other);
  21743. };
  21744. }
  21745. /**
  21746. * Creates a function that wraps `func` to continue currying.
  21747. *
  21748. * @private
  21749. * @param {Function} func The function to wrap.
  21750. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21751. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21752. * @param {*} placeholder The placeholder value.
  21753. * @param {*} [thisArg] The `this` binding of `func`.
  21754. * @param {Array} [partials] The arguments to prepend to those provided to
  21755. * the new function.
  21756. * @param {Array} [holders] The `partials` placeholder indexes.
  21757. * @param {Array} [argPos] The argument positions of the new function.
  21758. * @param {number} [ary] The arity cap of `func`.
  21759. * @param {number} [arity] The arity of `func`.
  21760. * @returns {Function} Returns the new wrapped function.
  21761. */
  21762. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21763. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21764. newHolders = isCurry ? holders : undefined,
  21765. newHoldersRight = isCurry ? undefined : holders,
  21766. newPartials = isCurry ? partials : undefined,
  21767. newPartialsRight = isCurry ? undefined : partials;
  21768. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21769. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21770. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21771. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21772. }
  21773. var newData = [
  21774. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21775. newHoldersRight, argPos, ary, arity
  21776. ];
  21777. var result = wrapFunc.apply(undefined, newData);
  21778. if (isLaziable(func)) {
  21779. setData(result, newData);
  21780. }
  21781. result.placeholder = placeholder;
  21782. return setWrapToString(result, func, bitmask);
  21783. }
  21784. /**
  21785. * Creates a function like `_.round`.
  21786. *
  21787. * @private
  21788. * @param {string} methodName The name of the `Math` method to use when rounding.
  21789. * @returns {Function} Returns the new round function.
  21790. */
  21791. function createRound(methodName) {
  21792. var func = Math[methodName];
  21793. return function(number, precision) {
  21794. number = toNumber(number);
  21795. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21796. if (precision && nativeIsFinite(number)) {
  21797. // Shift with exponential notation to avoid floating-point issues.
  21798. // See [MDN](https://mdn.io/round#Examples) for more details.
  21799. var pair = (toString(number) + 'e').split('e'),
  21800. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21801. pair = (toString(value) + 'e').split('e');
  21802. return +(pair[0] + 'e' + (+pair[1] - precision));
  21803. }
  21804. return func(number);
  21805. };
  21806. }
  21807. /**
  21808. * Creates a set object of `values`.
  21809. *
  21810. * @private
  21811. * @param {Array} values The values to add to the set.
  21812. * @returns {Object} Returns the new set.
  21813. */
  21814. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21815. return new Set(values);
  21816. };
  21817. /**
  21818. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21819. *
  21820. * @private
  21821. * @param {Function} keysFunc The function to get the keys of a given object.
  21822. * @returns {Function} Returns the new pairs function.
  21823. */
  21824. function createToPairs(keysFunc) {
  21825. return function(object) {
  21826. var tag = getTag(object);
  21827. if (tag == mapTag) {
  21828. return mapToArray(object);
  21829. }
  21830. if (tag == setTag) {
  21831. return setToPairs(object);
  21832. }
  21833. return baseToPairs(object, keysFunc(object));
  21834. };
  21835. }
  21836. /**
  21837. * Creates a function that either curries or invokes `func` with optional
  21838. * `this` binding and partially applied arguments.
  21839. *
  21840. * @private
  21841. * @param {Function|string} func The function or method name to wrap.
  21842. * @param {number} bitmask The bitmask flags.
  21843. * 1 - `_.bind`
  21844. * 2 - `_.bindKey`
  21845. * 4 - `_.curry` or `_.curryRight` of a bound function
  21846. * 8 - `_.curry`
  21847. * 16 - `_.curryRight`
  21848. * 32 - `_.partial`
  21849. * 64 - `_.partialRight`
  21850. * 128 - `_.rearg`
  21851. * 256 - `_.ary`
  21852. * 512 - `_.flip`
  21853. * @param {*} [thisArg] The `this` binding of `func`.
  21854. * @param {Array} [partials] The arguments to be partially applied.
  21855. * @param {Array} [holders] The `partials` placeholder indexes.
  21856. * @param {Array} [argPos] The argument positions of the new function.
  21857. * @param {number} [ary] The arity cap of `func`.
  21858. * @param {number} [arity] The arity of `func`.
  21859. * @returns {Function} Returns the new wrapped function.
  21860. */
  21861. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21862. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21863. if (!isBindKey && typeof func != 'function') {
  21864. throw new TypeError(FUNC_ERROR_TEXT);
  21865. }
  21866. var length = partials ? partials.length : 0;
  21867. if (!length) {
  21868. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21869. partials = holders = undefined;
  21870. }
  21871. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21872. arity = arity === undefined ? arity : toInteger(arity);
  21873. length -= holders ? holders.length : 0;
  21874. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21875. var partialsRight = partials,
  21876. holdersRight = holders;
  21877. partials = holders = undefined;
  21878. }
  21879. var data = isBindKey ? undefined : getData(func);
  21880. var newData = [
  21881. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21882. argPos, ary, arity
  21883. ];
  21884. if (data) {
  21885. mergeData(newData, data);
  21886. }
  21887. func = newData[0];
  21888. bitmask = newData[1];
  21889. thisArg = newData[2];
  21890. partials = newData[3];
  21891. holders = newData[4];
  21892. arity = newData[9] = newData[9] === undefined
  21893. ? (isBindKey ? 0 : func.length)
  21894. : nativeMax(newData[9] - length, 0);
  21895. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21896. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21897. }
  21898. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21899. var result = createBind(func, bitmask, thisArg);
  21900. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21901. result = createCurry(func, bitmask, arity);
  21902. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21903. result = createPartial(func, bitmask, thisArg, partials);
  21904. } else {
  21905. result = createHybrid.apply(undefined, newData);
  21906. }
  21907. var setter = data ? baseSetData : setData;
  21908. return setWrapToString(setter(result, newData), func, bitmask);
  21909. }
  21910. /**
  21911. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21912. * of source objects to the destination object for all destination properties
  21913. * that resolve to `undefined`.
  21914. *
  21915. * @private
  21916. * @param {*} objValue The destination value.
  21917. * @param {*} srcValue The source value.
  21918. * @param {string} key The key of the property to assign.
  21919. * @param {Object} object The parent object of `objValue`.
  21920. * @returns {*} Returns the value to assign.
  21921. */
  21922. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21923. if (objValue === undefined ||
  21924. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21925. return srcValue;
  21926. }
  21927. return objValue;
  21928. }
  21929. /**
  21930. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21931. * objects into destination objects that are passed thru.
  21932. *
  21933. * @private
  21934. * @param {*} objValue The destination value.
  21935. * @param {*} srcValue The source value.
  21936. * @param {string} key The key of the property to merge.
  21937. * @param {Object} object The parent object of `objValue`.
  21938. * @param {Object} source The parent object of `srcValue`.
  21939. * @param {Object} [stack] Tracks traversed source values and their merged
  21940. * counterparts.
  21941. * @returns {*} Returns the value to assign.
  21942. */
  21943. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21944. if (isObject(objValue) && isObject(srcValue)) {
  21945. // Recursively merge objects and arrays (susceptible to call stack limits).
  21946. stack.set(srcValue, objValue);
  21947. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21948. stack['delete'](srcValue);
  21949. }
  21950. return objValue;
  21951. }
  21952. /**
  21953. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21954. * objects.
  21955. *
  21956. * @private
  21957. * @param {*} value The value to inspect.
  21958. * @param {string} key The key of the property to inspect.
  21959. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21960. */
  21961. function customOmitClone(value) {
  21962. return isPlainObject(value) ? undefined : value;
  21963. }
  21964. /**
  21965. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21966. * partial deep comparisons.
  21967. *
  21968. * @private
  21969. * @param {Array} array The array to compare.
  21970. * @param {Array} other The other array to compare.
  21971. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21972. * @param {Function} customizer The function to customize comparisons.
  21973. * @param {Function} equalFunc The function to determine equivalents of values.
  21974. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21975. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21976. */
  21977. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21978. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21979. arrLength = array.length,
  21980. othLength = other.length;
  21981. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21982. return false;
  21983. }
  21984. // Assume cyclic values are equal.
  21985. var stacked = stack.get(array);
  21986. if (stacked && stack.get(other)) {
  21987. return stacked == other;
  21988. }
  21989. var index = -1,
  21990. result = true,
  21991. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21992. stack.set(array, other);
  21993. stack.set(other, array);
  21994. // Ignore non-index properties.
  21995. while (++index < arrLength) {
  21996. var arrValue = array[index],
  21997. othValue = other[index];
  21998. if (customizer) {
  21999. var compared = isPartial
  22000. ? customizer(othValue, arrValue, index, other, array, stack)
  22001. : customizer(arrValue, othValue, index, array, other, stack);
  22002. }
  22003. if (compared !== undefined) {
  22004. if (compared) {
  22005. continue;
  22006. }
  22007. result = false;
  22008. break;
  22009. }
  22010. // Recursively compare arrays (susceptible to call stack limits).
  22011. if (seen) {
  22012. if (!arraySome(other, function(othValue, othIndex) {
  22013. if (!cacheHas(seen, othIndex) &&
  22014. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22015. return seen.push(othIndex);
  22016. }
  22017. })) {
  22018. result = false;
  22019. break;
  22020. }
  22021. } else if (!(
  22022. arrValue === othValue ||
  22023. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22024. )) {
  22025. result = false;
  22026. break;
  22027. }
  22028. }
  22029. stack['delete'](array);
  22030. stack['delete'](other);
  22031. return result;
  22032. }
  22033. /**
  22034. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22035. * the same `toStringTag`.
  22036. *
  22037. * **Note:** This function only supports comparing values with tags of
  22038. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22039. *
  22040. * @private
  22041. * @param {Object} object The object to compare.
  22042. * @param {Object} other The other object to compare.
  22043. * @param {string} tag The `toStringTag` of the objects to compare.
  22044. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22045. * @param {Function} customizer The function to customize comparisons.
  22046. * @param {Function} equalFunc The function to determine equivalents of values.
  22047. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22048. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22049. */
  22050. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22051. switch (tag) {
  22052. case dataViewTag:
  22053. if ((object.byteLength != other.byteLength) ||
  22054. (object.byteOffset != other.byteOffset)) {
  22055. return false;
  22056. }
  22057. object = object.buffer;
  22058. other = other.buffer;
  22059. case arrayBufferTag:
  22060. if ((object.byteLength != other.byteLength) ||
  22061. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22062. return false;
  22063. }
  22064. return true;
  22065. case boolTag:
  22066. case dateTag:
  22067. case numberTag:
  22068. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22069. // Invalid dates are coerced to `NaN`.
  22070. return eq(+object, +other);
  22071. case errorTag:
  22072. return object.name == other.name && object.message == other.message;
  22073. case regexpTag:
  22074. case stringTag:
  22075. // Coerce regexes to strings and treat strings, primitives and objects,
  22076. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22077. // for more details.
  22078. return object == (other + '');
  22079. case mapTag:
  22080. var convert = mapToArray;
  22081. case setTag:
  22082. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22083. convert || (convert = setToArray);
  22084. if (object.size != other.size && !isPartial) {
  22085. return false;
  22086. }
  22087. // Assume cyclic values are equal.
  22088. var stacked = stack.get(object);
  22089. if (stacked) {
  22090. return stacked == other;
  22091. }
  22092. bitmask |= COMPARE_UNORDERED_FLAG;
  22093. // Recursively compare objects (susceptible to call stack limits).
  22094. stack.set(object, other);
  22095. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22096. stack['delete'](object);
  22097. return result;
  22098. case symbolTag:
  22099. if (symbolValueOf) {
  22100. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22101. }
  22102. }
  22103. return false;
  22104. }
  22105. /**
  22106. * A specialized version of `baseIsEqualDeep` for objects with support for
  22107. * partial deep comparisons.
  22108. *
  22109. * @private
  22110. * @param {Object} object The object to compare.
  22111. * @param {Object} other The other object to compare.
  22112. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22113. * @param {Function} customizer The function to customize comparisons.
  22114. * @param {Function} equalFunc The function to determine equivalents of values.
  22115. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22116. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22117. */
  22118. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22119. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22120. objProps = getAllKeys(object),
  22121. objLength = objProps.length,
  22122. othProps = getAllKeys(other),
  22123. othLength = othProps.length;
  22124. if (objLength != othLength && !isPartial) {
  22125. return false;
  22126. }
  22127. var index = objLength;
  22128. while (index--) {
  22129. var key = objProps[index];
  22130. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22131. return false;
  22132. }
  22133. }
  22134. // Assume cyclic values are equal.
  22135. var stacked = stack.get(object);
  22136. if (stacked && stack.get(other)) {
  22137. return stacked == other;
  22138. }
  22139. var result = true;
  22140. stack.set(object, other);
  22141. stack.set(other, object);
  22142. var skipCtor = isPartial;
  22143. while (++index < objLength) {
  22144. key = objProps[index];
  22145. var objValue = object[key],
  22146. othValue = other[key];
  22147. if (customizer) {
  22148. var compared = isPartial
  22149. ? customizer(othValue, objValue, key, other, object, stack)
  22150. : customizer(objValue, othValue, key, object, other, stack);
  22151. }
  22152. // Recursively compare objects (susceptible to call stack limits).
  22153. if (!(compared === undefined
  22154. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22155. : compared
  22156. )) {
  22157. result = false;
  22158. break;
  22159. }
  22160. skipCtor || (skipCtor = key == 'constructor');
  22161. }
  22162. if (result && !skipCtor) {
  22163. var objCtor = object.constructor,
  22164. othCtor = other.constructor;
  22165. // Non `Object` object instances with different constructors are not equal.
  22166. if (objCtor != othCtor &&
  22167. ('constructor' in object && 'constructor' in other) &&
  22168. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22169. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22170. result = false;
  22171. }
  22172. }
  22173. stack['delete'](object);
  22174. stack['delete'](other);
  22175. return result;
  22176. }
  22177. /**
  22178. * A specialized version of `baseRest` which flattens the rest array.
  22179. *
  22180. * @private
  22181. * @param {Function} func The function to apply a rest parameter to.
  22182. * @returns {Function} Returns the new function.
  22183. */
  22184. function flatRest(func) {
  22185. return setToString(overRest(func, undefined, flatten), func + '');
  22186. }
  22187. /**
  22188. * Creates an array of own enumerable property names and symbols of `object`.
  22189. *
  22190. * @private
  22191. * @param {Object} object The object to query.
  22192. * @returns {Array} Returns the array of property names and symbols.
  22193. */
  22194. function getAllKeys(object) {
  22195. return baseGetAllKeys(object, keys, getSymbols);
  22196. }
  22197. /**
  22198. * Creates an array of own and inherited enumerable property names and
  22199. * symbols of `object`.
  22200. *
  22201. * @private
  22202. * @param {Object} object The object to query.
  22203. * @returns {Array} Returns the array of property names and symbols.
  22204. */
  22205. function getAllKeysIn(object) {
  22206. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22207. }
  22208. /**
  22209. * Gets metadata for `func`.
  22210. *
  22211. * @private
  22212. * @param {Function} func The function to query.
  22213. * @returns {*} Returns the metadata for `func`.
  22214. */
  22215. var getData = !metaMap ? noop : function(func) {
  22216. return metaMap.get(func);
  22217. };
  22218. /**
  22219. * Gets the name of `func`.
  22220. *
  22221. * @private
  22222. * @param {Function} func The function to query.
  22223. * @returns {string} Returns the function name.
  22224. */
  22225. function getFuncName(func) {
  22226. var result = (func.name + ''),
  22227. array = realNames[result],
  22228. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22229. while (length--) {
  22230. var data = array[length],
  22231. otherFunc = data.func;
  22232. if (otherFunc == null || otherFunc == func) {
  22233. return data.name;
  22234. }
  22235. }
  22236. return result;
  22237. }
  22238. /**
  22239. * Gets the argument placeholder value for `func`.
  22240. *
  22241. * @private
  22242. * @param {Function} func The function to inspect.
  22243. * @returns {*} Returns the placeholder value.
  22244. */
  22245. function getHolder(func) {
  22246. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22247. return object.placeholder;
  22248. }
  22249. /**
  22250. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22251. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22252. * If arguments are provided, the chosen function is invoked with them and
  22253. * its result is returned.
  22254. *
  22255. * @private
  22256. * @param {*} [value] The value to convert to an iteratee.
  22257. * @param {number} [arity] The arity of the created iteratee.
  22258. * @returns {Function} Returns the chosen function or its result.
  22259. */
  22260. function getIteratee() {
  22261. var result = lodash.iteratee || iteratee;
  22262. result = result === iteratee ? baseIteratee : result;
  22263. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22264. }
  22265. /**
  22266. * Gets the data for `map`.
  22267. *
  22268. * @private
  22269. * @param {Object} map The map to query.
  22270. * @param {string} key The reference key.
  22271. * @returns {*} Returns the map data.
  22272. */
  22273. function getMapData(map, key) {
  22274. var data = map.__data__;
  22275. return isKeyable(key)
  22276. ? data[typeof key == 'string' ? 'string' : 'hash']
  22277. : data.map;
  22278. }
  22279. /**
  22280. * Gets the property names, values, and compare flags of `object`.
  22281. *
  22282. * @private
  22283. * @param {Object} object The object to query.
  22284. * @returns {Array} Returns the match data of `object`.
  22285. */
  22286. function getMatchData(object) {
  22287. var result = keys(object),
  22288. length = result.length;
  22289. while (length--) {
  22290. var key = result[length],
  22291. value = object[key];
  22292. result[length] = [key, value, isStrictComparable(value)];
  22293. }
  22294. return result;
  22295. }
  22296. /**
  22297. * Gets the native function at `key` of `object`.
  22298. *
  22299. * @private
  22300. * @param {Object} object The object to query.
  22301. * @param {string} key The key of the method to get.
  22302. * @returns {*} Returns the function if it's native, else `undefined`.
  22303. */
  22304. function getNative(object, key) {
  22305. var value = getValue(object, key);
  22306. return baseIsNative(value) ? value : undefined;
  22307. }
  22308. /**
  22309. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22310. *
  22311. * @private
  22312. * @param {*} value The value to query.
  22313. * @returns {string} Returns the raw `toStringTag`.
  22314. */
  22315. function getRawTag(value) {
  22316. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22317. tag = value[symToStringTag];
  22318. try {
  22319. value[symToStringTag] = undefined;
  22320. var unmasked = true;
  22321. } catch (e) {}
  22322. var result = nativeObjectToString.call(value);
  22323. if (unmasked) {
  22324. if (isOwn) {
  22325. value[symToStringTag] = tag;
  22326. } else {
  22327. delete value[symToStringTag];
  22328. }
  22329. }
  22330. return result;
  22331. }
  22332. /**
  22333. * Creates an array of the own enumerable symbols of `object`.
  22334. *
  22335. * @private
  22336. * @param {Object} object The object to query.
  22337. * @returns {Array} Returns the array of symbols.
  22338. */
  22339. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22340. if (object == null) {
  22341. return [];
  22342. }
  22343. object = Object(object);
  22344. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22345. return propertyIsEnumerable.call(object, symbol);
  22346. });
  22347. };
  22348. /**
  22349. * Creates an array of the own and inherited enumerable symbols of `object`.
  22350. *
  22351. * @private
  22352. * @param {Object} object The object to query.
  22353. * @returns {Array} Returns the array of symbols.
  22354. */
  22355. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22356. var result = [];
  22357. while (object) {
  22358. arrayPush(result, getSymbols(object));
  22359. object = getPrototype(object);
  22360. }
  22361. return result;
  22362. };
  22363. /**
  22364. * Gets the `toStringTag` of `value`.
  22365. *
  22366. * @private
  22367. * @param {*} value The value to query.
  22368. * @returns {string} Returns the `toStringTag`.
  22369. */
  22370. var getTag = baseGetTag;
  22371. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22372. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22373. (Map && getTag(new Map) != mapTag) ||
  22374. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22375. (Set && getTag(new Set) != setTag) ||
  22376. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22377. getTag = function(value) {
  22378. var result = baseGetTag(value),
  22379. Ctor = result == objectTag ? value.constructor : undefined,
  22380. ctorString = Ctor ? toSource(Ctor) : '';
  22381. if (ctorString) {
  22382. switch (ctorString) {
  22383. case dataViewCtorString: return dataViewTag;
  22384. case mapCtorString: return mapTag;
  22385. case promiseCtorString: return promiseTag;
  22386. case setCtorString: return setTag;
  22387. case weakMapCtorString: return weakMapTag;
  22388. }
  22389. }
  22390. return result;
  22391. };
  22392. }
  22393. /**
  22394. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22395. *
  22396. * @private
  22397. * @param {number} start The start of the view.
  22398. * @param {number} end The end of the view.
  22399. * @param {Array} transforms The transformations to apply to the view.
  22400. * @returns {Object} Returns an object containing the `start` and `end`
  22401. * positions of the view.
  22402. */
  22403. function getView(start, end, transforms) {
  22404. var index = -1,
  22405. length = transforms.length;
  22406. while (++index < length) {
  22407. var data = transforms[index],
  22408. size = data.size;
  22409. switch (data.type) {
  22410. case 'drop': start += size; break;
  22411. case 'dropRight': end -= size; break;
  22412. case 'take': end = nativeMin(end, start + size); break;
  22413. case 'takeRight': start = nativeMax(start, end - size); break;
  22414. }
  22415. }
  22416. return { 'start': start, 'end': end };
  22417. }
  22418. /**
  22419. * Extracts wrapper details from the `source` body comment.
  22420. *
  22421. * @private
  22422. * @param {string} source The source to inspect.
  22423. * @returns {Array} Returns the wrapper details.
  22424. */
  22425. function getWrapDetails(source) {
  22426. var match = source.match(reWrapDetails);
  22427. return match ? match[1].split(reSplitDetails) : [];
  22428. }
  22429. /**
  22430. * Checks if `path` exists on `object`.
  22431. *
  22432. * @private
  22433. * @param {Object} object The object to query.
  22434. * @param {Array|string} path The path to check.
  22435. * @param {Function} hasFunc The function to check properties.
  22436. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22437. */
  22438. function hasPath(object, path, hasFunc) {
  22439. path = castPath(path, object);
  22440. var index = -1,
  22441. length = path.length,
  22442. result = false;
  22443. while (++index < length) {
  22444. var key = toKey(path[index]);
  22445. if (!(result = object != null && hasFunc(object, key))) {
  22446. break;
  22447. }
  22448. object = object[key];
  22449. }
  22450. if (result || ++index != length) {
  22451. return result;
  22452. }
  22453. length = object == null ? 0 : object.length;
  22454. return !!length && isLength(length) && isIndex(key, length) &&
  22455. (isArray(object) || isArguments(object));
  22456. }
  22457. /**
  22458. * Initializes an array clone.
  22459. *
  22460. * @private
  22461. * @param {Array} array The array to clone.
  22462. * @returns {Array} Returns the initialized clone.
  22463. */
  22464. function initCloneArray(array) {
  22465. var length = array.length,
  22466. result = new array.constructor(length);
  22467. // Add properties assigned by `RegExp#exec`.
  22468. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22469. result.index = array.index;
  22470. result.input = array.input;
  22471. }
  22472. return result;
  22473. }
  22474. /**
  22475. * Initializes an object clone.
  22476. *
  22477. * @private
  22478. * @param {Object} object The object to clone.
  22479. * @returns {Object} Returns the initialized clone.
  22480. */
  22481. function initCloneObject(object) {
  22482. return (typeof object.constructor == 'function' && !isPrototype(object))
  22483. ? baseCreate(getPrototype(object))
  22484. : {};
  22485. }
  22486. /**
  22487. * Initializes an object clone based on its `toStringTag`.
  22488. *
  22489. * **Note:** This function only supports cloning values with tags of
  22490. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22491. *
  22492. * @private
  22493. * @param {Object} object The object to clone.
  22494. * @param {string} tag The `toStringTag` of the object to clone.
  22495. * @param {boolean} [isDeep] Specify a deep clone.
  22496. * @returns {Object} Returns the initialized clone.
  22497. */
  22498. function initCloneByTag(object, tag, isDeep) {
  22499. var Ctor = object.constructor;
  22500. switch (tag) {
  22501. case arrayBufferTag:
  22502. return cloneArrayBuffer(object);
  22503. case boolTag:
  22504. case dateTag:
  22505. return new Ctor(+object);
  22506. case dataViewTag:
  22507. return cloneDataView(object, isDeep);
  22508. case float32Tag: case float64Tag:
  22509. case int8Tag: case int16Tag: case int32Tag:
  22510. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22511. return cloneTypedArray(object, isDeep);
  22512. case mapTag:
  22513. return new Ctor;
  22514. case numberTag:
  22515. case stringTag:
  22516. return new Ctor(object);
  22517. case regexpTag:
  22518. return cloneRegExp(object);
  22519. case setTag:
  22520. return new Ctor;
  22521. case symbolTag:
  22522. return cloneSymbol(object);
  22523. }
  22524. }
  22525. /**
  22526. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22527. *
  22528. * @private
  22529. * @param {string} source The source to modify.
  22530. * @returns {Array} details The details to insert.
  22531. * @returns {string} Returns the modified source.
  22532. */
  22533. function insertWrapDetails(source, details) {
  22534. var length = details.length;
  22535. if (!length) {
  22536. return source;
  22537. }
  22538. var lastIndex = length - 1;
  22539. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22540. details = details.join(length > 2 ? ', ' : ' ');
  22541. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22542. }
  22543. /**
  22544. * Checks if `value` is a flattenable `arguments` object or array.
  22545. *
  22546. * @private
  22547. * @param {*} value The value to check.
  22548. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22549. */
  22550. function isFlattenable(value) {
  22551. return isArray(value) || isArguments(value) ||
  22552. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22553. }
  22554. /**
  22555. * Checks if `value` is a valid array-like index.
  22556. *
  22557. * @private
  22558. * @param {*} value The value to check.
  22559. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22560. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22561. */
  22562. function isIndex(value, length) {
  22563. var type = typeof value;
  22564. length = length == null ? MAX_SAFE_INTEGER : length;
  22565. return !!length &&
  22566. (type == 'number' ||
  22567. (type != 'symbol' && reIsUint.test(value))) &&
  22568. (value > -1 && value % 1 == 0 && value < length);
  22569. }
  22570. /**
  22571. * Checks if the given arguments are from an iteratee call.
  22572. *
  22573. * @private
  22574. * @param {*} value The potential iteratee value argument.
  22575. * @param {*} index The potential iteratee index or key argument.
  22576. * @param {*} object The potential iteratee object argument.
  22577. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22578. * else `false`.
  22579. */
  22580. function isIterateeCall(value, index, object) {
  22581. if (!isObject(object)) {
  22582. return false;
  22583. }
  22584. var type = typeof index;
  22585. if (type == 'number'
  22586. ? (isArrayLike(object) && isIndex(index, object.length))
  22587. : (type == 'string' && index in object)
  22588. ) {
  22589. return eq(object[index], value);
  22590. }
  22591. return false;
  22592. }
  22593. /**
  22594. * Checks if `value` is a property name and not a property path.
  22595. *
  22596. * @private
  22597. * @param {*} value The value to check.
  22598. * @param {Object} [object] The object to query keys on.
  22599. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22600. */
  22601. function isKey(value, object) {
  22602. if (isArray(value)) {
  22603. return false;
  22604. }
  22605. var type = typeof value;
  22606. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22607. value == null || isSymbol(value)) {
  22608. return true;
  22609. }
  22610. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22611. (object != null && value in Object(object));
  22612. }
  22613. /**
  22614. * Checks if `value` is suitable for use as unique object key.
  22615. *
  22616. * @private
  22617. * @param {*} value The value to check.
  22618. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22619. */
  22620. function isKeyable(value) {
  22621. var type = typeof value;
  22622. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22623. ? (value !== '__proto__')
  22624. : (value === null);
  22625. }
  22626. /**
  22627. * Checks if `func` has a lazy counterpart.
  22628. *
  22629. * @private
  22630. * @param {Function} func The function to check.
  22631. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22632. * else `false`.
  22633. */
  22634. function isLaziable(func) {
  22635. var funcName = getFuncName(func),
  22636. other = lodash[funcName];
  22637. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22638. return false;
  22639. }
  22640. if (func === other) {
  22641. return true;
  22642. }
  22643. var data = getData(other);
  22644. return !!data && func === data[0];
  22645. }
  22646. /**
  22647. * Checks if `func` has its source masked.
  22648. *
  22649. * @private
  22650. * @param {Function} func The function to check.
  22651. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22652. */
  22653. function isMasked(func) {
  22654. return !!maskSrcKey && (maskSrcKey in func);
  22655. }
  22656. /**
  22657. * Checks if `func` is capable of being masked.
  22658. *
  22659. * @private
  22660. * @param {*} value The value to check.
  22661. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22662. */
  22663. var isMaskable = coreJsData ? isFunction : stubFalse;
  22664. /**
  22665. * Checks if `value` is likely a prototype object.
  22666. *
  22667. * @private
  22668. * @param {*} value The value to check.
  22669. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22670. */
  22671. function isPrototype(value) {
  22672. var Ctor = value && value.constructor,
  22673. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22674. return value === proto;
  22675. }
  22676. /**
  22677. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22678. *
  22679. * @private
  22680. * @param {*} value The value to check.
  22681. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22682. * equality comparisons, else `false`.
  22683. */
  22684. function isStrictComparable(value) {
  22685. return value === value && !isObject(value);
  22686. }
  22687. /**
  22688. * A specialized version of `matchesProperty` for source values suitable
  22689. * for strict equality comparisons, i.e. `===`.
  22690. *
  22691. * @private
  22692. * @param {string} key The key of the property to get.
  22693. * @param {*} srcValue The value to match.
  22694. * @returns {Function} Returns the new spec function.
  22695. */
  22696. function matchesStrictComparable(key, srcValue) {
  22697. return function(object) {
  22698. if (object == null) {
  22699. return false;
  22700. }
  22701. return object[key] === srcValue &&
  22702. (srcValue !== undefined || (key in Object(object)));
  22703. };
  22704. }
  22705. /**
  22706. * A specialized version of `_.memoize` which clears the memoized function's
  22707. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22708. *
  22709. * @private
  22710. * @param {Function} func The function to have its output memoized.
  22711. * @returns {Function} Returns the new memoized function.
  22712. */
  22713. function memoizeCapped(func) {
  22714. var result = memoize(func, function(key) {
  22715. if (cache.size === MAX_MEMOIZE_SIZE) {
  22716. cache.clear();
  22717. }
  22718. return key;
  22719. });
  22720. var cache = result.cache;
  22721. return result;
  22722. }
  22723. /**
  22724. * Merges the function metadata of `source` into `data`.
  22725. *
  22726. * Merging metadata reduces the number of wrappers used to invoke a function.
  22727. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22728. * may be applied regardless of execution order. Methods like `_.ary` and
  22729. * `_.rearg` modify function arguments, making the order in which they are
  22730. * executed important, preventing the merging of metadata. However, we make
  22731. * an exception for a safe combined case where curried functions have `_.ary`
  22732. * and or `_.rearg` applied.
  22733. *
  22734. * @private
  22735. * @param {Array} data The destination metadata.
  22736. * @param {Array} source The source metadata.
  22737. * @returns {Array} Returns `data`.
  22738. */
  22739. function mergeData(data, source) {
  22740. var bitmask = data[1],
  22741. srcBitmask = source[1],
  22742. newBitmask = bitmask | srcBitmask,
  22743. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22744. var isCombo =
  22745. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22746. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22747. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22748. // Exit early if metadata can't be merged.
  22749. if (!(isCommon || isCombo)) {
  22750. return data;
  22751. }
  22752. // Use source `thisArg` if available.
  22753. if (srcBitmask & WRAP_BIND_FLAG) {
  22754. data[2] = source[2];
  22755. // Set when currying a bound function.
  22756. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22757. }
  22758. // Compose partial arguments.
  22759. var value = source[3];
  22760. if (value) {
  22761. var partials = data[3];
  22762. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22763. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22764. }
  22765. // Compose partial right arguments.
  22766. value = source[5];
  22767. if (value) {
  22768. partials = data[5];
  22769. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22770. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22771. }
  22772. // Use source `argPos` if available.
  22773. value = source[7];
  22774. if (value) {
  22775. data[7] = value;
  22776. }
  22777. // Use source `ary` if it's smaller.
  22778. if (srcBitmask & WRAP_ARY_FLAG) {
  22779. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22780. }
  22781. // Use source `arity` if one is not provided.
  22782. if (data[9] == null) {
  22783. data[9] = source[9];
  22784. }
  22785. // Use source `func` and merge bitmasks.
  22786. data[0] = source[0];
  22787. data[1] = newBitmask;
  22788. return data;
  22789. }
  22790. /**
  22791. * This function is like
  22792. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22793. * except that it includes inherited enumerable properties.
  22794. *
  22795. * @private
  22796. * @param {Object} object The object to query.
  22797. * @returns {Array} Returns the array of property names.
  22798. */
  22799. function nativeKeysIn(object) {
  22800. var result = [];
  22801. if (object != null) {
  22802. for (var key in Object(object)) {
  22803. result.push(key);
  22804. }
  22805. }
  22806. return result;
  22807. }
  22808. /**
  22809. * Converts `value` to a string using `Object.prototype.toString`.
  22810. *
  22811. * @private
  22812. * @param {*} value The value to convert.
  22813. * @returns {string} Returns the converted string.
  22814. */
  22815. function objectToString(value) {
  22816. return nativeObjectToString.call(value);
  22817. }
  22818. /**
  22819. * A specialized version of `baseRest` which transforms the rest array.
  22820. *
  22821. * @private
  22822. * @param {Function} func The function to apply a rest parameter to.
  22823. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22824. * @param {Function} transform The rest array transform.
  22825. * @returns {Function} Returns the new function.
  22826. */
  22827. function overRest(func, start, transform) {
  22828. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22829. return function() {
  22830. var args = arguments,
  22831. index = -1,
  22832. length = nativeMax(args.length - start, 0),
  22833. array = Array(length);
  22834. while (++index < length) {
  22835. array[index] = args[start + index];
  22836. }
  22837. index = -1;
  22838. var otherArgs = Array(start + 1);
  22839. while (++index < start) {
  22840. otherArgs[index] = args[index];
  22841. }
  22842. otherArgs[start] = transform(array);
  22843. return apply(func, this, otherArgs);
  22844. };
  22845. }
  22846. /**
  22847. * Gets the parent value at `path` of `object`.
  22848. *
  22849. * @private
  22850. * @param {Object} object The object to query.
  22851. * @param {Array} path The path to get the parent value of.
  22852. * @returns {*} Returns the parent value.
  22853. */
  22854. function parent(object, path) {
  22855. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22856. }
  22857. /**
  22858. * Reorder `array` according to the specified indexes where the element at
  22859. * the first index is assigned as the first element, the element at
  22860. * the second index is assigned as the second element, and so on.
  22861. *
  22862. * @private
  22863. * @param {Array} array The array to reorder.
  22864. * @param {Array} indexes The arranged array indexes.
  22865. * @returns {Array} Returns `array`.
  22866. */
  22867. function reorder(array, indexes) {
  22868. var arrLength = array.length,
  22869. length = nativeMin(indexes.length, arrLength),
  22870. oldArray = copyArray(array);
  22871. while (length--) {
  22872. var index = indexes[length];
  22873. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22874. }
  22875. return array;
  22876. }
  22877. /**
  22878. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22879. *
  22880. * @private
  22881. * @param {Object} object The object to query.
  22882. * @param {string} key The key of the property to get.
  22883. * @returns {*} Returns the property value.
  22884. */
  22885. function safeGet(object, key) {
  22886. if (key === 'constructor' && typeof object[key] === 'function') {
  22887. return;
  22888. }
  22889. if (key == '__proto__') {
  22890. return;
  22891. }
  22892. return object[key];
  22893. }
  22894. /**
  22895. * Sets metadata for `func`.
  22896. *
  22897. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22898. * period of time, it will trip its breaker and transition to an identity
  22899. * function to avoid garbage collection pauses in V8. See
  22900. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22901. * for more details.
  22902. *
  22903. * @private
  22904. * @param {Function} func The function to associate metadata with.
  22905. * @param {*} data The metadata.
  22906. * @returns {Function} Returns `func`.
  22907. */
  22908. var setData = shortOut(baseSetData);
  22909. /**
  22910. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22911. *
  22912. * @private
  22913. * @param {Function} func The function to delay.
  22914. * @param {number} wait The number of milliseconds to delay invocation.
  22915. * @returns {number|Object} Returns the timer id or timeout object.
  22916. */
  22917. var setTimeout = ctxSetTimeout || function(func, wait) {
  22918. return root.setTimeout(func, wait);
  22919. };
  22920. /**
  22921. * Sets the `toString` method of `func` to return `string`.
  22922. *
  22923. * @private
  22924. * @param {Function} func The function to modify.
  22925. * @param {Function} string The `toString` result.
  22926. * @returns {Function} Returns `func`.
  22927. */
  22928. var setToString = shortOut(baseSetToString);
  22929. /**
  22930. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22931. * with wrapper details in a comment at the top of the source body.
  22932. *
  22933. * @private
  22934. * @param {Function} wrapper The function to modify.
  22935. * @param {Function} reference The reference function.
  22936. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22937. * @returns {Function} Returns `wrapper`.
  22938. */
  22939. function setWrapToString(wrapper, reference, bitmask) {
  22940. var source = (reference + '');
  22941. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22942. }
  22943. /**
  22944. * Creates a function that'll short out and invoke `identity` instead
  22945. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22946. * milliseconds.
  22947. *
  22948. * @private
  22949. * @param {Function} func The function to restrict.
  22950. * @returns {Function} Returns the new shortable function.
  22951. */
  22952. function shortOut(func) {
  22953. var count = 0,
  22954. lastCalled = 0;
  22955. return function() {
  22956. var stamp = nativeNow(),
  22957. remaining = HOT_SPAN - (stamp - lastCalled);
  22958. lastCalled = stamp;
  22959. if (remaining > 0) {
  22960. if (++count >= HOT_COUNT) {
  22961. return arguments[0];
  22962. }
  22963. } else {
  22964. count = 0;
  22965. }
  22966. return func.apply(undefined, arguments);
  22967. };
  22968. }
  22969. /**
  22970. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22971. *
  22972. * @private
  22973. * @param {Array} array The array to shuffle.
  22974. * @param {number} [size=array.length] The size of `array`.
  22975. * @returns {Array} Returns `array`.
  22976. */
  22977. function shuffleSelf(array, size) {
  22978. var index = -1,
  22979. length = array.length,
  22980. lastIndex = length - 1;
  22981. size = size === undefined ? length : size;
  22982. while (++index < size) {
  22983. var rand = baseRandom(index, lastIndex),
  22984. value = array[rand];
  22985. array[rand] = array[index];
  22986. array[index] = value;
  22987. }
  22988. array.length = size;
  22989. return array;
  22990. }
  22991. /**
  22992. * Converts `string` to a property path array.
  22993. *
  22994. * @private
  22995. * @param {string} string The string to convert.
  22996. * @returns {Array} Returns the property path array.
  22997. */
  22998. var stringToPath = memoizeCapped(function(string) {
  22999. var result = [];
  23000. if (string.charCodeAt(0) === 46 /* . */) {
  23001. result.push('');
  23002. }
  23003. string.replace(rePropName, function(match, number, quote, subString) {
  23004. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23005. });
  23006. return result;
  23007. });
  23008. /**
  23009. * Converts `value` to a string key if it's not a string or symbol.
  23010. *
  23011. * @private
  23012. * @param {*} value The value to inspect.
  23013. * @returns {string|symbol} Returns the key.
  23014. */
  23015. function toKey(value) {
  23016. if (typeof value == 'string' || isSymbol(value)) {
  23017. return value;
  23018. }
  23019. var result = (value + '');
  23020. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23021. }
  23022. /**
  23023. * Converts `func` to its source code.
  23024. *
  23025. * @private
  23026. * @param {Function} func The function to convert.
  23027. * @returns {string} Returns the source code.
  23028. */
  23029. function toSource(func) {
  23030. if (func != null) {
  23031. try {
  23032. return funcToString.call(func);
  23033. } catch (e) {}
  23034. try {
  23035. return (func + '');
  23036. } catch (e) {}
  23037. }
  23038. return '';
  23039. }
  23040. /**
  23041. * Updates wrapper `details` based on `bitmask` flags.
  23042. *
  23043. * @private
  23044. * @returns {Array} details The details to modify.
  23045. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23046. * @returns {Array} Returns `details`.
  23047. */
  23048. function updateWrapDetails(details, bitmask) {
  23049. arrayEach(wrapFlags, function(pair) {
  23050. var value = '_.' + pair[0];
  23051. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23052. details.push(value);
  23053. }
  23054. });
  23055. return details.sort();
  23056. }
  23057. /**
  23058. * Creates a clone of `wrapper`.
  23059. *
  23060. * @private
  23061. * @param {Object} wrapper The wrapper to clone.
  23062. * @returns {Object} Returns the cloned wrapper.
  23063. */
  23064. function wrapperClone(wrapper) {
  23065. if (wrapper instanceof LazyWrapper) {
  23066. return wrapper.clone();
  23067. }
  23068. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23069. result.__actions__ = copyArray(wrapper.__actions__);
  23070. result.__index__ = wrapper.__index__;
  23071. result.__values__ = wrapper.__values__;
  23072. return result;
  23073. }
  23074. /*------------------------------------------------------------------------*/
  23075. /**
  23076. * Creates an array of elements split into groups the length of `size`.
  23077. * If `array` can't be split evenly, the final chunk will be the remaining
  23078. * elements.
  23079. *
  23080. * @static
  23081. * @memberOf _
  23082. * @since 3.0.0
  23083. * @category Array
  23084. * @param {Array} array The array to process.
  23085. * @param {number} [size=1] The length of each chunk
  23086. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23087. * @returns {Array} Returns the new array of chunks.
  23088. * @example
  23089. *
  23090. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23091. * // => [['a', 'b'], ['c', 'd']]
  23092. *
  23093. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23094. * // => [['a', 'b', 'c'], ['d']]
  23095. */
  23096. function chunk(array, size, guard) {
  23097. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23098. size = 1;
  23099. } else {
  23100. size = nativeMax(toInteger(size), 0);
  23101. }
  23102. var length = array == null ? 0 : array.length;
  23103. if (!length || size < 1) {
  23104. return [];
  23105. }
  23106. var index = 0,
  23107. resIndex = 0,
  23108. result = Array(nativeCeil(length / size));
  23109. while (index < length) {
  23110. result[resIndex++] = baseSlice(array, index, (index += size));
  23111. }
  23112. return result;
  23113. }
  23114. /**
  23115. * Creates an array with all falsey values removed. The values `false`, `null`,
  23116. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23117. *
  23118. * @static
  23119. * @memberOf _
  23120. * @since 0.1.0
  23121. * @category Array
  23122. * @param {Array} array The array to compact.
  23123. * @returns {Array} Returns the new array of filtered values.
  23124. * @example
  23125. *
  23126. * _.compact([0, 1, false, 2, '', 3]);
  23127. * // => [1, 2, 3]
  23128. */
  23129. function compact(array) {
  23130. var index = -1,
  23131. length = array == null ? 0 : array.length,
  23132. resIndex = 0,
  23133. result = [];
  23134. while (++index < length) {
  23135. var value = array[index];
  23136. if (value) {
  23137. result[resIndex++] = value;
  23138. }
  23139. }
  23140. return result;
  23141. }
  23142. /**
  23143. * Creates a new array concatenating `array` with any additional arrays
  23144. * and/or values.
  23145. *
  23146. * @static
  23147. * @memberOf _
  23148. * @since 4.0.0
  23149. * @category Array
  23150. * @param {Array} array The array to concatenate.
  23151. * @param {...*} [values] The values to concatenate.
  23152. * @returns {Array} Returns the new concatenated array.
  23153. * @example
  23154. *
  23155. * var array = [1];
  23156. * var other = _.concat(array, 2, [3], [[4]]);
  23157. *
  23158. * console.log(other);
  23159. * // => [1, 2, 3, [4]]
  23160. *
  23161. * console.log(array);
  23162. * // => [1]
  23163. */
  23164. function concat() {
  23165. var length = arguments.length;
  23166. if (!length) {
  23167. return [];
  23168. }
  23169. var args = Array(length - 1),
  23170. array = arguments[0],
  23171. index = length;
  23172. while (index--) {
  23173. args[index - 1] = arguments[index];
  23174. }
  23175. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23176. }
  23177. /**
  23178. * Creates an array of `array` values not included in the other given arrays
  23179. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23180. * for equality comparisons. The order and references of result values are
  23181. * determined by the first array.
  23182. *
  23183. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23184. *
  23185. * @static
  23186. * @memberOf _
  23187. * @since 0.1.0
  23188. * @category Array
  23189. * @param {Array} array The array to inspect.
  23190. * @param {...Array} [values] The values to exclude.
  23191. * @returns {Array} Returns the new array of filtered values.
  23192. * @see _.without, _.xor
  23193. * @example
  23194. *
  23195. * _.difference([2, 1], [2, 3]);
  23196. * // => [1]
  23197. */
  23198. var difference = baseRest(function(array, values) {
  23199. return isArrayLikeObject(array)
  23200. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23201. : [];
  23202. });
  23203. /**
  23204. * This method is like `_.difference` except that it accepts `iteratee` which
  23205. * is invoked for each element of `array` and `values` to generate the criterion
  23206. * by which they're compared. The order and references of result values are
  23207. * determined by the first array. The iteratee is invoked with one argument:
  23208. * (value).
  23209. *
  23210. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23211. *
  23212. * @static
  23213. * @memberOf _
  23214. * @since 4.0.0
  23215. * @category Array
  23216. * @param {Array} array The array to inspect.
  23217. * @param {...Array} [values] The values to exclude.
  23218. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23219. * @returns {Array} Returns the new array of filtered values.
  23220. * @example
  23221. *
  23222. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23223. * // => [1.2]
  23224. *
  23225. * // The `_.property` iteratee shorthand.
  23226. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23227. * // => [{ 'x': 2 }]
  23228. */
  23229. var differenceBy = baseRest(function(array, values) {
  23230. var iteratee = last(values);
  23231. if (isArrayLikeObject(iteratee)) {
  23232. iteratee = undefined;
  23233. }
  23234. return isArrayLikeObject(array)
  23235. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23236. : [];
  23237. });
  23238. /**
  23239. * This method is like `_.difference` except that it accepts `comparator`
  23240. * which is invoked to compare elements of `array` to `values`. The order and
  23241. * references of result values are determined by the first array. The comparator
  23242. * is invoked with two arguments: (arrVal, othVal).
  23243. *
  23244. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23245. *
  23246. * @static
  23247. * @memberOf _
  23248. * @since 4.0.0
  23249. * @category Array
  23250. * @param {Array} array The array to inspect.
  23251. * @param {...Array} [values] The values to exclude.
  23252. * @param {Function} [comparator] The comparator invoked per element.
  23253. * @returns {Array} Returns the new array of filtered values.
  23254. * @example
  23255. *
  23256. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23257. *
  23258. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23259. * // => [{ 'x': 2, 'y': 1 }]
  23260. */
  23261. var differenceWith = baseRest(function(array, values) {
  23262. var comparator = last(values);
  23263. if (isArrayLikeObject(comparator)) {
  23264. comparator = undefined;
  23265. }
  23266. return isArrayLikeObject(array)
  23267. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23268. : [];
  23269. });
  23270. /**
  23271. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23272. *
  23273. * @static
  23274. * @memberOf _
  23275. * @since 0.5.0
  23276. * @category Array
  23277. * @param {Array} array The array to query.
  23278. * @param {number} [n=1] The number of elements to drop.
  23279. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23280. * @returns {Array} Returns the slice of `array`.
  23281. * @example
  23282. *
  23283. * _.drop([1, 2, 3]);
  23284. * // => [2, 3]
  23285. *
  23286. * _.drop([1, 2, 3], 2);
  23287. * // => [3]
  23288. *
  23289. * _.drop([1, 2, 3], 5);
  23290. * // => []
  23291. *
  23292. * _.drop([1, 2, 3], 0);
  23293. * // => [1, 2, 3]
  23294. */
  23295. function drop(array, n, guard) {
  23296. var length = array == null ? 0 : array.length;
  23297. if (!length) {
  23298. return [];
  23299. }
  23300. n = (guard || n === undefined) ? 1 : toInteger(n);
  23301. return baseSlice(array, n < 0 ? 0 : n, length);
  23302. }
  23303. /**
  23304. * Creates a slice of `array` with `n` elements dropped from the end.
  23305. *
  23306. * @static
  23307. * @memberOf _
  23308. * @since 3.0.0
  23309. * @category Array
  23310. * @param {Array} array The array to query.
  23311. * @param {number} [n=1] The number of elements to drop.
  23312. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23313. * @returns {Array} Returns the slice of `array`.
  23314. * @example
  23315. *
  23316. * _.dropRight([1, 2, 3]);
  23317. * // => [1, 2]
  23318. *
  23319. * _.dropRight([1, 2, 3], 2);
  23320. * // => [1]
  23321. *
  23322. * _.dropRight([1, 2, 3], 5);
  23323. * // => []
  23324. *
  23325. * _.dropRight([1, 2, 3], 0);
  23326. * // => [1, 2, 3]
  23327. */
  23328. function dropRight(array, n, guard) {
  23329. var length = array == null ? 0 : array.length;
  23330. if (!length) {
  23331. return [];
  23332. }
  23333. n = (guard || n === undefined) ? 1 : toInteger(n);
  23334. n = length - n;
  23335. return baseSlice(array, 0, n < 0 ? 0 : n);
  23336. }
  23337. /**
  23338. * Creates a slice of `array` excluding elements dropped from the end.
  23339. * Elements are dropped until `predicate` returns falsey. The predicate is
  23340. * invoked with three arguments: (value, index, array).
  23341. *
  23342. * @static
  23343. * @memberOf _
  23344. * @since 3.0.0
  23345. * @category Array
  23346. * @param {Array} array The array to query.
  23347. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23348. * @returns {Array} Returns the slice of `array`.
  23349. * @example
  23350. *
  23351. * var users = [
  23352. * { 'user': 'barney', 'active': true },
  23353. * { 'user': 'fred', 'active': false },
  23354. * { 'user': 'pebbles', 'active': false }
  23355. * ];
  23356. *
  23357. * _.dropRightWhile(users, function(o) { return !o.active; });
  23358. * // => objects for ['barney']
  23359. *
  23360. * // The `_.matches` iteratee shorthand.
  23361. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23362. * // => objects for ['barney', 'fred']
  23363. *
  23364. * // The `_.matchesProperty` iteratee shorthand.
  23365. * _.dropRightWhile(users, ['active', false]);
  23366. * // => objects for ['barney']
  23367. *
  23368. * // The `_.property` iteratee shorthand.
  23369. * _.dropRightWhile(users, 'active');
  23370. * // => objects for ['barney', 'fred', 'pebbles']
  23371. */
  23372. function dropRightWhile(array, predicate) {
  23373. return (array && array.length)
  23374. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23375. : [];
  23376. }
  23377. /**
  23378. * Creates a slice of `array` excluding elements dropped from the beginning.
  23379. * Elements are dropped until `predicate` returns falsey. The predicate is
  23380. * invoked with three arguments: (value, index, array).
  23381. *
  23382. * @static
  23383. * @memberOf _
  23384. * @since 3.0.0
  23385. * @category Array
  23386. * @param {Array} array The array to query.
  23387. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23388. * @returns {Array} Returns the slice of `array`.
  23389. * @example
  23390. *
  23391. * var users = [
  23392. * { 'user': 'barney', 'active': false },
  23393. * { 'user': 'fred', 'active': false },
  23394. * { 'user': 'pebbles', 'active': true }
  23395. * ];
  23396. *
  23397. * _.dropWhile(users, function(o) { return !o.active; });
  23398. * // => objects for ['pebbles']
  23399. *
  23400. * // The `_.matches` iteratee shorthand.
  23401. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23402. * // => objects for ['fred', 'pebbles']
  23403. *
  23404. * // The `_.matchesProperty` iteratee shorthand.
  23405. * _.dropWhile(users, ['active', false]);
  23406. * // => objects for ['pebbles']
  23407. *
  23408. * // The `_.property` iteratee shorthand.
  23409. * _.dropWhile(users, 'active');
  23410. * // => objects for ['barney', 'fred', 'pebbles']
  23411. */
  23412. function dropWhile(array, predicate) {
  23413. return (array && array.length)
  23414. ? baseWhile(array, getIteratee(predicate, 3), true)
  23415. : [];
  23416. }
  23417. /**
  23418. * Fills elements of `array` with `value` from `start` up to, but not
  23419. * including, `end`.
  23420. *
  23421. * **Note:** This method mutates `array`.
  23422. *
  23423. * @static
  23424. * @memberOf _
  23425. * @since 3.2.0
  23426. * @category Array
  23427. * @param {Array} array The array to fill.
  23428. * @param {*} value The value to fill `array` with.
  23429. * @param {number} [start=0] The start position.
  23430. * @param {number} [end=array.length] The end position.
  23431. * @returns {Array} Returns `array`.
  23432. * @example
  23433. *
  23434. * var array = [1, 2, 3];
  23435. *
  23436. * _.fill(array, 'a');
  23437. * console.log(array);
  23438. * // => ['a', 'a', 'a']
  23439. *
  23440. * _.fill(Array(3), 2);
  23441. * // => [2, 2, 2]
  23442. *
  23443. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23444. * // => [4, '*', '*', 10]
  23445. */
  23446. function fill(array, value, start, end) {
  23447. var length = array == null ? 0 : array.length;
  23448. if (!length) {
  23449. return [];
  23450. }
  23451. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23452. start = 0;
  23453. end = length;
  23454. }
  23455. return baseFill(array, value, start, end);
  23456. }
  23457. /**
  23458. * This method is like `_.find` except that it returns the index of the first
  23459. * element `predicate` returns truthy for instead of the element itself.
  23460. *
  23461. * @static
  23462. * @memberOf _
  23463. * @since 1.1.0
  23464. * @category Array
  23465. * @param {Array} array The array to inspect.
  23466. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23467. * @param {number} [fromIndex=0] The index to search from.
  23468. * @returns {number} Returns the index of the found element, else `-1`.
  23469. * @example
  23470. *
  23471. * var users = [
  23472. * { 'user': 'barney', 'active': false },
  23473. * { 'user': 'fred', 'active': false },
  23474. * { 'user': 'pebbles', 'active': true }
  23475. * ];
  23476. *
  23477. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23478. * // => 0
  23479. *
  23480. * // The `_.matches` iteratee shorthand.
  23481. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23482. * // => 1
  23483. *
  23484. * // The `_.matchesProperty` iteratee shorthand.
  23485. * _.findIndex(users, ['active', false]);
  23486. * // => 0
  23487. *
  23488. * // The `_.property` iteratee shorthand.
  23489. * _.findIndex(users, 'active');
  23490. * // => 2
  23491. */
  23492. function findIndex(array, predicate, fromIndex) {
  23493. var length = array == null ? 0 : array.length;
  23494. if (!length) {
  23495. return -1;
  23496. }
  23497. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23498. if (index < 0) {
  23499. index = nativeMax(length + index, 0);
  23500. }
  23501. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23502. }
  23503. /**
  23504. * This method is like `_.findIndex` except that it iterates over elements
  23505. * of `collection` from right to left.
  23506. *
  23507. * @static
  23508. * @memberOf _
  23509. * @since 2.0.0
  23510. * @category Array
  23511. * @param {Array} array The array to inspect.
  23512. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23513. * @param {number} [fromIndex=array.length-1] The index to search from.
  23514. * @returns {number} Returns the index of the found element, else `-1`.
  23515. * @example
  23516. *
  23517. * var users = [
  23518. * { 'user': 'barney', 'active': true },
  23519. * { 'user': 'fred', 'active': false },
  23520. * { 'user': 'pebbles', 'active': false }
  23521. * ];
  23522. *
  23523. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23524. * // => 2
  23525. *
  23526. * // The `_.matches` iteratee shorthand.
  23527. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23528. * // => 0
  23529. *
  23530. * // The `_.matchesProperty` iteratee shorthand.
  23531. * _.findLastIndex(users, ['active', false]);
  23532. * // => 2
  23533. *
  23534. * // The `_.property` iteratee shorthand.
  23535. * _.findLastIndex(users, 'active');
  23536. * // => 0
  23537. */
  23538. function findLastIndex(array, predicate, fromIndex) {
  23539. var length = array == null ? 0 : array.length;
  23540. if (!length) {
  23541. return -1;
  23542. }
  23543. var index = length - 1;
  23544. if (fromIndex !== undefined) {
  23545. index = toInteger(fromIndex);
  23546. index = fromIndex < 0
  23547. ? nativeMax(length + index, 0)
  23548. : nativeMin(index, length - 1);
  23549. }
  23550. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23551. }
  23552. /**
  23553. * Flattens `array` a single level deep.
  23554. *
  23555. * @static
  23556. * @memberOf _
  23557. * @since 0.1.0
  23558. * @category Array
  23559. * @param {Array} array The array to flatten.
  23560. * @returns {Array} Returns the new flattened array.
  23561. * @example
  23562. *
  23563. * _.flatten([1, [2, [3, [4]], 5]]);
  23564. * // => [1, 2, [3, [4]], 5]
  23565. */
  23566. function flatten(array) {
  23567. var length = array == null ? 0 : array.length;
  23568. return length ? baseFlatten(array, 1) : [];
  23569. }
  23570. /**
  23571. * Recursively flattens `array`.
  23572. *
  23573. * @static
  23574. * @memberOf _
  23575. * @since 3.0.0
  23576. * @category Array
  23577. * @param {Array} array The array to flatten.
  23578. * @returns {Array} Returns the new flattened array.
  23579. * @example
  23580. *
  23581. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23582. * // => [1, 2, 3, 4, 5]
  23583. */
  23584. function flattenDeep(array) {
  23585. var length = array == null ? 0 : array.length;
  23586. return length ? baseFlatten(array, INFINITY) : [];
  23587. }
  23588. /**
  23589. * Recursively flatten `array` up to `depth` times.
  23590. *
  23591. * @static
  23592. * @memberOf _
  23593. * @since 4.4.0
  23594. * @category Array
  23595. * @param {Array} array The array to flatten.
  23596. * @param {number} [depth=1] The maximum recursion depth.
  23597. * @returns {Array} Returns the new flattened array.
  23598. * @example
  23599. *
  23600. * var array = [1, [2, [3, [4]], 5]];
  23601. *
  23602. * _.flattenDepth(array, 1);
  23603. * // => [1, 2, [3, [4]], 5]
  23604. *
  23605. * _.flattenDepth(array, 2);
  23606. * // => [1, 2, 3, [4], 5]
  23607. */
  23608. function flattenDepth(array, depth) {
  23609. var length = array == null ? 0 : array.length;
  23610. if (!length) {
  23611. return [];
  23612. }
  23613. depth = depth === undefined ? 1 : toInteger(depth);
  23614. return baseFlatten(array, depth);
  23615. }
  23616. /**
  23617. * The inverse of `_.toPairs`; this method returns an object composed
  23618. * from key-value `pairs`.
  23619. *
  23620. * @static
  23621. * @memberOf _
  23622. * @since 4.0.0
  23623. * @category Array
  23624. * @param {Array} pairs The key-value pairs.
  23625. * @returns {Object} Returns the new object.
  23626. * @example
  23627. *
  23628. * _.fromPairs([['a', 1], ['b', 2]]);
  23629. * // => { 'a': 1, 'b': 2 }
  23630. */
  23631. function fromPairs(pairs) {
  23632. var index = -1,
  23633. length = pairs == null ? 0 : pairs.length,
  23634. result = {};
  23635. while (++index < length) {
  23636. var pair = pairs[index];
  23637. result[pair[0]] = pair[1];
  23638. }
  23639. return result;
  23640. }
  23641. /**
  23642. * Gets the first element of `array`.
  23643. *
  23644. * @static
  23645. * @memberOf _
  23646. * @since 0.1.0
  23647. * @alias first
  23648. * @category Array
  23649. * @param {Array} array The array to query.
  23650. * @returns {*} Returns the first element of `array`.
  23651. * @example
  23652. *
  23653. * _.head([1, 2, 3]);
  23654. * // => 1
  23655. *
  23656. * _.head([]);
  23657. * // => undefined
  23658. */
  23659. function head(array) {
  23660. return (array && array.length) ? array[0] : undefined;
  23661. }
  23662. /**
  23663. * Gets the index at which the first occurrence of `value` is found in `array`
  23664. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23665. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23666. * offset from the end of `array`.
  23667. *
  23668. * @static
  23669. * @memberOf _
  23670. * @since 0.1.0
  23671. * @category Array
  23672. * @param {Array} array The array to inspect.
  23673. * @param {*} value The value to search for.
  23674. * @param {number} [fromIndex=0] The index to search from.
  23675. * @returns {number} Returns the index of the matched value, else `-1`.
  23676. * @example
  23677. *
  23678. * _.indexOf([1, 2, 1, 2], 2);
  23679. * // => 1
  23680. *
  23681. * // Search from the `fromIndex`.
  23682. * _.indexOf([1, 2, 1, 2], 2, 2);
  23683. * // => 3
  23684. */
  23685. function indexOf(array, value, fromIndex) {
  23686. var length = array == null ? 0 : array.length;
  23687. if (!length) {
  23688. return -1;
  23689. }
  23690. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23691. if (index < 0) {
  23692. index = nativeMax(length + index, 0);
  23693. }
  23694. return baseIndexOf(array, value, index);
  23695. }
  23696. /**
  23697. * Gets all but the last element of `array`.
  23698. *
  23699. * @static
  23700. * @memberOf _
  23701. * @since 0.1.0
  23702. * @category Array
  23703. * @param {Array} array The array to query.
  23704. * @returns {Array} Returns the slice of `array`.
  23705. * @example
  23706. *
  23707. * _.initial([1, 2, 3]);
  23708. * // => [1, 2]
  23709. */
  23710. function initial(array) {
  23711. var length = array == null ? 0 : array.length;
  23712. return length ? baseSlice(array, 0, -1) : [];
  23713. }
  23714. /**
  23715. * Creates an array of unique values that are included in all given arrays
  23716. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23717. * for equality comparisons. The order and references of result values are
  23718. * determined by the first array.
  23719. *
  23720. * @static
  23721. * @memberOf _
  23722. * @since 0.1.0
  23723. * @category Array
  23724. * @param {...Array} [arrays] The arrays to inspect.
  23725. * @returns {Array} Returns the new array of intersecting values.
  23726. * @example
  23727. *
  23728. * _.intersection([2, 1], [2, 3]);
  23729. * // => [2]
  23730. */
  23731. var intersection = baseRest(function(arrays) {
  23732. var mapped = arrayMap(arrays, castArrayLikeObject);
  23733. return (mapped.length && mapped[0] === arrays[0])
  23734. ? baseIntersection(mapped)
  23735. : [];
  23736. });
  23737. /**
  23738. * This method is like `_.intersection` except that it accepts `iteratee`
  23739. * which is invoked for each element of each `arrays` to generate the criterion
  23740. * by which they're compared. The order and references of result values are
  23741. * determined by the first array. The iteratee is invoked with one argument:
  23742. * (value).
  23743. *
  23744. * @static
  23745. * @memberOf _
  23746. * @since 4.0.0
  23747. * @category Array
  23748. * @param {...Array} [arrays] The arrays to inspect.
  23749. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23750. * @returns {Array} Returns the new array of intersecting values.
  23751. * @example
  23752. *
  23753. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23754. * // => [2.1]
  23755. *
  23756. * // The `_.property` iteratee shorthand.
  23757. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23758. * // => [{ 'x': 1 }]
  23759. */
  23760. var intersectionBy = baseRest(function(arrays) {
  23761. var iteratee = last(arrays),
  23762. mapped = arrayMap(arrays, castArrayLikeObject);
  23763. if (iteratee === last(mapped)) {
  23764. iteratee = undefined;
  23765. } else {
  23766. mapped.pop();
  23767. }
  23768. return (mapped.length && mapped[0] === arrays[0])
  23769. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23770. : [];
  23771. });
  23772. /**
  23773. * This method is like `_.intersection` except that it accepts `comparator`
  23774. * which is invoked to compare elements of `arrays`. The order and references
  23775. * of result values are determined by the first array. The comparator is
  23776. * invoked with two arguments: (arrVal, othVal).
  23777. *
  23778. * @static
  23779. * @memberOf _
  23780. * @since 4.0.0
  23781. * @category Array
  23782. * @param {...Array} [arrays] The arrays to inspect.
  23783. * @param {Function} [comparator] The comparator invoked per element.
  23784. * @returns {Array} Returns the new array of intersecting values.
  23785. * @example
  23786. *
  23787. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23788. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23789. *
  23790. * _.intersectionWith(objects, others, _.isEqual);
  23791. * // => [{ 'x': 1, 'y': 2 }]
  23792. */
  23793. var intersectionWith = baseRest(function(arrays) {
  23794. var comparator = last(arrays),
  23795. mapped = arrayMap(arrays, castArrayLikeObject);
  23796. comparator = typeof comparator == 'function' ? comparator : undefined;
  23797. if (comparator) {
  23798. mapped.pop();
  23799. }
  23800. return (mapped.length && mapped[0] === arrays[0])
  23801. ? baseIntersection(mapped, undefined, comparator)
  23802. : [];
  23803. });
  23804. /**
  23805. * Converts all elements in `array` into a string separated by `separator`.
  23806. *
  23807. * @static
  23808. * @memberOf _
  23809. * @since 4.0.0
  23810. * @category Array
  23811. * @param {Array} array The array to convert.
  23812. * @param {string} [separator=','] The element separator.
  23813. * @returns {string} Returns the joined string.
  23814. * @example
  23815. *
  23816. * _.join(['a', 'b', 'c'], '~');
  23817. * // => 'a~b~c'
  23818. */
  23819. function join(array, separator) {
  23820. return array == null ? '' : nativeJoin.call(array, separator);
  23821. }
  23822. /**
  23823. * Gets the last element of `array`.
  23824. *
  23825. * @static
  23826. * @memberOf _
  23827. * @since 0.1.0
  23828. * @category Array
  23829. * @param {Array} array The array to query.
  23830. * @returns {*} Returns the last element of `array`.
  23831. * @example
  23832. *
  23833. * _.last([1, 2, 3]);
  23834. * // => 3
  23835. */
  23836. function last(array) {
  23837. var length = array == null ? 0 : array.length;
  23838. return length ? array[length - 1] : undefined;
  23839. }
  23840. /**
  23841. * This method is like `_.indexOf` except that it iterates over elements of
  23842. * `array` from right to left.
  23843. *
  23844. * @static
  23845. * @memberOf _
  23846. * @since 0.1.0
  23847. * @category Array
  23848. * @param {Array} array The array to inspect.
  23849. * @param {*} value The value to search for.
  23850. * @param {number} [fromIndex=array.length-1] The index to search from.
  23851. * @returns {number} Returns the index of the matched value, else `-1`.
  23852. * @example
  23853. *
  23854. * _.lastIndexOf([1, 2, 1, 2], 2);
  23855. * // => 3
  23856. *
  23857. * // Search from the `fromIndex`.
  23858. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23859. * // => 1
  23860. */
  23861. function lastIndexOf(array, value, fromIndex) {
  23862. var length = array == null ? 0 : array.length;
  23863. if (!length) {
  23864. return -1;
  23865. }
  23866. var index = length;
  23867. if (fromIndex !== undefined) {
  23868. index = toInteger(fromIndex);
  23869. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23870. }
  23871. return value === value
  23872. ? strictLastIndexOf(array, value, index)
  23873. : baseFindIndex(array, baseIsNaN, index, true);
  23874. }
  23875. /**
  23876. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23877. * element from the end is returned.
  23878. *
  23879. * @static
  23880. * @memberOf _
  23881. * @since 4.11.0
  23882. * @category Array
  23883. * @param {Array} array The array to query.
  23884. * @param {number} [n=0] The index of the element to return.
  23885. * @returns {*} Returns the nth element of `array`.
  23886. * @example
  23887. *
  23888. * var array = ['a', 'b', 'c', 'd'];
  23889. *
  23890. * _.nth(array, 1);
  23891. * // => 'b'
  23892. *
  23893. * _.nth(array, -2);
  23894. * // => 'c';
  23895. */
  23896. function nth(array, n) {
  23897. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23898. }
  23899. /**
  23900. * Removes all given values from `array` using
  23901. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23902. * for equality comparisons.
  23903. *
  23904. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23905. * to remove elements from an array by predicate.
  23906. *
  23907. * @static
  23908. * @memberOf _
  23909. * @since 2.0.0
  23910. * @category Array
  23911. * @param {Array} array The array to modify.
  23912. * @param {...*} [values] The values to remove.
  23913. * @returns {Array} Returns `array`.
  23914. * @example
  23915. *
  23916. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23917. *
  23918. * _.pull(array, 'a', 'c');
  23919. * console.log(array);
  23920. * // => ['b', 'b']
  23921. */
  23922. var pull = baseRest(pullAll);
  23923. /**
  23924. * This method is like `_.pull` except that it accepts an array of values to remove.
  23925. *
  23926. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23927. *
  23928. * @static
  23929. * @memberOf _
  23930. * @since 4.0.0
  23931. * @category Array
  23932. * @param {Array} array The array to modify.
  23933. * @param {Array} values The values to remove.
  23934. * @returns {Array} Returns `array`.
  23935. * @example
  23936. *
  23937. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23938. *
  23939. * _.pullAll(array, ['a', 'c']);
  23940. * console.log(array);
  23941. * // => ['b', 'b']
  23942. */
  23943. function pullAll(array, values) {
  23944. return (array && array.length && values && values.length)
  23945. ? basePullAll(array, values)
  23946. : array;
  23947. }
  23948. /**
  23949. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23950. * invoked for each element of `array` and `values` to generate the criterion
  23951. * by which they're compared. The iteratee is invoked with one argument: (value).
  23952. *
  23953. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23954. *
  23955. * @static
  23956. * @memberOf _
  23957. * @since 4.0.0
  23958. * @category Array
  23959. * @param {Array} array The array to modify.
  23960. * @param {Array} values The values to remove.
  23961. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23962. * @returns {Array} Returns `array`.
  23963. * @example
  23964. *
  23965. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23966. *
  23967. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23968. * console.log(array);
  23969. * // => [{ 'x': 2 }]
  23970. */
  23971. function pullAllBy(array, values, iteratee) {
  23972. return (array && array.length && values && values.length)
  23973. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23974. : array;
  23975. }
  23976. /**
  23977. * This method is like `_.pullAll` except that it accepts `comparator` which
  23978. * is invoked to compare elements of `array` to `values`. The comparator is
  23979. * invoked with two arguments: (arrVal, othVal).
  23980. *
  23981. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23982. *
  23983. * @static
  23984. * @memberOf _
  23985. * @since 4.6.0
  23986. * @category Array
  23987. * @param {Array} array The array to modify.
  23988. * @param {Array} values The values to remove.
  23989. * @param {Function} [comparator] The comparator invoked per element.
  23990. * @returns {Array} Returns `array`.
  23991. * @example
  23992. *
  23993. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23994. *
  23995. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23996. * console.log(array);
  23997. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23998. */
  23999. function pullAllWith(array, values, comparator) {
  24000. return (array && array.length && values && values.length)
  24001. ? basePullAll(array, values, undefined, comparator)
  24002. : array;
  24003. }
  24004. /**
  24005. * Removes elements from `array` corresponding to `indexes` and returns an
  24006. * array of removed elements.
  24007. *
  24008. * **Note:** Unlike `_.at`, this method mutates `array`.
  24009. *
  24010. * @static
  24011. * @memberOf _
  24012. * @since 3.0.0
  24013. * @category Array
  24014. * @param {Array} array The array to modify.
  24015. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24016. * @returns {Array} Returns the new array of removed elements.
  24017. * @example
  24018. *
  24019. * var array = ['a', 'b', 'c', 'd'];
  24020. * var pulled = _.pullAt(array, [1, 3]);
  24021. *
  24022. * console.log(array);
  24023. * // => ['a', 'c']
  24024. *
  24025. * console.log(pulled);
  24026. * // => ['b', 'd']
  24027. */
  24028. var pullAt = flatRest(function(array, indexes) {
  24029. var length = array == null ? 0 : array.length,
  24030. result = baseAt(array, indexes);
  24031. basePullAt(array, arrayMap(indexes, function(index) {
  24032. return isIndex(index, length) ? +index : index;
  24033. }).sort(compareAscending));
  24034. return result;
  24035. });
  24036. /**
  24037. * Removes all elements from `array` that `predicate` returns truthy for
  24038. * and returns an array of the removed elements. The predicate is invoked
  24039. * with three arguments: (value, index, array).
  24040. *
  24041. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24042. * to pull elements from an array by value.
  24043. *
  24044. * @static
  24045. * @memberOf _
  24046. * @since 2.0.0
  24047. * @category Array
  24048. * @param {Array} array The array to modify.
  24049. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24050. * @returns {Array} Returns the new array of removed elements.
  24051. * @example
  24052. *
  24053. * var array = [1, 2, 3, 4];
  24054. * var evens = _.remove(array, function(n) {
  24055. * return n % 2 == 0;
  24056. * });
  24057. *
  24058. * console.log(array);
  24059. * // => [1, 3]
  24060. *
  24061. * console.log(evens);
  24062. * // => [2, 4]
  24063. */
  24064. function remove(array, predicate) {
  24065. var result = [];
  24066. if (!(array && array.length)) {
  24067. return result;
  24068. }
  24069. var index = -1,
  24070. indexes = [],
  24071. length = array.length;
  24072. predicate = getIteratee(predicate, 3);
  24073. while (++index < length) {
  24074. var value = array[index];
  24075. if (predicate(value, index, array)) {
  24076. result.push(value);
  24077. indexes.push(index);
  24078. }
  24079. }
  24080. basePullAt(array, indexes);
  24081. return result;
  24082. }
  24083. /**
  24084. * Reverses `array` so that the first element becomes the last, the second
  24085. * element becomes the second to last, and so on.
  24086. *
  24087. * **Note:** This method mutates `array` and is based on
  24088. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24089. *
  24090. * @static
  24091. * @memberOf _
  24092. * @since 4.0.0
  24093. * @category Array
  24094. * @param {Array} array The array to modify.
  24095. * @returns {Array} Returns `array`.
  24096. * @example
  24097. *
  24098. * var array = [1, 2, 3];
  24099. *
  24100. * _.reverse(array);
  24101. * // => [3, 2, 1]
  24102. *
  24103. * console.log(array);
  24104. * // => [3, 2, 1]
  24105. */
  24106. function reverse(array) {
  24107. return array == null ? array : nativeReverse.call(array);
  24108. }
  24109. /**
  24110. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24111. *
  24112. * **Note:** This method is used instead of
  24113. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24114. * returned.
  24115. *
  24116. * @static
  24117. * @memberOf _
  24118. * @since 3.0.0
  24119. * @category Array
  24120. * @param {Array} array The array to slice.
  24121. * @param {number} [start=0] The start position.
  24122. * @param {number} [end=array.length] The end position.
  24123. * @returns {Array} Returns the slice of `array`.
  24124. */
  24125. function slice(array, start, end) {
  24126. var length = array == null ? 0 : array.length;
  24127. if (!length) {
  24128. return [];
  24129. }
  24130. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24131. start = 0;
  24132. end = length;
  24133. }
  24134. else {
  24135. start = start == null ? 0 : toInteger(start);
  24136. end = end === undefined ? length : toInteger(end);
  24137. }
  24138. return baseSlice(array, start, end);
  24139. }
  24140. /**
  24141. * Uses a binary search to determine the lowest index at which `value`
  24142. * should be inserted into `array` in order to maintain its sort order.
  24143. *
  24144. * @static
  24145. * @memberOf _
  24146. * @since 0.1.0
  24147. * @category Array
  24148. * @param {Array} array The sorted array to inspect.
  24149. * @param {*} value The value to evaluate.
  24150. * @returns {number} Returns the index at which `value` should be inserted
  24151. * into `array`.
  24152. * @example
  24153. *
  24154. * _.sortedIndex([30, 50], 40);
  24155. * // => 1
  24156. */
  24157. function sortedIndex(array, value) {
  24158. return baseSortedIndex(array, value);
  24159. }
  24160. /**
  24161. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24162. * which is invoked for `value` and each element of `array` to compute their
  24163. * sort ranking. The iteratee is invoked with one argument: (value).
  24164. *
  24165. * @static
  24166. * @memberOf _
  24167. * @since 4.0.0
  24168. * @category Array
  24169. * @param {Array} array The sorted array to inspect.
  24170. * @param {*} value The value to evaluate.
  24171. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24172. * @returns {number} Returns the index at which `value` should be inserted
  24173. * into `array`.
  24174. * @example
  24175. *
  24176. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24177. *
  24178. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24179. * // => 0
  24180. *
  24181. * // The `_.property` iteratee shorthand.
  24182. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24183. * // => 0
  24184. */
  24185. function sortedIndexBy(array, value, iteratee) {
  24186. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24187. }
  24188. /**
  24189. * This method is like `_.indexOf` except that it performs a binary
  24190. * search on a sorted `array`.
  24191. *
  24192. * @static
  24193. * @memberOf _
  24194. * @since 4.0.0
  24195. * @category Array
  24196. * @param {Array} array The array to inspect.
  24197. * @param {*} value The value to search for.
  24198. * @returns {number} Returns the index of the matched value, else `-1`.
  24199. * @example
  24200. *
  24201. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24202. * // => 1
  24203. */
  24204. function sortedIndexOf(array, value) {
  24205. var length = array == null ? 0 : array.length;
  24206. if (length) {
  24207. var index = baseSortedIndex(array, value);
  24208. if (index < length && eq(array[index], value)) {
  24209. return index;
  24210. }
  24211. }
  24212. return -1;
  24213. }
  24214. /**
  24215. * This method is like `_.sortedIndex` except that it returns the highest
  24216. * index at which `value` should be inserted into `array` in order to
  24217. * maintain its sort order.
  24218. *
  24219. * @static
  24220. * @memberOf _
  24221. * @since 3.0.0
  24222. * @category Array
  24223. * @param {Array} array The sorted array to inspect.
  24224. * @param {*} value The value to evaluate.
  24225. * @returns {number} Returns the index at which `value` should be inserted
  24226. * into `array`.
  24227. * @example
  24228. *
  24229. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24230. * // => 4
  24231. */
  24232. function sortedLastIndex(array, value) {
  24233. return baseSortedIndex(array, value, true);
  24234. }
  24235. /**
  24236. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24237. * which is invoked for `value` and each element of `array` to compute their
  24238. * sort ranking. The iteratee is invoked with one argument: (value).
  24239. *
  24240. * @static
  24241. * @memberOf _
  24242. * @since 4.0.0
  24243. * @category Array
  24244. * @param {Array} array The sorted array to inspect.
  24245. * @param {*} value The value to evaluate.
  24246. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24247. * @returns {number} Returns the index at which `value` should be inserted
  24248. * into `array`.
  24249. * @example
  24250. *
  24251. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24252. *
  24253. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24254. * // => 1
  24255. *
  24256. * // The `_.property` iteratee shorthand.
  24257. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24258. * // => 1
  24259. */
  24260. function sortedLastIndexBy(array, value, iteratee) {
  24261. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24262. }
  24263. /**
  24264. * This method is like `_.lastIndexOf` except that it performs a binary
  24265. * search on a sorted `array`.
  24266. *
  24267. * @static
  24268. * @memberOf _
  24269. * @since 4.0.0
  24270. * @category Array
  24271. * @param {Array} array The array to inspect.
  24272. * @param {*} value The value to search for.
  24273. * @returns {number} Returns the index of the matched value, else `-1`.
  24274. * @example
  24275. *
  24276. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24277. * // => 3
  24278. */
  24279. function sortedLastIndexOf(array, value) {
  24280. var length = array == null ? 0 : array.length;
  24281. if (length) {
  24282. var index = baseSortedIndex(array, value, true) - 1;
  24283. if (eq(array[index], value)) {
  24284. return index;
  24285. }
  24286. }
  24287. return -1;
  24288. }
  24289. /**
  24290. * This method is like `_.uniq` except that it's designed and optimized
  24291. * for sorted arrays.
  24292. *
  24293. * @static
  24294. * @memberOf _
  24295. * @since 4.0.0
  24296. * @category Array
  24297. * @param {Array} array The array to inspect.
  24298. * @returns {Array} Returns the new duplicate free array.
  24299. * @example
  24300. *
  24301. * _.sortedUniq([1, 1, 2]);
  24302. * // => [1, 2]
  24303. */
  24304. function sortedUniq(array) {
  24305. return (array && array.length)
  24306. ? baseSortedUniq(array)
  24307. : [];
  24308. }
  24309. /**
  24310. * This method is like `_.uniqBy` except that it's designed and optimized
  24311. * for sorted arrays.
  24312. *
  24313. * @static
  24314. * @memberOf _
  24315. * @since 4.0.0
  24316. * @category Array
  24317. * @param {Array} array The array to inspect.
  24318. * @param {Function} [iteratee] The iteratee invoked per element.
  24319. * @returns {Array} Returns the new duplicate free array.
  24320. * @example
  24321. *
  24322. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24323. * // => [1.1, 2.3]
  24324. */
  24325. function sortedUniqBy(array, iteratee) {
  24326. return (array && array.length)
  24327. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24328. : [];
  24329. }
  24330. /**
  24331. * Gets all but the first element of `array`.
  24332. *
  24333. * @static
  24334. * @memberOf _
  24335. * @since 4.0.0
  24336. * @category Array
  24337. * @param {Array} array The array to query.
  24338. * @returns {Array} Returns the slice of `array`.
  24339. * @example
  24340. *
  24341. * _.tail([1, 2, 3]);
  24342. * // => [2, 3]
  24343. */
  24344. function tail(array) {
  24345. var length = array == null ? 0 : array.length;
  24346. return length ? baseSlice(array, 1, length) : [];
  24347. }
  24348. /**
  24349. * Creates a slice of `array` with `n` elements taken from the beginning.
  24350. *
  24351. * @static
  24352. * @memberOf _
  24353. * @since 0.1.0
  24354. * @category Array
  24355. * @param {Array} array The array to query.
  24356. * @param {number} [n=1] The number of elements to take.
  24357. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24358. * @returns {Array} Returns the slice of `array`.
  24359. * @example
  24360. *
  24361. * _.take([1, 2, 3]);
  24362. * // => [1]
  24363. *
  24364. * _.take([1, 2, 3], 2);
  24365. * // => [1, 2]
  24366. *
  24367. * _.take([1, 2, 3], 5);
  24368. * // => [1, 2, 3]
  24369. *
  24370. * _.take([1, 2, 3], 0);
  24371. * // => []
  24372. */
  24373. function take(array, n, guard) {
  24374. if (!(array && array.length)) {
  24375. return [];
  24376. }
  24377. n = (guard || n === undefined) ? 1 : toInteger(n);
  24378. return baseSlice(array, 0, n < 0 ? 0 : n);
  24379. }
  24380. /**
  24381. * Creates a slice of `array` with `n` elements taken from the end.
  24382. *
  24383. * @static
  24384. * @memberOf _
  24385. * @since 3.0.0
  24386. * @category Array
  24387. * @param {Array} array The array to query.
  24388. * @param {number} [n=1] The number of elements to take.
  24389. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24390. * @returns {Array} Returns the slice of `array`.
  24391. * @example
  24392. *
  24393. * _.takeRight([1, 2, 3]);
  24394. * // => [3]
  24395. *
  24396. * _.takeRight([1, 2, 3], 2);
  24397. * // => [2, 3]
  24398. *
  24399. * _.takeRight([1, 2, 3], 5);
  24400. * // => [1, 2, 3]
  24401. *
  24402. * _.takeRight([1, 2, 3], 0);
  24403. * // => []
  24404. */
  24405. function takeRight(array, n, guard) {
  24406. var length = array == null ? 0 : array.length;
  24407. if (!length) {
  24408. return [];
  24409. }
  24410. n = (guard || n === undefined) ? 1 : toInteger(n);
  24411. n = length - n;
  24412. return baseSlice(array, n < 0 ? 0 : n, length);
  24413. }
  24414. /**
  24415. * Creates a slice of `array` with elements taken from the end. Elements are
  24416. * taken until `predicate` returns falsey. The predicate is invoked with
  24417. * three arguments: (value, index, array).
  24418. *
  24419. * @static
  24420. * @memberOf _
  24421. * @since 3.0.0
  24422. * @category Array
  24423. * @param {Array} array The array to query.
  24424. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24425. * @returns {Array} Returns the slice of `array`.
  24426. * @example
  24427. *
  24428. * var users = [
  24429. * { 'user': 'barney', 'active': true },
  24430. * { 'user': 'fred', 'active': false },
  24431. * { 'user': 'pebbles', 'active': false }
  24432. * ];
  24433. *
  24434. * _.takeRightWhile(users, function(o) { return !o.active; });
  24435. * // => objects for ['fred', 'pebbles']
  24436. *
  24437. * // The `_.matches` iteratee shorthand.
  24438. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24439. * // => objects for ['pebbles']
  24440. *
  24441. * // The `_.matchesProperty` iteratee shorthand.
  24442. * _.takeRightWhile(users, ['active', false]);
  24443. * // => objects for ['fred', 'pebbles']
  24444. *
  24445. * // The `_.property` iteratee shorthand.
  24446. * _.takeRightWhile(users, 'active');
  24447. * // => []
  24448. */
  24449. function takeRightWhile(array, predicate) {
  24450. return (array && array.length)
  24451. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24452. : [];
  24453. }
  24454. /**
  24455. * Creates a slice of `array` with elements taken from the beginning. Elements
  24456. * are taken until `predicate` returns falsey. The predicate is invoked with
  24457. * three arguments: (value, index, array).
  24458. *
  24459. * @static
  24460. * @memberOf _
  24461. * @since 3.0.0
  24462. * @category Array
  24463. * @param {Array} array The array to query.
  24464. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24465. * @returns {Array} Returns the slice of `array`.
  24466. * @example
  24467. *
  24468. * var users = [
  24469. * { 'user': 'barney', 'active': false },
  24470. * { 'user': 'fred', 'active': false },
  24471. * { 'user': 'pebbles', 'active': true }
  24472. * ];
  24473. *
  24474. * _.takeWhile(users, function(o) { return !o.active; });
  24475. * // => objects for ['barney', 'fred']
  24476. *
  24477. * // The `_.matches` iteratee shorthand.
  24478. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24479. * // => objects for ['barney']
  24480. *
  24481. * // The `_.matchesProperty` iteratee shorthand.
  24482. * _.takeWhile(users, ['active', false]);
  24483. * // => objects for ['barney', 'fred']
  24484. *
  24485. * // The `_.property` iteratee shorthand.
  24486. * _.takeWhile(users, 'active');
  24487. * // => []
  24488. */
  24489. function takeWhile(array, predicate) {
  24490. return (array && array.length)
  24491. ? baseWhile(array, getIteratee(predicate, 3))
  24492. : [];
  24493. }
  24494. /**
  24495. * Creates an array of unique values, in order, from all given arrays using
  24496. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24497. * for equality comparisons.
  24498. *
  24499. * @static
  24500. * @memberOf _
  24501. * @since 0.1.0
  24502. * @category Array
  24503. * @param {...Array} [arrays] The arrays to inspect.
  24504. * @returns {Array} Returns the new array of combined values.
  24505. * @example
  24506. *
  24507. * _.union([2], [1, 2]);
  24508. * // => [2, 1]
  24509. */
  24510. var union = baseRest(function(arrays) {
  24511. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24512. });
  24513. /**
  24514. * This method is like `_.union` except that it accepts `iteratee` which is
  24515. * invoked for each element of each `arrays` to generate the criterion by
  24516. * which uniqueness is computed. Result values are chosen from the first
  24517. * array in which the value occurs. The iteratee is invoked with one argument:
  24518. * (value).
  24519. *
  24520. * @static
  24521. * @memberOf _
  24522. * @since 4.0.0
  24523. * @category Array
  24524. * @param {...Array} [arrays] The arrays to inspect.
  24525. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24526. * @returns {Array} Returns the new array of combined values.
  24527. * @example
  24528. *
  24529. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24530. * // => [2.1, 1.2]
  24531. *
  24532. * // The `_.property` iteratee shorthand.
  24533. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24534. * // => [{ 'x': 1 }, { 'x': 2 }]
  24535. */
  24536. var unionBy = baseRest(function(arrays) {
  24537. var iteratee = last(arrays);
  24538. if (isArrayLikeObject(iteratee)) {
  24539. iteratee = undefined;
  24540. }
  24541. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24542. });
  24543. /**
  24544. * This method is like `_.union` except that it accepts `comparator` which
  24545. * is invoked to compare elements of `arrays`. Result values are chosen from
  24546. * the first array in which the value occurs. The comparator is invoked
  24547. * with two arguments: (arrVal, othVal).
  24548. *
  24549. * @static
  24550. * @memberOf _
  24551. * @since 4.0.0
  24552. * @category Array
  24553. * @param {...Array} [arrays] The arrays to inspect.
  24554. * @param {Function} [comparator] The comparator invoked per element.
  24555. * @returns {Array} Returns the new array of combined values.
  24556. * @example
  24557. *
  24558. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24559. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24560. *
  24561. * _.unionWith(objects, others, _.isEqual);
  24562. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24563. */
  24564. var unionWith = baseRest(function(arrays) {
  24565. var comparator = last(arrays);
  24566. comparator = typeof comparator == 'function' ? comparator : undefined;
  24567. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24568. });
  24569. /**
  24570. * Creates a duplicate-free version of an array, using
  24571. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24572. * for equality comparisons, in which only the first occurrence of each element
  24573. * is kept. The order of result values is determined by the order they occur
  24574. * in the array.
  24575. *
  24576. * @static
  24577. * @memberOf _
  24578. * @since 0.1.0
  24579. * @category Array
  24580. * @param {Array} array The array to inspect.
  24581. * @returns {Array} Returns the new duplicate free array.
  24582. * @example
  24583. *
  24584. * _.uniq([2, 1, 2]);
  24585. * // => [2, 1]
  24586. */
  24587. function uniq(array) {
  24588. return (array && array.length) ? baseUniq(array) : [];
  24589. }
  24590. /**
  24591. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24592. * invoked for each element in `array` to generate the criterion by which
  24593. * uniqueness is computed. The order of result values is determined by the
  24594. * order they occur in the array. The iteratee is invoked with one argument:
  24595. * (value).
  24596. *
  24597. * @static
  24598. * @memberOf _
  24599. * @since 4.0.0
  24600. * @category Array
  24601. * @param {Array} array The array to inspect.
  24602. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24603. * @returns {Array} Returns the new duplicate free array.
  24604. * @example
  24605. *
  24606. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24607. * // => [2.1, 1.2]
  24608. *
  24609. * // The `_.property` iteratee shorthand.
  24610. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24611. * // => [{ 'x': 1 }, { 'x': 2 }]
  24612. */
  24613. function uniqBy(array, iteratee) {
  24614. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24615. }
  24616. /**
  24617. * This method is like `_.uniq` except that it accepts `comparator` which
  24618. * is invoked to compare elements of `array`. The order of result values is
  24619. * determined by the order they occur in the array.The comparator is invoked
  24620. * with two arguments: (arrVal, othVal).
  24621. *
  24622. * @static
  24623. * @memberOf _
  24624. * @since 4.0.0
  24625. * @category Array
  24626. * @param {Array} array The array to inspect.
  24627. * @param {Function} [comparator] The comparator invoked per element.
  24628. * @returns {Array} Returns the new duplicate free array.
  24629. * @example
  24630. *
  24631. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24632. *
  24633. * _.uniqWith(objects, _.isEqual);
  24634. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24635. */
  24636. function uniqWith(array, comparator) {
  24637. comparator = typeof comparator == 'function' ? comparator : undefined;
  24638. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24639. }
  24640. /**
  24641. * This method is like `_.zip` except that it accepts an array of grouped
  24642. * elements and creates an array regrouping the elements to their pre-zip
  24643. * configuration.
  24644. *
  24645. * @static
  24646. * @memberOf _
  24647. * @since 1.2.0
  24648. * @category Array
  24649. * @param {Array} array The array of grouped elements to process.
  24650. * @returns {Array} Returns the new array of regrouped elements.
  24651. * @example
  24652. *
  24653. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24654. * // => [['a', 1, true], ['b', 2, false]]
  24655. *
  24656. * _.unzip(zipped);
  24657. * // => [['a', 'b'], [1, 2], [true, false]]
  24658. */
  24659. function unzip(array) {
  24660. if (!(array && array.length)) {
  24661. return [];
  24662. }
  24663. var length = 0;
  24664. array = arrayFilter(array, function(group) {
  24665. if (isArrayLikeObject(group)) {
  24666. length = nativeMax(group.length, length);
  24667. return true;
  24668. }
  24669. });
  24670. return baseTimes(length, function(index) {
  24671. return arrayMap(array, baseProperty(index));
  24672. });
  24673. }
  24674. /**
  24675. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24676. * how regrouped values should be combined. The iteratee is invoked with the
  24677. * elements of each group: (...group).
  24678. *
  24679. * @static
  24680. * @memberOf _
  24681. * @since 3.8.0
  24682. * @category Array
  24683. * @param {Array} array The array of grouped elements to process.
  24684. * @param {Function} [iteratee=_.identity] The function to combine
  24685. * regrouped values.
  24686. * @returns {Array} Returns the new array of regrouped elements.
  24687. * @example
  24688. *
  24689. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24690. * // => [[1, 10, 100], [2, 20, 200]]
  24691. *
  24692. * _.unzipWith(zipped, _.add);
  24693. * // => [3, 30, 300]
  24694. */
  24695. function unzipWith(array, iteratee) {
  24696. if (!(array && array.length)) {
  24697. return [];
  24698. }
  24699. var result = unzip(array);
  24700. if (iteratee == null) {
  24701. return result;
  24702. }
  24703. return arrayMap(result, function(group) {
  24704. return apply(iteratee, undefined, group);
  24705. });
  24706. }
  24707. /**
  24708. * Creates an array excluding all given values using
  24709. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24710. * for equality comparisons.
  24711. *
  24712. * **Note:** Unlike `_.pull`, this method returns a new array.
  24713. *
  24714. * @static
  24715. * @memberOf _
  24716. * @since 0.1.0
  24717. * @category Array
  24718. * @param {Array} array The array to inspect.
  24719. * @param {...*} [values] The values to exclude.
  24720. * @returns {Array} Returns the new array of filtered values.
  24721. * @see _.difference, _.xor
  24722. * @example
  24723. *
  24724. * _.without([2, 1, 2, 3], 1, 2);
  24725. * // => [3]
  24726. */
  24727. var without = baseRest(function(array, values) {
  24728. return isArrayLikeObject(array)
  24729. ? baseDifference(array, values)
  24730. : [];
  24731. });
  24732. /**
  24733. * Creates an array of unique values that is the
  24734. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24735. * of the given arrays. The order of result values is determined by the order
  24736. * they occur in the arrays.
  24737. *
  24738. * @static
  24739. * @memberOf _
  24740. * @since 2.4.0
  24741. * @category Array
  24742. * @param {...Array} [arrays] The arrays to inspect.
  24743. * @returns {Array} Returns the new array of filtered values.
  24744. * @see _.difference, _.without
  24745. * @example
  24746. *
  24747. * _.xor([2, 1], [2, 3]);
  24748. * // => [1, 3]
  24749. */
  24750. var xor = baseRest(function(arrays) {
  24751. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24752. });
  24753. /**
  24754. * This method is like `_.xor` except that it accepts `iteratee` which is
  24755. * invoked for each element of each `arrays` to generate the criterion by
  24756. * which by which they're compared. The order of result values is determined
  24757. * by the order they occur in the arrays. The iteratee is invoked with one
  24758. * argument: (value).
  24759. *
  24760. * @static
  24761. * @memberOf _
  24762. * @since 4.0.0
  24763. * @category Array
  24764. * @param {...Array} [arrays] The arrays to inspect.
  24765. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24766. * @returns {Array} Returns the new array of filtered values.
  24767. * @example
  24768. *
  24769. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24770. * // => [1.2, 3.4]
  24771. *
  24772. * // The `_.property` iteratee shorthand.
  24773. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24774. * // => [{ 'x': 2 }]
  24775. */
  24776. var xorBy = baseRest(function(arrays) {
  24777. var iteratee = last(arrays);
  24778. if (isArrayLikeObject(iteratee)) {
  24779. iteratee = undefined;
  24780. }
  24781. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24782. });
  24783. /**
  24784. * This method is like `_.xor` except that it accepts `comparator` which is
  24785. * invoked to compare elements of `arrays`. The order of result values is
  24786. * determined by the order they occur in the arrays. The comparator is invoked
  24787. * with two arguments: (arrVal, othVal).
  24788. *
  24789. * @static
  24790. * @memberOf _
  24791. * @since 4.0.0
  24792. * @category Array
  24793. * @param {...Array} [arrays] The arrays to inspect.
  24794. * @param {Function} [comparator] The comparator invoked per element.
  24795. * @returns {Array} Returns the new array of filtered values.
  24796. * @example
  24797. *
  24798. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24799. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24800. *
  24801. * _.xorWith(objects, others, _.isEqual);
  24802. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24803. */
  24804. var xorWith = baseRest(function(arrays) {
  24805. var comparator = last(arrays);
  24806. comparator = typeof comparator == 'function' ? comparator : undefined;
  24807. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24808. });
  24809. /**
  24810. * Creates an array of grouped elements, the first of which contains the
  24811. * first elements of the given arrays, the second of which contains the
  24812. * second elements of the given arrays, and so on.
  24813. *
  24814. * @static
  24815. * @memberOf _
  24816. * @since 0.1.0
  24817. * @category Array
  24818. * @param {...Array} [arrays] The arrays to process.
  24819. * @returns {Array} Returns the new array of grouped elements.
  24820. * @example
  24821. *
  24822. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24823. * // => [['a', 1, true], ['b', 2, false]]
  24824. */
  24825. var zip = baseRest(unzip);
  24826. /**
  24827. * This method is like `_.fromPairs` except that it accepts two arrays,
  24828. * one of property identifiers and one of corresponding values.
  24829. *
  24830. * @static
  24831. * @memberOf _
  24832. * @since 0.4.0
  24833. * @category Array
  24834. * @param {Array} [props=[]] The property identifiers.
  24835. * @param {Array} [values=[]] The property values.
  24836. * @returns {Object} Returns the new object.
  24837. * @example
  24838. *
  24839. * _.zipObject(['a', 'b'], [1, 2]);
  24840. * // => { 'a': 1, 'b': 2 }
  24841. */
  24842. function zipObject(props, values) {
  24843. return baseZipObject(props || [], values || [], assignValue);
  24844. }
  24845. /**
  24846. * This method is like `_.zipObject` except that it supports property paths.
  24847. *
  24848. * @static
  24849. * @memberOf _
  24850. * @since 4.1.0
  24851. * @category Array
  24852. * @param {Array} [props=[]] The property identifiers.
  24853. * @param {Array} [values=[]] The property values.
  24854. * @returns {Object} Returns the new object.
  24855. * @example
  24856. *
  24857. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24858. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24859. */
  24860. function zipObjectDeep(props, values) {
  24861. return baseZipObject(props || [], values || [], baseSet);
  24862. }
  24863. /**
  24864. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24865. * how grouped values should be combined. The iteratee is invoked with the
  24866. * elements of each group: (...group).
  24867. *
  24868. * @static
  24869. * @memberOf _
  24870. * @since 3.8.0
  24871. * @category Array
  24872. * @param {...Array} [arrays] The arrays to process.
  24873. * @param {Function} [iteratee=_.identity] The function to combine
  24874. * grouped values.
  24875. * @returns {Array} Returns the new array of grouped elements.
  24876. * @example
  24877. *
  24878. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24879. * return a + b + c;
  24880. * });
  24881. * // => [111, 222]
  24882. */
  24883. var zipWith = baseRest(function(arrays) {
  24884. var length = arrays.length,
  24885. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24886. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24887. return unzipWith(arrays, iteratee);
  24888. });
  24889. /*------------------------------------------------------------------------*/
  24890. /**
  24891. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24892. * chain sequences enabled. The result of such sequences must be unwrapped
  24893. * with `_#value`.
  24894. *
  24895. * @static
  24896. * @memberOf _
  24897. * @since 1.3.0
  24898. * @category Seq
  24899. * @param {*} value The value to wrap.
  24900. * @returns {Object} Returns the new `lodash` wrapper instance.
  24901. * @example
  24902. *
  24903. * var users = [
  24904. * { 'user': 'barney', 'age': 36 },
  24905. * { 'user': 'fred', 'age': 40 },
  24906. * { 'user': 'pebbles', 'age': 1 }
  24907. * ];
  24908. *
  24909. * var youngest = _
  24910. * .chain(users)
  24911. * .sortBy('age')
  24912. * .map(function(o) {
  24913. * return o.user + ' is ' + o.age;
  24914. * })
  24915. * .head()
  24916. * .value();
  24917. * // => 'pebbles is 1'
  24918. */
  24919. function chain(value) {
  24920. var result = lodash(value);
  24921. result.__chain__ = true;
  24922. return result;
  24923. }
  24924. /**
  24925. * This method invokes `interceptor` and returns `value`. The interceptor
  24926. * is invoked with one argument; (value). The purpose of this method is to
  24927. * "tap into" a method chain sequence in order to modify intermediate results.
  24928. *
  24929. * @static
  24930. * @memberOf _
  24931. * @since 0.1.0
  24932. * @category Seq
  24933. * @param {*} value The value to provide to `interceptor`.
  24934. * @param {Function} interceptor The function to invoke.
  24935. * @returns {*} Returns `value`.
  24936. * @example
  24937. *
  24938. * _([1, 2, 3])
  24939. * .tap(function(array) {
  24940. * // Mutate input array.
  24941. * array.pop();
  24942. * })
  24943. * .reverse()
  24944. * .value();
  24945. * // => [2, 1]
  24946. */
  24947. function tap(value, interceptor) {
  24948. interceptor(value);
  24949. return value;
  24950. }
  24951. /**
  24952. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24953. * The purpose of this method is to "pass thru" values replacing intermediate
  24954. * results in a method chain sequence.
  24955. *
  24956. * @static
  24957. * @memberOf _
  24958. * @since 3.0.0
  24959. * @category Seq
  24960. * @param {*} value The value to provide to `interceptor`.
  24961. * @param {Function} interceptor The function to invoke.
  24962. * @returns {*} Returns the result of `interceptor`.
  24963. * @example
  24964. *
  24965. * _(' abc ')
  24966. * .chain()
  24967. * .trim()
  24968. * .thru(function(value) {
  24969. * return [value];
  24970. * })
  24971. * .value();
  24972. * // => ['abc']
  24973. */
  24974. function thru(value, interceptor) {
  24975. return interceptor(value);
  24976. }
  24977. /**
  24978. * This method is the wrapper version of `_.at`.
  24979. *
  24980. * @name at
  24981. * @memberOf _
  24982. * @since 1.0.0
  24983. * @category Seq
  24984. * @param {...(string|string[])} [paths] The property paths to pick.
  24985. * @returns {Object} Returns the new `lodash` wrapper instance.
  24986. * @example
  24987. *
  24988. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24989. *
  24990. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24991. * // => [3, 4]
  24992. */
  24993. var wrapperAt = flatRest(function(paths) {
  24994. var length = paths.length,
  24995. start = length ? paths[0] : 0,
  24996. value = this.__wrapped__,
  24997. interceptor = function(object) { return baseAt(object, paths); };
  24998. if (length > 1 || this.__actions__.length ||
  24999. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25000. return this.thru(interceptor);
  25001. }
  25002. value = value.slice(start, +start + (length ? 1 : 0));
  25003. value.__actions__.push({
  25004. 'func': thru,
  25005. 'args': [interceptor],
  25006. 'thisArg': undefined
  25007. });
  25008. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25009. if (length && !array.length) {
  25010. array.push(undefined);
  25011. }
  25012. return array;
  25013. });
  25014. });
  25015. /**
  25016. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25017. *
  25018. * @name chain
  25019. * @memberOf _
  25020. * @since 0.1.0
  25021. * @category Seq
  25022. * @returns {Object} Returns the new `lodash` wrapper instance.
  25023. * @example
  25024. *
  25025. * var users = [
  25026. * { 'user': 'barney', 'age': 36 },
  25027. * { 'user': 'fred', 'age': 40 }
  25028. * ];
  25029. *
  25030. * // A sequence without explicit chaining.
  25031. * _(users).head();
  25032. * // => { 'user': 'barney', 'age': 36 }
  25033. *
  25034. * // A sequence with explicit chaining.
  25035. * _(users)
  25036. * .chain()
  25037. * .head()
  25038. * .pick('user')
  25039. * .value();
  25040. * // => { 'user': 'barney' }
  25041. */
  25042. function wrapperChain() {
  25043. return chain(this);
  25044. }
  25045. /**
  25046. * Executes the chain sequence and returns the wrapped result.
  25047. *
  25048. * @name commit
  25049. * @memberOf _
  25050. * @since 3.2.0
  25051. * @category Seq
  25052. * @returns {Object} Returns the new `lodash` wrapper instance.
  25053. * @example
  25054. *
  25055. * var array = [1, 2];
  25056. * var wrapped = _(array).push(3);
  25057. *
  25058. * console.log(array);
  25059. * // => [1, 2]
  25060. *
  25061. * wrapped = wrapped.commit();
  25062. * console.log(array);
  25063. * // => [1, 2, 3]
  25064. *
  25065. * wrapped.last();
  25066. * // => 3
  25067. *
  25068. * console.log(array);
  25069. * // => [1, 2, 3]
  25070. */
  25071. function wrapperCommit() {
  25072. return new LodashWrapper(this.value(), this.__chain__);
  25073. }
  25074. /**
  25075. * Gets the next value on a wrapped object following the
  25076. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25077. *
  25078. * @name next
  25079. * @memberOf _
  25080. * @since 4.0.0
  25081. * @category Seq
  25082. * @returns {Object} Returns the next iterator value.
  25083. * @example
  25084. *
  25085. * var wrapped = _([1, 2]);
  25086. *
  25087. * wrapped.next();
  25088. * // => { 'done': false, 'value': 1 }
  25089. *
  25090. * wrapped.next();
  25091. * // => { 'done': false, 'value': 2 }
  25092. *
  25093. * wrapped.next();
  25094. * // => { 'done': true, 'value': undefined }
  25095. */
  25096. function wrapperNext() {
  25097. if (this.__values__ === undefined) {
  25098. this.__values__ = toArray(this.value());
  25099. }
  25100. var done = this.__index__ >= this.__values__.length,
  25101. value = done ? undefined : this.__values__[this.__index__++];
  25102. return { 'done': done, 'value': value };
  25103. }
  25104. /**
  25105. * Enables the wrapper to be iterable.
  25106. *
  25107. * @name Symbol.iterator
  25108. * @memberOf _
  25109. * @since 4.0.0
  25110. * @category Seq
  25111. * @returns {Object} Returns the wrapper object.
  25112. * @example
  25113. *
  25114. * var wrapped = _([1, 2]);
  25115. *
  25116. * wrapped[Symbol.iterator]() === wrapped;
  25117. * // => true
  25118. *
  25119. * Array.from(wrapped);
  25120. * // => [1, 2]
  25121. */
  25122. function wrapperToIterator() {
  25123. return this;
  25124. }
  25125. /**
  25126. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25127. *
  25128. * @name plant
  25129. * @memberOf _
  25130. * @since 3.2.0
  25131. * @category Seq
  25132. * @param {*} value The value to plant.
  25133. * @returns {Object} Returns the new `lodash` wrapper instance.
  25134. * @example
  25135. *
  25136. * function square(n) {
  25137. * return n * n;
  25138. * }
  25139. *
  25140. * var wrapped = _([1, 2]).map(square);
  25141. * var other = wrapped.plant([3, 4]);
  25142. *
  25143. * other.value();
  25144. * // => [9, 16]
  25145. *
  25146. * wrapped.value();
  25147. * // => [1, 4]
  25148. */
  25149. function wrapperPlant(value) {
  25150. var result,
  25151. parent = this;
  25152. while (parent instanceof baseLodash) {
  25153. var clone = wrapperClone(parent);
  25154. clone.__index__ = 0;
  25155. clone.__values__ = undefined;
  25156. if (result) {
  25157. previous.__wrapped__ = clone;
  25158. } else {
  25159. result = clone;
  25160. }
  25161. var previous = clone;
  25162. parent = parent.__wrapped__;
  25163. }
  25164. previous.__wrapped__ = value;
  25165. return result;
  25166. }
  25167. /**
  25168. * This method is the wrapper version of `_.reverse`.
  25169. *
  25170. * **Note:** This method mutates the wrapped array.
  25171. *
  25172. * @name reverse
  25173. * @memberOf _
  25174. * @since 0.1.0
  25175. * @category Seq
  25176. * @returns {Object} Returns the new `lodash` wrapper instance.
  25177. * @example
  25178. *
  25179. * var array = [1, 2, 3];
  25180. *
  25181. * _(array).reverse().value()
  25182. * // => [3, 2, 1]
  25183. *
  25184. * console.log(array);
  25185. * // => [3, 2, 1]
  25186. */
  25187. function wrapperReverse() {
  25188. var value = this.__wrapped__;
  25189. if (value instanceof LazyWrapper) {
  25190. var wrapped = value;
  25191. if (this.__actions__.length) {
  25192. wrapped = new LazyWrapper(this);
  25193. }
  25194. wrapped = wrapped.reverse();
  25195. wrapped.__actions__.push({
  25196. 'func': thru,
  25197. 'args': [reverse],
  25198. 'thisArg': undefined
  25199. });
  25200. return new LodashWrapper(wrapped, this.__chain__);
  25201. }
  25202. return this.thru(reverse);
  25203. }
  25204. /**
  25205. * Executes the chain sequence to resolve the unwrapped value.
  25206. *
  25207. * @name value
  25208. * @memberOf _
  25209. * @since 0.1.0
  25210. * @alias toJSON, valueOf
  25211. * @category Seq
  25212. * @returns {*} Returns the resolved unwrapped value.
  25213. * @example
  25214. *
  25215. * _([1, 2, 3]).value();
  25216. * // => [1, 2, 3]
  25217. */
  25218. function wrapperValue() {
  25219. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25220. }
  25221. /*------------------------------------------------------------------------*/
  25222. /**
  25223. * Creates an object composed of keys generated from the results of running
  25224. * each element of `collection` thru `iteratee`. The corresponding value of
  25225. * each key is the number of times the key was returned by `iteratee`. The
  25226. * iteratee is invoked with one argument: (value).
  25227. *
  25228. * @static
  25229. * @memberOf _
  25230. * @since 0.5.0
  25231. * @category Collection
  25232. * @param {Array|Object} collection The collection to iterate over.
  25233. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25234. * @returns {Object} Returns the composed aggregate object.
  25235. * @example
  25236. *
  25237. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25238. * // => { '4': 1, '6': 2 }
  25239. *
  25240. * // The `_.property` iteratee shorthand.
  25241. * _.countBy(['one', 'two', 'three'], 'length');
  25242. * // => { '3': 2, '5': 1 }
  25243. */
  25244. var countBy = createAggregator(function(result, value, key) {
  25245. if (hasOwnProperty.call(result, key)) {
  25246. ++result[key];
  25247. } else {
  25248. baseAssignValue(result, key, 1);
  25249. }
  25250. });
  25251. /**
  25252. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25253. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25254. * invoked with three arguments: (value, index|key, collection).
  25255. *
  25256. * **Note:** This method returns `true` for
  25257. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25258. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25259. * elements of empty collections.
  25260. *
  25261. * @static
  25262. * @memberOf _
  25263. * @since 0.1.0
  25264. * @category Collection
  25265. * @param {Array|Object} collection The collection to iterate over.
  25266. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25267. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25268. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25269. * else `false`.
  25270. * @example
  25271. *
  25272. * _.every([true, 1, null, 'yes'], Boolean);
  25273. * // => false
  25274. *
  25275. * var users = [
  25276. * { 'user': 'barney', 'age': 36, 'active': false },
  25277. * { 'user': 'fred', 'age': 40, 'active': false }
  25278. * ];
  25279. *
  25280. * // The `_.matches` iteratee shorthand.
  25281. * _.every(users, { 'user': 'barney', 'active': false });
  25282. * // => false
  25283. *
  25284. * // The `_.matchesProperty` iteratee shorthand.
  25285. * _.every(users, ['active', false]);
  25286. * // => true
  25287. *
  25288. * // The `_.property` iteratee shorthand.
  25289. * _.every(users, 'active');
  25290. * // => false
  25291. */
  25292. function every(collection, predicate, guard) {
  25293. var func = isArray(collection) ? arrayEvery : baseEvery;
  25294. if (guard && isIterateeCall(collection, predicate, guard)) {
  25295. predicate = undefined;
  25296. }
  25297. return func(collection, getIteratee(predicate, 3));
  25298. }
  25299. /**
  25300. * Iterates over elements of `collection`, returning an array of all elements
  25301. * `predicate` returns truthy for. The predicate is invoked with three
  25302. * arguments: (value, index|key, collection).
  25303. *
  25304. * **Note:** Unlike `_.remove`, this method returns a new array.
  25305. *
  25306. * @static
  25307. * @memberOf _
  25308. * @since 0.1.0
  25309. * @category Collection
  25310. * @param {Array|Object} collection The collection to iterate over.
  25311. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25312. * @returns {Array} Returns the new filtered array.
  25313. * @see _.reject
  25314. * @example
  25315. *
  25316. * var users = [
  25317. * { 'user': 'barney', 'age': 36, 'active': true },
  25318. * { 'user': 'fred', 'age': 40, 'active': false }
  25319. * ];
  25320. *
  25321. * _.filter(users, function(o) { return !o.active; });
  25322. * // => objects for ['fred']
  25323. *
  25324. * // The `_.matches` iteratee shorthand.
  25325. * _.filter(users, { 'age': 36, 'active': true });
  25326. * // => objects for ['barney']
  25327. *
  25328. * // The `_.matchesProperty` iteratee shorthand.
  25329. * _.filter(users, ['active', false]);
  25330. * // => objects for ['fred']
  25331. *
  25332. * // The `_.property` iteratee shorthand.
  25333. * _.filter(users, 'active');
  25334. * // => objects for ['barney']
  25335. */
  25336. function filter(collection, predicate) {
  25337. var func = isArray(collection) ? arrayFilter : baseFilter;
  25338. return func(collection, getIteratee(predicate, 3));
  25339. }
  25340. /**
  25341. * Iterates over elements of `collection`, returning the first element
  25342. * `predicate` returns truthy for. The predicate is invoked with three
  25343. * arguments: (value, index|key, collection).
  25344. *
  25345. * @static
  25346. * @memberOf _
  25347. * @since 0.1.0
  25348. * @category Collection
  25349. * @param {Array|Object} collection The collection to inspect.
  25350. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25351. * @param {number} [fromIndex=0] The index to search from.
  25352. * @returns {*} Returns the matched element, else `undefined`.
  25353. * @example
  25354. *
  25355. * var users = [
  25356. * { 'user': 'barney', 'age': 36, 'active': true },
  25357. * { 'user': 'fred', 'age': 40, 'active': false },
  25358. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25359. * ];
  25360. *
  25361. * _.find(users, function(o) { return o.age < 40; });
  25362. * // => object for 'barney'
  25363. *
  25364. * // The `_.matches` iteratee shorthand.
  25365. * _.find(users, { 'age': 1, 'active': true });
  25366. * // => object for 'pebbles'
  25367. *
  25368. * // The `_.matchesProperty` iteratee shorthand.
  25369. * _.find(users, ['active', false]);
  25370. * // => object for 'fred'
  25371. *
  25372. * // The `_.property` iteratee shorthand.
  25373. * _.find(users, 'active');
  25374. * // => object for 'barney'
  25375. */
  25376. var find = createFind(findIndex);
  25377. /**
  25378. * This method is like `_.find` except that it iterates over elements of
  25379. * `collection` from right to left.
  25380. *
  25381. * @static
  25382. * @memberOf _
  25383. * @since 2.0.0
  25384. * @category Collection
  25385. * @param {Array|Object} collection The collection to inspect.
  25386. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25387. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25388. * @returns {*} Returns the matched element, else `undefined`.
  25389. * @example
  25390. *
  25391. * _.findLast([1, 2, 3, 4], function(n) {
  25392. * return n % 2 == 1;
  25393. * });
  25394. * // => 3
  25395. */
  25396. var findLast = createFind(findLastIndex);
  25397. /**
  25398. * Creates a flattened array of values by running each element in `collection`
  25399. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25400. * with three arguments: (value, index|key, collection).
  25401. *
  25402. * @static
  25403. * @memberOf _
  25404. * @since 4.0.0
  25405. * @category Collection
  25406. * @param {Array|Object} collection The collection to iterate over.
  25407. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25408. * @returns {Array} Returns the new flattened array.
  25409. * @example
  25410. *
  25411. * function duplicate(n) {
  25412. * return [n, n];
  25413. * }
  25414. *
  25415. * _.flatMap([1, 2], duplicate);
  25416. * // => [1, 1, 2, 2]
  25417. */
  25418. function flatMap(collection, iteratee) {
  25419. return baseFlatten(map(collection, iteratee), 1);
  25420. }
  25421. /**
  25422. * This method is like `_.flatMap` except that it recursively flattens the
  25423. * mapped results.
  25424. *
  25425. * @static
  25426. * @memberOf _
  25427. * @since 4.7.0
  25428. * @category Collection
  25429. * @param {Array|Object} collection The collection to iterate over.
  25430. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25431. * @returns {Array} Returns the new flattened array.
  25432. * @example
  25433. *
  25434. * function duplicate(n) {
  25435. * return [[[n, n]]];
  25436. * }
  25437. *
  25438. * _.flatMapDeep([1, 2], duplicate);
  25439. * // => [1, 1, 2, 2]
  25440. */
  25441. function flatMapDeep(collection, iteratee) {
  25442. return baseFlatten(map(collection, iteratee), INFINITY);
  25443. }
  25444. /**
  25445. * This method is like `_.flatMap` except that it recursively flattens the
  25446. * mapped results up to `depth` times.
  25447. *
  25448. * @static
  25449. * @memberOf _
  25450. * @since 4.7.0
  25451. * @category Collection
  25452. * @param {Array|Object} collection The collection to iterate over.
  25453. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25454. * @param {number} [depth=1] The maximum recursion depth.
  25455. * @returns {Array} Returns the new flattened array.
  25456. * @example
  25457. *
  25458. * function duplicate(n) {
  25459. * return [[[n, n]]];
  25460. * }
  25461. *
  25462. * _.flatMapDepth([1, 2], duplicate, 2);
  25463. * // => [[1, 1], [2, 2]]
  25464. */
  25465. function flatMapDepth(collection, iteratee, depth) {
  25466. depth = depth === undefined ? 1 : toInteger(depth);
  25467. return baseFlatten(map(collection, iteratee), depth);
  25468. }
  25469. /**
  25470. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25471. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25472. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25473. *
  25474. * **Note:** As with other "Collections" methods, objects with a "length"
  25475. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25476. * or `_.forOwn` for object iteration.
  25477. *
  25478. * @static
  25479. * @memberOf _
  25480. * @since 0.1.0
  25481. * @alias each
  25482. * @category Collection
  25483. * @param {Array|Object} collection The collection to iterate over.
  25484. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25485. * @returns {Array|Object} Returns `collection`.
  25486. * @see _.forEachRight
  25487. * @example
  25488. *
  25489. * _.forEach([1, 2], function(value) {
  25490. * console.log(value);
  25491. * });
  25492. * // => Logs `1` then `2`.
  25493. *
  25494. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25495. * console.log(key);
  25496. * });
  25497. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25498. */
  25499. function forEach(collection, iteratee) {
  25500. var func = isArray(collection) ? arrayEach : baseEach;
  25501. return func(collection, getIteratee(iteratee, 3));
  25502. }
  25503. /**
  25504. * This method is like `_.forEach` except that it iterates over elements of
  25505. * `collection` from right to left.
  25506. *
  25507. * @static
  25508. * @memberOf _
  25509. * @since 2.0.0
  25510. * @alias eachRight
  25511. * @category Collection
  25512. * @param {Array|Object} collection The collection to iterate over.
  25513. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25514. * @returns {Array|Object} Returns `collection`.
  25515. * @see _.forEach
  25516. * @example
  25517. *
  25518. * _.forEachRight([1, 2], function(value) {
  25519. * console.log(value);
  25520. * });
  25521. * // => Logs `2` then `1`.
  25522. */
  25523. function forEachRight(collection, iteratee) {
  25524. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25525. return func(collection, getIteratee(iteratee, 3));
  25526. }
  25527. /**
  25528. * Creates an object composed of keys generated from the results of running
  25529. * each element of `collection` thru `iteratee`. The order of grouped values
  25530. * is determined by the order they occur in `collection`. The corresponding
  25531. * value of each key is an array of elements responsible for generating the
  25532. * key. The iteratee is invoked with one argument: (value).
  25533. *
  25534. * @static
  25535. * @memberOf _
  25536. * @since 0.1.0
  25537. * @category Collection
  25538. * @param {Array|Object} collection The collection to iterate over.
  25539. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25540. * @returns {Object} Returns the composed aggregate object.
  25541. * @example
  25542. *
  25543. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25544. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25545. *
  25546. * // The `_.property` iteratee shorthand.
  25547. * _.groupBy(['one', 'two', 'three'], 'length');
  25548. * // => { '3': ['one', 'two'], '5': ['three'] }
  25549. */
  25550. var groupBy = createAggregator(function(result, value, key) {
  25551. if (hasOwnProperty.call(result, key)) {
  25552. result[key].push(value);
  25553. } else {
  25554. baseAssignValue(result, key, [value]);
  25555. }
  25556. });
  25557. /**
  25558. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25559. * checked for a substring of `value`, otherwise
  25560. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25561. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25562. * the offset from the end of `collection`.
  25563. *
  25564. * @static
  25565. * @memberOf _
  25566. * @since 0.1.0
  25567. * @category Collection
  25568. * @param {Array|Object|string} collection The collection to inspect.
  25569. * @param {*} value The value to search for.
  25570. * @param {number} [fromIndex=0] The index to search from.
  25571. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25572. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25573. * @example
  25574. *
  25575. * _.includes([1, 2, 3], 1);
  25576. * // => true
  25577. *
  25578. * _.includes([1, 2, 3], 1, 2);
  25579. * // => false
  25580. *
  25581. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25582. * // => true
  25583. *
  25584. * _.includes('abcd', 'bc');
  25585. * // => true
  25586. */
  25587. function includes(collection, value, fromIndex, guard) {
  25588. collection = isArrayLike(collection) ? collection : values(collection);
  25589. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25590. var length = collection.length;
  25591. if (fromIndex < 0) {
  25592. fromIndex = nativeMax(length + fromIndex, 0);
  25593. }
  25594. return isString(collection)
  25595. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25596. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25597. }
  25598. /**
  25599. * Invokes the method at `path` of each element in `collection`, returning
  25600. * an array of the results of each invoked method. Any additional arguments
  25601. * are provided to each invoked method. If `path` is a function, it's invoked
  25602. * for, and `this` bound to, each element in `collection`.
  25603. *
  25604. * @static
  25605. * @memberOf _
  25606. * @since 4.0.0
  25607. * @category Collection
  25608. * @param {Array|Object} collection The collection to iterate over.
  25609. * @param {Array|Function|string} path The path of the method to invoke or
  25610. * the function invoked per iteration.
  25611. * @param {...*} [args] The arguments to invoke each method with.
  25612. * @returns {Array} Returns the array of results.
  25613. * @example
  25614. *
  25615. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25616. * // => [[1, 5, 7], [1, 2, 3]]
  25617. *
  25618. * _.invokeMap([123, 456], String.prototype.split, '');
  25619. * // => [['1', '2', '3'], ['4', '5', '6']]
  25620. */
  25621. var invokeMap = baseRest(function(collection, path, args) {
  25622. var index = -1,
  25623. isFunc = typeof path == 'function',
  25624. result = isArrayLike(collection) ? Array(collection.length) : [];
  25625. baseEach(collection, function(value) {
  25626. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25627. });
  25628. return result;
  25629. });
  25630. /**
  25631. * Creates an object composed of keys generated from the results of running
  25632. * each element of `collection` thru `iteratee`. The corresponding value of
  25633. * each key is the last element responsible for generating the key. The
  25634. * iteratee is invoked with one argument: (value).
  25635. *
  25636. * @static
  25637. * @memberOf _
  25638. * @since 4.0.0
  25639. * @category Collection
  25640. * @param {Array|Object} collection The collection to iterate over.
  25641. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25642. * @returns {Object} Returns the composed aggregate object.
  25643. * @example
  25644. *
  25645. * var array = [
  25646. * { 'dir': 'left', 'code': 97 },
  25647. * { 'dir': 'right', 'code': 100 }
  25648. * ];
  25649. *
  25650. * _.keyBy(array, function(o) {
  25651. * return String.fromCharCode(o.code);
  25652. * });
  25653. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25654. *
  25655. * _.keyBy(array, 'dir');
  25656. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25657. */
  25658. var keyBy = createAggregator(function(result, value, key) {
  25659. baseAssignValue(result, key, value);
  25660. });
  25661. /**
  25662. * Creates an array of values by running each element in `collection` thru
  25663. * `iteratee`. The iteratee is invoked with three arguments:
  25664. * (value, index|key, collection).
  25665. *
  25666. * Many lodash methods are guarded to work as iteratees for methods like
  25667. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25668. *
  25669. * The guarded methods are:
  25670. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25671. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25672. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25673. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25674. *
  25675. * @static
  25676. * @memberOf _
  25677. * @since 0.1.0
  25678. * @category Collection
  25679. * @param {Array|Object} collection The collection to iterate over.
  25680. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25681. * @returns {Array} Returns the new mapped array.
  25682. * @example
  25683. *
  25684. * function square(n) {
  25685. * return n * n;
  25686. * }
  25687. *
  25688. * _.map([4, 8], square);
  25689. * // => [16, 64]
  25690. *
  25691. * _.map({ 'a': 4, 'b': 8 }, square);
  25692. * // => [16, 64] (iteration order is not guaranteed)
  25693. *
  25694. * var users = [
  25695. * { 'user': 'barney' },
  25696. * { 'user': 'fred' }
  25697. * ];
  25698. *
  25699. * // The `_.property` iteratee shorthand.
  25700. * _.map(users, 'user');
  25701. * // => ['barney', 'fred']
  25702. */
  25703. function map(collection, iteratee) {
  25704. var func = isArray(collection) ? arrayMap : baseMap;
  25705. return func(collection, getIteratee(iteratee, 3));
  25706. }
  25707. /**
  25708. * This method is like `_.sortBy` except that it allows specifying the sort
  25709. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25710. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25711. * descending or "asc" for ascending sort order of corresponding values.
  25712. *
  25713. * @static
  25714. * @memberOf _
  25715. * @since 4.0.0
  25716. * @category Collection
  25717. * @param {Array|Object} collection The collection to iterate over.
  25718. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25719. * The iteratees to sort by.
  25720. * @param {string[]} [orders] The sort orders of `iteratees`.
  25721. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25722. * @returns {Array} Returns the new sorted array.
  25723. * @example
  25724. *
  25725. * var users = [
  25726. * { 'user': 'fred', 'age': 48 },
  25727. * { 'user': 'barney', 'age': 34 },
  25728. * { 'user': 'fred', 'age': 40 },
  25729. * { 'user': 'barney', 'age': 36 }
  25730. * ];
  25731. *
  25732. * // Sort by `user` in ascending order and by `age` in descending order.
  25733. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25734. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25735. */
  25736. function orderBy(collection, iteratees, orders, guard) {
  25737. if (collection == null) {
  25738. return [];
  25739. }
  25740. if (!isArray(iteratees)) {
  25741. iteratees = iteratees == null ? [] : [iteratees];
  25742. }
  25743. orders = guard ? undefined : orders;
  25744. if (!isArray(orders)) {
  25745. orders = orders == null ? [] : [orders];
  25746. }
  25747. return baseOrderBy(collection, iteratees, orders);
  25748. }
  25749. /**
  25750. * Creates an array of elements split into two groups, the first of which
  25751. * contains elements `predicate` returns truthy for, the second of which
  25752. * contains elements `predicate` returns falsey for. The predicate is
  25753. * invoked with one argument: (value).
  25754. *
  25755. * @static
  25756. * @memberOf _
  25757. * @since 3.0.0
  25758. * @category Collection
  25759. * @param {Array|Object} collection The collection to iterate over.
  25760. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25761. * @returns {Array} Returns the array of grouped elements.
  25762. * @example
  25763. *
  25764. * var users = [
  25765. * { 'user': 'barney', 'age': 36, 'active': false },
  25766. * { 'user': 'fred', 'age': 40, 'active': true },
  25767. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25768. * ];
  25769. *
  25770. * _.partition(users, function(o) { return o.active; });
  25771. * // => objects for [['fred'], ['barney', 'pebbles']]
  25772. *
  25773. * // The `_.matches` iteratee shorthand.
  25774. * _.partition(users, { 'age': 1, 'active': false });
  25775. * // => objects for [['pebbles'], ['barney', 'fred']]
  25776. *
  25777. * // The `_.matchesProperty` iteratee shorthand.
  25778. * _.partition(users, ['active', false]);
  25779. * // => objects for [['barney', 'pebbles'], ['fred']]
  25780. *
  25781. * // The `_.property` iteratee shorthand.
  25782. * _.partition(users, 'active');
  25783. * // => objects for [['fred'], ['barney', 'pebbles']]
  25784. */
  25785. var partition = createAggregator(function(result, value, key) {
  25786. result[key ? 0 : 1].push(value);
  25787. }, function() { return [[], []]; });
  25788. /**
  25789. * Reduces `collection` to a value which is the accumulated result of running
  25790. * each element in `collection` thru `iteratee`, where each successive
  25791. * invocation is supplied the return value of the previous. If `accumulator`
  25792. * is not given, the first element of `collection` is used as the initial
  25793. * value. The iteratee is invoked with four arguments:
  25794. * (accumulator, value, index|key, collection).
  25795. *
  25796. * Many lodash methods are guarded to work as iteratees for methods like
  25797. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25798. *
  25799. * The guarded methods are:
  25800. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25801. * and `sortBy`
  25802. *
  25803. * @static
  25804. * @memberOf _
  25805. * @since 0.1.0
  25806. * @category Collection
  25807. * @param {Array|Object} collection The collection to iterate over.
  25808. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25809. * @param {*} [accumulator] The initial value.
  25810. * @returns {*} Returns the accumulated value.
  25811. * @see _.reduceRight
  25812. * @example
  25813. *
  25814. * _.reduce([1, 2], function(sum, n) {
  25815. * return sum + n;
  25816. * }, 0);
  25817. * // => 3
  25818. *
  25819. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25820. * (result[value] || (result[value] = [])).push(key);
  25821. * return result;
  25822. * }, {});
  25823. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25824. */
  25825. function reduce(collection, iteratee, accumulator) {
  25826. var func = isArray(collection) ? arrayReduce : baseReduce,
  25827. initAccum = arguments.length < 3;
  25828. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25829. }
  25830. /**
  25831. * This method is like `_.reduce` except that it iterates over elements of
  25832. * `collection` from right to left.
  25833. *
  25834. * @static
  25835. * @memberOf _
  25836. * @since 0.1.0
  25837. * @category Collection
  25838. * @param {Array|Object} collection The collection to iterate over.
  25839. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25840. * @param {*} [accumulator] The initial value.
  25841. * @returns {*} Returns the accumulated value.
  25842. * @see _.reduce
  25843. * @example
  25844. *
  25845. * var array = [[0, 1], [2, 3], [4, 5]];
  25846. *
  25847. * _.reduceRight(array, function(flattened, other) {
  25848. * return flattened.concat(other);
  25849. * }, []);
  25850. * // => [4, 5, 2, 3, 0, 1]
  25851. */
  25852. function reduceRight(collection, iteratee, accumulator) {
  25853. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25854. initAccum = arguments.length < 3;
  25855. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25856. }
  25857. /**
  25858. * The opposite of `_.filter`; this method returns the elements of `collection`
  25859. * that `predicate` does **not** return truthy for.
  25860. *
  25861. * @static
  25862. * @memberOf _
  25863. * @since 0.1.0
  25864. * @category Collection
  25865. * @param {Array|Object} collection The collection to iterate over.
  25866. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25867. * @returns {Array} Returns the new filtered array.
  25868. * @see _.filter
  25869. * @example
  25870. *
  25871. * var users = [
  25872. * { 'user': 'barney', 'age': 36, 'active': false },
  25873. * { 'user': 'fred', 'age': 40, 'active': true }
  25874. * ];
  25875. *
  25876. * _.reject(users, function(o) { return !o.active; });
  25877. * // => objects for ['fred']
  25878. *
  25879. * // The `_.matches` iteratee shorthand.
  25880. * _.reject(users, { 'age': 40, 'active': true });
  25881. * // => objects for ['barney']
  25882. *
  25883. * // The `_.matchesProperty` iteratee shorthand.
  25884. * _.reject(users, ['active', false]);
  25885. * // => objects for ['fred']
  25886. *
  25887. * // The `_.property` iteratee shorthand.
  25888. * _.reject(users, 'active');
  25889. * // => objects for ['barney']
  25890. */
  25891. function reject(collection, predicate) {
  25892. var func = isArray(collection) ? arrayFilter : baseFilter;
  25893. return func(collection, negate(getIteratee(predicate, 3)));
  25894. }
  25895. /**
  25896. * Gets a random element from `collection`.
  25897. *
  25898. * @static
  25899. * @memberOf _
  25900. * @since 2.0.0
  25901. * @category Collection
  25902. * @param {Array|Object} collection The collection to sample.
  25903. * @returns {*} Returns the random element.
  25904. * @example
  25905. *
  25906. * _.sample([1, 2, 3, 4]);
  25907. * // => 2
  25908. */
  25909. function sample(collection) {
  25910. var func = isArray(collection) ? arraySample : baseSample;
  25911. return func(collection);
  25912. }
  25913. /**
  25914. * Gets `n` random elements at unique keys from `collection` up to the
  25915. * size of `collection`.
  25916. *
  25917. * @static
  25918. * @memberOf _
  25919. * @since 4.0.0
  25920. * @category Collection
  25921. * @param {Array|Object} collection The collection to sample.
  25922. * @param {number} [n=1] The number of elements to sample.
  25923. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25924. * @returns {Array} Returns the random elements.
  25925. * @example
  25926. *
  25927. * _.sampleSize([1, 2, 3], 2);
  25928. * // => [3, 1]
  25929. *
  25930. * _.sampleSize([1, 2, 3], 4);
  25931. * // => [2, 3, 1]
  25932. */
  25933. function sampleSize(collection, n, guard) {
  25934. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25935. n = 1;
  25936. } else {
  25937. n = toInteger(n);
  25938. }
  25939. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25940. return func(collection, n);
  25941. }
  25942. /**
  25943. * Creates an array of shuffled values, using a version of the
  25944. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25945. *
  25946. * @static
  25947. * @memberOf _
  25948. * @since 0.1.0
  25949. * @category Collection
  25950. * @param {Array|Object} collection The collection to shuffle.
  25951. * @returns {Array} Returns the new shuffled array.
  25952. * @example
  25953. *
  25954. * _.shuffle([1, 2, 3, 4]);
  25955. * // => [4, 1, 3, 2]
  25956. */
  25957. function shuffle(collection) {
  25958. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25959. return func(collection);
  25960. }
  25961. /**
  25962. * Gets the size of `collection` by returning its length for array-like
  25963. * values or the number of own enumerable string keyed properties for objects.
  25964. *
  25965. * @static
  25966. * @memberOf _
  25967. * @since 0.1.0
  25968. * @category Collection
  25969. * @param {Array|Object|string} collection The collection to inspect.
  25970. * @returns {number} Returns the collection size.
  25971. * @example
  25972. *
  25973. * _.size([1, 2, 3]);
  25974. * // => 3
  25975. *
  25976. * _.size({ 'a': 1, 'b': 2 });
  25977. * // => 2
  25978. *
  25979. * _.size('pebbles');
  25980. * // => 7
  25981. */
  25982. function size(collection) {
  25983. if (collection == null) {
  25984. return 0;
  25985. }
  25986. if (isArrayLike(collection)) {
  25987. return isString(collection) ? stringSize(collection) : collection.length;
  25988. }
  25989. var tag = getTag(collection);
  25990. if (tag == mapTag || tag == setTag) {
  25991. return collection.size;
  25992. }
  25993. return baseKeys(collection).length;
  25994. }
  25995. /**
  25996. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25997. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25998. * invoked with three arguments: (value, index|key, collection).
  25999. *
  26000. * @static
  26001. * @memberOf _
  26002. * @since 0.1.0
  26003. * @category Collection
  26004. * @param {Array|Object} collection The collection to iterate over.
  26005. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26006. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26007. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26008. * else `false`.
  26009. * @example
  26010. *
  26011. * _.some([null, 0, 'yes', false], Boolean);
  26012. * // => true
  26013. *
  26014. * var users = [
  26015. * { 'user': 'barney', 'active': true },
  26016. * { 'user': 'fred', 'active': false }
  26017. * ];
  26018. *
  26019. * // The `_.matches` iteratee shorthand.
  26020. * _.some(users, { 'user': 'barney', 'active': false });
  26021. * // => false
  26022. *
  26023. * // The `_.matchesProperty` iteratee shorthand.
  26024. * _.some(users, ['active', false]);
  26025. * // => true
  26026. *
  26027. * // The `_.property` iteratee shorthand.
  26028. * _.some(users, 'active');
  26029. * // => true
  26030. */
  26031. function some(collection, predicate, guard) {
  26032. var func = isArray(collection) ? arraySome : baseSome;
  26033. if (guard && isIterateeCall(collection, predicate, guard)) {
  26034. predicate = undefined;
  26035. }
  26036. return func(collection, getIteratee(predicate, 3));
  26037. }
  26038. /**
  26039. * Creates an array of elements, sorted in ascending order by the results of
  26040. * running each element in a collection thru each iteratee. This method
  26041. * performs a stable sort, that is, it preserves the original sort order of
  26042. * equal elements. The iteratees are invoked with one argument: (value).
  26043. *
  26044. * @static
  26045. * @memberOf _
  26046. * @since 0.1.0
  26047. * @category Collection
  26048. * @param {Array|Object} collection The collection to iterate over.
  26049. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26050. * The iteratees to sort by.
  26051. * @returns {Array} Returns the new sorted array.
  26052. * @example
  26053. *
  26054. * var users = [
  26055. * { 'user': 'fred', 'age': 48 },
  26056. * { 'user': 'barney', 'age': 36 },
  26057. * { 'user': 'fred', 'age': 40 },
  26058. * { 'user': 'barney', 'age': 34 }
  26059. * ];
  26060. *
  26061. * _.sortBy(users, [function(o) { return o.user; }]);
  26062. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26063. *
  26064. * _.sortBy(users, ['user', 'age']);
  26065. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26066. */
  26067. var sortBy = baseRest(function(collection, iteratees) {
  26068. if (collection == null) {
  26069. return [];
  26070. }
  26071. var length = iteratees.length;
  26072. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26073. iteratees = [];
  26074. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26075. iteratees = [iteratees[0]];
  26076. }
  26077. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26078. });
  26079. /*------------------------------------------------------------------------*/
  26080. /**
  26081. * Gets the timestamp of the number of milliseconds that have elapsed since
  26082. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26083. *
  26084. * @static
  26085. * @memberOf _
  26086. * @since 2.4.0
  26087. * @category Date
  26088. * @returns {number} Returns the timestamp.
  26089. * @example
  26090. *
  26091. * _.defer(function(stamp) {
  26092. * console.log(_.now() - stamp);
  26093. * }, _.now());
  26094. * // => Logs the number of milliseconds it took for the deferred invocation.
  26095. */
  26096. var now = ctxNow || function() {
  26097. return root.Date.now();
  26098. };
  26099. /*------------------------------------------------------------------------*/
  26100. /**
  26101. * The opposite of `_.before`; this method creates a function that invokes
  26102. * `func` once it's called `n` or more times.
  26103. *
  26104. * @static
  26105. * @memberOf _
  26106. * @since 0.1.0
  26107. * @category Function
  26108. * @param {number} n The number of calls before `func` is invoked.
  26109. * @param {Function} func The function to restrict.
  26110. * @returns {Function} Returns the new restricted function.
  26111. * @example
  26112. *
  26113. * var saves = ['profile', 'settings'];
  26114. *
  26115. * var done = _.after(saves.length, function() {
  26116. * console.log('done saving!');
  26117. * });
  26118. *
  26119. * _.forEach(saves, function(type) {
  26120. * asyncSave({ 'type': type, 'complete': done });
  26121. * });
  26122. * // => Logs 'done saving!' after the two async saves have completed.
  26123. */
  26124. function after(n, func) {
  26125. if (typeof func != 'function') {
  26126. throw new TypeError(FUNC_ERROR_TEXT);
  26127. }
  26128. n = toInteger(n);
  26129. return function() {
  26130. if (--n < 1) {
  26131. return func.apply(this, arguments);
  26132. }
  26133. };
  26134. }
  26135. /**
  26136. * Creates a function that invokes `func`, with up to `n` arguments,
  26137. * ignoring any additional arguments.
  26138. *
  26139. * @static
  26140. * @memberOf _
  26141. * @since 3.0.0
  26142. * @category Function
  26143. * @param {Function} func The function to cap arguments for.
  26144. * @param {number} [n=func.length] The arity cap.
  26145. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26146. * @returns {Function} Returns the new capped function.
  26147. * @example
  26148. *
  26149. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26150. * // => [6, 8, 10]
  26151. */
  26152. function ary(func, n, guard) {
  26153. n = guard ? undefined : n;
  26154. n = (func && n == null) ? func.length : n;
  26155. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26156. }
  26157. /**
  26158. * Creates a function that invokes `func`, with the `this` binding and arguments
  26159. * of the created function, while it's called less than `n` times. Subsequent
  26160. * calls to the created function return the result of the last `func` invocation.
  26161. *
  26162. * @static
  26163. * @memberOf _
  26164. * @since 3.0.0
  26165. * @category Function
  26166. * @param {number} n The number of calls at which `func` is no longer invoked.
  26167. * @param {Function} func The function to restrict.
  26168. * @returns {Function} Returns the new restricted function.
  26169. * @example
  26170. *
  26171. * jQuery(element).on('click', _.before(5, addContactToList));
  26172. * // => Allows adding up to 4 contacts to the list.
  26173. */
  26174. function before(n, func) {
  26175. var result;
  26176. if (typeof func != 'function') {
  26177. throw new TypeError(FUNC_ERROR_TEXT);
  26178. }
  26179. n = toInteger(n);
  26180. return function() {
  26181. if (--n > 0) {
  26182. result = func.apply(this, arguments);
  26183. }
  26184. if (n <= 1) {
  26185. func = undefined;
  26186. }
  26187. return result;
  26188. };
  26189. }
  26190. /**
  26191. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26192. * and `partials` prepended to the arguments it receives.
  26193. *
  26194. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26195. * may be used as a placeholder for partially applied arguments.
  26196. *
  26197. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26198. * property of bound functions.
  26199. *
  26200. * @static
  26201. * @memberOf _
  26202. * @since 0.1.0
  26203. * @category Function
  26204. * @param {Function} func The function to bind.
  26205. * @param {*} thisArg The `this` binding of `func`.
  26206. * @param {...*} [partials] The arguments to be partially applied.
  26207. * @returns {Function} Returns the new bound function.
  26208. * @example
  26209. *
  26210. * function greet(greeting, punctuation) {
  26211. * return greeting + ' ' + this.user + punctuation;
  26212. * }
  26213. *
  26214. * var object = { 'user': 'fred' };
  26215. *
  26216. * var bound = _.bind(greet, object, 'hi');
  26217. * bound('!');
  26218. * // => 'hi fred!'
  26219. *
  26220. * // Bound with placeholders.
  26221. * var bound = _.bind(greet, object, _, '!');
  26222. * bound('hi');
  26223. * // => 'hi fred!'
  26224. */
  26225. var bind = baseRest(function(func, thisArg, partials) {
  26226. var bitmask = WRAP_BIND_FLAG;
  26227. if (partials.length) {
  26228. var holders = replaceHolders(partials, getHolder(bind));
  26229. bitmask |= WRAP_PARTIAL_FLAG;
  26230. }
  26231. return createWrap(func, bitmask, thisArg, partials, holders);
  26232. });
  26233. /**
  26234. * Creates a function that invokes the method at `object[key]` with `partials`
  26235. * prepended to the arguments it receives.
  26236. *
  26237. * This method differs from `_.bind` by allowing bound functions to reference
  26238. * methods that may be redefined or don't yet exist. See
  26239. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26240. * for more details.
  26241. *
  26242. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26243. * builds, may be used as a placeholder for partially applied arguments.
  26244. *
  26245. * @static
  26246. * @memberOf _
  26247. * @since 0.10.0
  26248. * @category Function
  26249. * @param {Object} object The object to invoke the method on.
  26250. * @param {string} key The key of the method.
  26251. * @param {...*} [partials] The arguments to be partially applied.
  26252. * @returns {Function} Returns the new bound function.
  26253. * @example
  26254. *
  26255. * var object = {
  26256. * 'user': 'fred',
  26257. * 'greet': function(greeting, punctuation) {
  26258. * return greeting + ' ' + this.user + punctuation;
  26259. * }
  26260. * };
  26261. *
  26262. * var bound = _.bindKey(object, 'greet', 'hi');
  26263. * bound('!');
  26264. * // => 'hi fred!'
  26265. *
  26266. * object.greet = function(greeting, punctuation) {
  26267. * return greeting + 'ya ' + this.user + punctuation;
  26268. * };
  26269. *
  26270. * bound('!');
  26271. * // => 'hiya fred!'
  26272. *
  26273. * // Bound with placeholders.
  26274. * var bound = _.bindKey(object, 'greet', _, '!');
  26275. * bound('hi');
  26276. * // => 'hiya fred!'
  26277. */
  26278. var bindKey = baseRest(function(object, key, partials) {
  26279. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26280. if (partials.length) {
  26281. var holders = replaceHolders(partials, getHolder(bindKey));
  26282. bitmask |= WRAP_PARTIAL_FLAG;
  26283. }
  26284. return createWrap(key, bitmask, object, partials, holders);
  26285. });
  26286. /**
  26287. * Creates a function that accepts arguments of `func` and either invokes
  26288. * `func` returning its result, if at least `arity` number of arguments have
  26289. * been provided, or returns a function that accepts the remaining `func`
  26290. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26291. * is not sufficient.
  26292. *
  26293. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26294. * may be used as a placeholder for provided arguments.
  26295. *
  26296. * **Note:** This method doesn't set the "length" property of curried functions.
  26297. *
  26298. * @static
  26299. * @memberOf _
  26300. * @since 2.0.0
  26301. * @category Function
  26302. * @param {Function} func The function to curry.
  26303. * @param {number} [arity=func.length] The arity of `func`.
  26304. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26305. * @returns {Function} Returns the new curried function.
  26306. * @example
  26307. *
  26308. * var abc = function(a, b, c) {
  26309. * return [a, b, c];
  26310. * };
  26311. *
  26312. * var curried = _.curry(abc);
  26313. *
  26314. * curried(1)(2)(3);
  26315. * // => [1, 2, 3]
  26316. *
  26317. * curried(1, 2)(3);
  26318. * // => [1, 2, 3]
  26319. *
  26320. * curried(1, 2, 3);
  26321. * // => [1, 2, 3]
  26322. *
  26323. * // Curried with placeholders.
  26324. * curried(1)(_, 3)(2);
  26325. * // => [1, 2, 3]
  26326. */
  26327. function curry(func, arity, guard) {
  26328. arity = guard ? undefined : arity;
  26329. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26330. result.placeholder = curry.placeholder;
  26331. return result;
  26332. }
  26333. /**
  26334. * This method is like `_.curry` except that arguments are applied to `func`
  26335. * in the manner of `_.partialRight` instead of `_.partial`.
  26336. *
  26337. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26338. * builds, may be used as a placeholder for provided arguments.
  26339. *
  26340. * **Note:** This method doesn't set the "length" property of curried functions.
  26341. *
  26342. * @static
  26343. * @memberOf _
  26344. * @since 3.0.0
  26345. * @category Function
  26346. * @param {Function} func The function to curry.
  26347. * @param {number} [arity=func.length] The arity of `func`.
  26348. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26349. * @returns {Function} Returns the new curried function.
  26350. * @example
  26351. *
  26352. * var abc = function(a, b, c) {
  26353. * return [a, b, c];
  26354. * };
  26355. *
  26356. * var curried = _.curryRight(abc);
  26357. *
  26358. * curried(3)(2)(1);
  26359. * // => [1, 2, 3]
  26360. *
  26361. * curried(2, 3)(1);
  26362. * // => [1, 2, 3]
  26363. *
  26364. * curried(1, 2, 3);
  26365. * // => [1, 2, 3]
  26366. *
  26367. * // Curried with placeholders.
  26368. * curried(3)(1, _)(2);
  26369. * // => [1, 2, 3]
  26370. */
  26371. function curryRight(func, arity, guard) {
  26372. arity = guard ? undefined : arity;
  26373. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26374. result.placeholder = curryRight.placeholder;
  26375. return result;
  26376. }
  26377. /**
  26378. * Creates a debounced function that delays invoking `func` until after `wait`
  26379. * milliseconds have elapsed since the last time the debounced function was
  26380. * invoked. The debounced function comes with a `cancel` method to cancel
  26381. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26382. * Provide `options` to indicate whether `func` should be invoked on the
  26383. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26384. * with the last arguments provided to the debounced function. Subsequent
  26385. * calls to the debounced function return the result of the last `func`
  26386. * invocation.
  26387. *
  26388. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26389. * invoked on the trailing edge of the timeout only if the debounced function
  26390. * is invoked more than once during the `wait` timeout.
  26391. *
  26392. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26393. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26394. *
  26395. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26396. * for details over the differences between `_.debounce` and `_.throttle`.
  26397. *
  26398. * @static
  26399. * @memberOf _
  26400. * @since 0.1.0
  26401. * @category Function
  26402. * @param {Function} func The function to debounce.
  26403. * @param {number} [wait=0] The number of milliseconds to delay.
  26404. * @param {Object} [options={}] The options object.
  26405. * @param {boolean} [options.leading=false]
  26406. * Specify invoking on the leading edge of the timeout.
  26407. * @param {number} [options.maxWait]
  26408. * The maximum time `func` is allowed to be delayed before it's invoked.
  26409. * @param {boolean} [options.trailing=true]
  26410. * Specify invoking on the trailing edge of the timeout.
  26411. * @returns {Function} Returns the new debounced function.
  26412. * @example
  26413. *
  26414. * // Avoid costly calculations while the window size is in flux.
  26415. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26416. *
  26417. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26418. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26419. * 'leading': true,
  26420. * 'trailing': false
  26421. * }));
  26422. *
  26423. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26424. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26425. * var source = new EventSource('/stream');
  26426. * jQuery(source).on('message', debounced);
  26427. *
  26428. * // Cancel the trailing debounced invocation.
  26429. * jQuery(window).on('popstate', debounced.cancel);
  26430. */
  26431. function debounce(func, wait, options) {
  26432. var lastArgs,
  26433. lastThis,
  26434. maxWait,
  26435. result,
  26436. timerId,
  26437. lastCallTime,
  26438. lastInvokeTime = 0,
  26439. leading = false,
  26440. maxing = false,
  26441. trailing = true;
  26442. if (typeof func != 'function') {
  26443. throw new TypeError(FUNC_ERROR_TEXT);
  26444. }
  26445. wait = toNumber(wait) || 0;
  26446. if (isObject(options)) {
  26447. leading = !!options.leading;
  26448. maxing = 'maxWait' in options;
  26449. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26450. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26451. }
  26452. function invokeFunc(time) {
  26453. var args = lastArgs,
  26454. thisArg = lastThis;
  26455. lastArgs = lastThis = undefined;
  26456. lastInvokeTime = time;
  26457. result = func.apply(thisArg, args);
  26458. return result;
  26459. }
  26460. function leadingEdge(time) {
  26461. // Reset any `maxWait` timer.
  26462. lastInvokeTime = time;
  26463. // Start the timer for the trailing edge.
  26464. timerId = setTimeout(timerExpired, wait);
  26465. // Invoke the leading edge.
  26466. return leading ? invokeFunc(time) : result;
  26467. }
  26468. function remainingWait(time) {
  26469. var timeSinceLastCall = time - lastCallTime,
  26470. timeSinceLastInvoke = time - lastInvokeTime,
  26471. timeWaiting = wait - timeSinceLastCall;
  26472. return maxing
  26473. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26474. : timeWaiting;
  26475. }
  26476. function shouldInvoke(time) {
  26477. var timeSinceLastCall = time - lastCallTime,
  26478. timeSinceLastInvoke = time - lastInvokeTime;
  26479. // Either this is the first call, activity has stopped and we're at the
  26480. // trailing edge, the system time has gone backwards and we're treating
  26481. // it as the trailing edge, or we've hit the `maxWait` limit.
  26482. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26483. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26484. }
  26485. function timerExpired() {
  26486. var time = now();
  26487. if (shouldInvoke(time)) {
  26488. return trailingEdge(time);
  26489. }
  26490. // Restart the timer.
  26491. timerId = setTimeout(timerExpired, remainingWait(time));
  26492. }
  26493. function trailingEdge(time) {
  26494. timerId = undefined;
  26495. // Only invoke if we have `lastArgs` which means `func` has been
  26496. // debounced at least once.
  26497. if (trailing && lastArgs) {
  26498. return invokeFunc(time);
  26499. }
  26500. lastArgs = lastThis = undefined;
  26501. return result;
  26502. }
  26503. function cancel() {
  26504. if (timerId !== undefined) {
  26505. clearTimeout(timerId);
  26506. }
  26507. lastInvokeTime = 0;
  26508. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26509. }
  26510. function flush() {
  26511. return timerId === undefined ? result : trailingEdge(now());
  26512. }
  26513. function debounced() {
  26514. var time = now(),
  26515. isInvoking = shouldInvoke(time);
  26516. lastArgs = arguments;
  26517. lastThis = this;
  26518. lastCallTime = time;
  26519. if (isInvoking) {
  26520. if (timerId === undefined) {
  26521. return leadingEdge(lastCallTime);
  26522. }
  26523. if (maxing) {
  26524. // Handle invocations in a tight loop.
  26525. clearTimeout(timerId);
  26526. timerId = setTimeout(timerExpired, wait);
  26527. return invokeFunc(lastCallTime);
  26528. }
  26529. }
  26530. if (timerId === undefined) {
  26531. timerId = setTimeout(timerExpired, wait);
  26532. }
  26533. return result;
  26534. }
  26535. debounced.cancel = cancel;
  26536. debounced.flush = flush;
  26537. return debounced;
  26538. }
  26539. /**
  26540. * Defers invoking the `func` until the current call stack has cleared. Any
  26541. * additional arguments are provided to `func` when it's invoked.
  26542. *
  26543. * @static
  26544. * @memberOf _
  26545. * @since 0.1.0
  26546. * @category Function
  26547. * @param {Function} func The function to defer.
  26548. * @param {...*} [args] The arguments to invoke `func` with.
  26549. * @returns {number} Returns the timer id.
  26550. * @example
  26551. *
  26552. * _.defer(function(text) {
  26553. * console.log(text);
  26554. * }, 'deferred');
  26555. * // => Logs 'deferred' after one millisecond.
  26556. */
  26557. var defer = baseRest(function(func, args) {
  26558. return baseDelay(func, 1, args);
  26559. });
  26560. /**
  26561. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26562. * provided to `func` when it's invoked.
  26563. *
  26564. * @static
  26565. * @memberOf _
  26566. * @since 0.1.0
  26567. * @category Function
  26568. * @param {Function} func The function to delay.
  26569. * @param {number} wait The number of milliseconds to delay invocation.
  26570. * @param {...*} [args] The arguments to invoke `func` with.
  26571. * @returns {number} Returns the timer id.
  26572. * @example
  26573. *
  26574. * _.delay(function(text) {
  26575. * console.log(text);
  26576. * }, 1000, 'later');
  26577. * // => Logs 'later' after one second.
  26578. */
  26579. var delay = baseRest(function(func, wait, args) {
  26580. return baseDelay(func, toNumber(wait) || 0, args);
  26581. });
  26582. /**
  26583. * Creates a function that invokes `func` with arguments reversed.
  26584. *
  26585. * @static
  26586. * @memberOf _
  26587. * @since 4.0.0
  26588. * @category Function
  26589. * @param {Function} func The function to flip arguments for.
  26590. * @returns {Function} Returns the new flipped function.
  26591. * @example
  26592. *
  26593. * var flipped = _.flip(function() {
  26594. * return _.toArray(arguments);
  26595. * });
  26596. *
  26597. * flipped('a', 'b', 'c', 'd');
  26598. * // => ['d', 'c', 'b', 'a']
  26599. */
  26600. function flip(func) {
  26601. return createWrap(func, WRAP_FLIP_FLAG);
  26602. }
  26603. /**
  26604. * Creates a function that memoizes the result of `func`. If `resolver` is
  26605. * provided, it determines the cache key for storing the result based on the
  26606. * arguments provided to the memoized function. By default, the first argument
  26607. * provided to the memoized function is used as the map cache key. The `func`
  26608. * is invoked with the `this` binding of the memoized function.
  26609. *
  26610. * **Note:** The cache is exposed as the `cache` property on the memoized
  26611. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26612. * constructor with one whose instances implement the
  26613. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26614. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26615. *
  26616. * @static
  26617. * @memberOf _
  26618. * @since 0.1.0
  26619. * @category Function
  26620. * @param {Function} func The function to have its output memoized.
  26621. * @param {Function} [resolver] The function to resolve the cache key.
  26622. * @returns {Function} Returns the new memoized function.
  26623. * @example
  26624. *
  26625. * var object = { 'a': 1, 'b': 2 };
  26626. * var other = { 'c': 3, 'd': 4 };
  26627. *
  26628. * var values = _.memoize(_.values);
  26629. * values(object);
  26630. * // => [1, 2]
  26631. *
  26632. * values(other);
  26633. * // => [3, 4]
  26634. *
  26635. * object.a = 2;
  26636. * values(object);
  26637. * // => [1, 2]
  26638. *
  26639. * // Modify the result cache.
  26640. * values.cache.set(object, ['a', 'b']);
  26641. * values(object);
  26642. * // => ['a', 'b']
  26643. *
  26644. * // Replace `_.memoize.Cache`.
  26645. * _.memoize.Cache = WeakMap;
  26646. */
  26647. function memoize(func, resolver) {
  26648. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26649. throw new TypeError(FUNC_ERROR_TEXT);
  26650. }
  26651. var memoized = function() {
  26652. var args = arguments,
  26653. key = resolver ? resolver.apply(this, args) : args[0],
  26654. cache = memoized.cache;
  26655. if (cache.has(key)) {
  26656. return cache.get(key);
  26657. }
  26658. var result = func.apply(this, args);
  26659. memoized.cache = cache.set(key, result) || cache;
  26660. return result;
  26661. };
  26662. memoized.cache = new (memoize.Cache || MapCache);
  26663. return memoized;
  26664. }
  26665. // Expose `MapCache`.
  26666. memoize.Cache = MapCache;
  26667. /**
  26668. * Creates a function that negates the result of the predicate `func`. The
  26669. * `func` predicate is invoked with the `this` binding and arguments of the
  26670. * created function.
  26671. *
  26672. * @static
  26673. * @memberOf _
  26674. * @since 3.0.0
  26675. * @category Function
  26676. * @param {Function} predicate The predicate to negate.
  26677. * @returns {Function} Returns the new negated function.
  26678. * @example
  26679. *
  26680. * function isEven(n) {
  26681. * return n % 2 == 0;
  26682. * }
  26683. *
  26684. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26685. * // => [1, 3, 5]
  26686. */
  26687. function negate(predicate) {
  26688. if (typeof predicate != 'function') {
  26689. throw new TypeError(FUNC_ERROR_TEXT);
  26690. }
  26691. return function() {
  26692. var args = arguments;
  26693. switch (args.length) {
  26694. case 0: return !predicate.call(this);
  26695. case 1: return !predicate.call(this, args[0]);
  26696. case 2: return !predicate.call(this, args[0], args[1]);
  26697. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26698. }
  26699. return !predicate.apply(this, args);
  26700. };
  26701. }
  26702. /**
  26703. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26704. * to the function return the value of the first invocation. The `func` is
  26705. * invoked with the `this` binding and arguments of the created function.
  26706. *
  26707. * @static
  26708. * @memberOf _
  26709. * @since 0.1.0
  26710. * @category Function
  26711. * @param {Function} func The function to restrict.
  26712. * @returns {Function} Returns the new restricted function.
  26713. * @example
  26714. *
  26715. * var initialize = _.once(createApplication);
  26716. * initialize();
  26717. * initialize();
  26718. * // => `createApplication` is invoked once
  26719. */
  26720. function once(func) {
  26721. return before(2, func);
  26722. }
  26723. /**
  26724. * Creates a function that invokes `func` with its arguments transformed.
  26725. *
  26726. * @static
  26727. * @since 4.0.0
  26728. * @memberOf _
  26729. * @category Function
  26730. * @param {Function} func The function to wrap.
  26731. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26732. * The argument transforms.
  26733. * @returns {Function} Returns the new function.
  26734. * @example
  26735. *
  26736. * function doubled(n) {
  26737. * return n * 2;
  26738. * }
  26739. *
  26740. * function square(n) {
  26741. * return n * n;
  26742. * }
  26743. *
  26744. * var func = _.overArgs(function(x, y) {
  26745. * return [x, y];
  26746. * }, [square, doubled]);
  26747. *
  26748. * func(9, 3);
  26749. * // => [81, 6]
  26750. *
  26751. * func(10, 5);
  26752. * // => [100, 10]
  26753. */
  26754. var overArgs = castRest(function(func, transforms) {
  26755. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26756. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26757. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26758. var funcsLength = transforms.length;
  26759. return baseRest(function(args) {
  26760. var index = -1,
  26761. length = nativeMin(args.length, funcsLength);
  26762. while (++index < length) {
  26763. args[index] = transforms[index].call(this, args[index]);
  26764. }
  26765. return apply(func, this, args);
  26766. });
  26767. });
  26768. /**
  26769. * Creates a function that invokes `func` with `partials` prepended to the
  26770. * arguments it receives. This method is like `_.bind` except it does **not**
  26771. * alter the `this` binding.
  26772. *
  26773. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26774. * builds, may be used as a placeholder for partially applied arguments.
  26775. *
  26776. * **Note:** This method doesn't set the "length" property of partially
  26777. * applied functions.
  26778. *
  26779. * @static
  26780. * @memberOf _
  26781. * @since 0.2.0
  26782. * @category Function
  26783. * @param {Function} func The function to partially apply arguments to.
  26784. * @param {...*} [partials] The arguments to be partially applied.
  26785. * @returns {Function} Returns the new partially applied function.
  26786. * @example
  26787. *
  26788. * function greet(greeting, name) {
  26789. * return greeting + ' ' + name;
  26790. * }
  26791. *
  26792. * var sayHelloTo = _.partial(greet, 'hello');
  26793. * sayHelloTo('fred');
  26794. * // => 'hello fred'
  26795. *
  26796. * // Partially applied with placeholders.
  26797. * var greetFred = _.partial(greet, _, 'fred');
  26798. * greetFred('hi');
  26799. * // => 'hi fred'
  26800. */
  26801. var partial = baseRest(function(func, partials) {
  26802. var holders = replaceHolders(partials, getHolder(partial));
  26803. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26804. });
  26805. /**
  26806. * This method is like `_.partial` except that partially applied arguments
  26807. * are appended to the arguments it receives.
  26808. *
  26809. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26810. * builds, may be used as a placeholder for partially applied arguments.
  26811. *
  26812. * **Note:** This method doesn't set the "length" property of partially
  26813. * applied functions.
  26814. *
  26815. * @static
  26816. * @memberOf _
  26817. * @since 1.0.0
  26818. * @category Function
  26819. * @param {Function} func The function to partially apply arguments to.
  26820. * @param {...*} [partials] The arguments to be partially applied.
  26821. * @returns {Function} Returns the new partially applied function.
  26822. * @example
  26823. *
  26824. * function greet(greeting, name) {
  26825. * return greeting + ' ' + name;
  26826. * }
  26827. *
  26828. * var greetFred = _.partialRight(greet, 'fred');
  26829. * greetFred('hi');
  26830. * // => 'hi fred'
  26831. *
  26832. * // Partially applied with placeholders.
  26833. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26834. * sayHelloTo('fred');
  26835. * // => 'hello fred'
  26836. */
  26837. var partialRight = baseRest(function(func, partials) {
  26838. var holders = replaceHolders(partials, getHolder(partialRight));
  26839. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26840. });
  26841. /**
  26842. * Creates a function that invokes `func` with arguments arranged according
  26843. * to the specified `indexes` where the argument value at the first index is
  26844. * provided as the first argument, the argument value at the second index is
  26845. * provided as the second argument, and so on.
  26846. *
  26847. * @static
  26848. * @memberOf _
  26849. * @since 3.0.0
  26850. * @category Function
  26851. * @param {Function} func The function to rearrange arguments for.
  26852. * @param {...(number|number[])} indexes The arranged argument indexes.
  26853. * @returns {Function} Returns the new function.
  26854. * @example
  26855. *
  26856. * var rearged = _.rearg(function(a, b, c) {
  26857. * return [a, b, c];
  26858. * }, [2, 0, 1]);
  26859. *
  26860. * rearged('b', 'c', 'a')
  26861. * // => ['a', 'b', 'c']
  26862. */
  26863. var rearg = flatRest(function(func, indexes) {
  26864. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26865. });
  26866. /**
  26867. * Creates a function that invokes `func` with the `this` binding of the
  26868. * created function and arguments from `start` and beyond provided as
  26869. * an array.
  26870. *
  26871. * **Note:** This method is based on the
  26872. * [rest parameter](https://mdn.io/rest_parameters).
  26873. *
  26874. * @static
  26875. * @memberOf _
  26876. * @since 4.0.0
  26877. * @category Function
  26878. * @param {Function} func The function to apply a rest parameter to.
  26879. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26880. * @returns {Function} Returns the new function.
  26881. * @example
  26882. *
  26883. * var say = _.rest(function(what, names) {
  26884. * return what + ' ' + _.initial(names).join(', ') +
  26885. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26886. * });
  26887. *
  26888. * say('hello', 'fred', 'barney', 'pebbles');
  26889. * // => 'hello fred, barney, & pebbles'
  26890. */
  26891. function rest(func, start) {
  26892. if (typeof func != 'function') {
  26893. throw new TypeError(FUNC_ERROR_TEXT);
  26894. }
  26895. start = start === undefined ? start : toInteger(start);
  26896. return baseRest(func, start);
  26897. }
  26898. /**
  26899. * Creates a function that invokes `func` with the `this` binding of the
  26900. * create function and an array of arguments much like
  26901. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26902. *
  26903. * **Note:** This method is based on the
  26904. * [spread operator](https://mdn.io/spread_operator).
  26905. *
  26906. * @static
  26907. * @memberOf _
  26908. * @since 3.2.0
  26909. * @category Function
  26910. * @param {Function} func The function to spread arguments over.
  26911. * @param {number} [start=0] The start position of the spread.
  26912. * @returns {Function} Returns the new function.
  26913. * @example
  26914. *
  26915. * var say = _.spread(function(who, what) {
  26916. * return who + ' says ' + what;
  26917. * });
  26918. *
  26919. * say(['fred', 'hello']);
  26920. * // => 'fred says hello'
  26921. *
  26922. * var numbers = Promise.all([
  26923. * Promise.resolve(40),
  26924. * Promise.resolve(36)
  26925. * ]);
  26926. *
  26927. * numbers.then(_.spread(function(x, y) {
  26928. * return x + y;
  26929. * }));
  26930. * // => a Promise of 76
  26931. */
  26932. function spread(func, start) {
  26933. if (typeof func != 'function') {
  26934. throw new TypeError(FUNC_ERROR_TEXT);
  26935. }
  26936. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26937. return baseRest(function(args) {
  26938. var array = args[start],
  26939. otherArgs = castSlice(args, 0, start);
  26940. if (array) {
  26941. arrayPush(otherArgs, array);
  26942. }
  26943. return apply(func, this, otherArgs);
  26944. });
  26945. }
  26946. /**
  26947. * Creates a throttled function that only invokes `func` at most once per
  26948. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26949. * method to cancel delayed `func` invocations and a `flush` method to
  26950. * immediately invoke them. Provide `options` to indicate whether `func`
  26951. * should be invoked on the leading and/or trailing edge of the `wait`
  26952. * timeout. The `func` is invoked with the last arguments provided to the
  26953. * throttled function. Subsequent calls to the throttled function return the
  26954. * result of the last `func` invocation.
  26955. *
  26956. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26957. * invoked on the trailing edge of the timeout only if the throttled function
  26958. * is invoked more than once during the `wait` timeout.
  26959. *
  26960. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26961. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26962. *
  26963. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26964. * for details over the differences between `_.throttle` and `_.debounce`.
  26965. *
  26966. * @static
  26967. * @memberOf _
  26968. * @since 0.1.0
  26969. * @category Function
  26970. * @param {Function} func The function to throttle.
  26971. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26972. * @param {Object} [options={}] The options object.
  26973. * @param {boolean} [options.leading=true]
  26974. * Specify invoking on the leading edge of the timeout.
  26975. * @param {boolean} [options.trailing=true]
  26976. * Specify invoking on the trailing edge of the timeout.
  26977. * @returns {Function} Returns the new throttled function.
  26978. * @example
  26979. *
  26980. * // Avoid excessively updating the position while scrolling.
  26981. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26982. *
  26983. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26984. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26985. * jQuery(element).on('click', throttled);
  26986. *
  26987. * // Cancel the trailing throttled invocation.
  26988. * jQuery(window).on('popstate', throttled.cancel);
  26989. */
  26990. function throttle(func, wait, options) {
  26991. var leading = true,
  26992. trailing = true;
  26993. if (typeof func != 'function') {
  26994. throw new TypeError(FUNC_ERROR_TEXT);
  26995. }
  26996. if (isObject(options)) {
  26997. leading = 'leading' in options ? !!options.leading : leading;
  26998. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26999. }
  27000. return debounce(func, wait, {
  27001. 'leading': leading,
  27002. 'maxWait': wait,
  27003. 'trailing': trailing
  27004. });
  27005. }
  27006. /**
  27007. * Creates a function that accepts up to one argument, ignoring any
  27008. * additional arguments.
  27009. *
  27010. * @static
  27011. * @memberOf _
  27012. * @since 4.0.0
  27013. * @category Function
  27014. * @param {Function} func The function to cap arguments for.
  27015. * @returns {Function} Returns the new capped function.
  27016. * @example
  27017. *
  27018. * _.map(['6', '8', '10'], _.unary(parseInt));
  27019. * // => [6, 8, 10]
  27020. */
  27021. function unary(func) {
  27022. return ary(func, 1);
  27023. }
  27024. /**
  27025. * Creates a function that provides `value` to `wrapper` as its first
  27026. * argument. Any additional arguments provided to the function are appended
  27027. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27028. * binding of the created function.
  27029. *
  27030. * @static
  27031. * @memberOf _
  27032. * @since 0.1.0
  27033. * @category Function
  27034. * @param {*} value The value to wrap.
  27035. * @param {Function} [wrapper=identity] The wrapper function.
  27036. * @returns {Function} Returns the new function.
  27037. * @example
  27038. *
  27039. * var p = _.wrap(_.escape, function(func, text) {
  27040. * return '<p>' + func(text) + '</p>';
  27041. * });
  27042. *
  27043. * p('fred, barney, & pebbles');
  27044. * // => '<p>fred, barney, &amp; pebbles</p>'
  27045. */
  27046. function wrap(value, wrapper) {
  27047. return partial(castFunction(wrapper), value);
  27048. }
  27049. /*------------------------------------------------------------------------*/
  27050. /**
  27051. * Casts `value` as an array if it's not one.
  27052. *
  27053. * @static
  27054. * @memberOf _
  27055. * @since 4.4.0
  27056. * @category Lang
  27057. * @param {*} value The value to inspect.
  27058. * @returns {Array} Returns the cast array.
  27059. * @example
  27060. *
  27061. * _.castArray(1);
  27062. * // => [1]
  27063. *
  27064. * _.castArray({ 'a': 1 });
  27065. * // => [{ 'a': 1 }]
  27066. *
  27067. * _.castArray('abc');
  27068. * // => ['abc']
  27069. *
  27070. * _.castArray(null);
  27071. * // => [null]
  27072. *
  27073. * _.castArray(undefined);
  27074. * // => [undefined]
  27075. *
  27076. * _.castArray();
  27077. * // => []
  27078. *
  27079. * var array = [1, 2, 3];
  27080. * console.log(_.castArray(array) === array);
  27081. * // => true
  27082. */
  27083. function castArray() {
  27084. if (!arguments.length) {
  27085. return [];
  27086. }
  27087. var value = arguments[0];
  27088. return isArray(value) ? value : [value];
  27089. }
  27090. /**
  27091. * Creates a shallow clone of `value`.
  27092. *
  27093. * **Note:** This method is loosely based on the
  27094. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27095. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27096. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27097. * arrays. The own enumerable properties of `arguments` objects are cloned
  27098. * as plain objects. An empty object is returned for uncloneable values such
  27099. * as error objects, functions, DOM nodes, and WeakMaps.
  27100. *
  27101. * @static
  27102. * @memberOf _
  27103. * @since 0.1.0
  27104. * @category Lang
  27105. * @param {*} value The value to clone.
  27106. * @returns {*} Returns the cloned value.
  27107. * @see _.cloneDeep
  27108. * @example
  27109. *
  27110. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27111. *
  27112. * var shallow = _.clone(objects);
  27113. * console.log(shallow[0] === objects[0]);
  27114. * // => true
  27115. */
  27116. function clone(value) {
  27117. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27118. }
  27119. /**
  27120. * This method is like `_.clone` except that it accepts `customizer` which
  27121. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27122. * cloning is handled by the method instead. The `customizer` is invoked with
  27123. * up to four arguments; (value [, index|key, object, stack]).
  27124. *
  27125. * @static
  27126. * @memberOf _
  27127. * @since 4.0.0
  27128. * @category Lang
  27129. * @param {*} value The value to clone.
  27130. * @param {Function} [customizer] The function to customize cloning.
  27131. * @returns {*} Returns the cloned value.
  27132. * @see _.cloneDeepWith
  27133. * @example
  27134. *
  27135. * function customizer(value) {
  27136. * if (_.isElement(value)) {
  27137. * return value.cloneNode(false);
  27138. * }
  27139. * }
  27140. *
  27141. * var el = _.cloneWith(document.body, customizer);
  27142. *
  27143. * console.log(el === document.body);
  27144. * // => false
  27145. * console.log(el.nodeName);
  27146. * // => 'BODY'
  27147. * console.log(el.childNodes.length);
  27148. * // => 0
  27149. */
  27150. function cloneWith(value, customizer) {
  27151. customizer = typeof customizer == 'function' ? customizer : undefined;
  27152. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27153. }
  27154. /**
  27155. * This method is like `_.clone` except that it recursively clones `value`.
  27156. *
  27157. * @static
  27158. * @memberOf _
  27159. * @since 1.0.0
  27160. * @category Lang
  27161. * @param {*} value The value to recursively clone.
  27162. * @returns {*} Returns the deep cloned value.
  27163. * @see _.clone
  27164. * @example
  27165. *
  27166. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27167. *
  27168. * var deep = _.cloneDeep(objects);
  27169. * console.log(deep[0] === objects[0]);
  27170. * // => false
  27171. */
  27172. function cloneDeep(value) {
  27173. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27174. }
  27175. /**
  27176. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27177. *
  27178. * @static
  27179. * @memberOf _
  27180. * @since 4.0.0
  27181. * @category Lang
  27182. * @param {*} value The value to recursively clone.
  27183. * @param {Function} [customizer] The function to customize cloning.
  27184. * @returns {*} Returns the deep cloned value.
  27185. * @see _.cloneWith
  27186. * @example
  27187. *
  27188. * function customizer(value) {
  27189. * if (_.isElement(value)) {
  27190. * return value.cloneNode(true);
  27191. * }
  27192. * }
  27193. *
  27194. * var el = _.cloneDeepWith(document.body, customizer);
  27195. *
  27196. * console.log(el === document.body);
  27197. * // => false
  27198. * console.log(el.nodeName);
  27199. * // => 'BODY'
  27200. * console.log(el.childNodes.length);
  27201. * // => 20
  27202. */
  27203. function cloneDeepWith(value, customizer) {
  27204. customizer = typeof customizer == 'function' ? customizer : undefined;
  27205. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27206. }
  27207. /**
  27208. * Checks if `object` conforms to `source` by invoking the predicate
  27209. * properties of `source` with the corresponding property values of `object`.
  27210. *
  27211. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27212. * partially applied.
  27213. *
  27214. * @static
  27215. * @memberOf _
  27216. * @since 4.14.0
  27217. * @category Lang
  27218. * @param {Object} object The object to inspect.
  27219. * @param {Object} source The object of property predicates to conform to.
  27220. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27221. * @example
  27222. *
  27223. * var object = { 'a': 1, 'b': 2 };
  27224. *
  27225. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27226. * // => true
  27227. *
  27228. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27229. * // => false
  27230. */
  27231. function conformsTo(object, source) {
  27232. return source == null || baseConformsTo(object, source, keys(source));
  27233. }
  27234. /**
  27235. * Performs a
  27236. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27237. * comparison between two values to determine if they are equivalent.
  27238. *
  27239. * @static
  27240. * @memberOf _
  27241. * @since 4.0.0
  27242. * @category Lang
  27243. * @param {*} value The value to compare.
  27244. * @param {*} other The other value to compare.
  27245. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27246. * @example
  27247. *
  27248. * var object = { 'a': 1 };
  27249. * var other = { 'a': 1 };
  27250. *
  27251. * _.eq(object, object);
  27252. * // => true
  27253. *
  27254. * _.eq(object, other);
  27255. * // => false
  27256. *
  27257. * _.eq('a', 'a');
  27258. * // => true
  27259. *
  27260. * _.eq('a', Object('a'));
  27261. * // => false
  27262. *
  27263. * _.eq(NaN, NaN);
  27264. * // => true
  27265. */
  27266. function eq(value, other) {
  27267. return value === other || (value !== value && other !== other);
  27268. }
  27269. /**
  27270. * Checks if `value` is greater than `other`.
  27271. *
  27272. * @static
  27273. * @memberOf _
  27274. * @since 3.9.0
  27275. * @category Lang
  27276. * @param {*} value The value to compare.
  27277. * @param {*} other The other value to compare.
  27278. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27279. * else `false`.
  27280. * @see _.lt
  27281. * @example
  27282. *
  27283. * _.gt(3, 1);
  27284. * // => true
  27285. *
  27286. * _.gt(3, 3);
  27287. * // => false
  27288. *
  27289. * _.gt(1, 3);
  27290. * // => false
  27291. */
  27292. var gt = createRelationalOperation(baseGt);
  27293. /**
  27294. * Checks if `value` is greater than or equal to `other`.
  27295. *
  27296. * @static
  27297. * @memberOf _
  27298. * @since 3.9.0
  27299. * @category Lang
  27300. * @param {*} value The value to compare.
  27301. * @param {*} other The other value to compare.
  27302. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27303. * `other`, else `false`.
  27304. * @see _.lte
  27305. * @example
  27306. *
  27307. * _.gte(3, 1);
  27308. * // => true
  27309. *
  27310. * _.gte(3, 3);
  27311. * // => true
  27312. *
  27313. * _.gte(1, 3);
  27314. * // => false
  27315. */
  27316. var gte = createRelationalOperation(function(value, other) {
  27317. return value >= other;
  27318. });
  27319. /**
  27320. * Checks if `value` is likely an `arguments` object.
  27321. *
  27322. * @static
  27323. * @memberOf _
  27324. * @since 0.1.0
  27325. * @category Lang
  27326. * @param {*} value The value to check.
  27327. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27328. * else `false`.
  27329. * @example
  27330. *
  27331. * _.isArguments(function() { return arguments; }());
  27332. * // => true
  27333. *
  27334. * _.isArguments([1, 2, 3]);
  27335. * // => false
  27336. */
  27337. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27338. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27339. !propertyIsEnumerable.call(value, 'callee');
  27340. };
  27341. /**
  27342. * Checks if `value` is classified as an `Array` object.
  27343. *
  27344. * @static
  27345. * @memberOf _
  27346. * @since 0.1.0
  27347. * @category Lang
  27348. * @param {*} value The value to check.
  27349. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27350. * @example
  27351. *
  27352. * _.isArray([1, 2, 3]);
  27353. * // => true
  27354. *
  27355. * _.isArray(document.body.children);
  27356. * // => false
  27357. *
  27358. * _.isArray('abc');
  27359. * // => false
  27360. *
  27361. * _.isArray(_.noop);
  27362. * // => false
  27363. */
  27364. var isArray = Array.isArray;
  27365. /**
  27366. * Checks if `value` is classified as an `ArrayBuffer` object.
  27367. *
  27368. * @static
  27369. * @memberOf _
  27370. * @since 4.3.0
  27371. * @category Lang
  27372. * @param {*} value The value to check.
  27373. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27374. * @example
  27375. *
  27376. * _.isArrayBuffer(new ArrayBuffer(2));
  27377. * // => true
  27378. *
  27379. * _.isArrayBuffer(new Array(2));
  27380. * // => false
  27381. */
  27382. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27383. /**
  27384. * Checks if `value` is array-like. A value is considered array-like if it's
  27385. * not a function and has a `value.length` that's an integer greater than or
  27386. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27387. *
  27388. * @static
  27389. * @memberOf _
  27390. * @since 4.0.0
  27391. * @category Lang
  27392. * @param {*} value The value to check.
  27393. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27394. * @example
  27395. *
  27396. * _.isArrayLike([1, 2, 3]);
  27397. * // => true
  27398. *
  27399. * _.isArrayLike(document.body.children);
  27400. * // => true
  27401. *
  27402. * _.isArrayLike('abc');
  27403. * // => true
  27404. *
  27405. * _.isArrayLike(_.noop);
  27406. * // => false
  27407. */
  27408. function isArrayLike(value) {
  27409. return value != null && isLength(value.length) && !isFunction(value);
  27410. }
  27411. /**
  27412. * This method is like `_.isArrayLike` except that it also checks if `value`
  27413. * is an object.
  27414. *
  27415. * @static
  27416. * @memberOf _
  27417. * @since 4.0.0
  27418. * @category Lang
  27419. * @param {*} value The value to check.
  27420. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27421. * else `false`.
  27422. * @example
  27423. *
  27424. * _.isArrayLikeObject([1, 2, 3]);
  27425. * // => true
  27426. *
  27427. * _.isArrayLikeObject(document.body.children);
  27428. * // => true
  27429. *
  27430. * _.isArrayLikeObject('abc');
  27431. * // => false
  27432. *
  27433. * _.isArrayLikeObject(_.noop);
  27434. * // => false
  27435. */
  27436. function isArrayLikeObject(value) {
  27437. return isObjectLike(value) && isArrayLike(value);
  27438. }
  27439. /**
  27440. * Checks if `value` is classified as a boolean primitive or object.
  27441. *
  27442. * @static
  27443. * @memberOf _
  27444. * @since 0.1.0
  27445. * @category Lang
  27446. * @param {*} value The value to check.
  27447. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27448. * @example
  27449. *
  27450. * _.isBoolean(false);
  27451. * // => true
  27452. *
  27453. * _.isBoolean(null);
  27454. * // => false
  27455. */
  27456. function isBoolean(value) {
  27457. return value === true || value === false ||
  27458. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27459. }
  27460. /**
  27461. * Checks if `value` is a buffer.
  27462. *
  27463. * @static
  27464. * @memberOf _
  27465. * @since 4.3.0
  27466. * @category Lang
  27467. * @param {*} value The value to check.
  27468. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27469. * @example
  27470. *
  27471. * _.isBuffer(new Buffer(2));
  27472. * // => true
  27473. *
  27474. * _.isBuffer(new Uint8Array(2));
  27475. * // => false
  27476. */
  27477. var isBuffer = nativeIsBuffer || stubFalse;
  27478. /**
  27479. * Checks if `value` is classified as a `Date` object.
  27480. *
  27481. * @static
  27482. * @memberOf _
  27483. * @since 0.1.0
  27484. * @category Lang
  27485. * @param {*} value The value to check.
  27486. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27487. * @example
  27488. *
  27489. * _.isDate(new Date);
  27490. * // => true
  27491. *
  27492. * _.isDate('Mon April 23 2012');
  27493. * // => false
  27494. */
  27495. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27496. /**
  27497. * Checks if `value` is likely a DOM element.
  27498. *
  27499. * @static
  27500. * @memberOf _
  27501. * @since 0.1.0
  27502. * @category Lang
  27503. * @param {*} value The value to check.
  27504. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27505. * @example
  27506. *
  27507. * _.isElement(document.body);
  27508. * // => true
  27509. *
  27510. * _.isElement('<body>');
  27511. * // => false
  27512. */
  27513. function isElement(value) {
  27514. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27515. }
  27516. /**
  27517. * Checks if `value` is an empty object, collection, map, or set.
  27518. *
  27519. * Objects are considered empty if they have no own enumerable string keyed
  27520. * properties.
  27521. *
  27522. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27523. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27524. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27525. *
  27526. * @static
  27527. * @memberOf _
  27528. * @since 0.1.0
  27529. * @category Lang
  27530. * @param {*} value The value to check.
  27531. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27532. * @example
  27533. *
  27534. * _.isEmpty(null);
  27535. * // => true
  27536. *
  27537. * _.isEmpty(true);
  27538. * // => true
  27539. *
  27540. * _.isEmpty(1);
  27541. * // => true
  27542. *
  27543. * _.isEmpty([1, 2, 3]);
  27544. * // => false
  27545. *
  27546. * _.isEmpty({ 'a': 1 });
  27547. * // => false
  27548. */
  27549. function isEmpty(value) {
  27550. if (value == null) {
  27551. return true;
  27552. }
  27553. if (isArrayLike(value) &&
  27554. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27555. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27556. return !value.length;
  27557. }
  27558. var tag = getTag(value);
  27559. if (tag == mapTag || tag == setTag) {
  27560. return !value.size;
  27561. }
  27562. if (isPrototype(value)) {
  27563. return !baseKeys(value).length;
  27564. }
  27565. for (var key in value) {
  27566. if (hasOwnProperty.call(value, key)) {
  27567. return false;
  27568. }
  27569. }
  27570. return true;
  27571. }
  27572. /**
  27573. * Performs a deep comparison between two values to determine if they are
  27574. * equivalent.
  27575. *
  27576. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27577. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27578. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27579. * by their own, not inherited, enumerable properties. Functions and DOM
  27580. * nodes are compared by strict equality, i.e. `===`.
  27581. *
  27582. * @static
  27583. * @memberOf _
  27584. * @since 0.1.0
  27585. * @category Lang
  27586. * @param {*} value The value to compare.
  27587. * @param {*} other The other value to compare.
  27588. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27589. * @example
  27590. *
  27591. * var object = { 'a': 1 };
  27592. * var other = { 'a': 1 };
  27593. *
  27594. * _.isEqual(object, other);
  27595. * // => true
  27596. *
  27597. * object === other;
  27598. * // => false
  27599. */
  27600. function isEqual(value, other) {
  27601. return baseIsEqual(value, other);
  27602. }
  27603. /**
  27604. * This method is like `_.isEqual` except that it accepts `customizer` which
  27605. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27606. * are handled by the method instead. The `customizer` is invoked with up to
  27607. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27608. *
  27609. * @static
  27610. * @memberOf _
  27611. * @since 4.0.0
  27612. * @category Lang
  27613. * @param {*} value The value to compare.
  27614. * @param {*} other The other value to compare.
  27615. * @param {Function} [customizer] The function to customize comparisons.
  27616. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27617. * @example
  27618. *
  27619. * function isGreeting(value) {
  27620. * return /^h(?:i|ello)$/.test(value);
  27621. * }
  27622. *
  27623. * function customizer(objValue, othValue) {
  27624. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27625. * return true;
  27626. * }
  27627. * }
  27628. *
  27629. * var array = ['hello', 'goodbye'];
  27630. * var other = ['hi', 'goodbye'];
  27631. *
  27632. * _.isEqualWith(array, other, customizer);
  27633. * // => true
  27634. */
  27635. function isEqualWith(value, other, customizer) {
  27636. customizer = typeof customizer == 'function' ? customizer : undefined;
  27637. var result = customizer ? customizer(value, other) : undefined;
  27638. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27639. }
  27640. /**
  27641. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27642. * `SyntaxError`, `TypeError`, or `URIError` object.
  27643. *
  27644. * @static
  27645. * @memberOf _
  27646. * @since 3.0.0
  27647. * @category Lang
  27648. * @param {*} value The value to check.
  27649. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27650. * @example
  27651. *
  27652. * _.isError(new Error);
  27653. * // => true
  27654. *
  27655. * _.isError(Error);
  27656. * // => false
  27657. */
  27658. function isError(value) {
  27659. if (!isObjectLike(value)) {
  27660. return false;
  27661. }
  27662. var tag = baseGetTag(value);
  27663. return tag == errorTag || tag == domExcTag ||
  27664. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27665. }
  27666. /**
  27667. * Checks if `value` is a finite primitive number.
  27668. *
  27669. * **Note:** This method is based on
  27670. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27671. *
  27672. * @static
  27673. * @memberOf _
  27674. * @since 0.1.0
  27675. * @category Lang
  27676. * @param {*} value The value to check.
  27677. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27678. * @example
  27679. *
  27680. * _.isFinite(3);
  27681. * // => true
  27682. *
  27683. * _.isFinite(Number.MIN_VALUE);
  27684. * // => true
  27685. *
  27686. * _.isFinite(Infinity);
  27687. * // => false
  27688. *
  27689. * _.isFinite('3');
  27690. * // => false
  27691. */
  27692. function isFinite(value) {
  27693. return typeof value == 'number' && nativeIsFinite(value);
  27694. }
  27695. /**
  27696. * Checks if `value` is classified as a `Function` object.
  27697. *
  27698. * @static
  27699. * @memberOf _
  27700. * @since 0.1.0
  27701. * @category Lang
  27702. * @param {*} value The value to check.
  27703. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27704. * @example
  27705. *
  27706. * _.isFunction(_);
  27707. * // => true
  27708. *
  27709. * _.isFunction(/abc/);
  27710. * // => false
  27711. */
  27712. function isFunction(value) {
  27713. if (!isObject(value)) {
  27714. return false;
  27715. }
  27716. // The use of `Object#toString` avoids issues with the `typeof` operator
  27717. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27718. var tag = baseGetTag(value);
  27719. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27720. }
  27721. /**
  27722. * Checks if `value` is an integer.
  27723. *
  27724. * **Note:** This method is based on
  27725. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27726. *
  27727. * @static
  27728. * @memberOf _
  27729. * @since 4.0.0
  27730. * @category Lang
  27731. * @param {*} value The value to check.
  27732. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27733. * @example
  27734. *
  27735. * _.isInteger(3);
  27736. * // => true
  27737. *
  27738. * _.isInteger(Number.MIN_VALUE);
  27739. * // => false
  27740. *
  27741. * _.isInteger(Infinity);
  27742. * // => false
  27743. *
  27744. * _.isInteger('3');
  27745. * // => false
  27746. */
  27747. function isInteger(value) {
  27748. return typeof value == 'number' && value == toInteger(value);
  27749. }
  27750. /**
  27751. * Checks if `value` is a valid array-like length.
  27752. *
  27753. * **Note:** This method is loosely based on
  27754. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27755. *
  27756. * @static
  27757. * @memberOf _
  27758. * @since 4.0.0
  27759. * @category Lang
  27760. * @param {*} value The value to check.
  27761. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27762. * @example
  27763. *
  27764. * _.isLength(3);
  27765. * // => true
  27766. *
  27767. * _.isLength(Number.MIN_VALUE);
  27768. * // => false
  27769. *
  27770. * _.isLength(Infinity);
  27771. * // => false
  27772. *
  27773. * _.isLength('3');
  27774. * // => false
  27775. */
  27776. function isLength(value) {
  27777. return typeof value == 'number' &&
  27778. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27779. }
  27780. /**
  27781. * Checks if `value` is the
  27782. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27783. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27784. *
  27785. * @static
  27786. * @memberOf _
  27787. * @since 0.1.0
  27788. * @category Lang
  27789. * @param {*} value The value to check.
  27790. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27791. * @example
  27792. *
  27793. * _.isObject({});
  27794. * // => true
  27795. *
  27796. * _.isObject([1, 2, 3]);
  27797. * // => true
  27798. *
  27799. * _.isObject(_.noop);
  27800. * // => true
  27801. *
  27802. * _.isObject(null);
  27803. * // => false
  27804. */
  27805. function isObject(value) {
  27806. var type = typeof value;
  27807. return value != null && (type == 'object' || type == 'function');
  27808. }
  27809. /**
  27810. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27811. * and has a `typeof` result of "object".
  27812. *
  27813. * @static
  27814. * @memberOf _
  27815. * @since 4.0.0
  27816. * @category Lang
  27817. * @param {*} value The value to check.
  27818. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27819. * @example
  27820. *
  27821. * _.isObjectLike({});
  27822. * // => true
  27823. *
  27824. * _.isObjectLike([1, 2, 3]);
  27825. * // => true
  27826. *
  27827. * _.isObjectLike(_.noop);
  27828. * // => false
  27829. *
  27830. * _.isObjectLike(null);
  27831. * // => false
  27832. */
  27833. function isObjectLike(value) {
  27834. return value != null && typeof value == 'object';
  27835. }
  27836. /**
  27837. * Checks if `value` is classified as a `Map` object.
  27838. *
  27839. * @static
  27840. * @memberOf _
  27841. * @since 4.3.0
  27842. * @category Lang
  27843. * @param {*} value The value to check.
  27844. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27845. * @example
  27846. *
  27847. * _.isMap(new Map);
  27848. * // => true
  27849. *
  27850. * _.isMap(new WeakMap);
  27851. * // => false
  27852. */
  27853. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27854. /**
  27855. * Performs a partial deep comparison between `object` and `source` to
  27856. * determine if `object` contains equivalent property values.
  27857. *
  27858. * **Note:** This method is equivalent to `_.matches` when `source` is
  27859. * partially applied.
  27860. *
  27861. * Partial comparisons will match empty array and empty object `source`
  27862. * values against any array or object value, respectively. See `_.isEqual`
  27863. * for a list of supported value comparisons.
  27864. *
  27865. * @static
  27866. * @memberOf _
  27867. * @since 3.0.0
  27868. * @category Lang
  27869. * @param {Object} object The object to inspect.
  27870. * @param {Object} source The object of property values to match.
  27871. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27872. * @example
  27873. *
  27874. * var object = { 'a': 1, 'b': 2 };
  27875. *
  27876. * _.isMatch(object, { 'b': 2 });
  27877. * // => true
  27878. *
  27879. * _.isMatch(object, { 'b': 1 });
  27880. * // => false
  27881. */
  27882. function isMatch(object, source) {
  27883. return object === source || baseIsMatch(object, source, getMatchData(source));
  27884. }
  27885. /**
  27886. * This method is like `_.isMatch` except that it accepts `customizer` which
  27887. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27888. * are handled by the method instead. The `customizer` is invoked with five
  27889. * arguments: (objValue, srcValue, index|key, object, source).
  27890. *
  27891. * @static
  27892. * @memberOf _
  27893. * @since 4.0.0
  27894. * @category Lang
  27895. * @param {Object} object The object to inspect.
  27896. * @param {Object} source The object of property values to match.
  27897. * @param {Function} [customizer] The function to customize comparisons.
  27898. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27899. * @example
  27900. *
  27901. * function isGreeting(value) {
  27902. * return /^h(?:i|ello)$/.test(value);
  27903. * }
  27904. *
  27905. * function customizer(objValue, srcValue) {
  27906. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27907. * return true;
  27908. * }
  27909. * }
  27910. *
  27911. * var object = { 'greeting': 'hello' };
  27912. * var source = { 'greeting': 'hi' };
  27913. *
  27914. * _.isMatchWith(object, source, customizer);
  27915. * // => true
  27916. */
  27917. function isMatchWith(object, source, customizer) {
  27918. customizer = typeof customizer == 'function' ? customizer : undefined;
  27919. return baseIsMatch(object, source, getMatchData(source), customizer);
  27920. }
  27921. /**
  27922. * Checks if `value` is `NaN`.
  27923. *
  27924. * **Note:** This method is based on
  27925. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27926. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27927. * `undefined` and other non-number values.
  27928. *
  27929. * @static
  27930. * @memberOf _
  27931. * @since 0.1.0
  27932. * @category Lang
  27933. * @param {*} value The value to check.
  27934. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27935. * @example
  27936. *
  27937. * _.isNaN(NaN);
  27938. * // => true
  27939. *
  27940. * _.isNaN(new Number(NaN));
  27941. * // => true
  27942. *
  27943. * isNaN(undefined);
  27944. * // => true
  27945. *
  27946. * _.isNaN(undefined);
  27947. * // => false
  27948. */
  27949. function isNaN(value) {
  27950. // An `NaN` primitive is the only value that is not equal to itself.
  27951. // Perform the `toStringTag` check first to avoid errors with some
  27952. // ActiveX objects in IE.
  27953. return isNumber(value) && value != +value;
  27954. }
  27955. /**
  27956. * Checks if `value` is a pristine native function.
  27957. *
  27958. * **Note:** This method can't reliably detect native functions in the presence
  27959. * of the core-js package because core-js circumvents this kind of detection.
  27960. * Despite multiple requests, the core-js maintainer has made it clear: any
  27961. * attempt to fix the detection will be obstructed. As a result, we're left
  27962. * with little choice but to throw an error. Unfortunately, this also affects
  27963. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27964. * which rely on core-js.
  27965. *
  27966. * @static
  27967. * @memberOf _
  27968. * @since 3.0.0
  27969. * @category Lang
  27970. * @param {*} value The value to check.
  27971. * @returns {boolean} Returns `true` if `value` is a native function,
  27972. * else `false`.
  27973. * @example
  27974. *
  27975. * _.isNative(Array.prototype.push);
  27976. * // => true
  27977. *
  27978. * _.isNative(_);
  27979. * // => false
  27980. */
  27981. function isNative(value) {
  27982. if (isMaskable(value)) {
  27983. throw new Error(CORE_ERROR_TEXT);
  27984. }
  27985. return baseIsNative(value);
  27986. }
  27987. /**
  27988. * Checks if `value` is `null`.
  27989. *
  27990. * @static
  27991. * @memberOf _
  27992. * @since 0.1.0
  27993. * @category Lang
  27994. * @param {*} value The value to check.
  27995. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27996. * @example
  27997. *
  27998. * _.isNull(null);
  27999. * // => true
  28000. *
  28001. * _.isNull(void 0);
  28002. * // => false
  28003. */
  28004. function isNull(value) {
  28005. return value === null;
  28006. }
  28007. /**
  28008. * Checks if `value` is `null` or `undefined`.
  28009. *
  28010. * @static
  28011. * @memberOf _
  28012. * @since 4.0.0
  28013. * @category Lang
  28014. * @param {*} value The value to check.
  28015. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28016. * @example
  28017. *
  28018. * _.isNil(null);
  28019. * // => true
  28020. *
  28021. * _.isNil(void 0);
  28022. * // => true
  28023. *
  28024. * _.isNil(NaN);
  28025. * // => false
  28026. */
  28027. function isNil(value) {
  28028. return value == null;
  28029. }
  28030. /**
  28031. * Checks if `value` is classified as a `Number` primitive or object.
  28032. *
  28033. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28034. * classified as numbers, use the `_.isFinite` method.
  28035. *
  28036. * @static
  28037. * @memberOf _
  28038. * @since 0.1.0
  28039. * @category Lang
  28040. * @param {*} value The value to check.
  28041. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28042. * @example
  28043. *
  28044. * _.isNumber(3);
  28045. * // => true
  28046. *
  28047. * _.isNumber(Number.MIN_VALUE);
  28048. * // => true
  28049. *
  28050. * _.isNumber(Infinity);
  28051. * // => true
  28052. *
  28053. * _.isNumber('3');
  28054. * // => false
  28055. */
  28056. function isNumber(value) {
  28057. return typeof value == 'number' ||
  28058. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28059. }
  28060. /**
  28061. * Checks if `value` is a plain object, that is, an object created by the
  28062. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28063. *
  28064. * @static
  28065. * @memberOf _
  28066. * @since 0.8.0
  28067. * @category Lang
  28068. * @param {*} value The value to check.
  28069. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28070. * @example
  28071. *
  28072. * function Foo() {
  28073. * this.a = 1;
  28074. * }
  28075. *
  28076. * _.isPlainObject(new Foo);
  28077. * // => false
  28078. *
  28079. * _.isPlainObject([1, 2, 3]);
  28080. * // => false
  28081. *
  28082. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28083. * // => true
  28084. *
  28085. * _.isPlainObject(Object.create(null));
  28086. * // => true
  28087. */
  28088. function isPlainObject(value) {
  28089. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28090. return false;
  28091. }
  28092. var proto = getPrototype(value);
  28093. if (proto === null) {
  28094. return true;
  28095. }
  28096. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28097. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28098. funcToString.call(Ctor) == objectCtorString;
  28099. }
  28100. /**
  28101. * Checks if `value` is classified as a `RegExp` object.
  28102. *
  28103. * @static
  28104. * @memberOf _
  28105. * @since 0.1.0
  28106. * @category Lang
  28107. * @param {*} value The value to check.
  28108. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28109. * @example
  28110. *
  28111. * _.isRegExp(/abc/);
  28112. * // => true
  28113. *
  28114. * _.isRegExp('/abc/');
  28115. * // => false
  28116. */
  28117. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28118. /**
  28119. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28120. * double precision number which isn't the result of a rounded unsafe integer.
  28121. *
  28122. * **Note:** This method is based on
  28123. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28124. *
  28125. * @static
  28126. * @memberOf _
  28127. * @since 4.0.0
  28128. * @category Lang
  28129. * @param {*} value The value to check.
  28130. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28131. * @example
  28132. *
  28133. * _.isSafeInteger(3);
  28134. * // => true
  28135. *
  28136. * _.isSafeInteger(Number.MIN_VALUE);
  28137. * // => false
  28138. *
  28139. * _.isSafeInteger(Infinity);
  28140. * // => false
  28141. *
  28142. * _.isSafeInteger('3');
  28143. * // => false
  28144. */
  28145. function isSafeInteger(value) {
  28146. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28147. }
  28148. /**
  28149. * Checks if `value` is classified as a `Set` object.
  28150. *
  28151. * @static
  28152. * @memberOf _
  28153. * @since 4.3.0
  28154. * @category Lang
  28155. * @param {*} value The value to check.
  28156. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28157. * @example
  28158. *
  28159. * _.isSet(new Set);
  28160. * // => true
  28161. *
  28162. * _.isSet(new WeakSet);
  28163. * // => false
  28164. */
  28165. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28166. /**
  28167. * Checks if `value` is classified as a `String` primitive or object.
  28168. *
  28169. * @static
  28170. * @since 0.1.0
  28171. * @memberOf _
  28172. * @category Lang
  28173. * @param {*} value The value to check.
  28174. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28175. * @example
  28176. *
  28177. * _.isString('abc');
  28178. * // => true
  28179. *
  28180. * _.isString(1);
  28181. * // => false
  28182. */
  28183. function isString(value) {
  28184. return typeof value == 'string' ||
  28185. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28186. }
  28187. /**
  28188. * Checks if `value` is classified as a `Symbol` primitive or object.
  28189. *
  28190. * @static
  28191. * @memberOf _
  28192. * @since 4.0.0
  28193. * @category Lang
  28194. * @param {*} value The value to check.
  28195. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28196. * @example
  28197. *
  28198. * _.isSymbol(Symbol.iterator);
  28199. * // => true
  28200. *
  28201. * _.isSymbol('abc');
  28202. * // => false
  28203. */
  28204. function isSymbol(value) {
  28205. return typeof value == 'symbol' ||
  28206. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28207. }
  28208. /**
  28209. * Checks if `value` is classified as a typed array.
  28210. *
  28211. * @static
  28212. * @memberOf _
  28213. * @since 3.0.0
  28214. * @category Lang
  28215. * @param {*} value The value to check.
  28216. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28217. * @example
  28218. *
  28219. * _.isTypedArray(new Uint8Array);
  28220. * // => true
  28221. *
  28222. * _.isTypedArray([]);
  28223. * // => false
  28224. */
  28225. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28226. /**
  28227. * Checks if `value` is `undefined`.
  28228. *
  28229. * @static
  28230. * @since 0.1.0
  28231. * @memberOf _
  28232. * @category Lang
  28233. * @param {*} value The value to check.
  28234. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28235. * @example
  28236. *
  28237. * _.isUndefined(void 0);
  28238. * // => true
  28239. *
  28240. * _.isUndefined(null);
  28241. * // => false
  28242. */
  28243. function isUndefined(value) {
  28244. return value === undefined;
  28245. }
  28246. /**
  28247. * Checks if `value` is classified as a `WeakMap` object.
  28248. *
  28249. * @static
  28250. * @memberOf _
  28251. * @since 4.3.0
  28252. * @category Lang
  28253. * @param {*} value The value to check.
  28254. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28255. * @example
  28256. *
  28257. * _.isWeakMap(new WeakMap);
  28258. * // => true
  28259. *
  28260. * _.isWeakMap(new Map);
  28261. * // => false
  28262. */
  28263. function isWeakMap(value) {
  28264. return isObjectLike(value) && getTag(value) == weakMapTag;
  28265. }
  28266. /**
  28267. * Checks if `value` is classified as a `WeakSet` object.
  28268. *
  28269. * @static
  28270. * @memberOf _
  28271. * @since 4.3.0
  28272. * @category Lang
  28273. * @param {*} value The value to check.
  28274. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28275. * @example
  28276. *
  28277. * _.isWeakSet(new WeakSet);
  28278. * // => true
  28279. *
  28280. * _.isWeakSet(new Set);
  28281. * // => false
  28282. */
  28283. function isWeakSet(value) {
  28284. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28285. }
  28286. /**
  28287. * Checks if `value` is less than `other`.
  28288. *
  28289. * @static
  28290. * @memberOf _
  28291. * @since 3.9.0
  28292. * @category Lang
  28293. * @param {*} value The value to compare.
  28294. * @param {*} other The other value to compare.
  28295. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28296. * else `false`.
  28297. * @see _.gt
  28298. * @example
  28299. *
  28300. * _.lt(1, 3);
  28301. * // => true
  28302. *
  28303. * _.lt(3, 3);
  28304. * // => false
  28305. *
  28306. * _.lt(3, 1);
  28307. * // => false
  28308. */
  28309. var lt = createRelationalOperation(baseLt);
  28310. /**
  28311. * Checks if `value` is less than or equal to `other`.
  28312. *
  28313. * @static
  28314. * @memberOf _
  28315. * @since 3.9.0
  28316. * @category Lang
  28317. * @param {*} value The value to compare.
  28318. * @param {*} other The other value to compare.
  28319. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28320. * `other`, else `false`.
  28321. * @see _.gte
  28322. * @example
  28323. *
  28324. * _.lte(1, 3);
  28325. * // => true
  28326. *
  28327. * _.lte(3, 3);
  28328. * // => true
  28329. *
  28330. * _.lte(3, 1);
  28331. * // => false
  28332. */
  28333. var lte = createRelationalOperation(function(value, other) {
  28334. return value <= other;
  28335. });
  28336. /**
  28337. * Converts `value` to an array.
  28338. *
  28339. * @static
  28340. * @since 0.1.0
  28341. * @memberOf _
  28342. * @category Lang
  28343. * @param {*} value The value to convert.
  28344. * @returns {Array} Returns the converted array.
  28345. * @example
  28346. *
  28347. * _.toArray({ 'a': 1, 'b': 2 });
  28348. * // => [1, 2]
  28349. *
  28350. * _.toArray('abc');
  28351. * // => ['a', 'b', 'c']
  28352. *
  28353. * _.toArray(1);
  28354. * // => []
  28355. *
  28356. * _.toArray(null);
  28357. * // => []
  28358. */
  28359. function toArray(value) {
  28360. if (!value) {
  28361. return [];
  28362. }
  28363. if (isArrayLike(value)) {
  28364. return isString(value) ? stringToArray(value) : copyArray(value);
  28365. }
  28366. if (symIterator && value[symIterator]) {
  28367. return iteratorToArray(value[symIterator]());
  28368. }
  28369. var tag = getTag(value),
  28370. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28371. return func(value);
  28372. }
  28373. /**
  28374. * Converts `value` to a finite number.
  28375. *
  28376. * @static
  28377. * @memberOf _
  28378. * @since 4.12.0
  28379. * @category Lang
  28380. * @param {*} value The value to convert.
  28381. * @returns {number} Returns the converted number.
  28382. * @example
  28383. *
  28384. * _.toFinite(3.2);
  28385. * // => 3.2
  28386. *
  28387. * _.toFinite(Number.MIN_VALUE);
  28388. * // => 5e-324
  28389. *
  28390. * _.toFinite(Infinity);
  28391. * // => 1.7976931348623157e+308
  28392. *
  28393. * _.toFinite('3.2');
  28394. * // => 3.2
  28395. */
  28396. function toFinite(value) {
  28397. if (!value) {
  28398. return value === 0 ? value : 0;
  28399. }
  28400. value = toNumber(value);
  28401. if (value === INFINITY || value === -INFINITY) {
  28402. var sign = (value < 0 ? -1 : 1);
  28403. return sign * MAX_INTEGER;
  28404. }
  28405. return value === value ? value : 0;
  28406. }
  28407. /**
  28408. * Converts `value` to an integer.
  28409. *
  28410. * **Note:** This method is loosely based on
  28411. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28412. *
  28413. * @static
  28414. * @memberOf _
  28415. * @since 4.0.0
  28416. * @category Lang
  28417. * @param {*} value The value to convert.
  28418. * @returns {number} Returns the converted integer.
  28419. * @example
  28420. *
  28421. * _.toInteger(3.2);
  28422. * // => 3
  28423. *
  28424. * _.toInteger(Number.MIN_VALUE);
  28425. * // => 0
  28426. *
  28427. * _.toInteger(Infinity);
  28428. * // => 1.7976931348623157e+308
  28429. *
  28430. * _.toInteger('3.2');
  28431. * // => 3
  28432. */
  28433. function toInteger(value) {
  28434. var result = toFinite(value),
  28435. remainder = result % 1;
  28436. return result === result ? (remainder ? result - remainder : result) : 0;
  28437. }
  28438. /**
  28439. * Converts `value` to an integer suitable for use as the length of an
  28440. * array-like object.
  28441. *
  28442. * **Note:** This method is based on
  28443. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28444. *
  28445. * @static
  28446. * @memberOf _
  28447. * @since 4.0.0
  28448. * @category Lang
  28449. * @param {*} value The value to convert.
  28450. * @returns {number} Returns the converted integer.
  28451. * @example
  28452. *
  28453. * _.toLength(3.2);
  28454. * // => 3
  28455. *
  28456. * _.toLength(Number.MIN_VALUE);
  28457. * // => 0
  28458. *
  28459. * _.toLength(Infinity);
  28460. * // => 4294967295
  28461. *
  28462. * _.toLength('3.2');
  28463. * // => 3
  28464. */
  28465. function toLength(value) {
  28466. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28467. }
  28468. /**
  28469. * Converts `value` to a number.
  28470. *
  28471. * @static
  28472. * @memberOf _
  28473. * @since 4.0.0
  28474. * @category Lang
  28475. * @param {*} value The value to process.
  28476. * @returns {number} Returns the number.
  28477. * @example
  28478. *
  28479. * _.toNumber(3.2);
  28480. * // => 3.2
  28481. *
  28482. * _.toNumber(Number.MIN_VALUE);
  28483. * // => 5e-324
  28484. *
  28485. * _.toNumber(Infinity);
  28486. * // => Infinity
  28487. *
  28488. * _.toNumber('3.2');
  28489. * // => 3.2
  28490. */
  28491. function toNumber(value) {
  28492. if (typeof value == 'number') {
  28493. return value;
  28494. }
  28495. if (isSymbol(value)) {
  28496. return NAN;
  28497. }
  28498. if (isObject(value)) {
  28499. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28500. value = isObject(other) ? (other + '') : other;
  28501. }
  28502. if (typeof value != 'string') {
  28503. return value === 0 ? value : +value;
  28504. }
  28505. value = value.replace(reTrim, '');
  28506. var isBinary = reIsBinary.test(value);
  28507. return (isBinary || reIsOctal.test(value))
  28508. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28509. : (reIsBadHex.test(value) ? NAN : +value);
  28510. }
  28511. /**
  28512. * Converts `value` to a plain object flattening inherited enumerable string
  28513. * keyed properties of `value` to own properties of the plain object.
  28514. *
  28515. * @static
  28516. * @memberOf _
  28517. * @since 3.0.0
  28518. * @category Lang
  28519. * @param {*} value The value to convert.
  28520. * @returns {Object} Returns the converted plain object.
  28521. * @example
  28522. *
  28523. * function Foo() {
  28524. * this.b = 2;
  28525. * }
  28526. *
  28527. * Foo.prototype.c = 3;
  28528. *
  28529. * _.assign({ 'a': 1 }, new Foo);
  28530. * // => { 'a': 1, 'b': 2 }
  28531. *
  28532. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28533. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28534. */
  28535. function toPlainObject(value) {
  28536. return copyObject(value, keysIn(value));
  28537. }
  28538. /**
  28539. * Converts `value` to a safe integer. A safe integer can be compared and
  28540. * represented correctly.
  28541. *
  28542. * @static
  28543. * @memberOf _
  28544. * @since 4.0.0
  28545. * @category Lang
  28546. * @param {*} value The value to convert.
  28547. * @returns {number} Returns the converted integer.
  28548. * @example
  28549. *
  28550. * _.toSafeInteger(3.2);
  28551. * // => 3
  28552. *
  28553. * _.toSafeInteger(Number.MIN_VALUE);
  28554. * // => 0
  28555. *
  28556. * _.toSafeInteger(Infinity);
  28557. * // => 9007199254740991
  28558. *
  28559. * _.toSafeInteger('3.2');
  28560. * // => 3
  28561. */
  28562. function toSafeInteger(value) {
  28563. return value
  28564. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28565. : (value === 0 ? value : 0);
  28566. }
  28567. /**
  28568. * Converts `value` to a string. An empty string is returned for `null`
  28569. * and `undefined` values. The sign of `-0` is preserved.
  28570. *
  28571. * @static
  28572. * @memberOf _
  28573. * @since 4.0.0
  28574. * @category Lang
  28575. * @param {*} value The value to convert.
  28576. * @returns {string} Returns the converted string.
  28577. * @example
  28578. *
  28579. * _.toString(null);
  28580. * // => ''
  28581. *
  28582. * _.toString(-0);
  28583. * // => '-0'
  28584. *
  28585. * _.toString([1, 2, 3]);
  28586. * // => '1,2,3'
  28587. */
  28588. function toString(value) {
  28589. return value == null ? '' : baseToString(value);
  28590. }
  28591. /*------------------------------------------------------------------------*/
  28592. /**
  28593. * Assigns own enumerable string keyed properties of source objects to the
  28594. * destination object. Source objects are applied from left to right.
  28595. * Subsequent sources overwrite property assignments of previous sources.
  28596. *
  28597. * **Note:** This method mutates `object` and is loosely based on
  28598. * [`Object.assign`](https://mdn.io/Object/assign).
  28599. *
  28600. * @static
  28601. * @memberOf _
  28602. * @since 0.10.0
  28603. * @category Object
  28604. * @param {Object} object The destination object.
  28605. * @param {...Object} [sources] The source objects.
  28606. * @returns {Object} Returns `object`.
  28607. * @see _.assignIn
  28608. * @example
  28609. *
  28610. * function Foo() {
  28611. * this.a = 1;
  28612. * }
  28613. *
  28614. * function Bar() {
  28615. * this.c = 3;
  28616. * }
  28617. *
  28618. * Foo.prototype.b = 2;
  28619. * Bar.prototype.d = 4;
  28620. *
  28621. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28622. * // => { 'a': 1, 'c': 3 }
  28623. */
  28624. var assign = createAssigner(function(object, source) {
  28625. if (isPrototype(source) || isArrayLike(source)) {
  28626. copyObject(source, keys(source), object);
  28627. return;
  28628. }
  28629. for (var key in source) {
  28630. if (hasOwnProperty.call(source, key)) {
  28631. assignValue(object, key, source[key]);
  28632. }
  28633. }
  28634. });
  28635. /**
  28636. * This method is like `_.assign` except that it iterates over own and
  28637. * inherited source properties.
  28638. *
  28639. * **Note:** This method mutates `object`.
  28640. *
  28641. * @static
  28642. * @memberOf _
  28643. * @since 4.0.0
  28644. * @alias extend
  28645. * @category Object
  28646. * @param {Object} object The destination object.
  28647. * @param {...Object} [sources] The source objects.
  28648. * @returns {Object} Returns `object`.
  28649. * @see _.assign
  28650. * @example
  28651. *
  28652. * function Foo() {
  28653. * this.a = 1;
  28654. * }
  28655. *
  28656. * function Bar() {
  28657. * this.c = 3;
  28658. * }
  28659. *
  28660. * Foo.prototype.b = 2;
  28661. * Bar.prototype.d = 4;
  28662. *
  28663. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28664. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28665. */
  28666. var assignIn = createAssigner(function(object, source) {
  28667. copyObject(source, keysIn(source), object);
  28668. });
  28669. /**
  28670. * This method is like `_.assignIn` except that it accepts `customizer`
  28671. * which is invoked to produce the assigned values. If `customizer` returns
  28672. * `undefined`, assignment is handled by the method instead. The `customizer`
  28673. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28674. *
  28675. * **Note:** This method mutates `object`.
  28676. *
  28677. * @static
  28678. * @memberOf _
  28679. * @since 4.0.0
  28680. * @alias extendWith
  28681. * @category Object
  28682. * @param {Object} object The destination object.
  28683. * @param {...Object} sources The source objects.
  28684. * @param {Function} [customizer] The function to customize assigned values.
  28685. * @returns {Object} Returns `object`.
  28686. * @see _.assignWith
  28687. * @example
  28688. *
  28689. * function customizer(objValue, srcValue) {
  28690. * return _.isUndefined(objValue) ? srcValue : objValue;
  28691. * }
  28692. *
  28693. * var defaults = _.partialRight(_.assignInWith, customizer);
  28694. *
  28695. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28696. * // => { 'a': 1, 'b': 2 }
  28697. */
  28698. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28699. copyObject(source, keysIn(source), object, customizer);
  28700. });
  28701. /**
  28702. * This method is like `_.assign` except that it accepts `customizer`
  28703. * which is invoked to produce the assigned values. If `customizer` returns
  28704. * `undefined`, assignment is handled by the method instead. The `customizer`
  28705. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28706. *
  28707. * **Note:** This method mutates `object`.
  28708. *
  28709. * @static
  28710. * @memberOf _
  28711. * @since 4.0.0
  28712. * @category Object
  28713. * @param {Object} object The destination object.
  28714. * @param {...Object} sources The source objects.
  28715. * @param {Function} [customizer] The function to customize assigned values.
  28716. * @returns {Object} Returns `object`.
  28717. * @see _.assignInWith
  28718. * @example
  28719. *
  28720. * function customizer(objValue, srcValue) {
  28721. * return _.isUndefined(objValue) ? srcValue : objValue;
  28722. * }
  28723. *
  28724. * var defaults = _.partialRight(_.assignWith, customizer);
  28725. *
  28726. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28727. * // => { 'a': 1, 'b': 2 }
  28728. */
  28729. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28730. copyObject(source, keys(source), object, customizer);
  28731. });
  28732. /**
  28733. * Creates an array of values corresponding to `paths` of `object`.
  28734. *
  28735. * @static
  28736. * @memberOf _
  28737. * @since 1.0.0
  28738. * @category Object
  28739. * @param {Object} object The object to iterate over.
  28740. * @param {...(string|string[])} [paths] The property paths to pick.
  28741. * @returns {Array} Returns the picked values.
  28742. * @example
  28743. *
  28744. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28745. *
  28746. * _.at(object, ['a[0].b.c', 'a[1]']);
  28747. * // => [3, 4]
  28748. */
  28749. var at = flatRest(baseAt);
  28750. /**
  28751. * Creates an object that inherits from the `prototype` object. If a
  28752. * `properties` object is given, its own enumerable string keyed properties
  28753. * are assigned to the created object.
  28754. *
  28755. * @static
  28756. * @memberOf _
  28757. * @since 2.3.0
  28758. * @category Object
  28759. * @param {Object} prototype The object to inherit from.
  28760. * @param {Object} [properties] The properties to assign to the object.
  28761. * @returns {Object} Returns the new object.
  28762. * @example
  28763. *
  28764. * function Shape() {
  28765. * this.x = 0;
  28766. * this.y = 0;
  28767. * }
  28768. *
  28769. * function Circle() {
  28770. * Shape.call(this);
  28771. * }
  28772. *
  28773. * Circle.prototype = _.create(Shape.prototype, {
  28774. * 'constructor': Circle
  28775. * });
  28776. *
  28777. * var circle = new Circle;
  28778. * circle instanceof Circle;
  28779. * // => true
  28780. *
  28781. * circle instanceof Shape;
  28782. * // => true
  28783. */
  28784. function create(prototype, properties) {
  28785. var result = baseCreate(prototype);
  28786. return properties == null ? result : baseAssign(result, properties);
  28787. }
  28788. /**
  28789. * Assigns own and inherited enumerable string keyed properties of source
  28790. * objects to the destination object for all destination properties that
  28791. * resolve to `undefined`. Source objects are applied from left to right.
  28792. * Once a property is set, additional values of the same property are ignored.
  28793. *
  28794. * **Note:** This method mutates `object`.
  28795. *
  28796. * @static
  28797. * @since 0.1.0
  28798. * @memberOf _
  28799. * @category Object
  28800. * @param {Object} object The destination object.
  28801. * @param {...Object} [sources] The source objects.
  28802. * @returns {Object} Returns `object`.
  28803. * @see _.defaultsDeep
  28804. * @example
  28805. *
  28806. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28807. * // => { 'a': 1, 'b': 2 }
  28808. */
  28809. var defaults = baseRest(function(object, sources) {
  28810. object = Object(object);
  28811. var index = -1;
  28812. var length = sources.length;
  28813. var guard = length > 2 ? sources[2] : undefined;
  28814. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28815. length = 1;
  28816. }
  28817. while (++index < length) {
  28818. var source = sources[index];
  28819. var props = keysIn(source);
  28820. var propsIndex = -1;
  28821. var propsLength = props.length;
  28822. while (++propsIndex < propsLength) {
  28823. var key = props[propsIndex];
  28824. var value = object[key];
  28825. if (value === undefined ||
  28826. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28827. object[key] = source[key];
  28828. }
  28829. }
  28830. }
  28831. return object;
  28832. });
  28833. /**
  28834. * This method is like `_.defaults` except that it recursively assigns
  28835. * default properties.
  28836. *
  28837. * **Note:** This method mutates `object`.
  28838. *
  28839. * @static
  28840. * @memberOf _
  28841. * @since 3.10.0
  28842. * @category Object
  28843. * @param {Object} object The destination object.
  28844. * @param {...Object} [sources] The source objects.
  28845. * @returns {Object} Returns `object`.
  28846. * @see _.defaults
  28847. * @example
  28848. *
  28849. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28850. * // => { 'a': { 'b': 2, 'c': 3 } }
  28851. */
  28852. var defaultsDeep = baseRest(function(args) {
  28853. args.push(undefined, customDefaultsMerge);
  28854. return apply(mergeWith, undefined, args);
  28855. });
  28856. /**
  28857. * This method is like `_.find` except that it returns the key of the first
  28858. * element `predicate` returns truthy for instead of the element itself.
  28859. *
  28860. * @static
  28861. * @memberOf _
  28862. * @since 1.1.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. * _.findKey(users, function(o) { return o.age < 40; });
  28877. * // => 'barney' (iteration order is not guaranteed)
  28878. *
  28879. * // The `_.matches` iteratee shorthand.
  28880. * _.findKey(users, { 'age': 1, 'active': true });
  28881. * // => 'pebbles'
  28882. *
  28883. * // The `_.matchesProperty` iteratee shorthand.
  28884. * _.findKey(users, ['active', false]);
  28885. * // => 'fred'
  28886. *
  28887. * // The `_.property` iteratee shorthand.
  28888. * _.findKey(users, 'active');
  28889. * // => 'barney'
  28890. */
  28891. function findKey(object, predicate) {
  28892. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28893. }
  28894. /**
  28895. * This method is like `_.findKey` except that it iterates over elements of
  28896. * a collection in the opposite order.
  28897. *
  28898. * @static
  28899. * @memberOf _
  28900. * @since 2.0.0
  28901. * @category Object
  28902. * @param {Object} object The object to inspect.
  28903. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28904. * @returns {string|undefined} Returns the key of the matched element,
  28905. * else `undefined`.
  28906. * @example
  28907. *
  28908. * var users = {
  28909. * 'barney': { 'age': 36, 'active': true },
  28910. * 'fred': { 'age': 40, 'active': false },
  28911. * 'pebbles': { 'age': 1, 'active': true }
  28912. * };
  28913. *
  28914. * _.findLastKey(users, function(o) { return o.age < 40; });
  28915. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28916. *
  28917. * // The `_.matches` iteratee shorthand.
  28918. * _.findLastKey(users, { 'age': 36, 'active': true });
  28919. * // => 'barney'
  28920. *
  28921. * // The `_.matchesProperty` iteratee shorthand.
  28922. * _.findLastKey(users, ['active', false]);
  28923. * // => 'fred'
  28924. *
  28925. * // The `_.property` iteratee shorthand.
  28926. * _.findLastKey(users, 'active');
  28927. * // => 'pebbles'
  28928. */
  28929. function findLastKey(object, predicate) {
  28930. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28931. }
  28932. /**
  28933. * Iterates over own and inherited enumerable string keyed properties of an
  28934. * object and invokes `iteratee` for each property. The iteratee is invoked
  28935. * with three arguments: (value, key, object). Iteratee functions may exit
  28936. * iteration early by explicitly returning `false`.
  28937. *
  28938. * @static
  28939. * @memberOf _
  28940. * @since 0.3.0
  28941. * @category Object
  28942. * @param {Object} object The object to iterate over.
  28943. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28944. * @returns {Object} Returns `object`.
  28945. * @see _.forInRight
  28946. * @example
  28947. *
  28948. * function Foo() {
  28949. * this.a = 1;
  28950. * this.b = 2;
  28951. * }
  28952. *
  28953. * Foo.prototype.c = 3;
  28954. *
  28955. * _.forIn(new Foo, function(value, key) {
  28956. * console.log(key);
  28957. * });
  28958. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28959. */
  28960. function forIn(object, iteratee) {
  28961. return object == null
  28962. ? object
  28963. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28964. }
  28965. /**
  28966. * This method is like `_.forIn` except that it iterates over properties of
  28967. * `object` in the opposite order.
  28968. *
  28969. * @static
  28970. * @memberOf _
  28971. * @since 2.0.0
  28972. * @category Object
  28973. * @param {Object} object The object to iterate over.
  28974. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28975. * @returns {Object} Returns `object`.
  28976. * @see _.forIn
  28977. * @example
  28978. *
  28979. * function Foo() {
  28980. * this.a = 1;
  28981. * this.b = 2;
  28982. * }
  28983. *
  28984. * Foo.prototype.c = 3;
  28985. *
  28986. * _.forInRight(new Foo, function(value, key) {
  28987. * console.log(key);
  28988. * });
  28989. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28990. */
  28991. function forInRight(object, iteratee) {
  28992. return object == null
  28993. ? object
  28994. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28995. }
  28996. /**
  28997. * Iterates over own enumerable string keyed properties of an object and
  28998. * invokes `iteratee` for each property. The iteratee is invoked with three
  28999. * arguments: (value, key, object). Iteratee functions may exit iteration
  29000. * early by explicitly returning `false`.
  29001. *
  29002. * @static
  29003. * @memberOf _
  29004. * @since 0.3.0
  29005. * @category Object
  29006. * @param {Object} object The object to iterate over.
  29007. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29008. * @returns {Object} Returns `object`.
  29009. * @see _.forOwnRight
  29010. * @example
  29011. *
  29012. * function Foo() {
  29013. * this.a = 1;
  29014. * this.b = 2;
  29015. * }
  29016. *
  29017. * Foo.prototype.c = 3;
  29018. *
  29019. * _.forOwn(new Foo, function(value, key) {
  29020. * console.log(key);
  29021. * });
  29022. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29023. */
  29024. function forOwn(object, iteratee) {
  29025. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29026. }
  29027. /**
  29028. * This method is like `_.forOwn` except that it iterates over properties of
  29029. * `object` in the opposite order.
  29030. *
  29031. * @static
  29032. * @memberOf _
  29033. * @since 2.0.0
  29034. * @category Object
  29035. * @param {Object} object The object to iterate over.
  29036. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29037. * @returns {Object} Returns `object`.
  29038. * @see _.forOwn
  29039. * @example
  29040. *
  29041. * function Foo() {
  29042. * this.a = 1;
  29043. * this.b = 2;
  29044. * }
  29045. *
  29046. * Foo.prototype.c = 3;
  29047. *
  29048. * _.forOwnRight(new Foo, function(value, key) {
  29049. * console.log(key);
  29050. * });
  29051. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29052. */
  29053. function forOwnRight(object, iteratee) {
  29054. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29055. }
  29056. /**
  29057. * Creates an array of function property names from own enumerable properties
  29058. * of `object`.
  29059. *
  29060. * @static
  29061. * @since 0.1.0
  29062. * @memberOf _
  29063. * @category Object
  29064. * @param {Object} object The object to inspect.
  29065. * @returns {Array} Returns the function names.
  29066. * @see _.functionsIn
  29067. * @example
  29068. *
  29069. * function Foo() {
  29070. * this.a = _.constant('a');
  29071. * this.b = _.constant('b');
  29072. * }
  29073. *
  29074. * Foo.prototype.c = _.constant('c');
  29075. *
  29076. * _.functions(new Foo);
  29077. * // => ['a', 'b']
  29078. */
  29079. function functions(object) {
  29080. return object == null ? [] : baseFunctions(object, keys(object));
  29081. }
  29082. /**
  29083. * Creates an array of function property names from own and inherited
  29084. * enumerable properties of `object`.
  29085. *
  29086. * @static
  29087. * @memberOf _
  29088. * @since 4.0.0
  29089. * @category Object
  29090. * @param {Object} object The object to inspect.
  29091. * @returns {Array} Returns the function names.
  29092. * @see _.functions
  29093. * @example
  29094. *
  29095. * function Foo() {
  29096. * this.a = _.constant('a');
  29097. * this.b = _.constant('b');
  29098. * }
  29099. *
  29100. * Foo.prototype.c = _.constant('c');
  29101. *
  29102. * _.functionsIn(new Foo);
  29103. * // => ['a', 'b', 'c']
  29104. */
  29105. function functionsIn(object) {
  29106. return object == null ? [] : baseFunctions(object, keysIn(object));
  29107. }
  29108. /**
  29109. * Gets the value at `path` of `object`. If the resolved value is
  29110. * `undefined`, the `defaultValue` is returned in its place.
  29111. *
  29112. * @static
  29113. * @memberOf _
  29114. * @since 3.7.0
  29115. * @category Object
  29116. * @param {Object} object The object to query.
  29117. * @param {Array|string} path The path of the property to get.
  29118. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29119. * @returns {*} Returns the resolved value.
  29120. * @example
  29121. *
  29122. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29123. *
  29124. * _.get(object, 'a[0].b.c');
  29125. * // => 3
  29126. *
  29127. * _.get(object, ['a', '0', 'b', 'c']);
  29128. * // => 3
  29129. *
  29130. * _.get(object, 'a.b.c', 'default');
  29131. * // => 'default'
  29132. */
  29133. function get(object, path, defaultValue) {
  29134. var result = object == null ? undefined : baseGet(object, path);
  29135. return result === undefined ? defaultValue : result;
  29136. }
  29137. /**
  29138. * Checks if `path` is a direct property of `object`.
  29139. *
  29140. * @static
  29141. * @since 0.1.0
  29142. * @memberOf _
  29143. * @category Object
  29144. * @param {Object} object The object to query.
  29145. * @param {Array|string} path The path to check.
  29146. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29147. * @example
  29148. *
  29149. * var object = { 'a': { 'b': 2 } };
  29150. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29151. *
  29152. * _.has(object, 'a');
  29153. * // => true
  29154. *
  29155. * _.has(object, 'a.b');
  29156. * // => true
  29157. *
  29158. * _.has(object, ['a', 'b']);
  29159. * // => true
  29160. *
  29161. * _.has(other, 'a');
  29162. * // => false
  29163. */
  29164. function has(object, path) {
  29165. return object != null && hasPath(object, path, baseHas);
  29166. }
  29167. /**
  29168. * Checks if `path` is a direct or inherited property of `object`.
  29169. *
  29170. * @static
  29171. * @memberOf _
  29172. * @since 4.0.0
  29173. * @category Object
  29174. * @param {Object} object The object to query.
  29175. * @param {Array|string} path The path to check.
  29176. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29177. * @example
  29178. *
  29179. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29180. *
  29181. * _.hasIn(object, 'a');
  29182. * // => true
  29183. *
  29184. * _.hasIn(object, 'a.b');
  29185. * // => true
  29186. *
  29187. * _.hasIn(object, ['a', 'b']);
  29188. * // => true
  29189. *
  29190. * _.hasIn(object, 'b');
  29191. * // => false
  29192. */
  29193. function hasIn(object, path) {
  29194. return object != null && hasPath(object, path, baseHasIn);
  29195. }
  29196. /**
  29197. * Creates an object composed of the inverted keys and values of `object`.
  29198. * If `object` contains duplicate values, subsequent values overwrite
  29199. * property assignments of previous values.
  29200. *
  29201. * @static
  29202. * @memberOf _
  29203. * @since 0.7.0
  29204. * @category Object
  29205. * @param {Object} object The object to invert.
  29206. * @returns {Object} Returns the new inverted object.
  29207. * @example
  29208. *
  29209. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29210. *
  29211. * _.invert(object);
  29212. * // => { '1': 'c', '2': 'b' }
  29213. */
  29214. var invert = createInverter(function(result, value, key) {
  29215. if (value != null &&
  29216. typeof value.toString != 'function') {
  29217. value = nativeObjectToString.call(value);
  29218. }
  29219. result[value] = key;
  29220. }, constant(identity));
  29221. /**
  29222. * This method is like `_.invert` except that the inverted object is generated
  29223. * from the results of running each element of `object` thru `iteratee`. The
  29224. * corresponding inverted value of each inverted key is an array of keys
  29225. * responsible for generating the inverted value. The iteratee is invoked
  29226. * with one argument: (value).
  29227. *
  29228. * @static
  29229. * @memberOf _
  29230. * @since 4.1.0
  29231. * @category Object
  29232. * @param {Object} object The object to invert.
  29233. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29234. * @returns {Object} Returns the new inverted object.
  29235. * @example
  29236. *
  29237. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29238. *
  29239. * _.invertBy(object);
  29240. * // => { '1': ['a', 'c'], '2': ['b'] }
  29241. *
  29242. * _.invertBy(object, function(value) {
  29243. * return 'group' + value;
  29244. * });
  29245. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29246. */
  29247. var invertBy = createInverter(function(result, value, key) {
  29248. if (value != null &&
  29249. typeof value.toString != 'function') {
  29250. value = nativeObjectToString.call(value);
  29251. }
  29252. if (hasOwnProperty.call(result, value)) {
  29253. result[value].push(key);
  29254. } else {
  29255. result[value] = [key];
  29256. }
  29257. }, getIteratee);
  29258. /**
  29259. * Invokes the method at `path` of `object`.
  29260. *
  29261. * @static
  29262. * @memberOf _
  29263. * @since 4.0.0
  29264. * @category Object
  29265. * @param {Object} object The object to query.
  29266. * @param {Array|string} path The path of the method to invoke.
  29267. * @param {...*} [args] The arguments to invoke the method with.
  29268. * @returns {*} Returns the result of the invoked method.
  29269. * @example
  29270. *
  29271. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29272. *
  29273. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29274. * // => [2, 3]
  29275. */
  29276. var invoke = baseRest(baseInvoke);
  29277. /**
  29278. * Creates an array of the own enumerable property names of `object`.
  29279. *
  29280. * **Note:** Non-object values are coerced to objects. See the
  29281. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29282. * for more details.
  29283. *
  29284. * @static
  29285. * @since 0.1.0
  29286. * @memberOf _
  29287. * @category Object
  29288. * @param {Object} object The object to query.
  29289. * @returns {Array} Returns the array of property names.
  29290. * @example
  29291. *
  29292. * function Foo() {
  29293. * this.a = 1;
  29294. * this.b = 2;
  29295. * }
  29296. *
  29297. * Foo.prototype.c = 3;
  29298. *
  29299. * _.keys(new Foo);
  29300. * // => ['a', 'b'] (iteration order is not guaranteed)
  29301. *
  29302. * _.keys('hi');
  29303. * // => ['0', '1']
  29304. */
  29305. function keys(object) {
  29306. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29307. }
  29308. /**
  29309. * Creates an array of the own and inherited enumerable property names of `object`.
  29310. *
  29311. * **Note:** Non-object values are coerced to objects.
  29312. *
  29313. * @static
  29314. * @memberOf _
  29315. * @since 3.0.0
  29316. * @category Object
  29317. * @param {Object} object The object to query.
  29318. * @returns {Array} Returns the array of property names.
  29319. * @example
  29320. *
  29321. * function Foo() {
  29322. * this.a = 1;
  29323. * this.b = 2;
  29324. * }
  29325. *
  29326. * Foo.prototype.c = 3;
  29327. *
  29328. * _.keysIn(new Foo);
  29329. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29330. */
  29331. function keysIn(object) {
  29332. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29333. }
  29334. /**
  29335. * The opposite of `_.mapValues`; this method creates an object with the
  29336. * same values as `object` and keys generated by running each own enumerable
  29337. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29338. * with three arguments: (value, key, object).
  29339. *
  29340. * @static
  29341. * @memberOf _
  29342. * @since 3.8.0
  29343. * @category Object
  29344. * @param {Object} object The object to iterate over.
  29345. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29346. * @returns {Object} Returns the new mapped object.
  29347. * @see _.mapValues
  29348. * @example
  29349. *
  29350. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29351. * return key + value;
  29352. * });
  29353. * // => { 'a1': 1, 'b2': 2 }
  29354. */
  29355. function mapKeys(object, iteratee) {
  29356. var result = {};
  29357. iteratee = getIteratee(iteratee, 3);
  29358. baseForOwn(object, function(value, key, object) {
  29359. baseAssignValue(result, iteratee(value, key, object), value);
  29360. });
  29361. return result;
  29362. }
  29363. /**
  29364. * Creates an object with the same keys as `object` and values generated
  29365. * by running each own enumerable string keyed property of `object` thru
  29366. * `iteratee`. The iteratee is invoked with three arguments:
  29367. * (value, key, object).
  29368. *
  29369. * @static
  29370. * @memberOf _
  29371. * @since 2.4.0
  29372. * @category Object
  29373. * @param {Object} object The object to iterate over.
  29374. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29375. * @returns {Object} Returns the new mapped object.
  29376. * @see _.mapKeys
  29377. * @example
  29378. *
  29379. * var users = {
  29380. * 'fred': { 'user': 'fred', 'age': 40 },
  29381. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29382. * };
  29383. *
  29384. * _.mapValues(users, function(o) { return o.age; });
  29385. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29386. *
  29387. * // The `_.property` iteratee shorthand.
  29388. * _.mapValues(users, 'age');
  29389. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29390. */
  29391. function mapValues(object, iteratee) {
  29392. var result = {};
  29393. iteratee = getIteratee(iteratee, 3);
  29394. baseForOwn(object, function(value, key, object) {
  29395. baseAssignValue(result, key, iteratee(value, key, object));
  29396. });
  29397. return result;
  29398. }
  29399. /**
  29400. * This method is like `_.assign` except that it recursively merges own and
  29401. * inherited enumerable string keyed properties of source objects into the
  29402. * destination object. Source properties that resolve to `undefined` are
  29403. * skipped if a destination value exists. Array and plain object properties
  29404. * are merged recursively. Other objects and value types are overridden by
  29405. * assignment. Source objects are applied from left to right. Subsequent
  29406. * sources overwrite property assignments of previous sources.
  29407. *
  29408. * **Note:** This method mutates `object`.
  29409. *
  29410. * @static
  29411. * @memberOf _
  29412. * @since 0.5.0
  29413. * @category Object
  29414. * @param {Object} object The destination object.
  29415. * @param {...Object} [sources] The source objects.
  29416. * @returns {Object} Returns `object`.
  29417. * @example
  29418. *
  29419. * var object = {
  29420. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29421. * };
  29422. *
  29423. * var other = {
  29424. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29425. * };
  29426. *
  29427. * _.merge(object, other);
  29428. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29429. */
  29430. var merge = createAssigner(function(object, source, srcIndex) {
  29431. baseMerge(object, source, srcIndex);
  29432. });
  29433. /**
  29434. * This method is like `_.merge` except that it accepts `customizer` which
  29435. * is invoked to produce the merged values of the destination and source
  29436. * properties. If `customizer` returns `undefined`, merging is handled by the
  29437. * method instead. The `customizer` is invoked with six arguments:
  29438. * (objValue, srcValue, key, object, source, stack).
  29439. *
  29440. * **Note:** This method mutates `object`.
  29441. *
  29442. * @static
  29443. * @memberOf _
  29444. * @since 4.0.0
  29445. * @category Object
  29446. * @param {Object} object The destination object.
  29447. * @param {...Object} sources The source objects.
  29448. * @param {Function} customizer The function to customize assigned values.
  29449. * @returns {Object} Returns `object`.
  29450. * @example
  29451. *
  29452. * function customizer(objValue, srcValue) {
  29453. * if (_.isArray(objValue)) {
  29454. * return objValue.concat(srcValue);
  29455. * }
  29456. * }
  29457. *
  29458. * var object = { 'a': [1], 'b': [2] };
  29459. * var other = { 'a': [3], 'b': [4] };
  29460. *
  29461. * _.mergeWith(object, other, customizer);
  29462. * // => { 'a': [1, 3], 'b': [2, 4] }
  29463. */
  29464. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29465. baseMerge(object, source, srcIndex, customizer);
  29466. });
  29467. /**
  29468. * The opposite of `_.pick`; this method creates an object composed of the
  29469. * own and inherited enumerable property paths of `object` that are not omitted.
  29470. *
  29471. * **Note:** This method is considerably slower than `_.pick`.
  29472. *
  29473. * @static
  29474. * @since 0.1.0
  29475. * @memberOf _
  29476. * @category Object
  29477. * @param {Object} object The source object.
  29478. * @param {...(string|string[])} [paths] The property paths to omit.
  29479. * @returns {Object} Returns the new object.
  29480. * @example
  29481. *
  29482. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29483. *
  29484. * _.omit(object, ['a', 'c']);
  29485. * // => { 'b': '2' }
  29486. */
  29487. var omit = flatRest(function(object, paths) {
  29488. var result = {};
  29489. if (object == null) {
  29490. return result;
  29491. }
  29492. var isDeep = false;
  29493. paths = arrayMap(paths, function(path) {
  29494. path = castPath(path, object);
  29495. isDeep || (isDeep = path.length > 1);
  29496. return path;
  29497. });
  29498. copyObject(object, getAllKeysIn(object), result);
  29499. if (isDeep) {
  29500. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29501. }
  29502. var length = paths.length;
  29503. while (length--) {
  29504. baseUnset(result, paths[length]);
  29505. }
  29506. return result;
  29507. });
  29508. /**
  29509. * The opposite of `_.pickBy`; this method creates an object composed of
  29510. * the own and inherited enumerable string keyed properties of `object` that
  29511. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29512. * arguments: (value, key).
  29513. *
  29514. * @static
  29515. * @memberOf _
  29516. * @since 4.0.0
  29517. * @category Object
  29518. * @param {Object} object The source object.
  29519. * @param {Function} [predicate=_.identity] The function invoked per property.
  29520. * @returns {Object} Returns the new object.
  29521. * @example
  29522. *
  29523. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29524. *
  29525. * _.omitBy(object, _.isNumber);
  29526. * // => { 'b': '2' }
  29527. */
  29528. function omitBy(object, predicate) {
  29529. return pickBy(object, negate(getIteratee(predicate)));
  29530. }
  29531. /**
  29532. * Creates an object composed of the picked `object` properties.
  29533. *
  29534. * @static
  29535. * @since 0.1.0
  29536. * @memberOf _
  29537. * @category Object
  29538. * @param {Object} object The source object.
  29539. * @param {...(string|string[])} [paths] The property paths to pick.
  29540. * @returns {Object} Returns the new object.
  29541. * @example
  29542. *
  29543. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29544. *
  29545. * _.pick(object, ['a', 'c']);
  29546. * // => { 'a': 1, 'c': 3 }
  29547. */
  29548. var pick = flatRest(function(object, paths) {
  29549. return object == null ? {} : basePick(object, paths);
  29550. });
  29551. /**
  29552. * Creates an object composed of the `object` properties `predicate` returns
  29553. * truthy for. The predicate is invoked with two arguments: (value, key).
  29554. *
  29555. * @static
  29556. * @memberOf _
  29557. * @since 4.0.0
  29558. * @category Object
  29559. * @param {Object} object The source object.
  29560. * @param {Function} [predicate=_.identity] The function invoked per property.
  29561. * @returns {Object} Returns the new object.
  29562. * @example
  29563. *
  29564. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29565. *
  29566. * _.pickBy(object, _.isNumber);
  29567. * // => { 'a': 1, 'c': 3 }
  29568. */
  29569. function pickBy(object, predicate) {
  29570. if (object == null) {
  29571. return {};
  29572. }
  29573. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29574. return [prop];
  29575. });
  29576. predicate = getIteratee(predicate);
  29577. return basePickBy(object, props, function(value, path) {
  29578. return predicate(value, path[0]);
  29579. });
  29580. }
  29581. /**
  29582. * This method is like `_.get` except that if the resolved value is a
  29583. * function it's invoked with the `this` binding of its parent object and
  29584. * its result is returned.
  29585. *
  29586. * @static
  29587. * @since 0.1.0
  29588. * @memberOf _
  29589. * @category Object
  29590. * @param {Object} object The object to query.
  29591. * @param {Array|string} path The path of the property to resolve.
  29592. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29593. * @returns {*} Returns the resolved value.
  29594. * @example
  29595. *
  29596. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29597. *
  29598. * _.result(object, 'a[0].b.c1');
  29599. * // => 3
  29600. *
  29601. * _.result(object, 'a[0].b.c2');
  29602. * // => 4
  29603. *
  29604. * _.result(object, 'a[0].b.c3', 'default');
  29605. * // => 'default'
  29606. *
  29607. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29608. * // => 'default'
  29609. */
  29610. function result(object, path, defaultValue) {
  29611. path = castPath(path, object);
  29612. var index = -1,
  29613. length = path.length;
  29614. // Ensure the loop is entered when path is empty.
  29615. if (!length) {
  29616. length = 1;
  29617. object = undefined;
  29618. }
  29619. while (++index < length) {
  29620. var value = object == null ? undefined : object[toKey(path[index])];
  29621. if (value === undefined) {
  29622. index = length;
  29623. value = defaultValue;
  29624. }
  29625. object = isFunction(value) ? value.call(object) : value;
  29626. }
  29627. return object;
  29628. }
  29629. /**
  29630. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29631. * it's created. Arrays are created for missing index properties while objects
  29632. * are created for all other missing properties. Use `_.setWith` to customize
  29633. * `path` creation.
  29634. *
  29635. * **Note:** This method mutates `object`.
  29636. *
  29637. * @static
  29638. * @memberOf _
  29639. * @since 3.7.0
  29640. * @category Object
  29641. * @param {Object} object The object to modify.
  29642. * @param {Array|string} path The path of the property to set.
  29643. * @param {*} value The value to set.
  29644. * @returns {Object} Returns `object`.
  29645. * @example
  29646. *
  29647. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29648. *
  29649. * _.set(object, 'a[0].b.c', 4);
  29650. * console.log(object.a[0].b.c);
  29651. * // => 4
  29652. *
  29653. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29654. * console.log(object.x[0].y.z);
  29655. * // => 5
  29656. */
  29657. function set(object, path, value) {
  29658. return object == null ? object : baseSet(object, path, value);
  29659. }
  29660. /**
  29661. * This method is like `_.set` except that it accepts `customizer` which is
  29662. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29663. * path creation is handled by the method instead. The `customizer` is invoked
  29664. * with three arguments: (nsValue, key, nsObject).
  29665. *
  29666. * **Note:** This method mutates `object`.
  29667. *
  29668. * @static
  29669. * @memberOf _
  29670. * @since 4.0.0
  29671. * @category Object
  29672. * @param {Object} object The object to modify.
  29673. * @param {Array|string} path The path of the property to set.
  29674. * @param {*} value The value to set.
  29675. * @param {Function} [customizer] The function to customize assigned values.
  29676. * @returns {Object} Returns `object`.
  29677. * @example
  29678. *
  29679. * var object = {};
  29680. *
  29681. * _.setWith(object, '[0][1]', 'a', Object);
  29682. * // => { '0': { '1': 'a' } }
  29683. */
  29684. function setWith(object, path, value, customizer) {
  29685. customizer = typeof customizer == 'function' ? customizer : undefined;
  29686. return object == null ? object : baseSet(object, path, value, customizer);
  29687. }
  29688. /**
  29689. * Creates an array of own enumerable string keyed-value pairs for `object`
  29690. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29691. * entries are returned.
  29692. *
  29693. * @static
  29694. * @memberOf _
  29695. * @since 4.0.0
  29696. * @alias entries
  29697. * @category Object
  29698. * @param {Object} object The object to query.
  29699. * @returns {Array} Returns the key-value pairs.
  29700. * @example
  29701. *
  29702. * function Foo() {
  29703. * this.a = 1;
  29704. * this.b = 2;
  29705. * }
  29706. *
  29707. * Foo.prototype.c = 3;
  29708. *
  29709. * _.toPairs(new Foo);
  29710. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29711. */
  29712. var toPairs = createToPairs(keys);
  29713. /**
  29714. * Creates an array of own and inherited enumerable string keyed-value pairs
  29715. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29716. * or set, its entries are returned.
  29717. *
  29718. * @static
  29719. * @memberOf _
  29720. * @since 4.0.0
  29721. * @alias entriesIn
  29722. * @category Object
  29723. * @param {Object} object The object to query.
  29724. * @returns {Array} Returns the key-value pairs.
  29725. * @example
  29726. *
  29727. * function Foo() {
  29728. * this.a = 1;
  29729. * this.b = 2;
  29730. * }
  29731. *
  29732. * Foo.prototype.c = 3;
  29733. *
  29734. * _.toPairsIn(new Foo);
  29735. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29736. */
  29737. var toPairsIn = createToPairs(keysIn);
  29738. /**
  29739. * An alternative to `_.reduce`; this method transforms `object` to a new
  29740. * `accumulator` object which is the result of running each of its own
  29741. * enumerable string keyed properties thru `iteratee`, with each invocation
  29742. * potentially mutating the `accumulator` object. If `accumulator` is not
  29743. * provided, a new object with the same `[[Prototype]]` will be used. The
  29744. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29745. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29746. *
  29747. * @static
  29748. * @memberOf _
  29749. * @since 1.3.0
  29750. * @category Object
  29751. * @param {Object} object The object to iterate over.
  29752. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29753. * @param {*} [accumulator] The custom accumulator value.
  29754. * @returns {*} Returns the accumulated value.
  29755. * @example
  29756. *
  29757. * _.transform([2, 3, 4], function(result, n) {
  29758. * result.push(n *= n);
  29759. * return n % 2 == 0;
  29760. * }, []);
  29761. * // => [4, 9]
  29762. *
  29763. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29764. * (result[value] || (result[value] = [])).push(key);
  29765. * }, {});
  29766. * // => { '1': ['a', 'c'], '2': ['b'] }
  29767. */
  29768. function transform(object, iteratee, accumulator) {
  29769. var isArr = isArray(object),
  29770. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29771. iteratee = getIteratee(iteratee, 4);
  29772. if (accumulator == null) {
  29773. var Ctor = object && object.constructor;
  29774. if (isArrLike) {
  29775. accumulator = isArr ? new Ctor : [];
  29776. }
  29777. else if (isObject(object)) {
  29778. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29779. }
  29780. else {
  29781. accumulator = {};
  29782. }
  29783. }
  29784. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29785. return iteratee(accumulator, value, index, object);
  29786. });
  29787. return accumulator;
  29788. }
  29789. /**
  29790. * Removes the property at `path` of `object`.
  29791. *
  29792. * **Note:** This method mutates `object`.
  29793. *
  29794. * @static
  29795. * @memberOf _
  29796. * @since 4.0.0
  29797. * @category Object
  29798. * @param {Object} object The object to modify.
  29799. * @param {Array|string} path The path of the property to unset.
  29800. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29801. * @example
  29802. *
  29803. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29804. * _.unset(object, 'a[0].b.c');
  29805. * // => true
  29806. *
  29807. * console.log(object);
  29808. * // => { 'a': [{ 'b': {} }] };
  29809. *
  29810. * _.unset(object, ['a', '0', 'b', 'c']);
  29811. * // => true
  29812. *
  29813. * console.log(object);
  29814. * // => { 'a': [{ 'b': {} }] };
  29815. */
  29816. function unset(object, path) {
  29817. return object == null ? true : baseUnset(object, path);
  29818. }
  29819. /**
  29820. * This method is like `_.set` except that accepts `updater` to produce the
  29821. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29822. * is invoked with one argument: (value).
  29823. *
  29824. * **Note:** This method mutates `object`.
  29825. *
  29826. * @static
  29827. * @memberOf _
  29828. * @since 4.6.0
  29829. * @category Object
  29830. * @param {Object} object The object to modify.
  29831. * @param {Array|string} path The path of the property to set.
  29832. * @param {Function} updater The function to produce the updated value.
  29833. * @returns {Object} Returns `object`.
  29834. * @example
  29835. *
  29836. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29837. *
  29838. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29839. * console.log(object.a[0].b.c);
  29840. * // => 9
  29841. *
  29842. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29843. * console.log(object.x[0].y.z);
  29844. * // => 0
  29845. */
  29846. function update(object, path, updater) {
  29847. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29848. }
  29849. /**
  29850. * This method is like `_.update` except that it accepts `customizer` which is
  29851. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29852. * path creation is handled by the method instead. The `customizer` is invoked
  29853. * with three arguments: (nsValue, key, nsObject).
  29854. *
  29855. * **Note:** This method mutates `object`.
  29856. *
  29857. * @static
  29858. * @memberOf _
  29859. * @since 4.6.0
  29860. * @category Object
  29861. * @param {Object} object The object to modify.
  29862. * @param {Array|string} path The path of the property to set.
  29863. * @param {Function} updater The function to produce the updated value.
  29864. * @param {Function} [customizer] The function to customize assigned values.
  29865. * @returns {Object} Returns `object`.
  29866. * @example
  29867. *
  29868. * var object = {};
  29869. *
  29870. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29871. * // => { '0': { '1': 'a' } }
  29872. */
  29873. function updateWith(object, path, updater, customizer) {
  29874. customizer = typeof customizer == 'function' ? customizer : undefined;
  29875. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29876. }
  29877. /**
  29878. * Creates an array of the own enumerable string keyed property values of `object`.
  29879. *
  29880. * **Note:** Non-object values are coerced to objects.
  29881. *
  29882. * @static
  29883. * @since 0.1.0
  29884. * @memberOf _
  29885. * @category Object
  29886. * @param {Object} object The object to query.
  29887. * @returns {Array} Returns the array of property values.
  29888. * @example
  29889. *
  29890. * function Foo() {
  29891. * this.a = 1;
  29892. * this.b = 2;
  29893. * }
  29894. *
  29895. * Foo.prototype.c = 3;
  29896. *
  29897. * _.values(new Foo);
  29898. * // => [1, 2] (iteration order is not guaranteed)
  29899. *
  29900. * _.values('hi');
  29901. * // => ['h', 'i']
  29902. */
  29903. function values(object) {
  29904. return object == null ? [] : baseValues(object, keys(object));
  29905. }
  29906. /**
  29907. * Creates an array of the own and inherited enumerable string keyed property
  29908. * values of `object`.
  29909. *
  29910. * **Note:** Non-object values are coerced to objects.
  29911. *
  29912. * @static
  29913. * @memberOf _
  29914. * @since 3.0.0
  29915. * @category Object
  29916. * @param {Object} object The object to query.
  29917. * @returns {Array} Returns the array of property values.
  29918. * @example
  29919. *
  29920. * function Foo() {
  29921. * this.a = 1;
  29922. * this.b = 2;
  29923. * }
  29924. *
  29925. * Foo.prototype.c = 3;
  29926. *
  29927. * _.valuesIn(new Foo);
  29928. * // => [1, 2, 3] (iteration order is not guaranteed)
  29929. */
  29930. function valuesIn(object) {
  29931. return object == null ? [] : baseValues(object, keysIn(object));
  29932. }
  29933. /*------------------------------------------------------------------------*/
  29934. /**
  29935. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29936. *
  29937. * @static
  29938. * @memberOf _
  29939. * @since 4.0.0
  29940. * @category Number
  29941. * @param {number} number The number to clamp.
  29942. * @param {number} [lower] The lower bound.
  29943. * @param {number} upper The upper bound.
  29944. * @returns {number} Returns the clamped number.
  29945. * @example
  29946. *
  29947. * _.clamp(-10, -5, 5);
  29948. * // => -5
  29949. *
  29950. * _.clamp(10, -5, 5);
  29951. * // => 5
  29952. */
  29953. function clamp(number, lower, upper) {
  29954. if (upper === undefined) {
  29955. upper = lower;
  29956. lower = undefined;
  29957. }
  29958. if (upper !== undefined) {
  29959. upper = toNumber(upper);
  29960. upper = upper === upper ? upper : 0;
  29961. }
  29962. if (lower !== undefined) {
  29963. lower = toNumber(lower);
  29964. lower = lower === lower ? lower : 0;
  29965. }
  29966. return baseClamp(toNumber(number), lower, upper);
  29967. }
  29968. /**
  29969. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29970. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29971. * If `start` is greater than `end` the params are swapped to support
  29972. * negative ranges.
  29973. *
  29974. * @static
  29975. * @memberOf _
  29976. * @since 3.3.0
  29977. * @category Number
  29978. * @param {number} number The number to check.
  29979. * @param {number} [start=0] The start of the range.
  29980. * @param {number} end The end of the range.
  29981. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29982. * @see _.range, _.rangeRight
  29983. * @example
  29984. *
  29985. * _.inRange(3, 2, 4);
  29986. * // => true
  29987. *
  29988. * _.inRange(4, 8);
  29989. * // => true
  29990. *
  29991. * _.inRange(4, 2);
  29992. * // => false
  29993. *
  29994. * _.inRange(2, 2);
  29995. * // => false
  29996. *
  29997. * _.inRange(1.2, 2);
  29998. * // => true
  29999. *
  30000. * _.inRange(5.2, 4);
  30001. * // => false
  30002. *
  30003. * _.inRange(-3, -2, -6);
  30004. * // => true
  30005. */
  30006. function inRange(number, start, end) {
  30007. start = toFinite(start);
  30008. if (end === undefined) {
  30009. end = start;
  30010. start = 0;
  30011. } else {
  30012. end = toFinite(end);
  30013. }
  30014. number = toNumber(number);
  30015. return baseInRange(number, start, end);
  30016. }
  30017. /**
  30018. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30019. * If only one argument is provided a number between `0` and the given number
  30020. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30021. * floats, a floating-point number is returned instead of an integer.
  30022. *
  30023. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30024. * floating-point values which can produce unexpected results.
  30025. *
  30026. * @static
  30027. * @memberOf _
  30028. * @since 0.7.0
  30029. * @category Number
  30030. * @param {number} [lower=0] The lower bound.
  30031. * @param {number} [upper=1] The upper bound.
  30032. * @param {boolean} [floating] Specify returning a floating-point number.
  30033. * @returns {number} Returns the random number.
  30034. * @example
  30035. *
  30036. * _.random(0, 5);
  30037. * // => an integer between 0 and 5
  30038. *
  30039. * _.random(5);
  30040. * // => also an integer between 0 and 5
  30041. *
  30042. * _.random(5, true);
  30043. * // => a floating-point number between 0 and 5
  30044. *
  30045. * _.random(1.2, 5.2);
  30046. * // => a floating-point number between 1.2 and 5.2
  30047. */
  30048. function random(lower, upper, floating) {
  30049. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30050. upper = floating = undefined;
  30051. }
  30052. if (floating === undefined) {
  30053. if (typeof upper == 'boolean') {
  30054. floating = upper;
  30055. upper = undefined;
  30056. }
  30057. else if (typeof lower == 'boolean') {
  30058. floating = lower;
  30059. lower = undefined;
  30060. }
  30061. }
  30062. if (lower === undefined && upper === undefined) {
  30063. lower = 0;
  30064. upper = 1;
  30065. }
  30066. else {
  30067. lower = toFinite(lower);
  30068. if (upper === undefined) {
  30069. upper = lower;
  30070. lower = 0;
  30071. } else {
  30072. upper = toFinite(upper);
  30073. }
  30074. }
  30075. if (lower > upper) {
  30076. var temp = lower;
  30077. lower = upper;
  30078. upper = temp;
  30079. }
  30080. if (floating || lower % 1 || upper % 1) {
  30081. var rand = nativeRandom();
  30082. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30083. }
  30084. return baseRandom(lower, upper);
  30085. }
  30086. /*------------------------------------------------------------------------*/
  30087. /**
  30088. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30089. *
  30090. * @static
  30091. * @memberOf _
  30092. * @since 3.0.0
  30093. * @category String
  30094. * @param {string} [string=''] The string to convert.
  30095. * @returns {string} Returns the camel cased string.
  30096. * @example
  30097. *
  30098. * _.camelCase('Foo Bar');
  30099. * // => 'fooBar'
  30100. *
  30101. * _.camelCase('--foo-bar--');
  30102. * // => 'fooBar'
  30103. *
  30104. * _.camelCase('__FOO_BAR__');
  30105. * // => 'fooBar'
  30106. */
  30107. var camelCase = createCompounder(function(result, word, index) {
  30108. word = word.toLowerCase();
  30109. return result + (index ? capitalize(word) : word);
  30110. });
  30111. /**
  30112. * Converts the first character of `string` to upper case and the remaining
  30113. * to lower case.
  30114. *
  30115. * @static
  30116. * @memberOf _
  30117. * @since 3.0.0
  30118. * @category String
  30119. * @param {string} [string=''] The string to capitalize.
  30120. * @returns {string} Returns the capitalized string.
  30121. * @example
  30122. *
  30123. * _.capitalize('FRED');
  30124. * // => 'Fred'
  30125. */
  30126. function capitalize(string) {
  30127. return upperFirst(toString(string).toLowerCase());
  30128. }
  30129. /**
  30130. * Deburrs `string` by converting
  30131. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30132. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30133. * letters to basic Latin letters and removing
  30134. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30135. *
  30136. * @static
  30137. * @memberOf _
  30138. * @since 3.0.0
  30139. * @category String
  30140. * @param {string} [string=''] The string to deburr.
  30141. * @returns {string} Returns the deburred string.
  30142. * @example
  30143. *
  30144. * _.deburr('déjà vu');
  30145. * // => 'deja vu'
  30146. */
  30147. function deburr(string) {
  30148. string = toString(string);
  30149. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30150. }
  30151. /**
  30152. * Checks if `string` ends with the given target string.
  30153. *
  30154. * @static
  30155. * @memberOf _
  30156. * @since 3.0.0
  30157. * @category String
  30158. * @param {string} [string=''] The string to inspect.
  30159. * @param {string} [target] The string to search for.
  30160. * @param {number} [position=string.length] The position to search up to.
  30161. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30162. * else `false`.
  30163. * @example
  30164. *
  30165. * _.endsWith('abc', 'c');
  30166. * // => true
  30167. *
  30168. * _.endsWith('abc', 'b');
  30169. * // => false
  30170. *
  30171. * _.endsWith('abc', 'b', 2);
  30172. * // => true
  30173. */
  30174. function endsWith(string, target, position) {
  30175. string = toString(string);
  30176. target = baseToString(target);
  30177. var length = string.length;
  30178. position = position === undefined
  30179. ? length
  30180. : baseClamp(toInteger(position), 0, length);
  30181. var end = position;
  30182. position -= target.length;
  30183. return position >= 0 && string.slice(position, end) == target;
  30184. }
  30185. /**
  30186. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30187. * corresponding HTML entities.
  30188. *
  30189. * **Note:** No other characters are escaped. To escape additional
  30190. * characters use a third-party library like [_he_](https://mths.be/he).
  30191. *
  30192. * Though the ">" character is escaped for symmetry, characters like
  30193. * ">" and "/" don't need escaping in HTML and have no special meaning
  30194. * unless they're part of a tag or unquoted attribute value. See
  30195. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30196. * (under "semi-related fun fact") for more details.
  30197. *
  30198. * When working with HTML you should always
  30199. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30200. * XSS vectors.
  30201. *
  30202. * @static
  30203. * @since 0.1.0
  30204. * @memberOf _
  30205. * @category String
  30206. * @param {string} [string=''] The string to escape.
  30207. * @returns {string} Returns the escaped string.
  30208. * @example
  30209. *
  30210. * _.escape('fred, barney, & pebbles');
  30211. * // => 'fred, barney, &amp; pebbles'
  30212. */
  30213. function escape(string) {
  30214. string = toString(string);
  30215. return (string && reHasUnescapedHtml.test(string))
  30216. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30217. : string;
  30218. }
  30219. /**
  30220. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30221. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30222. *
  30223. * @static
  30224. * @memberOf _
  30225. * @since 3.0.0
  30226. * @category String
  30227. * @param {string} [string=''] The string to escape.
  30228. * @returns {string} Returns the escaped string.
  30229. * @example
  30230. *
  30231. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30232. * // => '\[lodash\]\(https://lodash\.com/\)'
  30233. */
  30234. function escapeRegExp(string) {
  30235. string = toString(string);
  30236. return (string && reHasRegExpChar.test(string))
  30237. ? string.replace(reRegExpChar, '\\$&')
  30238. : string;
  30239. }
  30240. /**
  30241. * Converts `string` to
  30242. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30243. *
  30244. * @static
  30245. * @memberOf _
  30246. * @since 3.0.0
  30247. * @category String
  30248. * @param {string} [string=''] The string to convert.
  30249. * @returns {string} Returns the kebab cased string.
  30250. * @example
  30251. *
  30252. * _.kebabCase('Foo Bar');
  30253. * // => 'foo-bar'
  30254. *
  30255. * _.kebabCase('fooBar');
  30256. * // => 'foo-bar'
  30257. *
  30258. * _.kebabCase('__FOO_BAR__');
  30259. * // => 'foo-bar'
  30260. */
  30261. var kebabCase = createCompounder(function(result, word, index) {
  30262. return result + (index ? '-' : '') + word.toLowerCase();
  30263. });
  30264. /**
  30265. * Converts `string`, as space separated words, to lower case.
  30266. *
  30267. * @static
  30268. * @memberOf _
  30269. * @since 4.0.0
  30270. * @category String
  30271. * @param {string} [string=''] The string to convert.
  30272. * @returns {string} Returns the lower cased string.
  30273. * @example
  30274. *
  30275. * _.lowerCase('--Foo-Bar--');
  30276. * // => 'foo bar'
  30277. *
  30278. * _.lowerCase('fooBar');
  30279. * // => 'foo bar'
  30280. *
  30281. * _.lowerCase('__FOO_BAR__');
  30282. * // => 'foo bar'
  30283. */
  30284. var lowerCase = createCompounder(function(result, word, index) {
  30285. return result + (index ? ' ' : '') + word.toLowerCase();
  30286. });
  30287. /**
  30288. * Converts the first character of `string` to lower case.
  30289. *
  30290. * @static
  30291. * @memberOf _
  30292. * @since 4.0.0
  30293. * @category String
  30294. * @param {string} [string=''] The string to convert.
  30295. * @returns {string} Returns the converted string.
  30296. * @example
  30297. *
  30298. * _.lowerFirst('Fred');
  30299. * // => 'fred'
  30300. *
  30301. * _.lowerFirst('FRED');
  30302. * // => 'fRED'
  30303. */
  30304. var lowerFirst = createCaseFirst('toLowerCase');
  30305. /**
  30306. * Pads `string` on the left and right sides if it's shorter than `length`.
  30307. * Padding characters are truncated if they can't be evenly divided by `length`.
  30308. *
  30309. * @static
  30310. * @memberOf _
  30311. * @since 3.0.0
  30312. * @category String
  30313. * @param {string} [string=''] The string to pad.
  30314. * @param {number} [length=0] The padding length.
  30315. * @param {string} [chars=' '] The string used as padding.
  30316. * @returns {string} Returns the padded string.
  30317. * @example
  30318. *
  30319. * _.pad('abc', 8);
  30320. * // => ' abc '
  30321. *
  30322. * _.pad('abc', 8, '_-');
  30323. * // => '_-abc_-_'
  30324. *
  30325. * _.pad('abc', 3);
  30326. * // => 'abc'
  30327. */
  30328. function pad(string, length, chars) {
  30329. string = toString(string);
  30330. length = toInteger(length);
  30331. var strLength = length ? stringSize(string) : 0;
  30332. if (!length || strLength >= length) {
  30333. return string;
  30334. }
  30335. var mid = (length - strLength) / 2;
  30336. return (
  30337. createPadding(nativeFloor(mid), chars) +
  30338. string +
  30339. createPadding(nativeCeil(mid), chars)
  30340. );
  30341. }
  30342. /**
  30343. * Pads `string` on the right side if it's shorter than `length`. Padding
  30344. * characters are truncated if they exceed `length`.
  30345. *
  30346. * @static
  30347. * @memberOf _
  30348. * @since 4.0.0
  30349. * @category String
  30350. * @param {string} [string=''] The string to pad.
  30351. * @param {number} [length=0] The padding length.
  30352. * @param {string} [chars=' '] The string used as padding.
  30353. * @returns {string} Returns the padded string.
  30354. * @example
  30355. *
  30356. * _.padEnd('abc', 6);
  30357. * // => 'abc '
  30358. *
  30359. * _.padEnd('abc', 6, '_-');
  30360. * // => 'abc_-_'
  30361. *
  30362. * _.padEnd('abc', 3);
  30363. * // => 'abc'
  30364. */
  30365. function padEnd(string, length, chars) {
  30366. string = toString(string);
  30367. length = toInteger(length);
  30368. var strLength = length ? stringSize(string) : 0;
  30369. return (length && strLength < length)
  30370. ? (string + createPadding(length - strLength, chars))
  30371. : string;
  30372. }
  30373. /**
  30374. * Pads `string` on the left side if it's shorter than `length`. Padding
  30375. * characters are truncated if they exceed `length`.
  30376. *
  30377. * @static
  30378. * @memberOf _
  30379. * @since 4.0.0
  30380. * @category String
  30381. * @param {string} [string=''] The string to pad.
  30382. * @param {number} [length=0] The padding length.
  30383. * @param {string} [chars=' '] The string used as padding.
  30384. * @returns {string} Returns the padded string.
  30385. * @example
  30386. *
  30387. * _.padStart('abc', 6);
  30388. * // => ' abc'
  30389. *
  30390. * _.padStart('abc', 6, '_-');
  30391. * // => '_-_abc'
  30392. *
  30393. * _.padStart('abc', 3);
  30394. * // => 'abc'
  30395. */
  30396. function padStart(string, length, chars) {
  30397. string = toString(string);
  30398. length = toInteger(length);
  30399. var strLength = length ? stringSize(string) : 0;
  30400. return (length && strLength < length)
  30401. ? (createPadding(length - strLength, chars) + string)
  30402. : string;
  30403. }
  30404. /**
  30405. * Converts `string` to an integer of the specified radix. If `radix` is
  30406. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30407. * hexadecimal, in which case a `radix` of `16` is used.
  30408. *
  30409. * **Note:** This method aligns with the
  30410. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30411. *
  30412. * @static
  30413. * @memberOf _
  30414. * @since 1.1.0
  30415. * @category String
  30416. * @param {string} string The string to convert.
  30417. * @param {number} [radix=10] The radix to interpret `value` by.
  30418. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30419. * @returns {number} Returns the converted integer.
  30420. * @example
  30421. *
  30422. * _.parseInt('08');
  30423. * // => 8
  30424. *
  30425. * _.map(['6', '08', '10'], _.parseInt);
  30426. * // => [6, 8, 10]
  30427. */
  30428. function parseInt(string, radix, guard) {
  30429. if (guard || radix == null) {
  30430. radix = 0;
  30431. } else if (radix) {
  30432. radix = +radix;
  30433. }
  30434. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30435. }
  30436. /**
  30437. * Repeats the given string `n` times.
  30438. *
  30439. * @static
  30440. * @memberOf _
  30441. * @since 3.0.0
  30442. * @category String
  30443. * @param {string} [string=''] The string to repeat.
  30444. * @param {number} [n=1] The number of times to repeat the string.
  30445. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30446. * @returns {string} Returns the repeated string.
  30447. * @example
  30448. *
  30449. * _.repeat('*', 3);
  30450. * // => '***'
  30451. *
  30452. * _.repeat('abc', 2);
  30453. * // => 'abcabc'
  30454. *
  30455. * _.repeat('abc', 0);
  30456. * // => ''
  30457. */
  30458. function repeat(string, n, guard) {
  30459. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30460. n = 1;
  30461. } else {
  30462. n = toInteger(n);
  30463. }
  30464. return baseRepeat(toString(string), n);
  30465. }
  30466. /**
  30467. * Replaces matches for `pattern` in `string` with `replacement`.
  30468. *
  30469. * **Note:** This method is based on
  30470. * [`String#replace`](https://mdn.io/String/replace).
  30471. *
  30472. * @static
  30473. * @memberOf _
  30474. * @since 4.0.0
  30475. * @category String
  30476. * @param {string} [string=''] The string to modify.
  30477. * @param {RegExp|string} pattern The pattern to replace.
  30478. * @param {Function|string} replacement The match replacement.
  30479. * @returns {string} Returns the modified string.
  30480. * @example
  30481. *
  30482. * _.replace('Hi Fred', 'Fred', 'Barney');
  30483. * // => 'Hi Barney'
  30484. */
  30485. function replace() {
  30486. var args = arguments,
  30487. string = toString(args[0]);
  30488. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30489. }
  30490. /**
  30491. * Converts `string` to
  30492. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30493. *
  30494. * @static
  30495. * @memberOf _
  30496. * @since 3.0.0
  30497. * @category String
  30498. * @param {string} [string=''] The string to convert.
  30499. * @returns {string} Returns the snake cased string.
  30500. * @example
  30501. *
  30502. * _.snakeCase('Foo Bar');
  30503. * // => 'foo_bar'
  30504. *
  30505. * _.snakeCase('fooBar');
  30506. * // => 'foo_bar'
  30507. *
  30508. * _.snakeCase('--FOO-BAR--');
  30509. * // => 'foo_bar'
  30510. */
  30511. var snakeCase = createCompounder(function(result, word, index) {
  30512. return result + (index ? '_' : '') + word.toLowerCase();
  30513. });
  30514. /**
  30515. * Splits `string` by `separator`.
  30516. *
  30517. * **Note:** This method is based on
  30518. * [`String#split`](https://mdn.io/String/split).
  30519. *
  30520. * @static
  30521. * @memberOf _
  30522. * @since 4.0.0
  30523. * @category String
  30524. * @param {string} [string=''] The string to split.
  30525. * @param {RegExp|string} separator The separator pattern to split by.
  30526. * @param {number} [limit] The length to truncate results to.
  30527. * @returns {Array} Returns the string segments.
  30528. * @example
  30529. *
  30530. * _.split('a-b-c', '-', 2);
  30531. * // => ['a', 'b']
  30532. */
  30533. function split(string, separator, limit) {
  30534. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30535. separator = limit = undefined;
  30536. }
  30537. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30538. if (!limit) {
  30539. return [];
  30540. }
  30541. string = toString(string);
  30542. if (string && (
  30543. typeof separator == 'string' ||
  30544. (separator != null && !isRegExp(separator))
  30545. )) {
  30546. separator = baseToString(separator);
  30547. if (!separator && hasUnicode(string)) {
  30548. return castSlice(stringToArray(string), 0, limit);
  30549. }
  30550. }
  30551. return string.split(separator, limit);
  30552. }
  30553. /**
  30554. * Converts `string` to
  30555. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30556. *
  30557. * @static
  30558. * @memberOf _
  30559. * @since 3.1.0
  30560. * @category String
  30561. * @param {string} [string=''] The string to convert.
  30562. * @returns {string} Returns the start cased string.
  30563. * @example
  30564. *
  30565. * _.startCase('--foo-bar--');
  30566. * // => 'Foo Bar'
  30567. *
  30568. * _.startCase('fooBar');
  30569. * // => 'Foo Bar'
  30570. *
  30571. * _.startCase('__FOO_BAR__');
  30572. * // => 'FOO BAR'
  30573. */
  30574. var startCase = createCompounder(function(result, word, index) {
  30575. return result + (index ? ' ' : '') + upperFirst(word);
  30576. });
  30577. /**
  30578. * Checks if `string` starts with the given target string.
  30579. *
  30580. * @static
  30581. * @memberOf _
  30582. * @since 3.0.0
  30583. * @category String
  30584. * @param {string} [string=''] The string to inspect.
  30585. * @param {string} [target] The string to search for.
  30586. * @param {number} [position=0] The position to search from.
  30587. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30588. * else `false`.
  30589. * @example
  30590. *
  30591. * _.startsWith('abc', 'a');
  30592. * // => true
  30593. *
  30594. * _.startsWith('abc', 'b');
  30595. * // => false
  30596. *
  30597. * _.startsWith('abc', 'b', 1);
  30598. * // => true
  30599. */
  30600. function startsWith(string, target, position) {
  30601. string = toString(string);
  30602. position = position == null
  30603. ? 0
  30604. : baseClamp(toInteger(position), 0, string.length);
  30605. target = baseToString(target);
  30606. return string.slice(position, position + target.length) == target;
  30607. }
  30608. /**
  30609. * Creates a compiled template function that can interpolate data properties
  30610. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30611. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30612. * properties may be accessed as free variables in the template. If a setting
  30613. * object is given, it takes precedence over `_.templateSettings` values.
  30614. *
  30615. * **Note:** In the development build `_.template` utilizes
  30616. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30617. * for easier debugging.
  30618. *
  30619. * For more information on precompiling templates see
  30620. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30621. *
  30622. * For more information on Chrome extension sandboxes see
  30623. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30624. *
  30625. * @static
  30626. * @since 0.1.0
  30627. * @memberOf _
  30628. * @category String
  30629. * @param {string} [string=''] The template string.
  30630. * @param {Object} [options={}] The options object.
  30631. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30632. * The HTML "escape" delimiter.
  30633. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30634. * The "evaluate" delimiter.
  30635. * @param {Object} [options.imports=_.templateSettings.imports]
  30636. * An object to import into the template as free variables.
  30637. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30638. * The "interpolate" delimiter.
  30639. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30640. * The sourceURL of the compiled template.
  30641. * @param {string} [options.variable='obj']
  30642. * The data object variable name.
  30643. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30644. * @returns {Function} Returns the compiled template function.
  30645. * @example
  30646. *
  30647. * // Use the "interpolate" delimiter to create a compiled template.
  30648. * var compiled = _.template('hello <%= user %>!');
  30649. * compiled({ 'user': 'fred' });
  30650. * // => 'hello fred!'
  30651. *
  30652. * // Use the HTML "escape" delimiter to escape data property values.
  30653. * var compiled = _.template('<b><%- value %></b>');
  30654. * compiled({ 'value': '<script>' });
  30655. * // => '<b>&lt;script&gt;</b>'
  30656. *
  30657. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30658. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30659. * compiled({ 'users': ['fred', 'barney'] });
  30660. * // => '<li>fred</li><li>barney</li>'
  30661. *
  30662. * // Use the internal `print` function in "evaluate" delimiters.
  30663. * var compiled = _.template('<% print("hello " + user); %>!');
  30664. * compiled({ 'user': 'barney' });
  30665. * // => 'hello barney!'
  30666. *
  30667. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30668. * // Disable support by replacing the "interpolate" delimiter.
  30669. * var compiled = _.template('hello ${ user }!');
  30670. * compiled({ 'user': 'pebbles' });
  30671. * // => 'hello pebbles!'
  30672. *
  30673. * // Use backslashes to treat delimiters as plain text.
  30674. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30675. * compiled({ 'value': 'ignored' });
  30676. * // => '<%- value %>'
  30677. *
  30678. * // Use the `imports` option to import `jQuery` as `jq`.
  30679. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30680. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30681. * compiled({ 'users': ['fred', 'barney'] });
  30682. * // => '<li>fred</li><li>barney</li>'
  30683. *
  30684. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30685. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30686. * compiled(data);
  30687. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30688. *
  30689. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30690. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30691. * compiled.source;
  30692. * // => function(data) {
  30693. * // var __t, __p = '';
  30694. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30695. * // return __p;
  30696. * // }
  30697. *
  30698. * // Use custom template delimiters.
  30699. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30700. * var compiled = _.template('hello {{ user }}!');
  30701. * compiled({ 'user': 'mustache' });
  30702. * // => 'hello mustache!'
  30703. *
  30704. * // Use the `source` property to inline compiled templates for meaningful
  30705. * // line numbers in error messages and stack traces.
  30706. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30707. * var JST = {\
  30708. * "main": ' + _.template(mainText).source + '\
  30709. * };\
  30710. * ');
  30711. */
  30712. function template(string, options, guard) {
  30713. // Based on John Resig's `tmpl` implementation
  30714. // (http://ejohn.org/blog/javascript-micro-templating/)
  30715. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30716. var settings = lodash.templateSettings;
  30717. if (guard && isIterateeCall(string, options, guard)) {
  30718. options = undefined;
  30719. }
  30720. string = toString(string);
  30721. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30722. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30723. importsKeys = keys(imports),
  30724. importsValues = baseValues(imports, importsKeys);
  30725. var isEscaping,
  30726. isEvaluating,
  30727. index = 0,
  30728. interpolate = options.interpolate || reNoMatch,
  30729. source = "__p += '";
  30730. // Compile the regexp to match each delimiter.
  30731. var reDelimiters = RegExp(
  30732. (options.escape || reNoMatch).source + '|' +
  30733. interpolate.source + '|' +
  30734. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30735. (options.evaluate || reNoMatch).source + '|$'
  30736. , 'g');
  30737. // Use a sourceURL for easier debugging.
  30738. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30739. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30740. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30741. var sourceURL = '//# sourceURL=' +
  30742. (hasOwnProperty.call(options, 'sourceURL')
  30743. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30744. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30745. ) + '\n';
  30746. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30747. interpolateValue || (interpolateValue = esTemplateValue);
  30748. // Escape characters that can't be included in string literals.
  30749. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30750. // Replace delimiters with snippets.
  30751. if (escapeValue) {
  30752. isEscaping = true;
  30753. source += "' +\n__e(" + escapeValue + ") +\n'";
  30754. }
  30755. if (evaluateValue) {
  30756. isEvaluating = true;
  30757. source += "';\n" + evaluateValue + ";\n__p += '";
  30758. }
  30759. if (interpolateValue) {
  30760. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30761. }
  30762. index = offset + match.length;
  30763. // The JS engine embedded in Adobe products needs `match` returned in
  30764. // order to produce the correct `offset` value.
  30765. return match;
  30766. });
  30767. source += "';\n";
  30768. // If `variable` is not specified wrap a with-statement around the generated
  30769. // code to add the data object to the top of the scope chain.
  30770. // Like with sourceURL, we take care to not check the option's prototype,
  30771. // as this configuration is a code injection vector.
  30772. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30773. if (!variable) {
  30774. source = 'with (obj) {\n' + source + '\n}\n';
  30775. }
  30776. // Cleanup code by stripping empty strings.
  30777. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30778. .replace(reEmptyStringMiddle, '$1')
  30779. .replace(reEmptyStringTrailing, '$1;');
  30780. // Frame code as the function body.
  30781. source = 'function(' + (variable || 'obj') + ') {\n' +
  30782. (variable
  30783. ? ''
  30784. : 'obj || (obj = {});\n'
  30785. ) +
  30786. "var __t, __p = ''" +
  30787. (isEscaping
  30788. ? ', __e = _.escape'
  30789. : ''
  30790. ) +
  30791. (isEvaluating
  30792. ? ', __j = Array.prototype.join;\n' +
  30793. "function print() { __p += __j.call(arguments, '') }\n"
  30794. : ';\n'
  30795. ) +
  30796. source +
  30797. 'return __p\n}';
  30798. var result = attempt(function() {
  30799. return Function(importsKeys, sourceURL + 'return ' + source)
  30800. .apply(undefined, importsValues);
  30801. });
  30802. // Provide the compiled function's source by its `toString` method or
  30803. // the `source` property as a convenience for inlining compiled templates.
  30804. result.source = source;
  30805. if (isError(result)) {
  30806. throw result;
  30807. }
  30808. return result;
  30809. }
  30810. /**
  30811. * Converts `string`, as a whole, to lower case just like
  30812. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30813. *
  30814. * @static
  30815. * @memberOf _
  30816. * @since 4.0.0
  30817. * @category String
  30818. * @param {string} [string=''] The string to convert.
  30819. * @returns {string} Returns the lower cased string.
  30820. * @example
  30821. *
  30822. * _.toLower('--Foo-Bar--');
  30823. * // => '--foo-bar--'
  30824. *
  30825. * _.toLower('fooBar');
  30826. * // => 'foobar'
  30827. *
  30828. * _.toLower('__FOO_BAR__');
  30829. * // => '__foo_bar__'
  30830. */
  30831. function toLower(value) {
  30832. return toString(value).toLowerCase();
  30833. }
  30834. /**
  30835. * Converts `string`, as a whole, to upper case just like
  30836. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30837. *
  30838. * @static
  30839. * @memberOf _
  30840. * @since 4.0.0
  30841. * @category String
  30842. * @param {string} [string=''] The string to convert.
  30843. * @returns {string} Returns the upper cased string.
  30844. * @example
  30845. *
  30846. * _.toUpper('--foo-bar--');
  30847. * // => '--FOO-BAR--'
  30848. *
  30849. * _.toUpper('fooBar');
  30850. * // => 'FOOBAR'
  30851. *
  30852. * _.toUpper('__foo_bar__');
  30853. * // => '__FOO_BAR__'
  30854. */
  30855. function toUpper(value) {
  30856. return toString(value).toUpperCase();
  30857. }
  30858. /**
  30859. * Removes leading and trailing whitespace or specified characters from `string`.
  30860. *
  30861. * @static
  30862. * @memberOf _
  30863. * @since 3.0.0
  30864. * @category String
  30865. * @param {string} [string=''] The string to trim.
  30866. * @param {string} [chars=whitespace] The characters to trim.
  30867. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30868. * @returns {string} Returns the trimmed string.
  30869. * @example
  30870. *
  30871. * _.trim(' abc ');
  30872. * // => 'abc'
  30873. *
  30874. * _.trim('-_-abc-_-', '_-');
  30875. * // => 'abc'
  30876. *
  30877. * _.map([' foo ', ' bar '], _.trim);
  30878. * // => ['foo', 'bar']
  30879. */
  30880. function trim(string, chars, guard) {
  30881. string = toString(string);
  30882. if (string && (guard || chars === undefined)) {
  30883. return string.replace(reTrim, '');
  30884. }
  30885. if (!string || !(chars = baseToString(chars))) {
  30886. return string;
  30887. }
  30888. var strSymbols = stringToArray(string),
  30889. chrSymbols = stringToArray(chars),
  30890. start = charsStartIndex(strSymbols, chrSymbols),
  30891. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30892. return castSlice(strSymbols, start, end).join('');
  30893. }
  30894. /**
  30895. * Removes trailing whitespace or specified characters from `string`.
  30896. *
  30897. * @static
  30898. * @memberOf _
  30899. * @since 4.0.0
  30900. * @category String
  30901. * @param {string} [string=''] The string to trim.
  30902. * @param {string} [chars=whitespace] The characters to trim.
  30903. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30904. * @returns {string} Returns the trimmed string.
  30905. * @example
  30906. *
  30907. * _.trimEnd(' abc ');
  30908. * // => ' abc'
  30909. *
  30910. * _.trimEnd('-_-abc-_-', '_-');
  30911. * // => '-_-abc'
  30912. */
  30913. function trimEnd(string, chars, guard) {
  30914. string = toString(string);
  30915. if (string && (guard || chars === undefined)) {
  30916. return string.replace(reTrimEnd, '');
  30917. }
  30918. if (!string || !(chars = baseToString(chars))) {
  30919. return string;
  30920. }
  30921. var strSymbols = stringToArray(string),
  30922. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30923. return castSlice(strSymbols, 0, end).join('');
  30924. }
  30925. /**
  30926. * Removes leading whitespace or specified characters from `string`.
  30927. *
  30928. * @static
  30929. * @memberOf _
  30930. * @since 4.0.0
  30931. * @category String
  30932. * @param {string} [string=''] The string to trim.
  30933. * @param {string} [chars=whitespace] The characters to trim.
  30934. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30935. * @returns {string} Returns the trimmed string.
  30936. * @example
  30937. *
  30938. * _.trimStart(' abc ');
  30939. * // => 'abc '
  30940. *
  30941. * _.trimStart('-_-abc-_-', '_-');
  30942. * // => 'abc-_-'
  30943. */
  30944. function trimStart(string, chars, guard) {
  30945. string = toString(string);
  30946. if (string && (guard || chars === undefined)) {
  30947. return string.replace(reTrimStart, '');
  30948. }
  30949. if (!string || !(chars = baseToString(chars))) {
  30950. return string;
  30951. }
  30952. var strSymbols = stringToArray(string),
  30953. start = charsStartIndex(strSymbols, stringToArray(chars));
  30954. return castSlice(strSymbols, start).join('');
  30955. }
  30956. /**
  30957. * Truncates `string` if it's longer than the given maximum string length.
  30958. * The last characters of the truncated string are replaced with the omission
  30959. * string which defaults to "...".
  30960. *
  30961. * @static
  30962. * @memberOf _
  30963. * @since 4.0.0
  30964. * @category String
  30965. * @param {string} [string=''] The string to truncate.
  30966. * @param {Object} [options={}] The options object.
  30967. * @param {number} [options.length=30] The maximum string length.
  30968. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30969. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30970. * @returns {string} Returns the truncated string.
  30971. * @example
  30972. *
  30973. * _.truncate('hi-diddly-ho there, neighborino');
  30974. * // => 'hi-diddly-ho there, neighbo...'
  30975. *
  30976. * _.truncate('hi-diddly-ho there, neighborino', {
  30977. * 'length': 24,
  30978. * 'separator': ' '
  30979. * });
  30980. * // => 'hi-diddly-ho there,...'
  30981. *
  30982. * _.truncate('hi-diddly-ho there, neighborino', {
  30983. * 'length': 24,
  30984. * 'separator': /,? +/
  30985. * });
  30986. * // => 'hi-diddly-ho there...'
  30987. *
  30988. * _.truncate('hi-diddly-ho there, neighborino', {
  30989. * 'omission': ' [...]'
  30990. * });
  30991. * // => 'hi-diddly-ho there, neig [...]'
  30992. */
  30993. function truncate(string, options) {
  30994. var length = DEFAULT_TRUNC_LENGTH,
  30995. omission = DEFAULT_TRUNC_OMISSION;
  30996. if (isObject(options)) {
  30997. var separator = 'separator' in options ? options.separator : separator;
  30998. length = 'length' in options ? toInteger(options.length) : length;
  30999. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31000. }
  31001. string = toString(string);
  31002. var strLength = string.length;
  31003. if (hasUnicode(string)) {
  31004. var strSymbols = stringToArray(string);
  31005. strLength = strSymbols.length;
  31006. }
  31007. if (length >= strLength) {
  31008. return string;
  31009. }
  31010. var end = length - stringSize(omission);
  31011. if (end < 1) {
  31012. return omission;
  31013. }
  31014. var result = strSymbols
  31015. ? castSlice(strSymbols, 0, end).join('')
  31016. : string.slice(0, end);
  31017. if (separator === undefined) {
  31018. return result + omission;
  31019. }
  31020. if (strSymbols) {
  31021. end += (result.length - end);
  31022. }
  31023. if (isRegExp(separator)) {
  31024. if (string.slice(end).search(separator)) {
  31025. var match,
  31026. substring = result;
  31027. if (!separator.global) {
  31028. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31029. }
  31030. separator.lastIndex = 0;
  31031. while ((match = separator.exec(substring))) {
  31032. var newEnd = match.index;
  31033. }
  31034. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31035. }
  31036. } else if (string.indexOf(baseToString(separator), end) != end) {
  31037. var index = result.lastIndexOf(separator);
  31038. if (index > -1) {
  31039. result = result.slice(0, index);
  31040. }
  31041. }
  31042. return result + omission;
  31043. }
  31044. /**
  31045. * The inverse of `_.escape`; this method converts the HTML entities
  31046. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31047. * their corresponding characters.
  31048. *
  31049. * **Note:** No other HTML entities are unescaped. To unescape additional
  31050. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31051. *
  31052. * @static
  31053. * @memberOf _
  31054. * @since 0.6.0
  31055. * @category String
  31056. * @param {string} [string=''] The string to unescape.
  31057. * @returns {string} Returns the unescaped string.
  31058. * @example
  31059. *
  31060. * _.unescape('fred, barney, &amp; pebbles');
  31061. * // => 'fred, barney, & pebbles'
  31062. */
  31063. function unescape(string) {
  31064. string = toString(string);
  31065. return (string && reHasEscapedHtml.test(string))
  31066. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31067. : string;
  31068. }
  31069. /**
  31070. * Converts `string`, as space separated words, to upper case.
  31071. *
  31072. * @static
  31073. * @memberOf _
  31074. * @since 4.0.0
  31075. * @category String
  31076. * @param {string} [string=''] The string to convert.
  31077. * @returns {string} Returns the upper cased string.
  31078. * @example
  31079. *
  31080. * _.upperCase('--foo-bar');
  31081. * // => 'FOO BAR'
  31082. *
  31083. * _.upperCase('fooBar');
  31084. * // => 'FOO BAR'
  31085. *
  31086. * _.upperCase('__foo_bar__');
  31087. * // => 'FOO BAR'
  31088. */
  31089. var upperCase = createCompounder(function(result, word, index) {
  31090. return result + (index ? ' ' : '') + word.toUpperCase();
  31091. });
  31092. /**
  31093. * Converts the first character of `string` to upper case.
  31094. *
  31095. * @static
  31096. * @memberOf _
  31097. * @since 4.0.0
  31098. * @category String
  31099. * @param {string} [string=''] The string to convert.
  31100. * @returns {string} Returns the converted string.
  31101. * @example
  31102. *
  31103. * _.upperFirst('fred');
  31104. * // => 'Fred'
  31105. *
  31106. * _.upperFirst('FRED');
  31107. * // => 'FRED'
  31108. */
  31109. var upperFirst = createCaseFirst('toUpperCase');
  31110. /**
  31111. * Splits `string` into an array of its words.
  31112. *
  31113. * @static
  31114. * @memberOf _
  31115. * @since 3.0.0
  31116. * @category String
  31117. * @param {string} [string=''] The string to inspect.
  31118. * @param {RegExp|string} [pattern] The pattern to match words.
  31119. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31120. * @returns {Array} Returns the words of `string`.
  31121. * @example
  31122. *
  31123. * _.words('fred, barney, & pebbles');
  31124. * // => ['fred', 'barney', 'pebbles']
  31125. *
  31126. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31127. * // => ['fred', 'barney', '&', 'pebbles']
  31128. */
  31129. function words(string, pattern, guard) {
  31130. string = toString(string);
  31131. pattern = guard ? undefined : pattern;
  31132. if (pattern === undefined) {
  31133. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31134. }
  31135. return string.match(pattern) || [];
  31136. }
  31137. /*------------------------------------------------------------------------*/
  31138. /**
  31139. * Attempts to invoke `func`, returning either the result or the caught error
  31140. * object. Any additional arguments are provided to `func` when it's invoked.
  31141. *
  31142. * @static
  31143. * @memberOf _
  31144. * @since 3.0.0
  31145. * @category Util
  31146. * @param {Function} func The function to attempt.
  31147. * @param {...*} [args] The arguments to invoke `func` with.
  31148. * @returns {*} Returns the `func` result or error object.
  31149. * @example
  31150. *
  31151. * // Avoid throwing errors for invalid selectors.
  31152. * var elements = _.attempt(function(selector) {
  31153. * return document.querySelectorAll(selector);
  31154. * }, '>_>');
  31155. *
  31156. * if (_.isError(elements)) {
  31157. * elements = [];
  31158. * }
  31159. */
  31160. var attempt = baseRest(function(func, args) {
  31161. try {
  31162. return apply(func, undefined, args);
  31163. } catch (e) {
  31164. return isError(e) ? e : new Error(e);
  31165. }
  31166. });
  31167. /**
  31168. * Binds methods of an object to the object itself, overwriting the existing
  31169. * method.
  31170. *
  31171. * **Note:** This method doesn't set the "length" property of bound functions.
  31172. *
  31173. * @static
  31174. * @since 0.1.0
  31175. * @memberOf _
  31176. * @category Util
  31177. * @param {Object} object The object to bind and assign the bound methods to.
  31178. * @param {...(string|string[])} methodNames The object method names to bind.
  31179. * @returns {Object} Returns `object`.
  31180. * @example
  31181. *
  31182. * var view = {
  31183. * 'label': 'docs',
  31184. * 'click': function() {
  31185. * console.log('clicked ' + this.label);
  31186. * }
  31187. * };
  31188. *
  31189. * _.bindAll(view, ['click']);
  31190. * jQuery(element).on('click', view.click);
  31191. * // => Logs 'clicked docs' when clicked.
  31192. */
  31193. var bindAll = flatRest(function(object, methodNames) {
  31194. arrayEach(methodNames, function(key) {
  31195. key = toKey(key);
  31196. baseAssignValue(object, key, bind(object[key], object));
  31197. });
  31198. return object;
  31199. });
  31200. /**
  31201. * Creates a function that iterates over `pairs` and invokes the corresponding
  31202. * function of the first predicate to return truthy. The predicate-function
  31203. * pairs are invoked with the `this` binding and arguments of the created
  31204. * function.
  31205. *
  31206. * @static
  31207. * @memberOf _
  31208. * @since 4.0.0
  31209. * @category Util
  31210. * @param {Array} pairs The predicate-function pairs.
  31211. * @returns {Function} Returns the new composite function.
  31212. * @example
  31213. *
  31214. * var func = _.cond([
  31215. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31216. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31217. * [_.stubTrue, _.constant('no match')]
  31218. * ]);
  31219. *
  31220. * func({ 'a': 1, 'b': 2 });
  31221. * // => 'matches A'
  31222. *
  31223. * func({ 'a': 0, 'b': 1 });
  31224. * // => 'matches B'
  31225. *
  31226. * func({ 'a': '1', 'b': '2' });
  31227. * // => 'no match'
  31228. */
  31229. function cond(pairs) {
  31230. var length = pairs == null ? 0 : pairs.length,
  31231. toIteratee = getIteratee();
  31232. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31233. if (typeof pair[1] != 'function') {
  31234. throw new TypeError(FUNC_ERROR_TEXT);
  31235. }
  31236. return [toIteratee(pair[0]), pair[1]];
  31237. });
  31238. return baseRest(function(args) {
  31239. var index = -1;
  31240. while (++index < length) {
  31241. var pair = pairs[index];
  31242. if (apply(pair[0], this, args)) {
  31243. return apply(pair[1], this, args);
  31244. }
  31245. }
  31246. });
  31247. }
  31248. /**
  31249. * Creates a function that invokes the predicate properties of `source` with
  31250. * the corresponding property values of a given object, returning `true` if
  31251. * all predicates return truthy, else `false`.
  31252. *
  31253. * **Note:** The created function is equivalent to `_.conformsTo` with
  31254. * `source` partially applied.
  31255. *
  31256. * @static
  31257. * @memberOf _
  31258. * @since 4.0.0
  31259. * @category Util
  31260. * @param {Object} source The object of property predicates to conform to.
  31261. * @returns {Function} Returns the new spec function.
  31262. * @example
  31263. *
  31264. * var objects = [
  31265. * { 'a': 2, 'b': 1 },
  31266. * { 'a': 1, 'b': 2 }
  31267. * ];
  31268. *
  31269. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31270. * // => [{ 'a': 1, 'b': 2 }]
  31271. */
  31272. function conforms(source) {
  31273. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31274. }
  31275. /**
  31276. * Creates a function that returns `value`.
  31277. *
  31278. * @static
  31279. * @memberOf _
  31280. * @since 2.4.0
  31281. * @category Util
  31282. * @param {*} value The value to return from the new function.
  31283. * @returns {Function} Returns the new constant function.
  31284. * @example
  31285. *
  31286. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31287. *
  31288. * console.log(objects);
  31289. * // => [{ 'a': 1 }, { 'a': 1 }]
  31290. *
  31291. * console.log(objects[0] === objects[1]);
  31292. * // => true
  31293. */
  31294. function constant(value) {
  31295. return function() {
  31296. return value;
  31297. };
  31298. }
  31299. /**
  31300. * Checks `value` to determine whether a default value should be returned in
  31301. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31302. * or `undefined`.
  31303. *
  31304. * @static
  31305. * @memberOf _
  31306. * @since 4.14.0
  31307. * @category Util
  31308. * @param {*} value The value to check.
  31309. * @param {*} defaultValue The default value.
  31310. * @returns {*} Returns the resolved value.
  31311. * @example
  31312. *
  31313. * _.defaultTo(1, 10);
  31314. * // => 1
  31315. *
  31316. * _.defaultTo(undefined, 10);
  31317. * // => 10
  31318. */
  31319. function defaultTo(value, defaultValue) {
  31320. return (value == null || value !== value) ? defaultValue : value;
  31321. }
  31322. /**
  31323. * Creates a function that returns the result of invoking the given functions
  31324. * with the `this` binding of the created function, where each successive
  31325. * invocation is supplied the return value of the previous.
  31326. *
  31327. * @static
  31328. * @memberOf _
  31329. * @since 3.0.0
  31330. * @category Util
  31331. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31332. * @returns {Function} Returns the new composite function.
  31333. * @see _.flowRight
  31334. * @example
  31335. *
  31336. * function square(n) {
  31337. * return n * n;
  31338. * }
  31339. *
  31340. * var addSquare = _.flow([_.add, square]);
  31341. * addSquare(1, 2);
  31342. * // => 9
  31343. */
  31344. var flow = createFlow();
  31345. /**
  31346. * This method is like `_.flow` except that it creates a function that
  31347. * invokes the given functions from right to left.
  31348. *
  31349. * @static
  31350. * @since 3.0.0
  31351. * @memberOf _
  31352. * @category Util
  31353. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31354. * @returns {Function} Returns the new composite function.
  31355. * @see _.flow
  31356. * @example
  31357. *
  31358. * function square(n) {
  31359. * return n * n;
  31360. * }
  31361. *
  31362. * var addSquare = _.flowRight([square, _.add]);
  31363. * addSquare(1, 2);
  31364. * // => 9
  31365. */
  31366. var flowRight = createFlow(true);
  31367. /**
  31368. * This method returns the first argument it receives.
  31369. *
  31370. * @static
  31371. * @since 0.1.0
  31372. * @memberOf _
  31373. * @category Util
  31374. * @param {*} value Any value.
  31375. * @returns {*} Returns `value`.
  31376. * @example
  31377. *
  31378. * var object = { 'a': 1 };
  31379. *
  31380. * console.log(_.identity(object) === object);
  31381. * // => true
  31382. */
  31383. function identity(value) {
  31384. return value;
  31385. }
  31386. /**
  31387. * Creates a function that invokes `func` with the arguments of the created
  31388. * function. If `func` is a property name, the created function returns the
  31389. * property value for a given element. If `func` is an array or object, the
  31390. * created function returns `true` for elements that contain the equivalent
  31391. * source properties, otherwise it returns `false`.
  31392. *
  31393. * @static
  31394. * @since 4.0.0
  31395. * @memberOf _
  31396. * @category Util
  31397. * @param {*} [func=_.identity] The value to convert to a callback.
  31398. * @returns {Function} Returns the callback.
  31399. * @example
  31400. *
  31401. * var users = [
  31402. * { 'user': 'barney', 'age': 36, 'active': true },
  31403. * { 'user': 'fred', 'age': 40, 'active': false }
  31404. * ];
  31405. *
  31406. * // The `_.matches` iteratee shorthand.
  31407. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31408. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31409. *
  31410. * // The `_.matchesProperty` iteratee shorthand.
  31411. * _.filter(users, _.iteratee(['user', 'fred']));
  31412. * // => [{ 'user': 'fred', 'age': 40 }]
  31413. *
  31414. * // The `_.property` iteratee shorthand.
  31415. * _.map(users, _.iteratee('user'));
  31416. * // => ['barney', 'fred']
  31417. *
  31418. * // Create custom iteratee shorthands.
  31419. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31420. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31421. * return func.test(string);
  31422. * };
  31423. * });
  31424. *
  31425. * _.filter(['abc', 'def'], /ef/);
  31426. * // => ['def']
  31427. */
  31428. function iteratee(func) {
  31429. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31430. }
  31431. /**
  31432. * Creates a function that performs a partial deep comparison between a given
  31433. * object and `source`, returning `true` if the given object has equivalent
  31434. * property values, else `false`.
  31435. *
  31436. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31437. * partially applied.
  31438. *
  31439. * Partial comparisons will match empty array and empty object `source`
  31440. * values against any array or object value, respectively. See `_.isEqual`
  31441. * for a list of supported value comparisons.
  31442. *
  31443. * @static
  31444. * @memberOf _
  31445. * @since 3.0.0
  31446. * @category Util
  31447. * @param {Object} source The object of property values to match.
  31448. * @returns {Function} Returns the new spec function.
  31449. * @example
  31450. *
  31451. * var objects = [
  31452. * { 'a': 1, 'b': 2, 'c': 3 },
  31453. * { 'a': 4, 'b': 5, 'c': 6 }
  31454. * ];
  31455. *
  31456. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31457. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31458. */
  31459. function matches(source) {
  31460. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31461. }
  31462. /**
  31463. * Creates a function that performs a partial deep comparison between the
  31464. * value at `path` of a given object to `srcValue`, returning `true` if the
  31465. * object value is equivalent, else `false`.
  31466. *
  31467. * **Note:** Partial comparisons will match empty array and empty object
  31468. * `srcValue` values against any array or object value, respectively. See
  31469. * `_.isEqual` for a list of supported value comparisons.
  31470. *
  31471. * @static
  31472. * @memberOf _
  31473. * @since 3.2.0
  31474. * @category Util
  31475. * @param {Array|string} path The path of the property to get.
  31476. * @param {*} srcValue The value to match.
  31477. * @returns {Function} Returns the new spec function.
  31478. * @example
  31479. *
  31480. * var objects = [
  31481. * { 'a': 1, 'b': 2, 'c': 3 },
  31482. * { 'a': 4, 'b': 5, 'c': 6 }
  31483. * ];
  31484. *
  31485. * _.find(objects, _.matchesProperty('a', 4));
  31486. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31487. */
  31488. function matchesProperty(path, srcValue) {
  31489. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31490. }
  31491. /**
  31492. * Creates a function that invokes the method at `path` of a given object.
  31493. * Any additional arguments are provided to the invoked method.
  31494. *
  31495. * @static
  31496. * @memberOf _
  31497. * @since 3.7.0
  31498. * @category Util
  31499. * @param {Array|string} path The path of the method to invoke.
  31500. * @param {...*} [args] The arguments to invoke the method with.
  31501. * @returns {Function} Returns the new invoker function.
  31502. * @example
  31503. *
  31504. * var objects = [
  31505. * { 'a': { 'b': _.constant(2) } },
  31506. * { 'a': { 'b': _.constant(1) } }
  31507. * ];
  31508. *
  31509. * _.map(objects, _.method('a.b'));
  31510. * // => [2, 1]
  31511. *
  31512. * _.map(objects, _.method(['a', 'b']));
  31513. * // => [2, 1]
  31514. */
  31515. var method = baseRest(function(path, args) {
  31516. return function(object) {
  31517. return baseInvoke(object, path, args);
  31518. };
  31519. });
  31520. /**
  31521. * The opposite of `_.method`; this method creates a function that invokes
  31522. * the method at a given path of `object`. Any additional arguments are
  31523. * provided to the invoked method.
  31524. *
  31525. * @static
  31526. * @memberOf _
  31527. * @since 3.7.0
  31528. * @category Util
  31529. * @param {Object} object The object to query.
  31530. * @param {...*} [args] The arguments to invoke the method with.
  31531. * @returns {Function} Returns the new invoker function.
  31532. * @example
  31533. *
  31534. * var array = _.times(3, _.constant),
  31535. * object = { 'a': array, 'b': array, 'c': array };
  31536. *
  31537. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31538. * // => [2, 0]
  31539. *
  31540. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31541. * // => [2, 0]
  31542. */
  31543. var methodOf = baseRest(function(object, args) {
  31544. return function(path) {
  31545. return baseInvoke(object, path, args);
  31546. };
  31547. });
  31548. /**
  31549. * Adds all own enumerable string keyed function properties of a source
  31550. * object to the destination object. If `object` is a function, then methods
  31551. * are added to its prototype as well.
  31552. *
  31553. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31554. * avoid conflicts caused by modifying the original.
  31555. *
  31556. * @static
  31557. * @since 0.1.0
  31558. * @memberOf _
  31559. * @category Util
  31560. * @param {Function|Object} [object=lodash] The destination object.
  31561. * @param {Object} source The object of functions to add.
  31562. * @param {Object} [options={}] The options object.
  31563. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31564. * @returns {Function|Object} Returns `object`.
  31565. * @example
  31566. *
  31567. * function vowels(string) {
  31568. * return _.filter(string, function(v) {
  31569. * return /[aeiou]/i.test(v);
  31570. * });
  31571. * }
  31572. *
  31573. * _.mixin({ 'vowels': vowels });
  31574. * _.vowels('fred');
  31575. * // => ['e']
  31576. *
  31577. * _('fred').vowels().value();
  31578. * // => ['e']
  31579. *
  31580. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31581. * _('fred').vowels();
  31582. * // => ['e']
  31583. */
  31584. function mixin(object, source, options) {
  31585. var props = keys(source),
  31586. methodNames = baseFunctions(source, props);
  31587. if (options == null &&
  31588. !(isObject(source) && (methodNames.length || !props.length))) {
  31589. options = source;
  31590. source = object;
  31591. object = this;
  31592. methodNames = baseFunctions(source, keys(source));
  31593. }
  31594. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31595. isFunc = isFunction(object);
  31596. arrayEach(methodNames, function(methodName) {
  31597. var func = source[methodName];
  31598. object[methodName] = func;
  31599. if (isFunc) {
  31600. object.prototype[methodName] = function() {
  31601. var chainAll = this.__chain__;
  31602. if (chain || chainAll) {
  31603. var result = object(this.__wrapped__),
  31604. actions = result.__actions__ = copyArray(this.__actions__);
  31605. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31606. result.__chain__ = chainAll;
  31607. return result;
  31608. }
  31609. return func.apply(object, arrayPush([this.value()], arguments));
  31610. };
  31611. }
  31612. });
  31613. return object;
  31614. }
  31615. /**
  31616. * Reverts the `_` variable to its previous value and returns a reference to
  31617. * the `lodash` function.
  31618. *
  31619. * @static
  31620. * @since 0.1.0
  31621. * @memberOf _
  31622. * @category Util
  31623. * @returns {Function} Returns the `lodash` function.
  31624. * @example
  31625. *
  31626. * var lodash = _.noConflict();
  31627. */
  31628. function noConflict() {
  31629. if (root._ === this) {
  31630. root._ = oldDash;
  31631. }
  31632. return this;
  31633. }
  31634. /**
  31635. * This method returns `undefined`.
  31636. *
  31637. * @static
  31638. * @memberOf _
  31639. * @since 2.3.0
  31640. * @category Util
  31641. * @example
  31642. *
  31643. * _.times(2, _.noop);
  31644. * // => [undefined, undefined]
  31645. */
  31646. function noop() {
  31647. // No operation performed.
  31648. }
  31649. /**
  31650. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31651. * the nth argument from the end is returned.
  31652. *
  31653. * @static
  31654. * @memberOf _
  31655. * @since 4.0.0
  31656. * @category Util
  31657. * @param {number} [n=0] The index of the argument to return.
  31658. * @returns {Function} Returns the new pass-thru function.
  31659. * @example
  31660. *
  31661. * var func = _.nthArg(1);
  31662. * func('a', 'b', 'c', 'd');
  31663. * // => 'b'
  31664. *
  31665. * var func = _.nthArg(-2);
  31666. * func('a', 'b', 'c', 'd');
  31667. * // => 'c'
  31668. */
  31669. function nthArg(n) {
  31670. n = toInteger(n);
  31671. return baseRest(function(args) {
  31672. return baseNth(args, n);
  31673. });
  31674. }
  31675. /**
  31676. * Creates a function that invokes `iteratees` with the arguments it receives
  31677. * and returns their results.
  31678. *
  31679. * @static
  31680. * @memberOf _
  31681. * @since 4.0.0
  31682. * @category Util
  31683. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31684. * The iteratees to invoke.
  31685. * @returns {Function} Returns the new function.
  31686. * @example
  31687. *
  31688. * var func = _.over([Math.max, Math.min]);
  31689. *
  31690. * func(1, 2, 3, 4);
  31691. * // => [4, 1]
  31692. */
  31693. var over = createOver(arrayMap);
  31694. /**
  31695. * Creates a function that checks if **all** of the `predicates` return
  31696. * truthy when invoked with the arguments it receives.
  31697. *
  31698. * @static
  31699. * @memberOf _
  31700. * @since 4.0.0
  31701. * @category Util
  31702. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31703. * The predicates to check.
  31704. * @returns {Function} Returns the new function.
  31705. * @example
  31706. *
  31707. * var func = _.overEvery([Boolean, isFinite]);
  31708. *
  31709. * func('1');
  31710. * // => true
  31711. *
  31712. * func(null);
  31713. * // => false
  31714. *
  31715. * func(NaN);
  31716. * // => false
  31717. */
  31718. var overEvery = createOver(arrayEvery);
  31719. /**
  31720. * Creates a function that checks if **any** of the `predicates` return
  31721. * truthy when invoked with the arguments it receives.
  31722. *
  31723. * @static
  31724. * @memberOf _
  31725. * @since 4.0.0
  31726. * @category Util
  31727. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31728. * The predicates to check.
  31729. * @returns {Function} Returns the new function.
  31730. * @example
  31731. *
  31732. * var func = _.overSome([Boolean, isFinite]);
  31733. *
  31734. * func('1');
  31735. * // => true
  31736. *
  31737. * func(null);
  31738. * // => true
  31739. *
  31740. * func(NaN);
  31741. * // => false
  31742. */
  31743. var overSome = createOver(arraySome);
  31744. /**
  31745. * Creates a function that returns the value at `path` of a given object.
  31746. *
  31747. * @static
  31748. * @memberOf _
  31749. * @since 2.4.0
  31750. * @category Util
  31751. * @param {Array|string} path The path of the property to get.
  31752. * @returns {Function} Returns the new accessor function.
  31753. * @example
  31754. *
  31755. * var objects = [
  31756. * { 'a': { 'b': 2 } },
  31757. * { 'a': { 'b': 1 } }
  31758. * ];
  31759. *
  31760. * _.map(objects, _.property('a.b'));
  31761. * // => [2, 1]
  31762. *
  31763. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31764. * // => [1, 2]
  31765. */
  31766. function property(path) {
  31767. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31768. }
  31769. /**
  31770. * The opposite of `_.property`; this method creates a function that returns
  31771. * the value at a given path of `object`.
  31772. *
  31773. * @static
  31774. * @memberOf _
  31775. * @since 3.0.0
  31776. * @category Util
  31777. * @param {Object} object The object to query.
  31778. * @returns {Function} Returns the new accessor function.
  31779. * @example
  31780. *
  31781. * var array = [0, 1, 2],
  31782. * object = { 'a': array, 'b': array, 'c': array };
  31783. *
  31784. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31785. * // => [2, 0]
  31786. *
  31787. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31788. * // => [2, 0]
  31789. */
  31790. function propertyOf(object) {
  31791. return function(path) {
  31792. return object == null ? undefined : baseGet(object, path);
  31793. };
  31794. }
  31795. /**
  31796. * Creates an array of numbers (positive and/or negative) progressing from
  31797. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31798. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31799. * it's set to `start` with `start` then set to `0`.
  31800. *
  31801. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31802. * floating-point values which can produce unexpected results.
  31803. *
  31804. * @static
  31805. * @since 0.1.0
  31806. * @memberOf _
  31807. * @category Util
  31808. * @param {number} [start=0] The start of the range.
  31809. * @param {number} end The end of the range.
  31810. * @param {number} [step=1] The value to increment or decrement by.
  31811. * @returns {Array} Returns the range of numbers.
  31812. * @see _.inRange, _.rangeRight
  31813. * @example
  31814. *
  31815. * _.range(4);
  31816. * // => [0, 1, 2, 3]
  31817. *
  31818. * _.range(-4);
  31819. * // => [0, -1, -2, -3]
  31820. *
  31821. * _.range(1, 5);
  31822. * // => [1, 2, 3, 4]
  31823. *
  31824. * _.range(0, 20, 5);
  31825. * // => [0, 5, 10, 15]
  31826. *
  31827. * _.range(0, -4, -1);
  31828. * // => [0, -1, -2, -3]
  31829. *
  31830. * _.range(1, 4, 0);
  31831. * // => [1, 1, 1]
  31832. *
  31833. * _.range(0);
  31834. * // => []
  31835. */
  31836. var range = createRange();
  31837. /**
  31838. * This method is like `_.range` except that it populates values in
  31839. * descending order.
  31840. *
  31841. * @static
  31842. * @memberOf _
  31843. * @since 4.0.0
  31844. * @category Util
  31845. * @param {number} [start=0] The start of the range.
  31846. * @param {number} end The end of the range.
  31847. * @param {number} [step=1] The value to increment or decrement by.
  31848. * @returns {Array} Returns the range of numbers.
  31849. * @see _.inRange, _.range
  31850. * @example
  31851. *
  31852. * _.rangeRight(4);
  31853. * // => [3, 2, 1, 0]
  31854. *
  31855. * _.rangeRight(-4);
  31856. * // => [-3, -2, -1, 0]
  31857. *
  31858. * _.rangeRight(1, 5);
  31859. * // => [4, 3, 2, 1]
  31860. *
  31861. * _.rangeRight(0, 20, 5);
  31862. * // => [15, 10, 5, 0]
  31863. *
  31864. * _.rangeRight(0, -4, -1);
  31865. * // => [-3, -2, -1, 0]
  31866. *
  31867. * _.rangeRight(1, 4, 0);
  31868. * // => [1, 1, 1]
  31869. *
  31870. * _.rangeRight(0);
  31871. * // => []
  31872. */
  31873. var rangeRight = createRange(true);
  31874. /**
  31875. * This method returns a new empty array.
  31876. *
  31877. * @static
  31878. * @memberOf _
  31879. * @since 4.13.0
  31880. * @category Util
  31881. * @returns {Array} Returns the new empty array.
  31882. * @example
  31883. *
  31884. * var arrays = _.times(2, _.stubArray);
  31885. *
  31886. * console.log(arrays);
  31887. * // => [[], []]
  31888. *
  31889. * console.log(arrays[0] === arrays[1]);
  31890. * // => false
  31891. */
  31892. function stubArray() {
  31893. return [];
  31894. }
  31895. /**
  31896. * This method returns `false`.
  31897. *
  31898. * @static
  31899. * @memberOf _
  31900. * @since 4.13.0
  31901. * @category Util
  31902. * @returns {boolean} Returns `false`.
  31903. * @example
  31904. *
  31905. * _.times(2, _.stubFalse);
  31906. * // => [false, false]
  31907. */
  31908. function stubFalse() {
  31909. return false;
  31910. }
  31911. /**
  31912. * This method returns a new empty object.
  31913. *
  31914. * @static
  31915. * @memberOf _
  31916. * @since 4.13.0
  31917. * @category Util
  31918. * @returns {Object} Returns the new empty object.
  31919. * @example
  31920. *
  31921. * var objects = _.times(2, _.stubObject);
  31922. *
  31923. * console.log(objects);
  31924. * // => [{}, {}]
  31925. *
  31926. * console.log(objects[0] === objects[1]);
  31927. * // => false
  31928. */
  31929. function stubObject() {
  31930. return {};
  31931. }
  31932. /**
  31933. * This method returns an empty string.
  31934. *
  31935. * @static
  31936. * @memberOf _
  31937. * @since 4.13.0
  31938. * @category Util
  31939. * @returns {string} Returns the empty string.
  31940. * @example
  31941. *
  31942. * _.times(2, _.stubString);
  31943. * // => ['', '']
  31944. */
  31945. function stubString() {
  31946. return '';
  31947. }
  31948. /**
  31949. * This method returns `true`.
  31950. *
  31951. * @static
  31952. * @memberOf _
  31953. * @since 4.13.0
  31954. * @category Util
  31955. * @returns {boolean} Returns `true`.
  31956. * @example
  31957. *
  31958. * _.times(2, _.stubTrue);
  31959. * // => [true, true]
  31960. */
  31961. function stubTrue() {
  31962. return true;
  31963. }
  31964. /**
  31965. * Invokes the iteratee `n` times, returning an array of the results of
  31966. * each invocation. The iteratee is invoked with one argument; (index).
  31967. *
  31968. * @static
  31969. * @since 0.1.0
  31970. * @memberOf _
  31971. * @category Util
  31972. * @param {number} n The number of times to invoke `iteratee`.
  31973. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31974. * @returns {Array} Returns the array of results.
  31975. * @example
  31976. *
  31977. * _.times(3, String);
  31978. * // => ['0', '1', '2']
  31979. *
  31980. * _.times(4, _.constant(0));
  31981. * // => [0, 0, 0, 0]
  31982. */
  31983. function times(n, iteratee) {
  31984. n = toInteger(n);
  31985. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31986. return [];
  31987. }
  31988. var index = MAX_ARRAY_LENGTH,
  31989. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31990. iteratee = getIteratee(iteratee);
  31991. n -= MAX_ARRAY_LENGTH;
  31992. var result = baseTimes(length, iteratee);
  31993. while (++index < n) {
  31994. iteratee(index);
  31995. }
  31996. return result;
  31997. }
  31998. /**
  31999. * Converts `value` to a property path array.
  32000. *
  32001. * @static
  32002. * @memberOf _
  32003. * @since 4.0.0
  32004. * @category Util
  32005. * @param {*} value The value to convert.
  32006. * @returns {Array} Returns the new property path array.
  32007. * @example
  32008. *
  32009. * _.toPath('a.b.c');
  32010. * // => ['a', 'b', 'c']
  32011. *
  32012. * _.toPath('a[0].b.c');
  32013. * // => ['a', '0', 'b', 'c']
  32014. */
  32015. function toPath(value) {
  32016. if (isArray(value)) {
  32017. return arrayMap(value, toKey);
  32018. }
  32019. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32020. }
  32021. /**
  32022. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32023. *
  32024. * @static
  32025. * @since 0.1.0
  32026. * @memberOf _
  32027. * @category Util
  32028. * @param {string} [prefix=''] The value to prefix the ID with.
  32029. * @returns {string} Returns the unique ID.
  32030. * @example
  32031. *
  32032. * _.uniqueId('contact_');
  32033. * // => 'contact_104'
  32034. *
  32035. * _.uniqueId();
  32036. * // => '105'
  32037. */
  32038. function uniqueId(prefix) {
  32039. var id = ++idCounter;
  32040. return toString(prefix) + id;
  32041. }
  32042. /*------------------------------------------------------------------------*/
  32043. /**
  32044. * Adds two numbers.
  32045. *
  32046. * @static
  32047. * @memberOf _
  32048. * @since 3.4.0
  32049. * @category Math
  32050. * @param {number} augend The first number in an addition.
  32051. * @param {number} addend The second number in an addition.
  32052. * @returns {number} Returns the total.
  32053. * @example
  32054. *
  32055. * _.add(6, 4);
  32056. * // => 10
  32057. */
  32058. var add = createMathOperation(function(augend, addend) {
  32059. return augend + addend;
  32060. }, 0);
  32061. /**
  32062. * Computes `number` rounded up to `precision`.
  32063. *
  32064. * @static
  32065. * @memberOf _
  32066. * @since 3.10.0
  32067. * @category Math
  32068. * @param {number} number The number to round up.
  32069. * @param {number} [precision=0] The precision to round up to.
  32070. * @returns {number} Returns the rounded up number.
  32071. * @example
  32072. *
  32073. * _.ceil(4.006);
  32074. * // => 5
  32075. *
  32076. * _.ceil(6.004, 2);
  32077. * // => 6.01
  32078. *
  32079. * _.ceil(6040, -2);
  32080. * // => 6100
  32081. */
  32082. var ceil = createRound('ceil');
  32083. /**
  32084. * Divide two numbers.
  32085. *
  32086. * @static
  32087. * @memberOf _
  32088. * @since 4.7.0
  32089. * @category Math
  32090. * @param {number} dividend The first number in a division.
  32091. * @param {number} divisor The second number in a division.
  32092. * @returns {number} Returns the quotient.
  32093. * @example
  32094. *
  32095. * _.divide(6, 4);
  32096. * // => 1.5
  32097. */
  32098. var divide = createMathOperation(function(dividend, divisor) {
  32099. return dividend / divisor;
  32100. }, 1);
  32101. /**
  32102. * Computes `number` rounded down to `precision`.
  32103. *
  32104. * @static
  32105. * @memberOf _
  32106. * @since 3.10.0
  32107. * @category Math
  32108. * @param {number} number The number to round down.
  32109. * @param {number} [precision=0] The precision to round down to.
  32110. * @returns {number} Returns the rounded down number.
  32111. * @example
  32112. *
  32113. * _.floor(4.006);
  32114. * // => 4
  32115. *
  32116. * _.floor(0.046, 2);
  32117. * // => 0.04
  32118. *
  32119. * _.floor(4060, -2);
  32120. * // => 4000
  32121. */
  32122. var floor = createRound('floor');
  32123. /**
  32124. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32125. * `undefined` is returned.
  32126. *
  32127. * @static
  32128. * @since 0.1.0
  32129. * @memberOf _
  32130. * @category Math
  32131. * @param {Array} array The array to iterate over.
  32132. * @returns {*} Returns the maximum value.
  32133. * @example
  32134. *
  32135. * _.max([4, 2, 8, 6]);
  32136. * // => 8
  32137. *
  32138. * _.max([]);
  32139. * // => undefined
  32140. */
  32141. function max(array) {
  32142. return (array && array.length)
  32143. ? baseExtremum(array, identity, baseGt)
  32144. : undefined;
  32145. }
  32146. /**
  32147. * This method is like `_.max` except that it accepts `iteratee` which is
  32148. * invoked for each element in `array` to generate the criterion by which
  32149. * the value is ranked. The iteratee is invoked with one argument: (value).
  32150. *
  32151. * @static
  32152. * @memberOf _
  32153. * @since 4.0.0
  32154. * @category Math
  32155. * @param {Array} array The array to iterate over.
  32156. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32157. * @returns {*} Returns the maximum value.
  32158. * @example
  32159. *
  32160. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32161. *
  32162. * _.maxBy(objects, function(o) { return o.n; });
  32163. * // => { 'n': 2 }
  32164. *
  32165. * // The `_.property` iteratee shorthand.
  32166. * _.maxBy(objects, 'n');
  32167. * // => { 'n': 2 }
  32168. */
  32169. function maxBy(array, iteratee) {
  32170. return (array && array.length)
  32171. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32172. : undefined;
  32173. }
  32174. /**
  32175. * Computes the mean of the values in `array`.
  32176. *
  32177. * @static
  32178. * @memberOf _
  32179. * @since 4.0.0
  32180. * @category Math
  32181. * @param {Array} array The array to iterate over.
  32182. * @returns {number} Returns the mean.
  32183. * @example
  32184. *
  32185. * _.mean([4, 2, 8, 6]);
  32186. * // => 5
  32187. */
  32188. function mean(array) {
  32189. return baseMean(array, identity);
  32190. }
  32191. /**
  32192. * This method is like `_.mean` except that it accepts `iteratee` which is
  32193. * invoked for each element in `array` to generate the value to be averaged.
  32194. * The iteratee is invoked with one argument: (value).
  32195. *
  32196. * @static
  32197. * @memberOf _
  32198. * @since 4.7.0
  32199. * @category Math
  32200. * @param {Array} array The array to iterate over.
  32201. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32202. * @returns {number} Returns the mean.
  32203. * @example
  32204. *
  32205. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32206. *
  32207. * _.meanBy(objects, function(o) { return o.n; });
  32208. * // => 5
  32209. *
  32210. * // The `_.property` iteratee shorthand.
  32211. * _.meanBy(objects, 'n');
  32212. * // => 5
  32213. */
  32214. function meanBy(array, iteratee) {
  32215. return baseMean(array, getIteratee(iteratee, 2));
  32216. }
  32217. /**
  32218. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32219. * `undefined` is returned.
  32220. *
  32221. * @static
  32222. * @since 0.1.0
  32223. * @memberOf _
  32224. * @category Math
  32225. * @param {Array} array The array to iterate over.
  32226. * @returns {*} Returns the minimum value.
  32227. * @example
  32228. *
  32229. * _.min([4, 2, 8, 6]);
  32230. * // => 2
  32231. *
  32232. * _.min([]);
  32233. * // => undefined
  32234. */
  32235. function min(array) {
  32236. return (array && array.length)
  32237. ? baseExtremum(array, identity, baseLt)
  32238. : undefined;
  32239. }
  32240. /**
  32241. * This method is like `_.min` except that it accepts `iteratee` which is
  32242. * invoked for each element in `array` to generate the criterion by which
  32243. * the value is ranked. The iteratee is invoked with one argument: (value).
  32244. *
  32245. * @static
  32246. * @memberOf _
  32247. * @since 4.0.0
  32248. * @category Math
  32249. * @param {Array} array The array to iterate over.
  32250. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32251. * @returns {*} Returns the minimum value.
  32252. * @example
  32253. *
  32254. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32255. *
  32256. * _.minBy(objects, function(o) { return o.n; });
  32257. * // => { 'n': 1 }
  32258. *
  32259. * // The `_.property` iteratee shorthand.
  32260. * _.minBy(objects, 'n');
  32261. * // => { 'n': 1 }
  32262. */
  32263. function minBy(array, iteratee) {
  32264. return (array && array.length)
  32265. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32266. : undefined;
  32267. }
  32268. /**
  32269. * Multiply two numbers.
  32270. *
  32271. * @static
  32272. * @memberOf _
  32273. * @since 4.7.0
  32274. * @category Math
  32275. * @param {number} multiplier The first number in a multiplication.
  32276. * @param {number} multiplicand The second number in a multiplication.
  32277. * @returns {number} Returns the product.
  32278. * @example
  32279. *
  32280. * _.multiply(6, 4);
  32281. * // => 24
  32282. */
  32283. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32284. return multiplier * multiplicand;
  32285. }, 1);
  32286. /**
  32287. * Computes `number` rounded to `precision`.
  32288. *
  32289. * @static
  32290. * @memberOf _
  32291. * @since 3.10.0
  32292. * @category Math
  32293. * @param {number} number The number to round.
  32294. * @param {number} [precision=0] The precision to round to.
  32295. * @returns {number} Returns the rounded number.
  32296. * @example
  32297. *
  32298. * _.round(4.006);
  32299. * // => 4
  32300. *
  32301. * _.round(4.006, 2);
  32302. * // => 4.01
  32303. *
  32304. * _.round(4060, -2);
  32305. * // => 4100
  32306. */
  32307. var round = createRound('round');
  32308. /**
  32309. * Subtract two numbers.
  32310. *
  32311. * @static
  32312. * @memberOf _
  32313. * @since 4.0.0
  32314. * @category Math
  32315. * @param {number} minuend The first number in a subtraction.
  32316. * @param {number} subtrahend The second number in a subtraction.
  32317. * @returns {number} Returns the difference.
  32318. * @example
  32319. *
  32320. * _.subtract(6, 4);
  32321. * // => 2
  32322. */
  32323. var subtract = createMathOperation(function(minuend, subtrahend) {
  32324. return minuend - subtrahend;
  32325. }, 0);
  32326. /**
  32327. * Computes the sum of the values in `array`.
  32328. *
  32329. * @static
  32330. * @memberOf _
  32331. * @since 3.4.0
  32332. * @category Math
  32333. * @param {Array} array The array to iterate over.
  32334. * @returns {number} Returns the sum.
  32335. * @example
  32336. *
  32337. * _.sum([4, 2, 8, 6]);
  32338. * // => 20
  32339. */
  32340. function sum(array) {
  32341. return (array && array.length)
  32342. ? baseSum(array, identity)
  32343. : 0;
  32344. }
  32345. /**
  32346. * This method is like `_.sum` except that it accepts `iteratee` which is
  32347. * invoked for each element in `array` to generate the value to be summed.
  32348. * The iteratee is invoked with one argument: (value).
  32349. *
  32350. * @static
  32351. * @memberOf _
  32352. * @since 4.0.0
  32353. * @category Math
  32354. * @param {Array} array The array to iterate over.
  32355. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32356. * @returns {number} Returns the sum.
  32357. * @example
  32358. *
  32359. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32360. *
  32361. * _.sumBy(objects, function(o) { return o.n; });
  32362. * // => 20
  32363. *
  32364. * // The `_.property` iteratee shorthand.
  32365. * _.sumBy(objects, 'n');
  32366. * // => 20
  32367. */
  32368. function sumBy(array, iteratee) {
  32369. return (array && array.length)
  32370. ? baseSum(array, getIteratee(iteratee, 2))
  32371. : 0;
  32372. }
  32373. /*------------------------------------------------------------------------*/
  32374. // Add methods that return wrapped values in chain sequences.
  32375. lodash.after = after;
  32376. lodash.ary = ary;
  32377. lodash.assign = assign;
  32378. lodash.assignIn = assignIn;
  32379. lodash.assignInWith = assignInWith;
  32380. lodash.assignWith = assignWith;
  32381. lodash.at = at;
  32382. lodash.before = before;
  32383. lodash.bind = bind;
  32384. lodash.bindAll = bindAll;
  32385. lodash.bindKey = bindKey;
  32386. lodash.castArray = castArray;
  32387. lodash.chain = chain;
  32388. lodash.chunk = chunk;
  32389. lodash.compact = compact;
  32390. lodash.concat = concat;
  32391. lodash.cond = cond;
  32392. lodash.conforms = conforms;
  32393. lodash.constant = constant;
  32394. lodash.countBy = countBy;
  32395. lodash.create = create;
  32396. lodash.curry = curry;
  32397. lodash.curryRight = curryRight;
  32398. lodash.debounce = debounce;
  32399. lodash.defaults = defaults;
  32400. lodash.defaultsDeep = defaultsDeep;
  32401. lodash.defer = defer;
  32402. lodash.delay = delay;
  32403. lodash.difference = difference;
  32404. lodash.differenceBy = differenceBy;
  32405. lodash.differenceWith = differenceWith;
  32406. lodash.drop = drop;
  32407. lodash.dropRight = dropRight;
  32408. lodash.dropRightWhile = dropRightWhile;
  32409. lodash.dropWhile = dropWhile;
  32410. lodash.fill = fill;
  32411. lodash.filter = filter;
  32412. lodash.flatMap = flatMap;
  32413. lodash.flatMapDeep = flatMapDeep;
  32414. lodash.flatMapDepth = flatMapDepth;
  32415. lodash.flatten = flatten;
  32416. lodash.flattenDeep = flattenDeep;
  32417. lodash.flattenDepth = flattenDepth;
  32418. lodash.flip = flip;
  32419. lodash.flow = flow;
  32420. lodash.flowRight = flowRight;
  32421. lodash.fromPairs = fromPairs;
  32422. lodash.functions = functions;
  32423. lodash.functionsIn = functionsIn;
  32424. lodash.groupBy = groupBy;
  32425. lodash.initial = initial;
  32426. lodash.intersection = intersection;
  32427. lodash.intersectionBy = intersectionBy;
  32428. lodash.intersectionWith = intersectionWith;
  32429. lodash.invert = invert;
  32430. lodash.invertBy = invertBy;
  32431. lodash.invokeMap = invokeMap;
  32432. lodash.iteratee = iteratee;
  32433. lodash.keyBy = keyBy;
  32434. lodash.keys = keys;
  32435. lodash.keysIn = keysIn;
  32436. lodash.map = map;
  32437. lodash.mapKeys = mapKeys;
  32438. lodash.mapValues = mapValues;
  32439. lodash.matches = matches;
  32440. lodash.matchesProperty = matchesProperty;
  32441. lodash.memoize = memoize;
  32442. lodash.merge = merge;
  32443. lodash.mergeWith = mergeWith;
  32444. lodash.method = method;
  32445. lodash.methodOf = methodOf;
  32446. lodash.mixin = mixin;
  32447. lodash.negate = negate;
  32448. lodash.nthArg = nthArg;
  32449. lodash.omit = omit;
  32450. lodash.omitBy = omitBy;
  32451. lodash.once = once;
  32452. lodash.orderBy = orderBy;
  32453. lodash.over = over;
  32454. lodash.overArgs = overArgs;
  32455. lodash.overEvery = overEvery;
  32456. lodash.overSome = overSome;
  32457. lodash.partial = partial;
  32458. lodash.partialRight = partialRight;
  32459. lodash.partition = partition;
  32460. lodash.pick = pick;
  32461. lodash.pickBy = pickBy;
  32462. lodash.property = property;
  32463. lodash.propertyOf = propertyOf;
  32464. lodash.pull = pull;
  32465. lodash.pullAll = pullAll;
  32466. lodash.pullAllBy = pullAllBy;
  32467. lodash.pullAllWith = pullAllWith;
  32468. lodash.pullAt = pullAt;
  32469. lodash.range = range;
  32470. lodash.rangeRight = rangeRight;
  32471. lodash.rearg = rearg;
  32472. lodash.reject = reject;
  32473. lodash.remove = remove;
  32474. lodash.rest = rest;
  32475. lodash.reverse = reverse;
  32476. lodash.sampleSize = sampleSize;
  32477. lodash.set = set;
  32478. lodash.setWith = setWith;
  32479. lodash.shuffle = shuffle;
  32480. lodash.slice = slice;
  32481. lodash.sortBy = sortBy;
  32482. lodash.sortedUniq = sortedUniq;
  32483. lodash.sortedUniqBy = sortedUniqBy;
  32484. lodash.split = split;
  32485. lodash.spread = spread;
  32486. lodash.tail = tail;
  32487. lodash.take = take;
  32488. lodash.takeRight = takeRight;
  32489. lodash.takeRightWhile = takeRightWhile;
  32490. lodash.takeWhile = takeWhile;
  32491. lodash.tap = tap;
  32492. lodash.throttle = throttle;
  32493. lodash.thru = thru;
  32494. lodash.toArray = toArray;
  32495. lodash.toPairs = toPairs;
  32496. lodash.toPairsIn = toPairsIn;
  32497. lodash.toPath = toPath;
  32498. lodash.toPlainObject = toPlainObject;
  32499. lodash.transform = transform;
  32500. lodash.unary = unary;
  32501. lodash.union = union;
  32502. lodash.unionBy = unionBy;
  32503. lodash.unionWith = unionWith;
  32504. lodash.uniq = uniq;
  32505. lodash.uniqBy = uniqBy;
  32506. lodash.uniqWith = uniqWith;
  32507. lodash.unset = unset;
  32508. lodash.unzip = unzip;
  32509. lodash.unzipWith = unzipWith;
  32510. lodash.update = update;
  32511. lodash.updateWith = updateWith;
  32512. lodash.values = values;
  32513. lodash.valuesIn = valuesIn;
  32514. lodash.without = without;
  32515. lodash.words = words;
  32516. lodash.wrap = wrap;
  32517. lodash.xor = xor;
  32518. lodash.xorBy = xorBy;
  32519. lodash.xorWith = xorWith;
  32520. lodash.zip = zip;
  32521. lodash.zipObject = zipObject;
  32522. lodash.zipObjectDeep = zipObjectDeep;
  32523. lodash.zipWith = zipWith;
  32524. // Add aliases.
  32525. lodash.entries = toPairs;
  32526. lodash.entriesIn = toPairsIn;
  32527. lodash.extend = assignIn;
  32528. lodash.extendWith = assignInWith;
  32529. // Add methods to `lodash.prototype`.
  32530. mixin(lodash, lodash);
  32531. /*------------------------------------------------------------------------*/
  32532. // Add methods that return unwrapped values in chain sequences.
  32533. lodash.add = add;
  32534. lodash.attempt = attempt;
  32535. lodash.camelCase = camelCase;
  32536. lodash.capitalize = capitalize;
  32537. lodash.ceil = ceil;
  32538. lodash.clamp = clamp;
  32539. lodash.clone = clone;
  32540. lodash.cloneDeep = cloneDeep;
  32541. lodash.cloneDeepWith = cloneDeepWith;
  32542. lodash.cloneWith = cloneWith;
  32543. lodash.conformsTo = conformsTo;
  32544. lodash.deburr = deburr;
  32545. lodash.defaultTo = defaultTo;
  32546. lodash.divide = divide;
  32547. lodash.endsWith = endsWith;
  32548. lodash.eq = eq;
  32549. lodash.escape = escape;
  32550. lodash.escapeRegExp = escapeRegExp;
  32551. lodash.every = every;
  32552. lodash.find = find;
  32553. lodash.findIndex = findIndex;
  32554. lodash.findKey = findKey;
  32555. lodash.findLast = findLast;
  32556. lodash.findLastIndex = findLastIndex;
  32557. lodash.findLastKey = findLastKey;
  32558. lodash.floor = floor;
  32559. lodash.forEach = forEach;
  32560. lodash.forEachRight = forEachRight;
  32561. lodash.forIn = forIn;
  32562. lodash.forInRight = forInRight;
  32563. lodash.forOwn = forOwn;
  32564. lodash.forOwnRight = forOwnRight;
  32565. lodash.get = get;
  32566. lodash.gt = gt;
  32567. lodash.gte = gte;
  32568. lodash.has = has;
  32569. lodash.hasIn = hasIn;
  32570. lodash.head = head;
  32571. lodash.identity = identity;
  32572. lodash.includes = includes;
  32573. lodash.indexOf = indexOf;
  32574. lodash.inRange = inRange;
  32575. lodash.invoke = invoke;
  32576. lodash.isArguments = isArguments;
  32577. lodash.isArray = isArray;
  32578. lodash.isArrayBuffer = isArrayBuffer;
  32579. lodash.isArrayLike = isArrayLike;
  32580. lodash.isArrayLikeObject = isArrayLikeObject;
  32581. lodash.isBoolean = isBoolean;
  32582. lodash.isBuffer = isBuffer;
  32583. lodash.isDate = isDate;
  32584. lodash.isElement = isElement;
  32585. lodash.isEmpty = isEmpty;
  32586. lodash.isEqual = isEqual;
  32587. lodash.isEqualWith = isEqualWith;
  32588. lodash.isError = isError;
  32589. lodash.isFinite = isFinite;
  32590. lodash.isFunction = isFunction;
  32591. lodash.isInteger = isInteger;
  32592. lodash.isLength = isLength;
  32593. lodash.isMap = isMap;
  32594. lodash.isMatch = isMatch;
  32595. lodash.isMatchWith = isMatchWith;
  32596. lodash.isNaN = isNaN;
  32597. lodash.isNative = isNative;
  32598. lodash.isNil = isNil;
  32599. lodash.isNull = isNull;
  32600. lodash.isNumber = isNumber;
  32601. lodash.isObject = isObject;
  32602. lodash.isObjectLike = isObjectLike;
  32603. lodash.isPlainObject = isPlainObject;
  32604. lodash.isRegExp = isRegExp;
  32605. lodash.isSafeInteger = isSafeInteger;
  32606. lodash.isSet = isSet;
  32607. lodash.isString = isString;
  32608. lodash.isSymbol = isSymbol;
  32609. lodash.isTypedArray = isTypedArray;
  32610. lodash.isUndefined = isUndefined;
  32611. lodash.isWeakMap = isWeakMap;
  32612. lodash.isWeakSet = isWeakSet;
  32613. lodash.join = join;
  32614. lodash.kebabCase = kebabCase;
  32615. lodash.last = last;
  32616. lodash.lastIndexOf = lastIndexOf;
  32617. lodash.lowerCase = lowerCase;
  32618. lodash.lowerFirst = lowerFirst;
  32619. lodash.lt = lt;
  32620. lodash.lte = lte;
  32621. lodash.max = max;
  32622. lodash.maxBy = maxBy;
  32623. lodash.mean = mean;
  32624. lodash.meanBy = meanBy;
  32625. lodash.min = min;
  32626. lodash.minBy = minBy;
  32627. lodash.stubArray = stubArray;
  32628. lodash.stubFalse = stubFalse;
  32629. lodash.stubObject = stubObject;
  32630. lodash.stubString = stubString;
  32631. lodash.stubTrue = stubTrue;
  32632. lodash.multiply = multiply;
  32633. lodash.nth = nth;
  32634. lodash.noConflict = noConflict;
  32635. lodash.noop = noop;
  32636. lodash.now = now;
  32637. lodash.pad = pad;
  32638. lodash.padEnd = padEnd;
  32639. lodash.padStart = padStart;
  32640. lodash.parseInt = parseInt;
  32641. lodash.random = random;
  32642. lodash.reduce = reduce;
  32643. lodash.reduceRight = reduceRight;
  32644. lodash.repeat = repeat;
  32645. lodash.replace = replace;
  32646. lodash.result = result;
  32647. lodash.round = round;
  32648. lodash.runInContext = runInContext;
  32649. lodash.sample = sample;
  32650. lodash.size = size;
  32651. lodash.snakeCase = snakeCase;
  32652. lodash.some = some;
  32653. lodash.sortedIndex = sortedIndex;
  32654. lodash.sortedIndexBy = sortedIndexBy;
  32655. lodash.sortedIndexOf = sortedIndexOf;
  32656. lodash.sortedLastIndex = sortedLastIndex;
  32657. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32658. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32659. lodash.startCase = startCase;
  32660. lodash.startsWith = startsWith;
  32661. lodash.subtract = subtract;
  32662. lodash.sum = sum;
  32663. lodash.sumBy = sumBy;
  32664. lodash.template = template;
  32665. lodash.times = times;
  32666. lodash.toFinite = toFinite;
  32667. lodash.toInteger = toInteger;
  32668. lodash.toLength = toLength;
  32669. lodash.toLower = toLower;
  32670. lodash.toNumber = toNumber;
  32671. lodash.toSafeInteger = toSafeInteger;
  32672. lodash.toString = toString;
  32673. lodash.toUpper = toUpper;
  32674. lodash.trim = trim;
  32675. lodash.trimEnd = trimEnd;
  32676. lodash.trimStart = trimStart;
  32677. lodash.truncate = truncate;
  32678. lodash.unescape = unescape;
  32679. lodash.uniqueId = uniqueId;
  32680. lodash.upperCase = upperCase;
  32681. lodash.upperFirst = upperFirst;
  32682. // Add aliases.
  32683. lodash.each = forEach;
  32684. lodash.eachRight = forEachRight;
  32685. lodash.first = head;
  32686. mixin(lodash, (function() {
  32687. var source = {};
  32688. baseForOwn(lodash, function(func, methodName) {
  32689. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32690. source[methodName] = func;
  32691. }
  32692. });
  32693. return source;
  32694. }()), { 'chain': false });
  32695. /*------------------------------------------------------------------------*/
  32696. /**
  32697. * The semantic version number.
  32698. *
  32699. * @static
  32700. * @memberOf _
  32701. * @type {string}
  32702. */
  32703. lodash.VERSION = VERSION;
  32704. // Assign default placeholders.
  32705. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32706. lodash[methodName].placeholder = lodash;
  32707. });
  32708. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32709. arrayEach(['drop', 'take'], function(methodName, index) {
  32710. LazyWrapper.prototype[methodName] = function(n) {
  32711. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32712. var result = (this.__filtered__ && !index)
  32713. ? new LazyWrapper(this)
  32714. : this.clone();
  32715. if (result.__filtered__) {
  32716. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32717. } else {
  32718. result.__views__.push({
  32719. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32720. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32721. });
  32722. }
  32723. return result;
  32724. };
  32725. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32726. return this.reverse()[methodName](n).reverse();
  32727. };
  32728. });
  32729. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32730. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32731. var type = index + 1,
  32732. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32733. LazyWrapper.prototype[methodName] = function(iteratee) {
  32734. var result = this.clone();
  32735. result.__iteratees__.push({
  32736. 'iteratee': getIteratee(iteratee, 3),
  32737. 'type': type
  32738. });
  32739. result.__filtered__ = result.__filtered__ || isFilter;
  32740. return result;
  32741. };
  32742. });
  32743. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32744. arrayEach(['head', 'last'], function(methodName, index) {
  32745. var takeName = 'take' + (index ? 'Right' : '');
  32746. LazyWrapper.prototype[methodName] = function() {
  32747. return this[takeName](1).value()[0];
  32748. };
  32749. });
  32750. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32751. arrayEach(['initial', 'tail'], function(methodName, index) {
  32752. var dropName = 'drop' + (index ? '' : 'Right');
  32753. LazyWrapper.prototype[methodName] = function() {
  32754. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32755. };
  32756. });
  32757. LazyWrapper.prototype.compact = function() {
  32758. return this.filter(identity);
  32759. };
  32760. LazyWrapper.prototype.find = function(predicate) {
  32761. return this.filter(predicate).head();
  32762. };
  32763. LazyWrapper.prototype.findLast = function(predicate) {
  32764. return this.reverse().find(predicate);
  32765. };
  32766. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32767. if (typeof path == 'function') {
  32768. return new LazyWrapper(this);
  32769. }
  32770. return this.map(function(value) {
  32771. return baseInvoke(value, path, args);
  32772. });
  32773. });
  32774. LazyWrapper.prototype.reject = function(predicate) {
  32775. return this.filter(negate(getIteratee(predicate)));
  32776. };
  32777. LazyWrapper.prototype.slice = function(start, end) {
  32778. start = toInteger(start);
  32779. var result = this;
  32780. if (result.__filtered__ && (start > 0 || end < 0)) {
  32781. return new LazyWrapper(result);
  32782. }
  32783. if (start < 0) {
  32784. result = result.takeRight(-start);
  32785. } else if (start) {
  32786. result = result.drop(start);
  32787. }
  32788. if (end !== undefined) {
  32789. end = toInteger(end);
  32790. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32791. }
  32792. return result;
  32793. };
  32794. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32795. return this.reverse().takeWhile(predicate).reverse();
  32796. };
  32797. LazyWrapper.prototype.toArray = function() {
  32798. return this.take(MAX_ARRAY_LENGTH);
  32799. };
  32800. // Add `LazyWrapper` methods to `lodash.prototype`.
  32801. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32802. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32803. isTaker = /^(?:head|last)$/.test(methodName),
  32804. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32805. retUnwrapped = isTaker || /^find/.test(methodName);
  32806. if (!lodashFunc) {
  32807. return;
  32808. }
  32809. lodash.prototype[methodName] = function() {
  32810. var value = this.__wrapped__,
  32811. args = isTaker ? [1] : arguments,
  32812. isLazy = value instanceof LazyWrapper,
  32813. iteratee = args[0],
  32814. useLazy = isLazy || isArray(value);
  32815. var interceptor = function(value) {
  32816. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32817. return (isTaker && chainAll) ? result[0] : result;
  32818. };
  32819. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32820. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32821. isLazy = useLazy = false;
  32822. }
  32823. var chainAll = this.__chain__,
  32824. isHybrid = !!this.__actions__.length,
  32825. isUnwrapped = retUnwrapped && !chainAll,
  32826. onlyLazy = isLazy && !isHybrid;
  32827. if (!retUnwrapped && useLazy) {
  32828. value = onlyLazy ? value : new LazyWrapper(this);
  32829. var result = func.apply(value, args);
  32830. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32831. return new LodashWrapper(result, chainAll);
  32832. }
  32833. if (isUnwrapped && onlyLazy) {
  32834. return func.apply(this, args);
  32835. }
  32836. result = this.thru(interceptor);
  32837. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32838. };
  32839. });
  32840. // Add `Array` methods to `lodash.prototype`.
  32841. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32842. var func = arrayProto[methodName],
  32843. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32844. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32845. lodash.prototype[methodName] = function() {
  32846. var args = arguments;
  32847. if (retUnwrapped && !this.__chain__) {
  32848. var value = this.value();
  32849. return func.apply(isArray(value) ? value : [], args);
  32850. }
  32851. return this[chainName](function(value) {
  32852. return func.apply(isArray(value) ? value : [], args);
  32853. });
  32854. };
  32855. });
  32856. // Map minified method names to their real names.
  32857. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32858. var lodashFunc = lodash[methodName];
  32859. if (lodashFunc) {
  32860. var key = lodashFunc.name + '';
  32861. if (!hasOwnProperty.call(realNames, key)) {
  32862. realNames[key] = [];
  32863. }
  32864. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32865. }
  32866. });
  32867. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32868. 'name': 'wrapper',
  32869. 'func': undefined
  32870. }];
  32871. // Add methods to `LazyWrapper`.
  32872. LazyWrapper.prototype.clone = lazyClone;
  32873. LazyWrapper.prototype.reverse = lazyReverse;
  32874. LazyWrapper.prototype.value = lazyValue;
  32875. // Add chain sequence methods to the `lodash` wrapper.
  32876. lodash.prototype.at = wrapperAt;
  32877. lodash.prototype.chain = wrapperChain;
  32878. lodash.prototype.commit = wrapperCommit;
  32879. lodash.prototype.next = wrapperNext;
  32880. lodash.prototype.plant = wrapperPlant;
  32881. lodash.prototype.reverse = wrapperReverse;
  32882. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32883. // Add lazy aliases.
  32884. lodash.prototype.first = lodash.prototype.head;
  32885. if (symIterator) {
  32886. lodash.prototype[symIterator] = wrapperToIterator;
  32887. }
  32888. return lodash;
  32889. });
  32890. /*--------------------------------------------------------------------------*/
  32891. // Export lodash.
  32892. var _ = runInContext();
  32893. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32894. if (true) {
  32895. // Expose Lodash on the global object to prevent errors when Lodash is
  32896. // loaded by a script tag in the presence of an AMD loader.
  32897. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32898. // Use `_.noConflict` to remove Lodash from the global object.
  32899. root._ = _;
  32900. // Define as an anonymous module so, through path mapping, it can be
  32901. // referenced as the "underscore" module.
  32902. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32903. return _;
  32904. }).call(exports, __webpack_require__, exports, module),
  32905. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32906. }
  32907. // Check for `exports` after `define` in case a build optimizer adds it.
  32908. else {}
  32909. }.call(this));
  32910. /* 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)))
  32911. /***/ }),
  32912. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32913. /*!***************************************************!*\
  32914. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32915. \***************************************************/
  32916. /*! exports provided: default */
  32917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32918. "use strict";
  32919. __webpack_require__.r(__webpack_exports__);
  32920. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32921. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32922. * @version 1.16.1
  32923. * @license
  32924. * Copyright (c) 2016 Federico Zivolo and contributors
  32925. *
  32926. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32927. * of this software and associated documentation files (the "Software"), to deal
  32928. * in the Software without restriction, including without limitation the rights
  32929. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32930. * copies of the Software, and to permit persons to whom the Software is
  32931. * furnished to do so, subject to the following conditions:
  32932. *
  32933. * The above copyright notice and this permission notice shall be included in all
  32934. * copies or substantial portions of the Software.
  32935. *
  32936. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32937. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32938. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32939. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32940. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32941. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32942. * SOFTWARE.
  32943. */
  32944. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32945. var timeoutDuration = function () {
  32946. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32947. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32948. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32949. return 1;
  32950. }
  32951. }
  32952. return 0;
  32953. }();
  32954. function microtaskDebounce(fn) {
  32955. var called = false;
  32956. return function () {
  32957. if (called) {
  32958. return;
  32959. }
  32960. called = true;
  32961. window.Promise.resolve().then(function () {
  32962. called = false;
  32963. fn();
  32964. });
  32965. };
  32966. }
  32967. function taskDebounce(fn) {
  32968. var scheduled = false;
  32969. return function () {
  32970. if (!scheduled) {
  32971. scheduled = true;
  32972. setTimeout(function () {
  32973. scheduled = false;
  32974. fn();
  32975. }, timeoutDuration);
  32976. }
  32977. };
  32978. }
  32979. var supportsMicroTasks = isBrowser && window.Promise;
  32980. /**
  32981. * Create a debounced version of a method, that's asynchronously deferred
  32982. * but called in the minimum time possible.
  32983. *
  32984. * @method
  32985. * @memberof Popper.Utils
  32986. * @argument {Function} fn
  32987. * @returns {Function}
  32988. */
  32989. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32990. /**
  32991. * Check if the given variable is a function
  32992. * @method
  32993. * @memberof Popper.Utils
  32994. * @argument {Any} functionToCheck - variable to check
  32995. * @returns {Boolean} answer to: is a function?
  32996. */
  32997. function isFunction(functionToCheck) {
  32998. var getType = {};
  32999. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33000. }
  33001. /**
  33002. * Get CSS computed property of the given element
  33003. * @method
  33004. * @memberof Popper.Utils
  33005. * @argument {Eement} element
  33006. * @argument {String} property
  33007. */
  33008. function getStyleComputedProperty(element, property) {
  33009. if (element.nodeType !== 1) {
  33010. return [];
  33011. }
  33012. // NOTE: 1 DOM access here
  33013. var window = element.ownerDocument.defaultView;
  33014. var css = window.getComputedStyle(element, null);
  33015. return property ? css[property] : css;
  33016. }
  33017. /**
  33018. * Returns the parentNode or the host of the element
  33019. * @method
  33020. * @memberof Popper.Utils
  33021. * @argument {Element} element
  33022. * @returns {Element} parent
  33023. */
  33024. function getParentNode(element) {
  33025. if (element.nodeName === 'HTML') {
  33026. return element;
  33027. }
  33028. return element.parentNode || element.host;
  33029. }
  33030. /**
  33031. * Returns the scrolling parent of the given element
  33032. * @method
  33033. * @memberof Popper.Utils
  33034. * @argument {Element} element
  33035. * @returns {Element} scroll parent
  33036. */
  33037. function getScrollParent(element) {
  33038. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33039. if (!element) {
  33040. return document.body;
  33041. }
  33042. switch (element.nodeName) {
  33043. case 'HTML':
  33044. case 'BODY':
  33045. return element.ownerDocument.body;
  33046. case '#document':
  33047. return element.body;
  33048. }
  33049. // Firefox want us to check `-x` and `-y` variations as well
  33050. var _getStyleComputedProp = getStyleComputedProperty(element),
  33051. overflow = _getStyleComputedProp.overflow,
  33052. overflowX = _getStyleComputedProp.overflowX,
  33053. overflowY = _getStyleComputedProp.overflowY;
  33054. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33055. return element;
  33056. }
  33057. return getScrollParent(getParentNode(element));
  33058. }
  33059. /**
  33060. * Returns the reference node of the reference object, or the reference object itself.
  33061. * @method
  33062. * @memberof Popper.Utils
  33063. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33064. * @returns {Element} parent
  33065. */
  33066. function getReferenceNode(reference) {
  33067. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33068. }
  33069. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33070. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33071. /**
  33072. * Determines if the browser is Internet Explorer
  33073. * @method
  33074. * @memberof Popper.Utils
  33075. * @param {Number} version to check
  33076. * @returns {Boolean} isIE
  33077. */
  33078. function isIE(version) {
  33079. if (version === 11) {
  33080. return isIE11;
  33081. }
  33082. if (version === 10) {
  33083. return isIE10;
  33084. }
  33085. return isIE11 || isIE10;
  33086. }
  33087. /**
  33088. * Returns the offset parent of the given element
  33089. * @method
  33090. * @memberof Popper.Utils
  33091. * @argument {Element} element
  33092. * @returns {Element} offset parent
  33093. */
  33094. function getOffsetParent(element) {
  33095. if (!element) {
  33096. return document.documentElement;
  33097. }
  33098. var noOffsetParent = isIE(10) ? document.body : null;
  33099. // NOTE: 1 DOM access here
  33100. var offsetParent = element.offsetParent || null;
  33101. // Skip hidden elements which don't have an offsetParent
  33102. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33103. offsetParent = (element = element.nextElementSibling).offsetParent;
  33104. }
  33105. var nodeName = offsetParent && offsetParent.nodeName;
  33106. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33107. return element ? element.ownerDocument.documentElement : document.documentElement;
  33108. }
  33109. // .offsetParent will return the closest TH, TD or TABLE in case
  33110. // no offsetParent is present, I hate this job...
  33111. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33112. return getOffsetParent(offsetParent);
  33113. }
  33114. return offsetParent;
  33115. }
  33116. function isOffsetContainer(element) {
  33117. var nodeName = element.nodeName;
  33118. if (nodeName === 'BODY') {
  33119. return false;
  33120. }
  33121. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33122. }
  33123. /**
  33124. * Finds the root node (document, shadowDOM root) of the given element
  33125. * @method
  33126. * @memberof Popper.Utils
  33127. * @argument {Element} node
  33128. * @returns {Element} root node
  33129. */
  33130. function getRoot(node) {
  33131. if (node.parentNode !== null) {
  33132. return getRoot(node.parentNode);
  33133. }
  33134. return node;
  33135. }
  33136. /**
  33137. * Finds the offset parent common to the two provided nodes
  33138. * @method
  33139. * @memberof Popper.Utils
  33140. * @argument {Element} element1
  33141. * @argument {Element} element2
  33142. * @returns {Element} common offset parent
  33143. */
  33144. function findCommonOffsetParent(element1, element2) {
  33145. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33146. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33147. return document.documentElement;
  33148. }
  33149. // Here we make sure to give as "start" the element that comes first in the DOM
  33150. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33151. var start = order ? element1 : element2;
  33152. var end = order ? element2 : element1;
  33153. // Get common ancestor container
  33154. var range = document.createRange();
  33155. range.setStart(start, 0);
  33156. range.setEnd(end, 0);
  33157. var commonAncestorContainer = range.commonAncestorContainer;
  33158. // Both nodes are inside #document
  33159. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33160. if (isOffsetContainer(commonAncestorContainer)) {
  33161. return commonAncestorContainer;
  33162. }
  33163. return getOffsetParent(commonAncestorContainer);
  33164. }
  33165. // one of the nodes is inside shadowDOM, find which one
  33166. var element1root = getRoot(element1);
  33167. if (element1root.host) {
  33168. return findCommonOffsetParent(element1root.host, element2);
  33169. } else {
  33170. return findCommonOffsetParent(element1, getRoot(element2).host);
  33171. }
  33172. }
  33173. /**
  33174. * Gets the scroll value of the given element in the given side (top and left)
  33175. * @method
  33176. * @memberof Popper.Utils
  33177. * @argument {Element} element
  33178. * @argument {String} side `top` or `left`
  33179. * @returns {number} amount of scrolled pixels
  33180. */
  33181. function getScroll(element) {
  33182. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33183. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33184. var nodeName = element.nodeName;
  33185. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33186. var html = element.ownerDocument.documentElement;
  33187. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33188. return scrollingElement[upperSide];
  33189. }
  33190. return element[upperSide];
  33191. }
  33192. /*
  33193. * Sum or subtract the element scroll values (left and top) from a given rect object
  33194. * @method
  33195. * @memberof Popper.Utils
  33196. * @param {Object} rect - Rect object you want to change
  33197. * @param {HTMLElement} element - The element from the function reads the scroll values
  33198. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33199. * @return {Object} rect - The modifier rect object
  33200. */
  33201. function includeScroll(rect, element) {
  33202. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33203. var scrollTop = getScroll(element, 'top');
  33204. var scrollLeft = getScroll(element, 'left');
  33205. var modifier = subtract ? -1 : 1;
  33206. rect.top += scrollTop * modifier;
  33207. rect.bottom += scrollTop * modifier;
  33208. rect.left += scrollLeft * modifier;
  33209. rect.right += scrollLeft * modifier;
  33210. return rect;
  33211. }
  33212. /*
  33213. * Helper to detect borders of a given element
  33214. * @method
  33215. * @memberof Popper.Utils
  33216. * @param {CSSStyleDeclaration} styles
  33217. * Result of `getStyleComputedProperty` on the given element
  33218. * @param {String} axis - `x` or `y`
  33219. * @return {number} borders - The borders size of the given axis
  33220. */
  33221. function getBordersSize(styles, axis) {
  33222. var sideA = axis === 'x' ? 'Left' : 'Top';
  33223. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33224. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33225. }
  33226. function getSize(axis, body, html, computedStyle) {
  33227. 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);
  33228. }
  33229. function getWindowSizes(document) {
  33230. var body = document.body;
  33231. var html = document.documentElement;
  33232. var computedStyle = isIE(10) && getComputedStyle(html);
  33233. return {
  33234. height: getSize('Height', body, html, computedStyle),
  33235. width: getSize('Width', body, html, computedStyle)
  33236. };
  33237. }
  33238. var classCallCheck = function (instance, Constructor) {
  33239. if (!(instance instanceof Constructor)) {
  33240. throw new TypeError("Cannot call a class as a function");
  33241. }
  33242. };
  33243. var createClass = function () {
  33244. function defineProperties(target, props) {
  33245. for (var i = 0; i < props.length; i++) {
  33246. var descriptor = props[i];
  33247. descriptor.enumerable = descriptor.enumerable || false;
  33248. descriptor.configurable = true;
  33249. if ("value" in descriptor) descriptor.writable = true;
  33250. Object.defineProperty(target, descriptor.key, descriptor);
  33251. }
  33252. }
  33253. return function (Constructor, protoProps, staticProps) {
  33254. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33255. if (staticProps) defineProperties(Constructor, staticProps);
  33256. return Constructor;
  33257. };
  33258. }();
  33259. var defineProperty = function (obj, key, value) {
  33260. if (key in obj) {
  33261. Object.defineProperty(obj, key, {
  33262. value: value,
  33263. enumerable: true,
  33264. configurable: true,
  33265. writable: true
  33266. });
  33267. } else {
  33268. obj[key] = value;
  33269. }
  33270. return obj;
  33271. };
  33272. var _extends = Object.assign || function (target) {
  33273. for (var i = 1; i < arguments.length; i++) {
  33274. var source = arguments[i];
  33275. for (var key in source) {
  33276. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33277. target[key] = source[key];
  33278. }
  33279. }
  33280. }
  33281. return target;
  33282. };
  33283. /**
  33284. * Given element offsets, generate an output similar to getBoundingClientRect
  33285. * @method
  33286. * @memberof Popper.Utils
  33287. * @argument {Object} offsets
  33288. * @returns {Object} ClientRect like output
  33289. */
  33290. function getClientRect(offsets) {
  33291. return _extends({}, offsets, {
  33292. right: offsets.left + offsets.width,
  33293. bottom: offsets.top + offsets.height
  33294. });
  33295. }
  33296. /**
  33297. * Get bounding client rect of given element
  33298. * @method
  33299. * @memberof Popper.Utils
  33300. * @param {HTMLElement} element
  33301. * @return {Object} client rect
  33302. */
  33303. function getBoundingClientRect(element) {
  33304. var rect = {};
  33305. // IE10 10 FIX: Please, don't ask, the element isn't
  33306. // considered in DOM in some circumstances...
  33307. // This isn't reproducible in IE10 compatibility mode of IE11
  33308. try {
  33309. if (isIE(10)) {
  33310. rect = element.getBoundingClientRect();
  33311. var scrollTop = getScroll(element, 'top');
  33312. var scrollLeft = getScroll(element, 'left');
  33313. rect.top += scrollTop;
  33314. rect.left += scrollLeft;
  33315. rect.bottom += scrollTop;
  33316. rect.right += scrollLeft;
  33317. } else {
  33318. rect = element.getBoundingClientRect();
  33319. }
  33320. } catch (e) {}
  33321. var result = {
  33322. left: rect.left,
  33323. top: rect.top,
  33324. width: rect.right - rect.left,
  33325. height: rect.bottom - rect.top
  33326. };
  33327. // subtract scrollbar size from sizes
  33328. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33329. var width = sizes.width || element.clientWidth || result.width;
  33330. var height = sizes.height || element.clientHeight || result.height;
  33331. var horizScrollbar = element.offsetWidth - width;
  33332. var vertScrollbar = element.offsetHeight - height;
  33333. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33334. // we make this check conditional for performance reasons
  33335. if (horizScrollbar || vertScrollbar) {
  33336. var styles = getStyleComputedProperty(element);
  33337. horizScrollbar -= getBordersSize(styles, 'x');
  33338. vertScrollbar -= getBordersSize(styles, 'y');
  33339. result.width -= horizScrollbar;
  33340. result.height -= vertScrollbar;
  33341. }
  33342. return getClientRect(result);
  33343. }
  33344. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33345. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33346. var isIE10 = isIE(10);
  33347. var isHTML = parent.nodeName === 'HTML';
  33348. var childrenRect = getBoundingClientRect(children);
  33349. var parentRect = getBoundingClientRect(parent);
  33350. var scrollParent = getScrollParent(children);
  33351. var styles = getStyleComputedProperty(parent);
  33352. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33353. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33354. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33355. if (fixedPosition && isHTML) {
  33356. parentRect.top = Math.max(parentRect.top, 0);
  33357. parentRect.left = Math.max(parentRect.left, 0);
  33358. }
  33359. var offsets = getClientRect({
  33360. top: childrenRect.top - parentRect.top - borderTopWidth,
  33361. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33362. width: childrenRect.width,
  33363. height: childrenRect.height
  33364. });
  33365. offsets.marginTop = 0;
  33366. offsets.marginLeft = 0;
  33367. // Subtract margins of documentElement in case it's being used as parent
  33368. // we do this only on HTML because it's the only element that behaves
  33369. // differently when margins are applied to it. The margins are included in
  33370. // the box of the documentElement, in the other cases not.
  33371. if (!isIE10 && isHTML) {
  33372. var marginTop = parseFloat(styles.marginTop);
  33373. var marginLeft = parseFloat(styles.marginLeft);
  33374. offsets.top -= borderTopWidth - marginTop;
  33375. offsets.bottom -= borderTopWidth - marginTop;
  33376. offsets.left -= borderLeftWidth - marginLeft;
  33377. offsets.right -= borderLeftWidth - marginLeft;
  33378. // Attach marginTop and marginLeft because in some circumstances we may need them
  33379. offsets.marginTop = marginTop;
  33380. offsets.marginLeft = marginLeft;
  33381. }
  33382. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33383. offsets = includeScroll(offsets, parent);
  33384. }
  33385. return offsets;
  33386. }
  33387. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33388. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33389. var html = element.ownerDocument.documentElement;
  33390. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33391. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33392. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33393. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33394. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33395. var offset = {
  33396. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33397. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33398. width: width,
  33399. height: height
  33400. };
  33401. return getClientRect(offset);
  33402. }
  33403. /**
  33404. * Check if the given element is fixed or is inside a fixed parent
  33405. * @method
  33406. * @memberof Popper.Utils
  33407. * @argument {Element} element
  33408. * @argument {Element} customContainer
  33409. * @returns {Boolean} answer to "isFixed?"
  33410. */
  33411. function isFixed(element) {
  33412. var nodeName = element.nodeName;
  33413. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33414. return false;
  33415. }
  33416. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33417. return true;
  33418. }
  33419. var parentNode = getParentNode(element);
  33420. if (!parentNode) {
  33421. return false;
  33422. }
  33423. return isFixed(parentNode);
  33424. }
  33425. /**
  33426. * Finds the first parent of an element that has a transformed property defined
  33427. * @method
  33428. * @memberof Popper.Utils
  33429. * @argument {Element} element
  33430. * @returns {Element} first transformed parent or documentElement
  33431. */
  33432. function getFixedPositionOffsetParent(element) {
  33433. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33434. if (!element || !element.parentElement || isIE()) {
  33435. return document.documentElement;
  33436. }
  33437. var el = element.parentElement;
  33438. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33439. el = el.parentElement;
  33440. }
  33441. return el || document.documentElement;
  33442. }
  33443. /**
  33444. * Computed the boundaries limits and return them
  33445. * @method
  33446. * @memberof Popper.Utils
  33447. * @param {HTMLElement} popper
  33448. * @param {HTMLElement} reference
  33449. * @param {number} padding
  33450. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33451. * @param {Boolean} fixedPosition - Is in fixed position mode
  33452. * @returns {Object} Coordinates of the boundaries
  33453. */
  33454. function getBoundaries(popper, reference, padding, boundariesElement) {
  33455. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33456. // NOTE: 1 DOM access here
  33457. var boundaries = { top: 0, left: 0 };
  33458. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33459. // Handle viewport case
  33460. if (boundariesElement === 'viewport') {
  33461. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33462. } else {
  33463. // Handle other cases based on DOM element used as boundaries
  33464. var boundariesNode = void 0;
  33465. if (boundariesElement === 'scrollParent') {
  33466. boundariesNode = getScrollParent(getParentNode(reference));
  33467. if (boundariesNode.nodeName === 'BODY') {
  33468. boundariesNode = popper.ownerDocument.documentElement;
  33469. }
  33470. } else if (boundariesElement === 'window') {
  33471. boundariesNode = popper.ownerDocument.documentElement;
  33472. } else {
  33473. boundariesNode = boundariesElement;
  33474. }
  33475. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33476. // In case of HTML, we need a different computation
  33477. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33478. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33479. height = _getWindowSizes.height,
  33480. width = _getWindowSizes.width;
  33481. boundaries.top += offsets.top - offsets.marginTop;
  33482. boundaries.bottom = height + offsets.top;
  33483. boundaries.left += offsets.left - offsets.marginLeft;
  33484. boundaries.right = width + offsets.left;
  33485. } else {
  33486. // for all the other DOM elements, this one is good
  33487. boundaries = offsets;
  33488. }
  33489. }
  33490. // Add paddings
  33491. padding = padding || 0;
  33492. var isPaddingNumber = typeof padding === 'number';
  33493. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33494. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33495. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33496. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33497. return boundaries;
  33498. }
  33499. function getArea(_ref) {
  33500. var width = _ref.width,
  33501. height = _ref.height;
  33502. return width * height;
  33503. }
  33504. /**
  33505. * Utility used to transform the `auto` placement to the placement with more
  33506. * available space.
  33507. * @method
  33508. * @memberof Popper.Utils
  33509. * @argument {Object} data - The data object generated by update method
  33510. * @argument {Object} options - Modifiers configuration and options
  33511. * @returns {Object} The data object, properly modified
  33512. */
  33513. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33514. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33515. if (placement.indexOf('auto') === -1) {
  33516. return placement;
  33517. }
  33518. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33519. var rects = {
  33520. top: {
  33521. width: boundaries.width,
  33522. height: refRect.top - boundaries.top
  33523. },
  33524. right: {
  33525. width: boundaries.right - refRect.right,
  33526. height: boundaries.height
  33527. },
  33528. bottom: {
  33529. width: boundaries.width,
  33530. height: boundaries.bottom - refRect.bottom
  33531. },
  33532. left: {
  33533. width: refRect.left - boundaries.left,
  33534. height: boundaries.height
  33535. }
  33536. };
  33537. var sortedAreas = Object.keys(rects).map(function (key) {
  33538. return _extends({
  33539. key: key
  33540. }, rects[key], {
  33541. area: getArea(rects[key])
  33542. });
  33543. }).sort(function (a, b) {
  33544. return b.area - a.area;
  33545. });
  33546. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33547. var width = _ref2.width,
  33548. height = _ref2.height;
  33549. return width >= popper.clientWidth && height >= popper.clientHeight;
  33550. });
  33551. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33552. var variation = placement.split('-')[1];
  33553. return computedPlacement + (variation ? '-' + variation : '');
  33554. }
  33555. /**
  33556. * Get offsets to the reference element
  33557. * @method
  33558. * @memberof Popper.Utils
  33559. * @param {Object} state
  33560. * @param {Element} popper - the popper element
  33561. * @param {Element} reference - the reference element (the popper will be relative to this)
  33562. * @param {Element} fixedPosition - is in fixed position mode
  33563. * @returns {Object} An object containing the offsets which will be applied to the popper
  33564. */
  33565. function getReferenceOffsets(state, popper, reference) {
  33566. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33567. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33568. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33569. }
  33570. /**
  33571. * Get the outer sizes of the given element (offset size + margins)
  33572. * @method
  33573. * @memberof Popper.Utils
  33574. * @argument {Element} element
  33575. * @returns {Object} object containing width and height properties
  33576. */
  33577. function getOuterSizes(element) {
  33578. var window = element.ownerDocument.defaultView;
  33579. var styles = window.getComputedStyle(element);
  33580. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33581. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33582. var result = {
  33583. width: element.offsetWidth + y,
  33584. height: element.offsetHeight + x
  33585. };
  33586. return result;
  33587. }
  33588. /**
  33589. * Get the opposite placement of the given one
  33590. * @method
  33591. * @memberof Popper.Utils
  33592. * @argument {String} placement
  33593. * @returns {String} flipped placement
  33594. */
  33595. function getOppositePlacement(placement) {
  33596. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33597. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33598. return hash[matched];
  33599. });
  33600. }
  33601. /**
  33602. * Get offsets to the popper
  33603. * @method
  33604. * @memberof Popper.Utils
  33605. * @param {Object} position - CSS position the Popper will get applied
  33606. * @param {HTMLElement} popper - the popper element
  33607. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33608. * @param {String} placement - one of the valid placement options
  33609. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33610. */
  33611. function getPopperOffsets(popper, referenceOffsets, placement) {
  33612. placement = placement.split('-')[0];
  33613. // Get popper node sizes
  33614. var popperRect = getOuterSizes(popper);
  33615. // Add position, width and height to our offsets object
  33616. var popperOffsets = {
  33617. width: popperRect.width,
  33618. height: popperRect.height
  33619. };
  33620. // depending by the popper placement we have to compute its offsets slightly differently
  33621. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33622. var mainSide = isHoriz ? 'top' : 'left';
  33623. var secondarySide = isHoriz ? 'left' : 'top';
  33624. var measurement = isHoriz ? 'height' : 'width';
  33625. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33626. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33627. if (placement === secondarySide) {
  33628. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33629. } else {
  33630. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33631. }
  33632. return popperOffsets;
  33633. }
  33634. /**
  33635. * Mimics the `find` method of Array
  33636. * @method
  33637. * @memberof Popper.Utils
  33638. * @argument {Array} arr
  33639. * @argument prop
  33640. * @argument value
  33641. * @returns index or -1
  33642. */
  33643. function find(arr, check) {
  33644. // use native find if supported
  33645. if (Array.prototype.find) {
  33646. return arr.find(check);
  33647. }
  33648. // use `filter` to obtain the same behavior of `find`
  33649. return arr.filter(check)[0];
  33650. }
  33651. /**
  33652. * Return the index of the matching object
  33653. * @method
  33654. * @memberof Popper.Utils
  33655. * @argument {Array} arr
  33656. * @argument prop
  33657. * @argument value
  33658. * @returns index or -1
  33659. */
  33660. function findIndex(arr, prop, value) {
  33661. // use native findIndex if supported
  33662. if (Array.prototype.findIndex) {
  33663. return arr.findIndex(function (cur) {
  33664. return cur[prop] === value;
  33665. });
  33666. }
  33667. // use `find` + `indexOf` if `findIndex` isn't supported
  33668. var match = find(arr, function (obj) {
  33669. return obj[prop] === value;
  33670. });
  33671. return arr.indexOf(match);
  33672. }
  33673. /**
  33674. * Loop trough the list of modifiers and run them in order,
  33675. * each of them will then edit the data object.
  33676. * @method
  33677. * @memberof Popper.Utils
  33678. * @param {dataObject} data
  33679. * @param {Array} modifiers
  33680. * @param {String} ends - Optional modifier name used as stopper
  33681. * @returns {dataObject}
  33682. */
  33683. function runModifiers(modifiers, data, ends) {
  33684. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33685. modifiersToRun.forEach(function (modifier) {
  33686. if (modifier['function']) {
  33687. // eslint-disable-line dot-notation
  33688. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33689. }
  33690. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33691. if (modifier.enabled && isFunction(fn)) {
  33692. // Add properties to offsets to make them a complete clientRect object
  33693. // we do this before each modifier to make sure the previous one doesn't
  33694. // mess with these values
  33695. data.offsets.popper = getClientRect(data.offsets.popper);
  33696. data.offsets.reference = getClientRect(data.offsets.reference);
  33697. data = fn(data, modifier);
  33698. }
  33699. });
  33700. return data;
  33701. }
  33702. /**
  33703. * Updates the position of the popper, computing the new offsets and applying
  33704. * the new style.<br />
  33705. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33706. * @method
  33707. * @memberof Popper
  33708. */
  33709. function update() {
  33710. // if popper is destroyed, don't perform any further update
  33711. if (this.state.isDestroyed) {
  33712. return;
  33713. }
  33714. var data = {
  33715. instance: this,
  33716. styles: {},
  33717. arrowStyles: {},
  33718. attributes: {},
  33719. flipped: false,
  33720. offsets: {}
  33721. };
  33722. // compute reference element offsets
  33723. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33724. // compute auto placement, store placement inside the data object,
  33725. // modifiers will be able to edit `placement` if needed
  33726. // and refer to originalPlacement to know the original value
  33727. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33728. // store the computed placement inside `originalPlacement`
  33729. data.originalPlacement = data.placement;
  33730. data.positionFixed = this.options.positionFixed;
  33731. // compute the popper offsets
  33732. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33733. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33734. // run the modifiers
  33735. data = runModifiers(this.modifiers, data);
  33736. // the first `update` will call `onCreate` callback
  33737. // the other ones will call `onUpdate` callback
  33738. if (!this.state.isCreated) {
  33739. this.state.isCreated = true;
  33740. this.options.onCreate(data);
  33741. } else {
  33742. this.options.onUpdate(data);
  33743. }
  33744. }
  33745. /**
  33746. * Helper used to know if the given modifier is enabled.
  33747. * @method
  33748. * @memberof Popper.Utils
  33749. * @returns {Boolean}
  33750. */
  33751. function isModifierEnabled(modifiers, modifierName) {
  33752. return modifiers.some(function (_ref) {
  33753. var name = _ref.name,
  33754. enabled = _ref.enabled;
  33755. return enabled && name === modifierName;
  33756. });
  33757. }
  33758. /**
  33759. * Get the prefixed supported property name
  33760. * @method
  33761. * @memberof Popper.Utils
  33762. * @argument {String} property (camelCase)
  33763. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33764. */
  33765. function getSupportedPropertyName(property) {
  33766. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33767. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33768. for (var i = 0; i < prefixes.length; i++) {
  33769. var prefix = prefixes[i];
  33770. var toCheck = prefix ? '' + prefix + upperProp : property;
  33771. if (typeof document.body.style[toCheck] !== 'undefined') {
  33772. return toCheck;
  33773. }
  33774. }
  33775. return null;
  33776. }
  33777. /**
  33778. * Destroys the popper.
  33779. * @method
  33780. * @memberof Popper
  33781. */
  33782. function destroy() {
  33783. this.state.isDestroyed = true;
  33784. // touch DOM only if `applyStyle` modifier is enabled
  33785. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33786. this.popper.removeAttribute('x-placement');
  33787. this.popper.style.position = '';
  33788. this.popper.style.top = '';
  33789. this.popper.style.left = '';
  33790. this.popper.style.right = '';
  33791. this.popper.style.bottom = '';
  33792. this.popper.style.willChange = '';
  33793. this.popper.style[getSupportedPropertyName('transform')] = '';
  33794. }
  33795. this.disableEventListeners();
  33796. // remove the popper if user explicitly asked for the deletion on destroy
  33797. // do not use `remove` because IE11 doesn't support it
  33798. if (this.options.removeOnDestroy) {
  33799. this.popper.parentNode.removeChild(this.popper);
  33800. }
  33801. return this;
  33802. }
  33803. /**
  33804. * Get the window associated with the element
  33805. * @argument {Element} element
  33806. * @returns {Window}
  33807. */
  33808. function getWindow(element) {
  33809. var ownerDocument = element.ownerDocument;
  33810. return ownerDocument ? ownerDocument.defaultView : window;
  33811. }
  33812. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33813. var isBody = scrollParent.nodeName === 'BODY';
  33814. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33815. target.addEventListener(event, callback, { passive: true });
  33816. if (!isBody) {
  33817. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33818. }
  33819. scrollParents.push(target);
  33820. }
  33821. /**
  33822. * Setup needed event listeners used to update the popper position
  33823. * @method
  33824. * @memberof Popper.Utils
  33825. * @private
  33826. */
  33827. function setupEventListeners(reference, options, state, updateBound) {
  33828. // Resize event listener on window
  33829. state.updateBound = updateBound;
  33830. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33831. // Scroll event listener on scroll parents
  33832. var scrollElement = getScrollParent(reference);
  33833. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33834. state.scrollElement = scrollElement;
  33835. state.eventsEnabled = true;
  33836. return state;
  33837. }
  33838. /**
  33839. * It will add resize/scroll events and start recalculating
  33840. * position of the popper element when they are triggered.
  33841. * @method
  33842. * @memberof Popper
  33843. */
  33844. function enableEventListeners() {
  33845. if (!this.state.eventsEnabled) {
  33846. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33847. }
  33848. }
  33849. /**
  33850. * Remove event listeners used to update the popper position
  33851. * @method
  33852. * @memberof Popper.Utils
  33853. * @private
  33854. */
  33855. function removeEventListeners(reference, state) {
  33856. // Remove resize event listener on window
  33857. getWindow(reference).removeEventListener('resize', state.updateBound);
  33858. // Remove scroll event listener on scroll parents
  33859. state.scrollParents.forEach(function (target) {
  33860. target.removeEventListener('scroll', state.updateBound);
  33861. });
  33862. // Reset state
  33863. state.updateBound = null;
  33864. state.scrollParents = [];
  33865. state.scrollElement = null;
  33866. state.eventsEnabled = false;
  33867. return state;
  33868. }
  33869. /**
  33870. * It will remove resize/scroll events and won't recalculate popper position
  33871. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33872. * unless you call `update` method manually.
  33873. * @method
  33874. * @memberof Popper
  33875. */
  33876. function disableEventListeners() {
  33877. if (this.state.eventsEnabled) {
  33878. cancelAnimationFrame(this.scheduleUpdate);
  33879. this.state = removeEventListeners(this.reference, this.state);
  33880. }
  33881. }
  33882. /**
  33883. * Tells if a given input is a number
  33884. * @method
  33885. * @memberof Popper.Utils
  33886. * @param {*} input to check
  33887. * @return {Boolean}
  33888. */
  33889. function isNumeric(n) {
  33890. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33891. }
  33892. /**
  33893. * Set the style to the given popper
  33894. * @method
  33895. * @memberof Popper.Utils
  33896. * @argument {Element} element - Element to apply the style to
  33897. * @argument {Object} styles
  33898. * Object with a list of properties and values which will be applied to the element
  33899. */
  33900. function setStyles(element, styles) {
  33901. Object.keys(styles).forEach(function (prop) {
  33902. var unit = '';
  33903. // add unit if the value is numeric and is one of the following
  33904. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33905. unit = 'px';
  33906. }
  33907. element.style[prop] = styles[prop] + unit;
  33908. });
  33909. }
  33910. /**
  33911. * Set the attributes to the given popper
  33912. * @method
  33913. * @memberof Popper.Utils
  33914. * @argument {Element} element - Element to apply the attributes to
  33915. * @argument {Object} styles
  33916. * Object with a list of properties and values which will be applied to the element
  33917. */
  33918. function setAttributes(element, attributes) {
  33919. Object.keys(attributes).forEach(function (prop) {
  33920. var value = attributes[prop];
  33921. if (value !== false) {
  33922. element.setAttribute(prop, attributes[prop]);
  33923. } else {
  33924. element.removeAttribute(prop);
  33925. }
  33926. });
  33927. }
  33928. /**
  33929. * @function
  33930. * @memberof Modifiers
  33931. * @argument {Object} data - The data object generated by `update` method
  33932. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33933. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33934. * @argument {Object} options - Modifiers configuration and options
  33935. * @returns {Object} The same data object
  33936. */
  33937. function applyStyle(data) {
  33938. // any property present in `data.styles` will be applied to the popper,
  33939. // in this way we can make the 3rd party modifiers add custom styles to it
  33940. // Be aware, modifiers could override the properties defined in the previous
  33941. // lines of this modifier!
  33942. setStyles(data.instance.popper, data.styles);
  33943. // any property present in `data.attributes` will be applied to the popper,
  33944. // they will be set as HTML attributes of the element
  33945. setAttributes(data.instance.popper, data.attributes);
  33946. // if arrowElement is defined and arrowStyles has some properties
  33947. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33948. setStyles(data.arrowElement, data.arrowStyles);
  33949. }
  33950. return data;
  33951. }
  33952. /**
  33953. * Set the x-placement attribute before everything else because it could be used
  33954. * to add margins to the popper margins needs to be calculated to get the
  33955. * correct popper offsets.
  33956. * @method
  33957. * @memberof Popper.modifiers
  33958. * @param {HTMLElement} reference - The reference element used to position the popper
  33959. * @param {HTMLElement} popper - The HTML element used as popper
  33960. * @param {Object} options - Popper.js options
  33961. */
  33962. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33963. // compute reference element offsets
  33964. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33965. // compute auto placement, store placement inside the data object,
  33966. // modifiers will be able to edit `placement` if needed
  33967. // and refer to originalPlacement to know the original value
  33968. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33969. popper.setAttribute('x-placement', placement);
  33970. // Apply `position` to popper before anything else because
  33971. // without the position applied we can't guarantee correct computations
  33972. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33973. return options;
  33974. }
  33975. /**
  33976. * @function
  33977. * @memberof Popper.Utils
  33978. * @argument {Object} data - The data object generated by `update` method
  33979. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33980. * @returns {Object} The popper's position offsets rounded
  33981. *
  33982. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33983. * good as it can be within reason.
  33984. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33985. *
  33986. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33987. * as well on High DPI screens).
  33988. *
  33989. * Firefox prefers no rounding for positioning and does not have blurriness on
  33990. * high DPI screens.
  33991. *
  33992. * Only horizontal placement and left/right values need to be considered.
  33993. */
  33994. function getRoundedOffsets(data, shouldRound) {
  33995. var _data$offsets = data.offsets,
  33996. popper = _data$offsets.popper,
  33997. reference = _data$offsets.reference;
  33998. var round = Math.round,
  33999. floor = Math.floor;
  34000. var noRound = function noRound(v) {
  34001. return v;
  34002. };
  34003. var referenceWidth = round(reference.width);
  34004. var popperWidth = round(popper.width);
  34005. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34006. var isVariation = data.placement.indexOf('-') !== -1;
  34007. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34008. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34009. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34010. var verticalToInteger = !shouldRound ? noRound : round;
  34011. return {
  34012. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34013. top: verticalToInteger(popper.top),
  34014. bottom: verticalToInteger(popper.bottom),
  34015. right: horizontalToInteger(popper.right)
  34016. };
  34017. }
  34018. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34019. /**
  34020. * @function
  34021. * @memberof Modifiers
  34022. * @argument {Object} data - The data object generated by `update` method
  34023. * @argument {Object} options - Modifiers configuration and options
  34024. * @returns {Object} The data object, properly modified
  34025. */
  34026. function computeStyle(data, options) {
  34027. var x = options.x,
  34028. y = options.y;
  34029. var popper = data.offsets.popper;
  34030. // Remove this legacy support in Popper.js v2
  34031. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34032. return modifier.name === 'applyStyle';
  34033. }).gpuAcceleration;
  34034. if (legacyGpuAccelerationOption !== undefined) {
  34035. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34036. }
  34037. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34038. var offsetParent = getOffsetParent(data.instance.popper);
  34039. var offsetParentRect = getBoundingClientRect(offsetParent);
  34040. // Styles
  34041. var styles = {
  34042. position: popper.position
  34043. };
  34044. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34045. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34046. var sideB = y === 'right' ? 'left' : 'right';
  34047. // if gpuAcceleration is set to `true` and transform is supported,
  34048. // we use `translate3d` to apply the position to the popper we
  34049. // automatically use the supported prefixed version if needed
  34050. var prefixedProperty = getSupportedPropertyName('transform');
  34051. // now, let's make a step back and look at this code closely (wtf?)
  34052. // If the content of the popper grows once it's been positioned, it
  34053. // may happen that the popper gets misplaced because of the new content
  34054. // overflowing its reference element
  34055. // To avoid this problem, we provide two options (x and y), which allow
  34056. // the consumer to define the offset origin.
  34057. // If we position a popper on top of a reference element, we can set
  34058. // `x` to `top` to make the popper grow towards its top instead of
  34059. // its bottom.
  34060. var left = void 0,
  34061. top = void 0;
  34062. if (sideA === 'bottom') {
  34063. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34064. // and not the bottom of the html element
  34065. if (offsetParent.nodeName === 'HTML') {
  34066. top = -offsetParent.clientHeight + offsets.bottom;
  34067. } else {
  34068. top = -offsetParentRect.height + offsets.bottom;
  34069. }
  34070. } else {
  34071. top = offsets.top;
  34072. }
  34073. if (sideB === 'right') {
  34074. if (offsetParent.nodeName === 'HTML') {
  34075. left = -offsetParent.clientWidth + offsets.right;
  34076. } else {
  34077. left = -offsetParentRect.width + offsets.right;
  34078. }
  34079. } else {
  34080. left = offsets.left;
  34081. }
  34082. if (gpuAcceleration && prefixedProperty) {
  34083. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34084. styles[sideA] = 0;
  34085. styles[sideB] = 0;
  34086. styles.willChange = 'transform';
  34087. } else {
  34088. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34089. var invertTop = sideA === 'bottom' ? -1 : 1;
  34090. var invertLeft = sideB === 'right' ? -1 : 1;
  34091. styles[sideA] = top * invertTop;
  34092. styles[sideB] = left * invertLeft;
  34093. styles.willChange = sideA + ', ' + sideB;
  34094. }
  34095. // Attributes
  34096. var attributes = {
  34097. 'x-placement': data.placement
  34098. };
  34099. // Update `data` attributes, styles and arrowStyles
  34100. data.attributes = _extends({}, attributes, data.attributes);
  34101. data.styles = _extends({}, styles, data.styles);
  34102. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34103. return data;
  34104. }
  34105. /**
  34106. * Helper used to know if the given modifier depends from another one.<br />
  34107. * It checks if the needed modifier is listed and enabled.
  34108. * @method
  34109. * @memberof Popper.Utils
  34110. * @param {Array} modifiers - list of modifiers
  34111. * @param {String} requestingName - name of requesting modifier
  34112. * @param {String} requestedName - name of requested modifier
  34113. * @returns {Boolean}
  34114. */
  34115. function isModifierRequired(modifiers, requestingName, requestedName) {
  34116. var requesting = find(modifiers, function (_ref) {
  34117. var name = _ref.name;
  34118. return name === requestingName;
  34119. });
  34120. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34121. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34122. });
  34123. if (!isRequired) {
  34124. var _requesting = '`' + requestingName + '`';
  34125. var requested = '`' + requestedName + '`';
  34126. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34127. }
  34128. return isRequired;
  34129. }
  34130. /**
  34131. * @function
  34132. * @memberof Modifiers
  34133. * @argument {Object} data - The data object generated by update method
  34134. * @argument {Object} options - Modifiers configuration and options
  34135. * @returns {Object} The data object, properly modified
  34136. */
  34137. function arrow(data, options) {
  34138. var _data$offsets$arrow;
  34139. // arrow depends on keepTogether in order to work
  34140. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34141. return data;
  34142. }
  34143. var arrowElement = options.element;
  34144. // if arrowElement is a string, suppose it's a CSS selector
  34145. if (typeof arrowElement === 'string') {
  34146. arrowElement = data.instance.popper.querySelector(arrowElement);
  34147. // if arrowElement is not found, don't run the modifier
  34148. if (!arrowElement) {
  34149. return data;
  34150. }
  34151. } else {
  34152. // if the arrowElement isn't a query selector we must check that the
  34153. // provided DOM node is child of its popper node
  34154. if (!data.instance.popper.contains(arrowElement)) {
  34155. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34156. return data;
  34157. }
  34158. }
  34159. var placement = data.placement.split('-')[0];
  34160. var _data$offsets = data.offsets,
  34161. popper = _data$offsets.popper,
  34162. reference = _data$offsets.reference;
  34163. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34164. var len = isVertical ? 'height' : 'width';
  34165. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34166. var side = sideCapitalized.toLowerCase();
  34167. var altSide = isVertical ? 'left' : 'top';
  34168. var opSide = isVertical ? 'bottom' : 'right';
  34169. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34170. //
  34171. // extends keepTogether behavior making sure the popper and its
  34172. // reference have enough pixels in conjunction
  34173. //
  34174. // top/left side
  34175. if (reference[opSide] - arrowElementSize < popper[side]) {
  34176. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34177. }
  34178. // bottom/right side
  34179. if (reference[side] + arrowElementSize > popper[opSide]) {
  34180. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34181. }
  34182. data.offsets.popper = getClientRect(data.offsets.popper);
  34183. // compute center of the popper
  34184. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34185. // Compute the sideValue using the updated popper offsets
  34186. // take popper margin in account because we don't have this info available
  34187. var css = getStyleComputedProperty(data.instance.popper);
  34188. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34189. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34190. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34191. // prevent arrowElement from being placed not contiguously to its popper
  34192. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34193. data.arrowElement = arrowElement;
  34194. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34195. return data;
  34196. }
  34197. /**
  34198. * Get the opposite placement variation of the given one
  34199. * @method
  34200. * @memberof Popper.Utils
  34201. * @argument {String} placement variation
  34202. * @returns {String} flipped placement variation
  34203. */
  34204. function getOppositeVariation(variation) {
  34205. if (variation === 'end') {
  34206. return 'start';
  34207. } else if (variation === 'start') {
  34208. return 'end';
  34209. }
  34210. return variation;
  34211. }
  34212. /**
  34213. * List of accepted placements to use as values of the `placement` option.<br />
  34214. * Valid placements are:
  34215. * - `auto`
  34216. * - `top`
  34217. * - `right`
  34218. * - `bottom`
  34219. * - `left`
  34220. *
  34221. * Each placement can have a variation from this list:
  34222. * - `-start`
  34223. * - `-end`
  34224. *
  34225. * Variations are interpreted easily if you think of them as the left to right
  34226. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34227. * is right.<br />
  34228. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34229. *
  34230. * Some valid examples are:
  34231. * - `top-end` (on top of reference, right aligned)
  34232. * - `right-start` (on right of reference, top aligned)
  34233. * - `bottom` (on bottom, centered)
  34234. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34235. *
  34236. * @static
  34237. * @type {Array}
  34238. * @enum {String}
  34239. * @readonly
  34240. * @method placements
  34241. * @memberof Popper
  34242. */
  34243. 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'];
  34244. // Get rid of `auto` `auto-start` and `auto-end`
  34245. var validPlacements = placements.slice(3);
  34246. /**
  34247. * Given an initial placement, returns all the subsequent placements
  34248. * clockwise (or counter-clockwise).
  34249. *
  34250. * @method
  34251. * @memberof Popper.Utils
  34252. * @argument {String} placement - A valid placement (it accepts variations)
  34253. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34254. * @returns {Array} placements including their variations
  34255. */
  34256. function clockwise(placement) {
  34257. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34258. var index = validPlacements.indexOf(placement);
  34259. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34260. return counter ? arr.reverse() : arr;
  34261. }
  34262. var BEHAVIORS = {
  34263. FLIP: 'flip',
  34264. CLOCKWISE: 'clockwise',
  34265. COUNTERCLOCKWISE: 'counterclockwise'
  34266. };
  34267. /**
  34268. * @function
  34269. * @memberof Modifiers
  34270. * @argument {Object} data - The data object generated by update method
  34271. * @argument {Object} options - Modifiers configuration and options
  34272. * @returns {Object} The data object, properly modified
  34273. */
  34274. function flip(data, options) {
  34275. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34276. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34277. return data;
  34278. }
  34279. if (data.flipped && data.placement === data.originalPlacement) {
  34280. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34281. return data;
  34282. }
  34283. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34284. var placement = data.placement.split('-')[0];
  34285. var placementOpposite = getOppositePlacement(placement);
  34286. var variation = data.placement.split('-')[1] || '';
  34287. var flipOrder = [];
  34288. switch (options.behavior) {
  34289. case BEHAVIORS.FLIP:
  34290. flipOrder = [placement, placementOpposite];
  34291. break;
  34292. case BEHAVIORS.CLOCKWISE:
  34293. flipOrder = clockwise(placement);
  34294. break;
  34295. case BEHAVIORS.COUNTERCLOCKWISE:
  34296. flipOrder = clockwise(placement, true);
  34297. break;
  34298. default:
  34299. flipOrder = options.behavior;
  34300. }
  34301. flipOrder.forEach(function (step, index) {
  34302. if (placement !== step || flipOrder.length === index + 1) {
  34303. return data;
  34304. }
  34305. placement = data.placement.split('-')[0];
  34306. placementOpposite = getOppositePlacement(placement);
  34307. var popperOffsets = data.offsets.popper;
  34308. var refOffsets = data.offsets.reference;
  34309. // using floor because the reference offsets may contain decimals we are not going to consider here
  34310. var floor = Math.floor;
  34311. 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);
  34312. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34313. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34314. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34315. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34316. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34317. // flip the variation if required
  34318. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34319. // flips variation if reference element overflows boundaries
  34320. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34321. // flips variation if popper content overflows boundaries
  34322. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34323. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34324. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34325. // this boolean to detect any flip loop
  34326. data.flipped = true;
  34327. if (overlapsRef || overflowsBoundaries) {
  34328. placement = flipOrder[index + 1];
  34329. }
  34330. if (flippedVariation) {
  34331. variation = getOppositeVariation(variation);
  34332. }
  34333. data.placement = placement + (variation ? '-' + variation : '');
  34334. // this object contains `position`, we want to preserve it along with
  34335. // any additional property we may add in the future
  34336. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34337. data = runModifiers(data.instance.modifiers, data, 'flip');
  34338. }
  34339. });
  34340. return data;
  34341. }
  34342. /**
  34343. * @function
  34344. * @memberof Modifiers
  34345. * @argument {Object} data - The data object generated by update method
  34346. * @argument {Object} options - Modifiers configuration and options
  34347. * @returns {Object} The data object, properly modified
  34348. */
  34349. function keepTogether(data) {
  34350. var _data$offsets = data.offsets,
  34351. popper = _data$offsets.popper,
  34352. reference = _data$offsets.reference;
  34353. var placement = data.placement.split('-')[0];
  34354. var floor = Math.floor;
  34355. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34356. var side = isVertical ? 'right' : 'bottom';
  34357. var opSide = isVertical ? 'left' : 'top';
  34358. var measurement = isVertical ? 'width' : 'height';
  34359. if (popper[side] < floor(reference[opSide])) {
  34360. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34361. }
  34362. if (popper[opSide] > floor(reference[side])) {
  34363. data.offsets.popper[opSide] = floor(reference[side]);
  34364. }
  34365. return data;
  34366. }
  34367. /**
  34368. * Converts a string containing value + unit into a px value number
  34369. * @function
  34370. * @memberof {modifiers~offset}
  34371. * @private
  34372. * @argument {String} str - Value + unit string
  34373. * @argument {String} measurement - `height` or `width`
  34374. * @argument {Object} popperOffsets
  34375. * @argument {Object} referenceOffsets
  34376. * @returns {Number|String}
  34377. * Value in pixels, or original string if no values were extracted
  34378. */
  34379. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34380. // separate value from unit
  34381. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34382. var value = +split[1];
  34383. var unit = split[2];
  34384. // If it's not a number it's an operator, I guess
  34385. if (!value) {
  34386. return str;
  34387. }
  34388. if (unit.indexOf('%') === 0) {
  34389. var element = void 0;
  34390. switch (unit) {
  34391. case '%p':
  34392. element = popperOffsets;
  34393. break;
  34394. case '%':
  34395. case '%r':
  34396. default:
  34397. element = referenceOffsets;
  34398. }
  34399. var rect = getClientRect(element);
  34400. return rect[measurement] / 100 * value;
  34401. } else if (unit === 'vh' || unit === 'vw') {
  34402. // if is a vh or vw, we calculate the size based on the viewport
  34403. var size = void 0;
  34404. if (unit === 'vh') {
  34405. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34406. } else {
  34407. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34408. }
  34409. return size / 100 * value;
  34410. } else {
  34411. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34412. // if is an implicit unit, it's px, and we return just the value
  34413. return value;
  34414. }
  34415. }
  34416. /**
  34417. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34418. * @function
  34419. * @memberof {modifiers~offset}
  34420. * @private
  34421. * @argument {String} offset
  34422. * @argument {Object} popperOffsets
  34423. * @argument {Object} referenceOffsets
  34424. * @argument {String} basePlacement
  34425. * @returns {Array} a two cells array with x and y offsets in numbers
  34426. */
  34427. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34428. var offsets = [0, 0];
  34429. // Use height if placement is left or right and index is 0 otherwise use width
  34430. // in this way the first offset will use an axis and the second one
  34431. // will use the other one
  34432. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34433. // Split the offset string to obtain a list of values and operands
  34434. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34435. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34436. return frag.trim();
  34437. });
  34438. // Detect if the offset string contains a pair of values or a single one
  34439. // they could be separated by comma or space
  34440. var divider = fragments.indexOf(find(fragments, function (frag) {
  34441. return frag.search(/,|\s/) !== -1;
  34442. }));
  34443. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34444. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34445. }
  34446. // If divider is found, we divide the list of values and operands to divide
  34447. // them by ofset X and Y.
  34448. var splitRegex = /\s*,\s*|\s+/;
  34449. 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];
  34450. // Convert the values with units to absolute pixels to allow our computations
  34451. ops = ops.map(function (op, index) {
  34452. // Most of the units rely on the orientation of the popper
  34453. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34454. var mergeWithPrevious = false;
  34455. return op
  34456. // This aggregates any `+` or `-` sign that aren't considered operators
  34457. // e.g.: 10 + +5 => [10, +, +5]
  34458. .reduce(function (a, b) {
  34459. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34460. a[a.length - 1] = b;
  34461. mergeWithPrevious = true;
  34462. return a;
  34463. } else if (mergeWithPrevious) {
  34464. a[a.length - 1] += b;
  34465. mergeWithPrevious = false;
  34466. return a;
  34467. } else {
  34468. return a.concat(b);
  34469. }
  34470. }, [])
  34471. // Here we convert the string values into number values (in px)
  34472. .map(function (str) {
  34473. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34474. });
  34475. });
  34476. // Loop trough the offsets arrays and execute the operations
  34477. ops.forEach(function (op, index) {
  34478. op.forEach(function (frag, index2) {
  34479. if (isNumeric(frag)) {
  34480. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34481. }
  34482. });
  34483. });
  34484. return offsets;
  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. * @argument {Number|String} options.offset=0
  34492. * The offset value as described in the modifier description
  34493. * @returns {Object} The data object, properly modified
  34494. */
  34495. function offset(data, _ref) {
  34496. var offset = _ref.offset;
  34497. var placement = data.placement,
  34498. _data$offsets = data.offsets,
  34499. popper = _data$offsets.popper,
  34500. reference = _data$offsets.reference;
  34501. var basePlacement = placement.split('-')[0];
  34502. var offsets = void 0;
  34503. if (isNumeric(+offset)) {
  34504. offsets = [+offset, 0];
  34505. } else {
  34506. offsets = parseOffset(offset, popper, reference, basePlacement);
  34507. }
  34508. if (basePlacement === 'left') {
  34509. popper.top += offsets[0];
  34510. popper.left -= offsets[1];
  34511. } else if (basePlacement === 'right') {
  34512. popper.top += offsets[0];
  34513. popper.left += offsets[1];
  34514. } else if (basePlacement === 'top') {
  34515. popper.left += offsets[0];
  34516. popper.top -= offsets[1];
  34517. } else if (basePlacement === 'bottom') {
  34518. popper.left += offsets[0];
  34519. popper.top += offsets[1];
  34520. }
  34521. data.popper = popper;
  34522. return data;
  34523. }
  34524. /**
  34525. * @function
  34526. * @memberof Modifiers
  34527. * @argument {Object} data - The data object generated by `update` method
  34528. * @argument {Object} options - Modifiers configuration and options
  34529. * @returns {Object} The data object, properly modified
  34530. */
  34531. function preventOverflow(data, options) {
  34532. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34533. // If offsetParent is the reference element, we really want to
  34534. // go one step up and use the next offsetParent as reference to
  34535. // avoid to make this modifier completely useless and look like broken
  34536. if (data.instance.reference === boundariesElement) {
  34537. boundariesElement = getOffsetParent(boundariesElement);
  34538. }
  34539. // NOTE: DOM access here
  34540. // resets the popper's position so that the document size can be calculated excluding
  34541. // the size of the popper element itself
  34542. var transformProp = getSupportedPropertyName('transform');
  34543. var popperStyles = data.instance.popper.style; // assignment to help minification
  34544. var top = popperStyles.top,
  34545. left = popperStyles.left,
  34546. transform = popperStyles[transformProp];
  34547. popperStyles.top = '';
  34548. popperStyles.left = '';
  34549. popperStyles[transformProp] = '';
  34550. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34551. // NOTE: DOM access here
  34552. // restores the original style properties after the offsets have been computed
  34553. popperStyles.top = top;
  34554. popperStyles.left = left;
  34555. popperStyles[transformProp] = transform;
  34556. options.boundaries = boundaries;
  34557. var order = options.priority;
  34558. var popper = data.offsets.popper;
  34559. var check = {
  34560. primary: function primary(placement) {
  34561. var value = popper[placement];
  34562. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34563. value = Math.max(popper[placement], boundaries[placement]);
  34564. }
  34565. return defineProperty({}, placement, value);
  34566. },
  34567. secondary: function secondary(placement) {
  34568. var mainSide = placement === 'right' ? 'left' : 'top';
  34569. var value = popper[mainSide];
  34570. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34571. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34572. }
  34573. return defineProperty({}, mainSide, value);
  34574. }
  34575. };
  34576. order.forEach(function (placement) {
  34577. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34578. popper = _extends({}, popper, check[side](placement));
  34579. });
  34580. data.offsets.popper = popper;
  34581. return data;
  34582. }
  34583. /**
  34584. * @function
  34585. * @memberof Modifiers
  34586. * @argument {Object} data - The data object generated by `update` method
  34587. * @argument {Object} options - Modifiers configuration and options
  34588. * @returns {Object} The data object, properly modified
  34589. */
  34590. function shift(data) {
  34591. var placement = data.placement;
  34592. var basePlacement = placement.split('-')[0];
  34593. var shiftvariation = placement.split('-')[1];
  34594. // if shift shiftvariation is specified, run the modifier
  34595. if (shiftvariation) {
  34596. var _data$offsets = data.offsets,
  34597. reference = _data$offsets.reference,
  34598. popper = _data$offsets.popper;
  34599. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34600. var side = isVertical ? 'left' : 'top';
  34601. var measurement = isVertical ? 'width' : 'height';
  34602. var shiftOffsets = {
  34603. start: defineProperty({}, side, reference[side]),
  34604. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34605. };
  34606. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34607. }
  34608. return data;
  34609. }
  34610. /**
  34611. * @function
  34612. * @memberof Modifiers
  34613. * @argument {Object} data - The data object generated by update method
  34614. * @argument {Object} options - Modifiers configuration and options
  34615. * @returns {Object} The data object, properly modified
  34616. */
  34617. function hide(data) {
  34618. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34619. return data;
  34620. }
  34621. var refRect = data.offsets.reference;
  34622. var bound = find(data.instance.modifiers, function (modifier) {
  34623. return modifier.name === 'preventOverflow';
  34624. }).boundaries;
  34625. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34626. // Avoid unnecessary DOM access if visibility hasn't changed
  34627. if (data.hide === true) {
  34628. return data;
  34629. }
  34630. data.hide = true;
  34631. data.attributes['x-out-of-boundaries'] = '';
  34632. } else {
  34633. // Avoid unnecessary DOM access if visibility hasn't changed
  34634. if (data.hide === false) {
  34635. return data;
  34636. }
  34637. data.hide = false;
  34638. data.attributes['x-out-of-boundaries'] = false;
  34639. }
  34640. return data;
  34641. }
  34642. /**
  34643. * @function
  34644. * @memberof Modifiers
  34645. * @argument {Object} data - The data object generated by `update` method
  34646. * @argument {Object} options - Modifiers configuration and options
  34647. * @returns {Object} The data object, properly modified
  34648. */
  34649. function inner(data) {
  34650. var placement = data.placement;
  34651. var basePlacement = placement.split('-')[0];
  34652. var _data$offsets = data.offsets,
  34653. popper = _data$offsets.popper,
  34654. reference = _data$offsets.reference;
  34655. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34656. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34657. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34658. data.placement = getOppositePlacement(placement);
  34659. data.offsets.popper = getClientRect(popper);
  34660. return data;
  34661. }
  34662. /**
  34663. * Modifier function, each modifier can have a function of this type assigned
  34664. * to its `fn` property.<br />
  34665. * These functions will be called on each update, this means that you must
  34666. * make sure they are performant enough to avoid performance bottlenecks.
  34667. *
  34668. * @function ModifierFn
  34669. * @argument {dataObject} data - The data object generated by `update` method
  34670. * @argument {Object} options - Modifiers configuration and options
  34671. * @returns {dataObject} The data object, properly modified
  34672. */
  34673. /**
  34674. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34675. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34676. * needed by the library.
  34677. *
  34678. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34679. * All the other properties are configurations that could be tweaked.
  34680. * @namespace modifiers
  34681. */
  34682. var modifiers = {
  34683. /**
  34684. * Modifier used to shift the popper on the start or end of its reference
  34685. * element.<br />
  34686. * It will read the variation of the `placement` property.<br />
  34687. * It can be one either `-end` or `-start`.
  34688. * @memberof modifiers
  34689. * @inner
  34690. */
  34691. shift: {
  34692. /** @prop {number} order=100 - Index used to define the order of execution */
  34693. order: 100,
  34694. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34695. enabled: true,
  34696. /** @prop {ModifierFn} */
  34697. fn: shift
  34698. },
  34699. /**
  34700. * The `offset` modifier can shift your popper on both its axis.
  34701. *
  34702. * It accepts the following units:
  34703. * - `px` or unit-less, interpreted as pixels
  34704. * - `%` or `%r`, percentage relative to the length of the reference element
  34705. * - `%p`, percentage relative to the length of the popper element
  34706. * - `vw`, CSS viewport width unit
  34707. * - `vh`, CSS viewport height unit
  34708. *
  34709. * For length is intended the main axis relative to the placement of the popper.<br />
  34710. * This means that if the placement is `top` or `bottom`, the length will be the
  34711. * `width`. In case of `left` or `right`, it will be the `height`.
  34712. *
  34713. * You can provide a single value (as `Number` or `String`), or a pair of values
  34714. * as `String` divided by a comma or one (or more) white spaces.<br />
  34715. * The latter is a deprecated method because it leads to confusion and will be
  34716. * removed in v2.<br />
  34717. * Additionally, it accepts additions and subtractions between different units.
  34718. * Note that multiplications and divisions aren't supported.
  34719. *
  34720. * Valid examples are:
  34721. * ```
  34722. * 10
  34723. * '10%'
  34724. * '10, 10'
  34725. * '10%, 10'
  34726. * '10 + 10%'
  34727. * '10 - 5vh + 3%'
  34728. * '-10px + 5vh, 5px - 6%'
  34729. * ```
  34730. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34731. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34732. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34733. *
  34734. * @memberof modifiers
  34735. * @inner
  34736. */
  34737. offset: {
  34738. /** @prop {number} order=200 - Index used to define the order of execution */
  34739. order: 200,
  34740. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34741. enabled: true,
  34742. /** @prop {ModifierFn} */
  34743. fn: offset,
  34744. /** @prop {Number|String} offset=0
  34745. * The offset value as described in the modifier description
  34746. */
  34747. offset: 0
  34748. },
  34749. /**
  34750. * Modifier used to prevent the popper from being positioned outside the boundary.
  34751. *
  34752. * A scenario exists where the reference itself is not within the boundaries.<br />
  34753. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34754. * In this case we need to decide whether the popper should either:
  34755. *
  34756. * - detach from the reference and remain "trapped" in the boundaries, or
  34757. * - if it should ignore the boundary and "escape with its reference"
  34758. *
  34759. * When `escapeWithReference` is set to`true` and reference is completely
  34760. * outside its boundaries, the popper will overflow (or completely leave)
  34761. * the boundaries in order to remain attached to the edge of the reference.
  34762. *
  34763. * @memberof modifiers
  34764. * @inner
  34765. */
  34766. preventOverflow: {
  34767. /** @prop {number} order=300 - Index used to define the order of execution */
  34768. order: 300,
  34769. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34770. enabled: true,
  34771. /** @prop {ModifierFn} */
  34772. fn: preventOverflow,
  34773. /**
  34774. * @prop {Array} [priority=['left','right','top','bottom']]
  34775. * Popper will try to prevent overflow following these priorities by default,
  34776. * then, it could overflow on the left and on top of the `boundariesElement`
  34777. */
  34778. priority: ['left', 'right', 'top', 'bottom'],
  34779. /**
  34780. * @prop {number} padding=5
  34781. * Amount of pixel used to define a minimum distance between the boundaries
  34782. * and the popper. This makes sure the popper always has a little padding
  34783. * between the edges of its container
  34784. */
  34785. padding: 5,
  34786. /**
  34787. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34788. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34789. * `viewport` or any DOM element.
  34790. */
  34791. boundariesElement: 'scrollParent'
  34792. },
  34793. /**
  34794. * Modifier used to make sure the reference and its popper stay near each other
  34795. * without leaving any gap between the two. Especially useful when the arrow is
  34796. * enabled and you want to ensure that it points to its reference element.
  34797. * It cares only about the first axis. You can still have poppers with margin
  34798. * between the popper and its reference element.
  34799. * @memberof modifiers
  34800. * @inner
  34801. */
  34802. keepTogether: {
  34803. /** @prop {number} order=400 - Index used to define the order of execution */
  34804. order: 400,
  34805. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34806. enabled: true,
  34807. /** @prop {ModifierFn} */
  34808. fn: keepTogether
  34809. },
  34810. /**
  34811. * This modifier is used to move the `arrowElement` of the popper to make
  34812. * sure it is positioned between the reference element and its popper element.
  34813. * It will read the outer size of the `arrowElement` node to detect how many
  34814. * pixels of conjunction are needed.
  34815. *
  34816. * It has no effect if no `arrowElement` is provided.
  34817. * @memberof modifiers
  34818. * @inner
  34819. */
  34820. arrow: {
  34821. /** @prop {number} order=500 - Index used to define the order of execution */
  34822. order: 500,
  34823. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34824. enabled: true,
  34825. /** @prop {ModifierFn} */
  34826. fn: arrow,
  34827. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34828. element: '[x-arrow]'
  34829. },
  34830. /**
  34831. * Modifier used to flip the popper's placement when it starts to overlap its
  34832. * reference element.
  34833. *
  34834. * Requires the `preventOverflow` modifier before it in order to work.
  34835. *
  34836. * **NOTE:** this modifier will interrupt the current update cycle and will
  34837. * restart it if it detects the need to flip the placement.
  34838. * @memberof modifiers
  34839. * @inner
  34840. */
  34841. flip: {
  34842. /** @prop {number} order=600 - Index used to define the order of execution */
  34843. order: 600,
  34844. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34845. enabled: true,
  34846. /** @prop {ModifierFn} */
  34847. fn: flip,
  34848. /**
  34849. * @prop {String|Array} behavior='flip'
  34850. * The behavior used to change the popper's placement. It can be one of
  34851. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34852. * placements (with optional variations)
  34853. */
  34854. behavior: 'flip',
  34855. /**
  34856. * @prop {number} padding=5
  34857. * The popper will flip if it hits the edges of the `boundariesElement`
  34858. */
  34859. padding: 5,
  34860. /**
  34861. * @prop {String|HTMLElement} boundariesElement='viewport'
  34862. * The element which will define the boundaries of the popper position.
  34863. * The popper will never be placed outside of the defined boundaries
  34864. * (except if `keepTogether` is enabled)
  34865. */
  34866. boundariesElement: 'viewport',
  34867. /**
  34868. * @prop {Boolean} flipVariations=false
  34869. * The popper will switch placement variation between `-start` and `-end` when
  34870. * the reference element overlaps its boundaries.
  34871. *
  34872. * The original placement should have a set variation.
  34873. */
  34874. flipVariations: false,
  34875. /**
  34876. * @prop {Boolean} flipVariationsByContent=false
  34877. * The popper will switch placement variation between `-start` and `-end` when
  34878. * the popper element overlaps its reference boundaries.
  34879. *
  34880. * The original placement should have a set variation.
  34881. */
  34882. flipVariationsByContent: false
  34883. },
  34884. /**
  34885. * Modifier used to make the popper flow toward the inner of the reference element.
  34886. * By default, when this modifier is disabled, the popper will be placed outside
  34887. * the reference element.
  34888. * @memberof modifiers
  34889. * @inner
  34890. */
  34891. inner: {
  34892. /** @prop {number} order=700 - Index used to define the order of execution */
  34893. order: 700,
  34894. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34895. enabled: false,
  34896. /** @prop {ModifierFn} */
  34897. fn: inner
  34898. },
  34899. /**
  34900. * Modifier used to hide the popper when its reference element is outside of the
  34901. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34902. * be used to hide with a CSS selector the popper when its reference is
  34903. * out of boundaries.
  34904. *
  34905. * Requires the `preventOverflow` modifier before it in order to work.
  34906. * @memberof modifiers
  34907. * @inner
  34908. */
  34909. hide: {
  34910. /** @prop {number} order=800 - Index used to define the order of execution */
  34911. order: 800,
  34912. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34913. enabled: true,
  34914. /** @prop {ModifierFn} */
  34915. fn: hide
  34916. },
  34917. /**
  34918. * Computes the style that will be applied to the popper element to gets
  34919. * properly positioned.
  34920. *
  34921. * Note that this modifier will not touch the DOM, it just prepares the styles
  34922. * so that `applyStyle` modifier can apply it. This separation is useful
  34923. * in case you need to replace `applyStyle` with a custom implementation.
  34924. *
  34925. * This modifier has `850` as `order` value to maintain backward compatibility
  34926. * with previous versions of Popper.js. Expect the modifiers ordering method
  34927. * to change in future major versions of the library.
  34928. *
  34929. * @memberof modifiers
  34930. * @inner
  34931. */
  34932. computeStyle: {
  34933. /** @prop {number} order=850 - Index used to define the order of execution */
  34934. order: 850,
  34935. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34936. enabled: true,
  34937. /** @prop {ModifierFn} */
  34938. fn: computeStyle,
  34939. /**
  34940. * @prop {Boolean} gpuAcceleration=true
  34941. * If true, it uses the CSS 3D transformation to position the popper.
  34942. * Otherwise, it will use the `top` and `left` properties
  34943. */
  34944. gpuAcceleration: true,
  34945. /**
  34946. * @prop {string} [x='bottom']
  34947. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34948. * Change this if your popper should grow in a direction different from `bottom`
  34949. */
  34950. x: 'bottom',
  34951. /**
  34952. * @prop {string} [x='left']
  34953. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34954. * Change this if your popper should grow in a direction different from `right`
  34955. */
  34956. y: 'right'
  34957. },
  34958. /**
  34959. * Applies the computed styles to the popper element.
  34960. *
  34961. * All the DOM manipulations are limited to this modifier. This is useful in case
  34962. * you want to integrate Popper.js inside a framework or view library and you
  34963. * want to delegate all the DOM manipulations to it.
  34964. *
  34965. * Note that if you disable this modifier, you must make sure the popper element
  34966. * has its position set to `absolute` before Popper.js can do its work!
  34967. *
  34968. * Just disable this modifier and define your own to achieve the desired effect.
  34969. *
  34970. * @memberof modifiers
  34971. * @inner
  34972. */
  34973. applyStyle: {
  34974. /** @prop {number} order=900 - Index used to define the order of execution */
  34975. order: 900,
  34976. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34977. enabled: true,
  34978. /** @prop {ModifierFn} */
  34979. fn: applyStyle,
  34980. /** @prop {Function} */
  34981. onLoad: applyStyleOnLoad,
  34982. /**
  34983. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34984. * @prop {Boolean} gpuAcceleration=true
  34985. * If true, it uses the CSS 3D transformation to position the popper.
  34986. * Otherwise, it will use the `top` and `left` properties
  34987. */
  34988. gpuAcceleration: undefined
  34989. }
  34990. };
  34991. /**
  34992. * The `dataObject` is an object containing all the information used by Popper.js.
  34993. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34994. * @name dataObject
  34995. * @property {Object} data.instance The Popper.js instance
  34996. * @property {String} data.placement Placement applied to popper
  34997. * @property {String} data.originalPlacement Placement originally defined on init
  34998. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34999. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35000. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35001. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35002. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35003. * @property {Object} data.boundaries Offsets of the popper boundaries
  35004. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35005. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35006. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35007. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35008. */
  35009. /**
  35010. * Default options provided to Popper.js constructor.<br />
  35011. * These can be overridden using the `options` argument of Popper.js.<br />
  35012. * To override an option, simply pass an object with the same
  35013. * structure of the `options` object, as the 3rd argument. For example:
  35014. * ```
  35015. * new Popper(ref, pop, {
  35016. * modifiers: {
  35017. * preventOverflow: { enabled: false }
  35018. * }
  35019. * })
  35020. * ```
  35021. * @type {Object}
  35022. * @static
  35023. * @memberof Popper
  35024. */
  35025. var Defaults = {
  35026. /**
  35027. * Popper's placement.
  35028. * @prop {Popper.placements} placement='bottom'
  35029. */
  35030. placement: 'bottom',
  35031. /**
  35032. * Set this to true if you want popper to position it self in 'fixed' mode
  35033. * @prop {Boolean} positionFixed=false
  35034. */
  35035. positionFixed: false,
  35036. /**
  35037. * Whether events (resize, scroll) are initially enabled.
  35038. * @prop {Boolean} eventsEnabled=true
  35039. */
  35040. eventsEnabled: true,
  35041. /**
  35042. * Set to true if you want to automatically remove the popper when
  35043. * you call the `destroy` method.
  35044. * @prop {Boolean} removeOnDestroy=false
  35045. */
  35046. removeOnDestroy: false,
  35047. /**
  35048. * Callback called when the popper is created.<br />
  35049. * By default, it is set to no-op.<br />
  35050. * Access Popper.js instance with `data.instance`.
  35051. * @prop {onCreate}
  35052. */
  35053. onCreate: function onCreate() {},
  35054. /**
  35055. * Callback called when the popper is updated. This callback is not called
  35056. * on the initialization/creation of the popper, but only on subsequent
  35057. * updates.<br />
  35058. * By default, it is set to no-op.<br />
  35059. * Access Popper.js instance with `data.instance`.
  35060. * @prop {onUpdate}
  35061. */
  35062. onUpdate: function onUpdate() {},
  35063. /**
  35064. * List of modifiers used to modify the offsets before they are applied to the popper.
  35065. * They provide most of the functionalities of Popper.js.
  35066. * @prop {modifiers}
  35067. */
  35068. modifiers: modifiers
  35069. };
  35070. /**
  35071. * @callback onCreate
  35072. * @param {dataObject} data
  35073. */
  35074. /**
  35075. * @callback onUpdate
  35076. * @param {dataObject} data
  35077. */
  35078. // Utils
  35079. // Methods
  35080. var Popper = function () {
  35081. /**
  35082. * Creates a new Popper.js instance.
  35083. * @class Popper
  35084. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35085. * @param {Element} popper - The HTML / XML element used as the popper
  35086. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35087. * @return {Object} instance - The generated Popper.js instance
  35088. */
  35089. function Popper(reference, popper) {
  35090. var _this = this;
  35091. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35092. classCallCheck(this, Popper);
  35093. this.scheduleUpdate = function () {
  35094. return requestAnimationFrame(_this.update);
  35095. };
  35096. // make update() debounced, so that it only runs at most once-per-tick
  35097. this.update = debounce(this.update.bind(this));
  35098. // with {} we create a new object with the options inside it
  35099. this.options = _extends({}, Popper.Defaults, options);
  35100. // init state
  35101. this.state = {
  35102. isDestroyed: false,
  35103. isCreated: false,
  35104. scrollParents: []
  35105. };
  35106. // get reference and popper elements (allow jQuery wrappers)
  35107. this.reference = reference && reference.jquery ? reference[0] : reference;
  35108. this.popper = popper && popper.jquery ? popper[0] : popper;
  35109. // Deep merge modifiers options
  35110. this.options.modifiers = {};
  35111. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35112. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35113. });
  35114. // Refactoring modifiers' list (Object => Array)
  35115. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35116. return _extends({
  35117. name: name
  35118. }, _this.options.modifiers[name]);
  35119. })
  35120. // sort the modifiers by order
  35121. .sort(function (a, b) {
  35122. return a.order - b.order;
  35123. });
  35124. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35125. // such code is executed in the same order of its modifier
  35126. // they could add new properties to their options configuration
  35127. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35128. this.modifiers.forEach(function (modifierOptions) {
  35129. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35130. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35131. }
  35132. });
  35133. // fire the first update to position the popper in the right place
  35134. this.update();
  35135. var eventsEnabled = this.options.eventsEnabled;
  35136. if (eventsEnabled) {
  35137. // setup event listeners, they will take care of update the position in specific situations
  35138. this.enableEventListeners();
  35139. }
  35140. this.state.eventsEnabled = eventsEnabled;
  35141. }
  35142. // We can't use class properties because they don't get listed in the
  35143. // class prototype and break stuff like Sinon stubs
  35144. createClass(Popper, [{
  35145. key: 'update',
  35146. value: function update$$1() {
  35147. return update.call(this);
  35148. }
  35149. }, {
  35150. key: 'destroy',
  35151. value: function destroy$$1() {
  35152. return destroy.call(this);
  35153. }
  35154. }, {
  35155. key: 'enableEventListeners',
  35156. value: function enableEventListeners$$1() {
  35157. return enableEventListeners.call(this);
  35158. }
  35159. }, {
  35160. key: 'disableEventListeners',
  35161. value: function disableEventListeners$$1() {
  35162. return disableEventListeners.call(this);
  35163. }
  35164. /**
  35165. * Schedules an update. It will run on the next UI update available.
  35166. * @method scheduleUpdate
  35167. * @memberof Popper
  35168. */
  35169. /**
  35170. * Collection of utilities useful when writing custom modifiers.
  35171. * Starting from version 1.7, this method is available only if you
  35172. * include `popper-utils.js` before `popper.js`.
  35173. *
  35174. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35175. * and will be removed in v2! Use the PopperUtils module directly instead.
  35176. * Due to the high instability of the methods contained in Utils, we can't
  35177. * guarantee them to follow semver. Use them at your own risk!
  35178. * @static
  35179. * @private
  35180. * @type {Object}
  35181. * @deprecated since version 1.8
  35182. * @member Utils
  35183. * @memberof Popper
  35184. */
  35185. }]);
  35186. return Popper;
  35187. }();
  35188. /**
  35189. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35190. * and lets you use it as replacement of a real DOM node.<br />
  35191. * You can use this method to position a popper relatively to a set of coordinates
  35192. * in case you don't have a DOM node to use as reference.
  35193. *
  35194. * ```
  35195. * new Popper(referenceObject, popperNode);
  35196. * ```
  35197. *
  35198. * NB: This feature isn't supported in Internet Explorer 10.
  35199. * @name referenceObject
  35200. * @property {Function} data.getBoundingClientRect
  35201. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35202. * @property {number} data.clientWidth
  35203. * An ES6 getter that will return the width of the virtual reference element.
  35204. * @property {number} data.clientHeight
  35205. * An ES6 getter that will return the height of the virtual reference element.
  35206. */
  35207. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35208. Popper.placements = placements;
  35209. Popper.Defaults = Defaults;
  35210. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35211. //# sourceMappingURL=popper.js.map
  35212. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35213. /***/ }),
  35214. /***/ "./node_modules/process/browser.js":
  35215. /*!*****************************************!*\
  35216. !*** ./node_modules/process/browser.js ***!
  35217. \*****************************************/
  35218. /*! no static exports found */
  35219. /***/ (function(module, exports) {
  35220. // shim for using process in browser
  35221. var process = module.exports = {};
  35222. // cached from whatever global is present so that test runners that stub it
  35223. // don't break things. But we need to wrap it in a try catch in case it is
  35224. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35225. // function because try/catches deoptimize in certain engines.
  35226. var cachedSetTimeout;
  35227. var cachedClearTimeout;
  35228. function defaultSetTimout() {
  35229. throw new Error('setTimeout has not been defined');
  35230. }
  35231. function defaultClearTimeout () {
  35232. throw new Error('clearTimeout has not been defined');
  35233. }
  35234. (function () {
  35235. try {
  35236. if (typeof setTimeout === 'function') {
  35237. cachedSetTimeout = setTimeout;
  35238. } else {
  35239. cachedSetTimeout = defaultSetTimout;
  35240. }
  35241. } catch (e) {
  35242. cachedSetTimeout = defaultSetTimout;
  35243. }
  35244. try {
  35245. if (typeof clearTimeout === 'function') {
  35246. cachedClearTimeout = clearTimeout;
  35247. } else {
  35248. cachedClearTimeout = defaultClearTimeout;
  35249. }
  35250. } catch (e) {
  35251. cachedClearTimeout = defaultClearTimeout;
  35252. }
  35253. } ())
  35254. function runTimeout(fun) {
  35255. if (cachedSetTimeout === setTimeout) {
  35256. //normal enviroments in sane situations
  35257. return setTimeout(fun, 0);
  35258. }
  35259. // if setTimeout wasn't available but was latter defined
  35260. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35261. cachedSetTimeout = setTimeout;
  35262. return setTimeout(fun, 0);
  35263. }
  35264. try {
  35265. // when when somebody has screwed with setTimeout but no I.E. maddness
  35266. return cachedSetTimeout(fun, 0);
  35267. } catch(e){
  35268. try {
  35269. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35270. return cachedSetTimeout.call(null, fun, 0);
  35271. } catch(e){
  35272. // 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
  35273. return cachedSetTimeout.call(this, fun, 0);
  35274. }
  35275. }
  35276. }
  35277. function runClearTimeout(marker) {
  35278. if (cachedClearTimeout === clearTimeout) {
  35279. //normal enviroments in sane situations
  35280. return clearTimeout(marker);
  35281. }
  35282. // if clearTimeout wasn't available but was latter defined
  35283. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35284. cachedClearTimeout = clearTimeout;
  35285. return clearTimeout(marker);
  35286. }
  35287. try {
  35288. // when when somebody has screwed with setTimeout but no I.E. maddness
  35289. return cachedClearTimeout(marker);
  35290. } catch (e){
  35291. try {
  35292. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35293. return cachedClearTimeout.call(null, marker);
  35294. } catch (e){
  35295. // 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.
  35296. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35297. return cachedClearTimeout.call(this, marker);
  35298. }
  35299. }
  35300. }
  35301. var queue = [];
  35302. var draining = false;
  35303. var currentQueue;
  35304. var queueIndex = -1;
  35305. function cleanUpNextTick() {
  35306. if (!draining || !currentQueue) {
  35307. return;
  35308. }
  35309. draining = false;
  35310. if (currentQueue.length) {
  35311. queue = currentQueue.concat(queue);
  35312. } else {
  35313. queueIndex = -1;
  35314. }
  35315. if (queue.length) {
  35316. drainQueue();
  35317. }
  35318. }
  35319. function drainQueue() {
  35320. if (draining) {
  35321. return;
  35322. }
  35323. var timeout = runTimeout(cleanUpNextTick);
  35324. draining = true;
  35325. var len = queue.length;
  35326. while(len) {
  35327. currentQueue = queue;
  35328. queue = [];
  35329. while (++queueIndex < len) {
  35330. if (currentQueue) {
  35331. currentQueue[queueIndex].run();
  35332. }
  35333. }
  35334. queueIndex = -1;
  35335. len = queue.length;
  35336. }
  35337. currentQueue = null;
  35338. draining = false;
  35339. runClearTimeout(timeout);
  35340. }
  35341. process.nextTick = function (fun) {
  35342. var args = new Array(arguments.length - 1);
  35343. if (arguments.length > 1) {
  35344. for (var i = 1; i < arguments.length; i++) {
  35345. args[i - 1] = arguments[i];
  35346. }
  35347. }
  35348. queue.push(new Item(fun, args));
  35349. if (queue.length === 1 && !draining) {
  35350. runTimeout(drainQueue);
  35351. }
  35352. };
  35353. // v8 likes predictible objects
  35354. function Item(fun, array) {
  35355. this.fun = fun;
  35356. this.array = array;
  35357. }
  35358. Item.prototype.run = function () {
  35359. this.fun.apply(null, this.array);
  35360. };
  35361. process.title = 'browser';
  35362. process.browser = true;
  35363. process.env = {};
  35364. process.argv = [];
  35365. process.version = ''; // empty string to avoid regexp issues
  35366. process.versions = {};
  35367. function noop() {}
  35368. process.on = noop;
  35369. process.addListener = noop;
  35370. process.once = noop;
  35371. process.off = noop;
  35372. process.removeListener = noop;
  35373. process.removeAllListeners = noop;
  35374. process.emit = noop;
  35375. process.prependListener = noop;
  35376. process.prependOnceListener = noop;
  35377. process.listeners = function (name) { return [] }
  35378. process.binding = function (name) {
  35379. throw new Error('process.binding is not supported');
  35380. };
  35381. process.cwd = function () { return '/' };
  35382. process.chdir = function (dir) {
  35383. throw new Error('process.chdir is not supported');
  35384. };
  35385. process.umask = function() { return 0; };
  35386. /***/ }),
  35387. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35388. /*!***************************************************!*\
  35389. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35390. \***************************************************/
  35391. /*! no static exports found */
  35392. /***/ (function(module, exports, __webpack_require__) {
  35393. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35394. * Pusher JavaScript Library v5.0.3
  35395. * https://pusher.com/
  35396. *
  35397. * Copyright 2017, Pusher
  35398. * Released under the MIT licence.
  35399. */
  35400. (function webpackUniversalModuleDefinition(root, factory) {
  35401. if(true)
  35402. module.exports = factory();
  35403. else {}
  35404. })(window, function() {
  35405. return /******/ (function(modules) { // webpackBootstrap
  35406. /******/ // The module cache
  35407. /******/ var installedModules = {};
  35408. /******/
  35409. /******/ // The require function
  35410. /******/ function __webpack_require__(moduleId) {
  35411. /******/
  35412. /******/ // Check if module is in cache
  35413. /******/ if(installedModules[moduleId]) {
  35414. /******/ return installedModules[moduleId].exports;
  35415. /******/ }
  35416. /******/ // Create a new module (and put it into the cache)
  35417. /******/ var module = installedModules[moduleId] = {
  35418. /******/ i: moduleId,
  35419. /******/ l: false,
  35420. /******/ exports: {}
  35421. /******/ };
  35422. /******/
  35423. /******/ // Execute the module function
  35424. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35425. /******/
  35426. /******/ // Flag the module as loaded
  35427. /******/ module.l = true;
  35428. /******/
  35429. /******/ // Return the exports of the module
  35430. /******/ return module.exports;
  35431. /******/ }
  35432. /******/
  35433. /******/
  35434. /******/ // expose the modules object (__webpack_modules__)
  35435. /******/ __webpack_require__.m = modules;
  35436. /******/
  35437. /******/ // expose the module cache
  35438. /******/ __webpack_require__.c = installedModules;
  35439. /******/
  35440. /******/ // define getter function for harmony exports
  35441. /******/ __webpack_require__.d = function(exports, name, getter) {
  35442. /******/ if(!__webpack_require__.o(exports, name)) {
  35443. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35444. /******/ }
  35445. /******/ };
  35446. /******/
  35447. /******/ // define __esModule on exports
  35448. /******/ __webpack_require__.r = function(exports) {
  35449. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35450. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35451. /******/ }
  35452. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35453. /******/ };
  35454. /******/
  35455. /******/ // create a fake namespace object
  35456. /******/ // mode & 1: value is a module id, require it
  35457. /******/ // mode & 2: merge all properties of value into the ns
  35458. /******/ // mode & 4: return value when already ns object
  35459. /******/ // mode & 8|1: behave like require
  35460. /******/ __webpack_require__.t = function(value, mode) {
  35461. /******/ if(mode & 1) value = __webpack_require__(value);
  35462. /******/ if(mode & 8) return value;
  35463. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35464. /******/ var ns = Object.create(null);
  35465. /******/ __webpack_require__.r(ns);
  35466. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35467. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35468. /******/ return ns;
  35469. /******/ };
  35470. /******/
  35471. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35472. /******/ __webpack_require__.n = function(module) {
  35473. /******/ var getter = module && module.__esModule ?
  35474. /******/ function getDefault() { return module['default']; } :
  35475. /******/ function getModuleExports() { return module; };
  35476. /******/ __webpack_require__.d(getter, 'a', getter);
  35477. /******/ return getter;
  35478. /******/ };
  35479. /******/
  35480. /******/ // Object.prototype.hasOwnProperty.call
  35481. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35482. /******/
  35483. /******/ // __webpack_public_path__
  35484. /******/ __webpack_require__.p = "";
  35485. /******/
  35486. /******/
  35487. /******/ // Load entry module and return exports
  35488. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35489. /******/ })
  35490. /************************************************************************/
  35491. /******/ ([
  35492. /* 0 */
  35493. /***/ (function(module, exports, __webpack_require__) {
  35494. (function(nacl) {
  35495. 'use strict';
  35496. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35497. // Public domain.
  35498. //
  35499. // Implementation derived from TweetNaCl version 20140427.
  35500. // See for details: http://tweetnacl.cr.yp.to/
  35501. var gf = function(init) {
  35502. var i, r = new Float64Array(16);
  35503. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35504. return r;
  35505. };
  35506. // Pluggable, initialized in high-level API below.
  35507. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35508. var _0 = new Uint8Array(16);
  35509. var _9 = new Uint8Array(32); _9[0] = 9;
  35510. var gf0 = gf(),
  35511. gf1 = gf([1]),
  35512. _121665 = gf([0xdb41, 1]),
  35513. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35514. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35515. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35516. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35517. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35518. function ts64(x, i, h, l) {
  35519. x[i] = (h >> 24) & 0xff;
  35520. x[i+1] = (h >> 16) & 0xff;
  35521. x[i+2] = (h >> 8) & 0xff;
  35522. x[i+3] = h & 0xff;
  35523. x[i+4] = (l >> 24) & 0xff;
  35524. x[i+5] = (l >> 16) & 0xff;
  35525. x[i+6] = (l >> 8) & 0xff;
  35526. x[i+7] = l & 0xff;
  35527. }
  35528. function vn(x, xi, y, yi, n) {
  35529. var i,d = 0;
  35530. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35531. return (1 & ((d - 1) >>> 8)) - 1;
  35532. }
  35533. function crypto_verify_16(x, xi, y, yi) {
  35534. return vn(x,xi,y,yi,16);
  35535. }
  35536. function crypto_verify_32(x, xi, y, yi) {
  35537. return vn(x,xi,y,yi,32);
  35538. }
  35539. function core_salsa20(o, p, k, c) {
  35540. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35541. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35542. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35543. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35544. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35545. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35546. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35547. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35548. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35549. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35550. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35551. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35552. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35553. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35554. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35555. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35556. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35557. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35558. x15 = j15, u;
  35559. for (var i = 0; i < 20; i += 2) {
  35560. u = x0 + x12 | 0;
  35561. x4 ^= u<<7 | u>>>(32-7);
  35562. u = x4 + x0 | 0;
  35563. x8 ^= u<<9 | u>>>(32-9);
  35564. u = x8 + x4 | 0;
  35565. x12 ^= u<<13 | u>>>(32-13);
  35566. u = x12 + x8 | 0;
  35567. x0 ^= u<<18 | u>>>(32-18);
  35568. u = x5 + x1 | 0;
  35569. x9 ^= u<<7 | u>>>(32-7);
  35570. u = x9 + x5 | 0;
  35571. x13 ^= u<<9 | u>>>(32-9);
  35572. u = x13 + x9 | 0;
  35573. x1 ^= u<<13 | u>>>(32-13);
  35574. u = x1 + x13 | 0;
  35575. x5 ^= u<<18 | u>>>(32-18);
  35576. u = x10 + x6 | 0;
  35577. x14 ^= u<<7 | u>>>(32-7);
  35578. u = x14 + x10 | 0;
  35579. x2 ^= u<<9 | u>>>(32-9);
  35580. u = x2 + x14 | 0;
  35581. x6 ^= u<<13 | u>>>(32-13);
  35582. u = x6 + x2 | 0;
  35583. x10 ^= u<<18 | u>>>(32-18);
  35584. u = x15 + x11 | 0;
  35585. x3 ^= u<<7 | u>>>(32-7);
  35586. u = x3 + x15 | 0;
  35587. x7 ^= u<<9 | u>>>(32-9);
  35588. u = x7 + x3 | 0;
  35589. x11 ^= u<<13 | u>>>(32-13);
  35590. u = x11 + x7 | 0;
  35591. x15 ^= u<<18 | u>>>(32-18);
  35592. u = x0 + x3 | 0;
  35593. x1 ^= u<<7 | u>>>(32-7);
  35594. u = x1 + x0 | 0;
  35595. x2 ^= u<<9 | u>>>(32-9);
  35596. u = x2 + x1 | 0;
  35597. x3 ^= u<<13 | u>>>(32-13);
  35598. u = x3 + x2 | 0;
  35599. x0 ^= u<<18 | u>>>(32-18);
  35600. u = x5 + x4 | 0;
  35601. x6 ^= u<<7 | u>>>(32-7);
  35602. u = x6 + x5 | 0;
  35603. x7 ^= u<<9 | u>>>(32-9);
  35604. u = x7 + x6 | 0;
  35605. x4 ^= u<<13 | u>>>(32-13);
  35606. u = x4 + x7 | 0;
  35607. x5 ^= u<<18 | u>>>(32-18);
  35608. u = x10 + x9 | 0;
  35609. x11 ^= u<<7 | u>>>(32-7);
  35610. u = x11 + x10 | 0;
  35611. x8 ^= u<<9 | u>>>(32-9);
  35612. u = x8 + x11 | 0;
  35613. x9 ^= u<<13 | u>>>(32-13);
  35614. u = x9 + x8 | 0;
  35615. x10 ^= u<<18 | u>>>(32-18);
  35616. u = x15 + x14 | 0;
  35617. x12 ^= u<<7 | u>>>(32-7);
  35618. u = x12 + x15 | 0;
  35619. x13 ^= u<<9 | u>>>(32-9);
  35620. u = x13 + x12 | 0;
  35621. x14 ^= u<<13 | u>>>(32-13);
  35622. u = x14 + x13 | 0;
  35623. x15 ^= u<<18 | u>>>(32-18);
  35624. }
  35625. x0 = x0 + j0 | 0;
  35626. x1 = x1 + j1 | 0;
  35627. x2 = x2 + j2 | 0;
  35628. x3 = x3 + j3 | 0;
  35629. x4 = x4 + j4 | 0;
  35630. x5 = x5 + j5 | 0;
  35631. x6 = x6 + j6 | 0;
  35632. x7 = x7 + j7 | 0;
  35633. x8 = x8 + j8 | 0;
  35634. x9 = x9 + j9 | 0;
  35635. x10 = x10 + j10 | 0;
  35636. x11 = x11 + j11 | 0;
  35637. x12 = x12 + j12 | 0;
  35638. x13 = x13 + j13 | 0;
  35639. x14 = x14 + j14 | 0;
  35640. x15 = x15 + j15 | 0;
  35641. o[ 0] = x0 >>> 0 & 0xff;
  35642. o[ 1] = x0 >>> 8 & 0xff;
  35643. o[ 2] = x0 >>> 16 & 0xff;
  35644. o[ 3] = x0 >>> 24 & 0xff;
  35645. o[ 4] = x1 >>> 0 & 0xff;
  35646. o[ 5] = x1 >>> 8 & 0xff;
  35647. o[ 6] = x1 >>> 16 & 0xff;
  35648. o[ 7] = x1 >>> 24 & 0xff;
  35649. o[ 8] = x2 >>> 0 & 0xff;
  35650. o[ 9] = x2 >>> 8 & 0xff;
  35651. o[10] = x2 >>> 16 & 0xff;
  35652. o[11] = x2 >>> 24 & 0xff;
  35653. o[12] = x3 >>> 0 & 0xff;
  35654. o[13] = x3 >>> 8 & 0xff;
  35655. o[14] = x3 >>> 16 & 0xff;
  35656. o[15] = x3 >>> 24 & 0xff;
  35657. o[16] = x4 >>> 0 & 0xff;
  35658. o[17] = x4 >>> 8 & 0xff;
  35659. o[18] = x4 >>> 16 & 0xff;
  35660. o[19] = x4 >>> 24 & 0xff;
  35661. o[20] = x5 >>> 0 & 0xff;
  35662. o[21] = x5 >>> 8 & 0xff;
  35663. o[22] = x5 >>> 16 & 0xff;
  35664. o[23] = x5 >>> 24 & 0xff;
  35665. o[24] = x6 >>> 0 & 0xff;
  35666. o[25] = x6 >>> 8 & 0xff;
  35667. o[26] = x6 >>> 16 & 0xff;
  35668. o[27] = x6 >>> 24 & 0xff;
  35669. o[28] = x7 >>> 0 & 0xff;
  35670. o[29] = x7 >>> 8 & 0xff;
  35671. o[30] = x7 >>> 16 & 0xff;
  35672. o[31] = x7 >>> 24 & 0xff;
  35673. o[32] = x8 >>> 0 & 0xff;
  35674. o[33] = x8 >>> 8 & 0xff;
  35675. o[34] = x8 >>> 16 & 0xff;
  35676. o[35] = x8 >>> 24 & 0xff;
  35677. o[36] = x9 >>> 0 & 0xff;
  35678. o[37] = x9 >>> 8 & 0xff;
  35679. o[38] = x9 >>> 16 & 0xff;
  35680. o[39] = x9 >>> 24 & 0xff;
  35681. o[40] = x10 >>> 0 & 0xff;
  35682. o[41] = x10 >>> 8 & 0xff;
  35683. o[42] = x10 >>> 16 & 0xff;
  35684. o[43] = x10 >>> 24 & 0xff;
  35685. o[44] = x11 >>> 0 & 0xff;
  35686. o[45] = x11 >>> 8 & 0xff;
  35687. o[46] = x11 >>> 16 & 0xff;
  35688. o[47] = x11 >>> 24 & 0xff;
  35689. o[48] = x12 >>> 0 & 0xff;
  35690. o[49] = x12 >>> 8 & 0xff;
  35691. o[50] = x12 >>> 16 & 0xff;
  35692. o[51] = x12 >>> 24 & 0xff;
  35693. o[52] = x13 >>> 0 & 0xff;
  35694. o[53] = x13 >>> 8 & 0xff;
  35695. o[54] = x13 >>> 16 & 0xff;
  35696. o[55] = x13 >>> 24 & 0xff;
  35697. o[56] = x14 >>> 0 & 0xff;
  35698. o[57] = x14 >>> 8 & 0xff;
  35699. o[58] = x14 >>> 16 & 0xff;
  35700. o[59] = x14 >>> 24 & 0xff;
  35701. o[60] = x15 >>> 0 & 0xff;
  35702. o[61] = x15 >>> 8 & 0xff;
  35703. o[62] = x15 >>> 16 & 0xff;
  35704. o[63] = x15 >>> 24 & 0xff;
  35705. }
  35706. function core_hsalsa20(o,p,k,c) {
  35707. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35708. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35709. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35710. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35711. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35712. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35713. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35714. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35715. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35716. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35717. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35718. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35719. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35720. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35721. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35722. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35723. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35724. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35725. x15 = j15, u;
  35726. for (var i = 0; i < 20; i += 2) {
  35727. u = x0 + x12 | 0;
  35728. x4 ^= u<<7 | u>>>(32-7);
  35729. u = x4 + x0 | 0;
  35730. x8 ^= u<<9 | u>>>(32-9);
  35731. u = x8 + x4 | 0;
  35732. x12 ^= u<<13 | u>>>(32-13);
  35733. u = x12 + x8 | 0;
  35734. x0 ^= u<<18 | u>>>(32-18);
  35735. u = x5 + x1 | 0;
  35736. x9 ^= u<<7 | u>>>(32-7);
  35737. u = x9 + x5 | 0;
  35738. x13 ^= u<<9 | u>>>(32-9);
  35739. u = x13 + x9 | 0;
  35740. x1 ^= u<<13 | u>>>(32-13);
  35741. u = x1 + x13 | 0;
  35742. x5 ^= u<<18 | u>>>(32-18);
  35743. u = x10 + x6 | 0;
  35744. x14 ^= u<<7 | u>>>(32-7);
  35745. u = x14 + x10 | 0;
  35746. x2 ^= u<<9 | u>>>(32-9);
  35747. u = x2 + x14 | 0;
  35748. x6 ^= u<<13 | u>>>(32-13);
  35749. u = x6 + x2 | 0;
  35750. x10 ^= u<<18 | u>>>(32-18);
  35751. u = x15 + x11 | 0;
  35752. x3 ^= u<<7 | u>>>(32-7);
  35753. u = x3 + x15 | 0;
  35754. x7 ^= u<<9 | u>>>(32-9);
  35755. u = x7 + x3 | 0;
  35756. x11 ^= u<<13 | u>>>(32-13);
  35757. u = x11 + x7 | 0;
  35758. x15 ^= u<<18 | u>>>(32-18);
  35759. u = x0 + x3 | 0;
  35760. x1 ^= u<<7 | u>>>(32-7);
  35761. u = x1 + x0 | 0;
  35762. x2 ^= u<<9 | u>>>(32-9);
  35763. u = x2 + x1 | 0;
  35764. x3 ^= u<<13 | u>>>(32-13);
  35765. u = x3 + x2 | 0;
  35766. x0 ^= u<<18 | u>>>(32-18);
  35767. u = x5 + x4 | 0;
  35768. x6 ^= u<<7 | u>>>(32-7);
  35769. u = x6 + x5 | 0;
  35770. x7 ^= u<<9 | u>>>(32-9);
  35771. u = x7 + x6 | 0;
  35772. x4 ^= u<<13 | u>>>(32-13);
  35773. u = x4 + x7 | 0;
  35774. x5 ^= u<<18 | u>>>(32-18);
  35775. u = x10 + x9 | 0;
  35776. x11 ^= u<<7 | u>>>(32-7);
  35777. u = x11 + x10 | 0;
  35778. x8 ^= u<<9 | u>>>(32-9);
  35779. u = x8 + x11 | 0;
  35780. x9 ^= u<<13 | u>>>(32-13);
  35781. u = x9 + x8 | 0;
  35782. x10 ^= u<<18 | u>>>(32-18);
  35783. u = x15 + x14 | 0;
  35784. x12 ^= u<<7 | u>>>(32-7);
  35785. u = x12 + x15 | 0;
  35786. x13 ^= u<<9 | u>>>(32-9);
  35787. u = x13 + x12 | 0;
  35788. x14 ^= u<<13 | u>>>(32-13);
  35789. u = x14 + x13 | 0;
  35790. x15 ^= u<<18 | u>>>(32-18);
  35791. }
  35792. o[ 0] = x0 >>> 0 & 0xff;
  35793. o[ 1] = x0 >>> 8 & 0xff;
  35794. o[ 2] = x0 >>> 16 & 0xff;
  35795. o[ 3] = x0 >>> 24 & 0xff;
  35796. o[ 4] = x5 >>> 0 & 0xff;
  35797. o[ 5] = x5 >>> 8 & 0xff;
  35798. o[ 6] = x5 >>> 16 & 0xff;
  35799. o[ 7] = x5 >>> 24 & 0xff;
  35800. o[ 8] = x10 >>> 0 & 0xff;
  35801. o[ 9] = x10 >>> 8 & 0xff;
  35802. o[10] = x10 >>> 16 & 0xff;
  35803. o[11] = x10 >>> 24 & 0xff;
  35804. o[12] = x15 >>> 0 & 0xff;
  35805. o[13] = x15 >>> 8 & 0xff;
  35806. o[14] = x15 >>> 16 & 0xff;
  35807. o[15] = x15 >>> 24 & 0xff;
  35808. o[16] = x6 >>> 0 & 0xff;
  35809. o[17] = x6 >>> 8 & 0xff;
  35810. o[18] = x6 >>> 16 & 0xff;
  35811. o[19] = x6 >>> 24 & 0xff;
  35812. o[20] = x7 >>> 0 & 0xff;
  35813. o[21] = x7 >>> 8 & 0xff;
  35814. o[22] = x7 >>> 16 & 0xff;
  35815. o[23] = x7 >>> 24 & 0xff;
  35816. o[24] = x8 >>> 0 & 0xff;
  35817. o[25] = x8 >>> 8 & 0xff;
  35818. o[26] = x8 >>> 16 & 0xff;
  35819. o[27] = x8 >>> 24 & 0xff;
  35820. o[28] = x9 >>> 0 & 0xff;
  35821. o[29] = x9 >>> 8 & 0xff;
  35822. o[30] = x9 >>> 16 & 0xff;
  35823. o[31] = x9 >>> 24 & 0xff;
  35824. }
  35825. function crypto_core_salsa20(out,inp,k,c) {
  35826. core_salsa20(out,inp,k,c);
  35827. }
  35828. function crypto_core_hsalsa20(out,inp,k,c) {
  35829. core_hsalsa20(out,inp,k,c);
  35830. }
  35831. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35832. // "expand 32-byte k"
  35833. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35834. var z = new Uint8Array(16), x = new Uint8Array(64);
  35835. var u, i;
  35836. for (i = 0; i < 16; i++) z[i] = 0;
  35837. for (i = 0; i < 8; i++) z[i] = n[i];
  35838. while (b >= 64) {
  35839. crypto_core_salsa20(x,z,k,sigma);
  35840. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35841. u = 1;
  35842. for (i = 8; i < 16; i++) {
  35843. u = u + (z[i] & 0xff) | 0;
  35844. z[i] = u & 0xff;
  35845. u >>>= 8;
  35846. }
  35847. b -= 64;
  35848. cpos += 64;
  35849. mpos += 64;
  35850. }
  35851. if (b > 0) {
  35852. crypto_core_salsa20(x,z,k,sigma);
  35853. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35854. }
  35855. return 0;
  35856. }
  35857. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35858. var z = new Uint8Array(16), x = new Uint8Array(64);
  35859. var u, i;
  35860. for (i = 0; i < 16; i++) z[i] = 0;
  35861. for (i = 0; i < 8; i++) z[i] = n[i];
  35862. while (b >= 64) {
  35863. crypto_core_salsa20(x,z,k,sigma);
  35864. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35865. u = 1;
  35866. for (i = 8; i < 16; i++) {
  35867. u = u + (z[i] & 0xff) | 0;
  35868. z[i] = u & 0xff;
  35869. u >>>= 8;
  35870. }
  35871. b -= 64;
  35872. cpos += 64;
  35873. }
  35874. if (b > 0) {
  35875. crypto_core_salsa20(x,z,k,sigma);
  35876. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35877. }
  35878. return 0;
  35879. }
  35880. function crypto_stream(c,cpos,d,n,k) {
  35881. var s = new Uint8Array(32);
  35882. crypto_core_hsalsa20(s,n,k,sigma);
  35883. var sn = new Uint8Array(8);
  35884. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35885. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35886. }
  35887. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35888. var s = new Uint8Array(32);
  35889. crypto_core_hsalsa20(s,n,k,sigma);
  35890. var sn = new Uint8Array(8);
  35891. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35892. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35893. }
  35894. /*
  35895. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35896. * https://github.com/floodyberry/poly1305-donna
  35897. */
  35898. var poly1305 = function(key) {
  35899. this.buffer = new Uint8Array(16);
  35900. this.r = new Uint16Array(10);
  35901. this.h = new Uint16Array(10);
  35902. this.pad = new Uint16Array(8);
  35903. this.leftover = 0;
  35904. this.fin = 0;
  35905. var t0, t1, t2, t3, t4, t5, t6, t7;
  35906. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35907. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35908. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35909. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35910. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35911. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35912. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35913. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35914. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35915. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35916. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35917. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35918. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35919. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35920. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35921. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35922. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35923. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35924. };
  35925. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35926. var hibit = this.fin ? 0 : (1 << 11);
  35927. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35928. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35929. var h0 = this.h[0],
  35930. h1 = this.h[1],
  35931. h2 = this.h[2],
  35932. h3 = this.h[3],
  35933. h4 = this.h[4],
  35934. h5 = this.h[5],
  35935. h6 = this.h[6],
  35936. h7 = this.h[7],
  35937. h8 = this.h[8],
  35938. h9 = this.h[9];
  35939. var r0 = this.r[0],
  35940. r1 = this.r[1],
  35941. r2 = this.r[2],
  35942. r3 = this.r[3],
  35943. r4 = this.r[4],
  35944. r5 = this.r[5],
  35945. r6 = this.r[6],
  35946. r7 = this.r[7],
  35947. r8 = this.r[8],
  35948. r9 = this.r[9];
  35949. while (bytes >= 16) {
  35950. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35951. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35952. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35953. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35954. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35955. h5 += ((t4 >>> 1)) & 0x1fff;
  35956. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35957. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35958. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35959. h9 += ((t7 >>> 5)) | hibit;
  35960. c = 0;
  35961. d0 = c;
  35962. d0 += h0 * r0;
  35963. d0 += h1 * (5 * r9);
  35964. d0 += h2 * (5 * r8);
  35965. d0 += h3 * (5 * r7);
  35966. d0 += h4 * (5 * r6);
  35967. c = (d0 >>> 13); d0 &= 0x1fff;
  35968. d0 += h5 * (5 * r5);
  35969. d0 += h6 * (5 * r4);
  35970. d0 += h7 * (5 * r3);
  35971. d0 += h8 * (5 * r2);
  35972. d0 += h9 * (5 * r1);
  35973. c += (d0 >>> 13); d0 &= 0x1fff;
  35974. d1 = c;
  35975. d1 += h0 * r1;
  35976. d1 += h1 * r0;
  35977. d1 += h2 * (5 * r9);
  35978. d1 += h3 * (5 * r8);
  35979. d1 += h4 * (5 * r7);
  35980. c = (d1 >>> 13); d1 &= 0x1fff;
  35981. d1 += h5 * (5 * r6);
  35982. d1 += h6 * (5 * r5);
  35983. d1 += h7 * (5 * r4);
  35984. d1 += h8 * (5 * r3);
  35985. d1 += h9 * (5 * r2);
  35986. c += (d1 >>> 13); d1 &= 0x1fff;
  35987. d2 = c;
  35988. d2 += h0 * r2;
  35989. d2 += h1 * r1;
  35990. d2 += h2 * r0;
  35991. d2 += h3 * (5 * r9);
  35992. d2 += h4 * (5 * r8);
  35993. c = (d2 >>> 13); d2 &= 0x1fff;
  35994. d2 += h5 * (5 * r7);
  35995. d2 += h6 * (5 * r6);
  35996. d2 += h7 * (5 * r5);
  35997. d2 += h8 * (5 * r4);
  35998. d2 += h9 * (5 * r3);
  35999. c += (d2 >>> 13); d2 &= 0x1fff;
  36000. d3 = c;
  36001. d3 += h0 * r3;
  36002. d3 += h1 * r2;
  36003. d3 += h2 * r1;
  36004. d3 += h3 * r0;
  36005. d3 += h4 * (5 * r9);
  36006. c = (d3 >>> 13); d3 &= 0x1fff;
  36007. d3 += h5 * (5 * r8);
  36008. d3 += h6 * (5 * r7);
  36009. d3 += h7 * (5 * r6);
  36010. d3 += h8 * (5 * r5);
  36011. d3 += h9 * (5 * r4);
  36012. c += (d3 >>> 13); d3 &= 0x1fff;
  36013. d4 = c;
  36014. d4 += h0 * r4;
  36015. d4 += h1 * r3;
  36016. d4 += h2 * r2;
  36017. d4 += h3 * r1;
  36018. d4 += h4 * r0;
  36019. c = (d4 >>> 13); d4 &= 0x1fff;
  36020. d4 += h5 * (5 * r9);
  36021. d4 += h6 * (5 * r8);
  36022. d4 += h7 * (5 * r7);
  36023. d4 += h8 * (5 * r6);
  36024. d4 += h9 * (5 * r5);
  36025. c += (d4 >>> 13); d4 &= 0x1fff;
  36026. d5 = c;
  36027. d5 += h0 * r5;
  36028. d5 += h1 * r4;
  36029. d5 += h2 * r3;
  36030. d5 += h3 * r2;
  36031. d5 += h4 * r1;
  36032. c = (d5 >>> 13); d5 &= 0x1fff;
  36033. d5 += h5 * r0;
  36034. d5 += h6 * (5 * r9);
  36035. d5 += h7 * (5 * r8);
  36036. d5 += h8 * (5 * r7);
  36037. d5 += h9 * (5 * r6);
  36038. c += (d5 >>> 13); d5 &= 0x1fff;
  36039. d6 = c;
  36040. d6 += h0 * r6;
  36041. d6 += h1 * r5;
  36042. d6 += h2 * r4;
  36043. d6 += h3 * r3;
  36044. d6 += h4 * r2;
  36045. c = (d6 >>> 13); d6 &= 0x1fff;
  36046. d6 += h5 * r1;
  36047. d6 += h6 * r0;
  36048. d6 += h7 * (5 * r9);
  36049. d6 += h8 * (5 * r8);
  36050. d6 += h9 * (5 * r7);
  36051. c += (d6 >>> 13); d6 &= 0x1fff;
  36052. d7 = c;
  36053. d7 += h0 * r7;
  36054. d7 += h1 * r6;
  36055. d7 += h2 * r5;
  36056. d7 += h3 * r4;
  36057. d7 += h4 * r3;
  36058. c = (d7 >>> 13); d7 &= 0x1fff;
  36059. d7 += h5 * r2;
  36060. d7 += h6 * r1;
  36061. d7 += h7 * r0;
  36062. d7 += h8 * (5 * r9);
  36063. d7 += h9 * (5 * r8);
  36064. c += (d7 >>> 13); d7 &= 0x1fff;
  36065. d8 = c;
  36066. d8 += h0 * r8;
  36067. d8 += h1 * r7;
  36068. d8 += h2 * r6;
  36069. d8 += h3 * r5;
  36070. d8 += h4 * r4;
  36071. c = (d8 >>> 13); d8 &= 0x1fff;
  36072. d8 += h5 * r3;
  36073. d8 += h6 * r2;
  36074. d8 += h7 * r1;
  36075. d8 += h8 * r0;
  36076. d8 += h9 * (5 * r9);
  36077. c += (d8 >>> 13); d8 &= 0x1fff;
  36078. d9 = c;
  36079. d9 += h0 * r9;
  36080. d9 += h1 * r8;
  36081. d9 += h2 * r7;
  36082. d9 += h3 * r6;
  36083. d9 += h4 * r5;
  36084. c = (d9 >>> 13); d9 &= 0x1fff;
  36085. d9 += h5 * r4;
  36086. d9 += h6 * r3;
  36087. d9 += h7 * r2;
  36088. d9 += h8 * r1;
  36089. d9 += h9 * r0;
  36090. c += (d9 >>> 13); d9 &= 0x1fff;
  36091. c = (((c << 2) + c)) | 0;
  36092. c = (c + d0) | 0;
  36093. d0 = c & 0x1fff;
  36094. c = (c >>> 13);
  36095. d1 += c;
  36096. h0 = d0;
  36097. h1 = d1;
  36098. h2 = d2;
  36099. h3 = d3;
  36100. h4 = d4;
  36101. h5 = d5;
  36102. h6 = d6;
  36103. h7 = d7;
  36104. h8 = d8;
  36105. h9 = d9;
  36106. mpos += 16;
  36107. bytes -= 16;
  36108. }
  36109. this.h[0] = h0;
  36110. this.h[1] = h1;
  36111. this.h[2] = h2;
  36112. this.h[3] = h3;
  36113. this.h[4] = h4;
  36114. this.h[5] = h5;
  36115. this.h[6] = h6;
  36116. this.h[7] = h7;
  36117. this.h[8] = h8;
  36118. this.h[9] = h9;
  36119. };
  36120. poly1305.prototype.finish = function(mac, macpos) {
  36121. var g = new Uint16Array(10);
  36122. var c, mask, f, i;
  36123. if (this.leftover) {
  36124. i = this.leftover;
  36125. this.buffer[i++] = 1;
  36126. for (; i < 16; i++) this.buffer[i] = 0;
  36127. this.fin = 1;
  36128. this.blocks(this.buffer, 0, 16);
  36129. }
  36130. c = this.h[1] >>> 13;
  36131. this.h[1] &= 0x1fff;
  36132. for (i = 2; i < 10; i++) {
  36133. this.h[i] += c;
  36134. c = this.h[i] >>> 13;
  36135. this.h[i] &= 0x1fff;
  36136. }
  36137. this.h[0] += (c * 5);
  36138. c = this.h[0] >>> 13;
  36139. this.h[0] &= 0x1fff;
  36140. this.h[1] += c;
  36141. c = this.h[1] >>> 13;
  36142. this.h[1] &= 0x1fff;
  36143. this.h[2] += c;
  36144. g[0] = this.h[0] + 5;
  36145. c = g[0] >>> 13;
  36146. g[0] &= 0x1fff;
  36147. for (i = 1; i < 10; i++) {
  36148. g[i] = this.h[i] + c;
  36149. c = g[i] >>> 13;
  36150. g[i] &= 0x1fff;
  36151. }
  36152. g[9] -= (1 << 13);
  36153. mask = (c ^ 1) - 1;
  36154. for (i = 0; i < 10; i++) g[i] &= mask;
  36155. mask = ~mask;
  36156. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36157. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36158. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36159. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36160. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36161. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36162. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36163. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36164. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36165. f = this.h[0] + this.pad[0];
  36166. this.h[0] = f & 0xffff;
  36167. for (i = 1; i < 8; i++) {
  36168. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36169. this.h[i] = f & 0xffff;
  36170. }
  36171. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36172. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36173. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36174. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36175. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36176. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36177. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36178. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36179. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36180. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36181. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36182. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36183. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36184. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36185. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36186. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36187. };
  36188. poly1305.prototype.update = function(m, mpos, bytes) {
  36189. var i, want;
  36190. if (this.leftover) {
  36191. want = (16 - this.leftover);
  36192. if (want > bytes)
  36193. want = bytes;
  36194. for (i = 0; i < want; i++)
  36195. this.buffer[this.leftover + i] = m[mpos+i];
  36196. bytes -= want;
  36197. mpos += want;
  36198. this.leftover += want;
  36199. if (this.leftover < 16)
  36200. return;
  36201. this.blocks(this.buffer, 0, 16);
  36202. this.leftover = 0;
  36203. }
  36204. if (bytes >= 16) {
  36205. want = bytes - (bytes % 16);
  36206. this.blocks(m, mpos, want);
  36207. mpos += want;
  36208. bytes -= want;
  36209. }
  36210. if (bytes) {
  36211. for (i = 0; i < bytes; i++)
  36212. this.buffer[this.leftover + i] = m[mpos+i];
  36213. this.leftover += bytes;
  36214. }
  36215. };
  36216. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36217. var s = new poly1305(k);
  36218. s.update(m, mpos, n);
  36219. s.finish(out, outpos);
  36220. return 0;
  36221. }
  36222. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36223. var x = new Uint8Array(16);
  36224. crypto_onetimeauth(x,0,m,mpos,n,k);
  36225. return crypto_verify_16(h,hpos,x,0);
  36226. }
  36227. function crypto_secretbox(c,m,d,n,k) {
  36228. var i;
  36229. if (d < 32) return -1;
  36230. crypto_stream_xor(c,0,m,0,d,n,k);
  36231. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36232. for (i = 0; i < 16; i++) c[i] = 0;
  36233. return 0;
  36234. }
  36235. function crypto_secretbox_open(m,c,d,n,k) {
  36236. var i;
  36237. var x = new Uint8Array(32);
  36238. if (d < 32) return -1;
  36239. crypto_stream(x,0,32,n,k);
  36240. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36241. crypto_stream_xor(m,0,c,0,d,n,k);
  36242. for (i = 0; i < 32; i++) m[i] = 0;
  36243. return 0;
  36244. }
  36245. function set25519(r, a) {
  36246. var i;
  36247. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36248. }
  36249. function car25519(o) {
  36250. var i, v, c = 1;
  36251. for (i = 0; i < 16; i++) {
  36252. v = o[i] + c + 65535;
  36253. c = Math.floor(v / 65536);
  36254. o[i] = v - c * 65536;
  36255. }
  36256. o[0] += c-1 + 37 * (c-1);
  36257. }
  36258. function sel25519(p, q, b) {
  36259. var t, c = ~(b-1);
  36260. for (var i = 0; i < 16; i++) {
  36261. t = c & (p[i] ^ q[i]);
  36262. p[i] ^= t;
  36263. q[i] ^= t;
  36264. }
  36265. }
  36266. function pack25519(o, n) {
  36267. var i, j, b;
  36268. var m = gf(), t = gf();
  36269. for (i = 0; i < 16; i++) t[i] = n[i];
  36270. car25519(t);
  36271. car25519(t);
  36272. car25519(t);
  36273. for (j = 0; j < 2; j++) {
  36274. m[0] = t[0] - 0xffed;
  36275. for (i = 1; i < 15; i++) {
  36276. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36277. m[i-1] &= 0xffff;
  36278. }
  36279. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36280. b = (m[15]>>16) & 1;
  36281. m[14] &= 0xffff;
  36282. sel25519(t, m, 1-b);
  36283. }
  36284. for (i = 0; i < 16; i++) {
  36285. o[2*i] = t[i] & 0xff;
  36286. o[2*i+1] = t[i]>>8;
  36287. }
  36288. }
  36289. function neq25519(a, b) {
  36290. var c = new Uint8Array(32), d = new Uint8Array(32);
  36291. pack25519(c, a);
  36292. pack25519(d, b);
  36293. return crypto_verify_32(c, 0, d, 0);
  36294. }
  36295. function par25519(a) {
  36296. var d = new Uint8Array(32);
  36297. pack25519(d, a);
  36298. return d[0] & 1;
  36299. }
  36300. function unpack25519(o, n) {
  36301. var i;
  36302. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36303. o[15] &= 0x7fff;
  36304. }
  36305. function A(o, a, b) {
  36306. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36307. }
  36308. function Z(o, a, b) {
  36309. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36310. }
  36311. function M(o, a, b) {
  36312. var v, c,
  36313. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36314. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36315. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36316. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36317. b0 = b[0],
  36318. b1 = b[1],
  36319. b2 = b[2],
  36320. b3 = b[3],
  36321. b4 = b[4],
  36322. b5 = b[5],
  36323. b6 = b[6],
  36324. b7 = b[7],
  36325. b8 = b[8],
  36326. b9 = b[9],
  36327. b10 = b[10],
  36328. b11 = b[11],
  36329. b12 = b[12],
  36330. b13 = b[13],
  36331. b14 = b[14],
  36332. b15 = b[15];
  36333. v = a[0];
  36334. t0 += v * b0;
  36335. t1 += v * b1;
  36336. t2 += v * b2;
  36337. t3 += v * b3;
  36338. t4 += v * b4;
  36339. t5 += v * b5;
  36340. t6 += v * b6;
  36341. t7 += v * b7;
  36342. t8 += v * b8;
  36343. t9 += v * b9;
  36344. t10 += v * b10;
  36345. t11 += v * b11;
  36346. t12 += v * b12;
  36347. t13 += v * b13;
  36348. t14 += v * b14;
  36349. t15 += v * b15;
  36350. v = a[1];
  36351. t1 += v * b0;
  36352. t2 += v * b1;
  36353. t3 += v * b2;
  36354. t4 += v * b3;
  36355. t5 += v * b4;
  36356. t6 += v * b5;
  36357. t7 += v * b6;
  36358. t8 += v * b7;
  36359. t9 += v * b8;
  36360. t10 += v * b9;
  36361. t11 += v * b10;
  36362. t12 += v * b11;
  36363. t13 += v * b12;
  36364. t14 += v * b13;
  36365. t15 += v * b14;
  36366. t16 += v * b15;
  36367. v = a[2];
  36368. t2 += v * b0;
  36369. t3 += v * b1;
  36370. t4 += v * b2;
  36371. t5 += v * b3;
  36372. t6 += v * b4;
  36373. t7 += v * b5;
  36374. t8 += v * b6;
  36375. t9 += v * b7;
  36376. t10 += v * b8;
  36377. t11 += v * b9;
  36378. t12 += v * b10;
  36379. t13 += v * b11;
  36380. t14 += v * b12;
  36381. t15 += v * b13;
  36382. t16 += v * b14;
  36383. t17 += v * b15;
  36384. v = a[3];
  36385. t3 += v * b0;
  36386. t4 += v * b1;
  36387. t5 += v * b2;
  36388. t6 += v * b3;
  36389. t7 += v * b4;
  36390. t8 += v * b5;
  36391. t9 += v * b6;
  36392. t10 += v * b7;
  36393. t11 += v * b8;
  36394. t12 += v * b9;
  36395. t13 += v * b10;
  36396. t14 += v * b11;
  36397. t15 += v * b12;
  36398. t16 += v * b13;
  36399. t17 += v * b14;
  36400. t18 += v * b15;
  36401. v = a[4];
  36402. t4 += v * b0;
  36403. t5 += v * b1;
  36404. t6 += v * b2;
  36405. t7 += v * b3;
  36406. t8 += v * b4;
  36407. t9 += v * b5;
  36408. t10 += v * b6;
  36409. t11 += v * b7;
  36410. t12 += v * b8;
  36411. t13 += v * b9;
  36412. t14 += v * b10;
  36413. t15 += v * b11;
  36414. t16 += v * b12;
  36415. t17 += v * b13;
  36416. t18 += v * b14;
  36417. t19 += v * b15;
  36418. v = a[5];
  36419. t5 += v * b0;
  36420. t6 += v * b1;
  36421. t7 += v * b2;
  36422. t8 += v * b3;
  36423. t9 += v * b4;
  36424. t10 += v * b5;
  36425. t11 += v * b6;
  36426. t12 += v * b7;
  36427. t13 += v * b8;
  36428. t14 += v * b9;
  36429. t15 += v * b10;
  36430. t16 += v * b11;
  36431. t17 += v * b12;
  36432. t18 += v * b13;
  36433. t19 += v * b14;
  36434. t20 += v * b15;
  36435. v = a[6];
  36436. t6 += v * b0;
  36437. t7 += v * b1;
  36438. t8 += v * b2;
  36439. t9 += v * b3;
  36440. t10 += v * b4;
  36441. t11 += v * b5;
  36442. t12 += v * b6;
  36443. t13 += v * b7;
  36444. t14 += v * b8;
  36445. t15 += v * b9;
  36446. t16 += v * b10;
  36447. t17 += v * b11;
  36448. t18 += v * b12;
  36449. t19 += v * b13;
  36450. t20 += v * b14;
  36451. t21 += v * b15;
  36452. v = a[7];
  36453. t7 += v * b0;
  36454. t8 += v * b1;
  36455. t9 += v * b2;
  36456. t10 += v * b3;
  36457. t11 += v * b4;
  36458. t12 += v * b5;
  36459. t13 += v * b6;
  36460. t14 += v * b7;
  36461. t15 += v * b8;
  36462. t16 += v * b9;
  36463. t17 += v * b10;
  36464. t18 += v * b11;
  36465. t19 += v * b12;
  36466. t20 += v * b13;
  36467. t21 += v * b14;
  36468. t22 += v * b15;
  36469. v = a[8];
  36470. t8 += v * b0;
  36471. t9 += v * b1;
  36472. t10 += v * b2;
  36473. t11 += v * b3;
  36474. t12 += v * b4;
  36475. t13 += v * b5;
  36476. t14 += v * b6;
  36477. t15 += v * b7;
  36478. t16 += v * b8;
  36479. t17 += v * b9;
  36480. t18 += v * b10;
  36481. t19 += v * b11;
  36482. t20 += v * b12;
  36483. t21 += v * b13;
  36484. t22 += v * b14;
  36485. t23 += v * b15;
  36486. v = a[9];
  36487. t9 += v * b0;
  36488. t10 += v * b1;
  36489. t11 += v * b2;
  36490. t12 += v * b3;
  36491. t13 += v * b4;
  36492. t14 += v * b5;
  36493. t15 += v * b6;
  36494. t16 += v * b7;
  36495. t17 += v * b8;
  36496. t18 += v * b9;
  36497. t19 += v * b10;
  36498. t20 += v * b11;
  36499. t21 += v * b12;
  36500. t22 += v * b13;
  36501. t23 += v * b14;
  36502. t24 += v * b15;
  36503. v = a[10];
  36504. t10 += v * b0;
  36505. t11 += v * b1;
  36506. t12 += v * b2;
  36507. t13 += v * b3;
  36508. t14 += v * b4;
  36509. t15 += v * b5;
  36510. t16 += v * b6;
  36511. t17 += v * b7;
  36512. t18 += v * b8;
  36513. t19 += v * b9;
  36514. t20 += v * b10;
  36515. t21 += v * b11;
  36516. t22 += v * b12;
  36517. t23 += v * b13;
  36518. t24 += v * b14;
  36519. t25 += v * b15;
  36520. v = a[11];
  36521. t11 += v * b0;
  36522. t12 += v * b1;
  36523. t13 += v * b2;
  36524. t14 += v * b3;
  36525. t15 += v * b4;
  36526. t16 += v * b5;
  36527. t17 += v * b6;
  36528. t18 += v * b7;
  36529. t19 += v * b8;
  36530. t20 += v * b9;
  36531. t21 += v * b10;
  36532. t22 += v * b11;
  36533. t23 += v * b12;
  36534. t24 += v * b13;
  36535. t25 += v * b14;
  36536. t26 += v * b15;
  36537. v = a[12];
  36538. t12 += v * b0;
  36539. t13 += v * b1;
  36540. t14 += v * b2;
  36541. t15 += v * b3;
  36542. t16 += v * b4;
  36543. t17 += v * b5;
  36544. t18 += v * b6;
  36545. t19 += v * b7;
  36546. t20 += v * b8;
  36547. t21 += v * b9;
  36548. t22 += v * b10;
  36549. t23 += v * b11;
  36550. t24 += v * b12;
  36551. t25 += v * b13;
  36552. t26 += v * b14;
  36553. t27 += v * b15;
  36554. v = a[13];
  36555. t13 += v * b0;
  36556. t14 += v * b1;
  36557. t15 += v * b2;
  36558. t16 += v * b3;
  36559. t17 += v * b4;
  36560. t18 += v * b5;
  36561. t19 += v * b6;
  36562. t20 += v * b7;
  36563. t21 += v * b8;
  36564. t22 += v * b9;
  36565. t23 += v * b10;
  36566. t24 += v * b11;
  36567. t25 += v * b12;
  36568. t26 += v * b13;
  36569. t27 += v * b14;
  36570. t28 += v * b15;
  36571. v = a[14];
  36572. t14 += v * b0;
  36573. t15 += v * b1;
  36574. t16 += v * b2;
  36575. t17 += v * b3;
  36576. t18 += v * b4;
  36577. t19 += v * b5;
  36578. t20 += v * b6;
  36579. t21 += v * b7;
  36580. t22 += v * b8;
  36581. t23 += v * b9;
  36582. t24 += v * b10;
  36583. t25 += v * b11;
  36584. t26 += v * b12;
  36585. t27 += v * b13;
  36586. t28 += v * b14;
  36587. t29 += v * b15;
  36588. v = a[15];
  36589. t15 += v * b0;
  36590. t16 += v * b1;
  36591. t17 += v * b2;
  36592. t18 += v * b3;
  36593. t19 += v * b4;
  36594. t20 += v * b5;
  36595. t21 += v * b6;
  36596. t22 += v * b7;
  36597. t23 += v * b8;
  36598. t24 += v * b9;
  36599. t25 += v * b10;
  36600. t26 += v * b11;
  36601. t27 += v * b12;
  36602. t28 += v * b13;
  36603. t29 += v * b14;
  36604. t30 += v * b15;
  36605. t0 += 38 * t16;
  36606. t1 += 38 * t17;
  36607. t2 += 38 * t18;
  36608. t3 += 38 * t19;
  36609. t4 += 38 * t20;
  36610. t5 += 38 * t21;
  36611. t6 += 38 * t22;
  36612. t7 += 38 * t23;
  36613. t8 += 38 * t24;
  36614. t9 += 38 * t25;
  36615. t10 += 38 * t26;
  36616. t11 += 38 * t27;
  36617. t12 += 38 * t28;
  36618. t13 += 38 * t29;
  36619. t14 += 38 * t30;
  36620. // t15 left as is
  36621. // first car
  36622. c = 1;
  36623. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36624. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36625. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36626. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36627. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36628. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36629. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36630. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36631. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36632. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36633. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36634. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36635. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36636. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36637. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36638. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36639. t0 += c-1 + 37 * (c-1);
  36640. // second car
  36641. c = 1;
  36642. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36643. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36644. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36645. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36646. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36647. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36648. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36649. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36650. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36651. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36652. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36653. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36654. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36655. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36656. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36657. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36658. t0 += c-1 + 37 * (c-1);
  36659. o[ 0] = t0;
  36660. o[ 1] = t1;
  36661. o[ 2] = t2;
  36662. o[ 3] = t3;
  36663. o[ 4] = t4;
  36664. o[ 5] = t5;
  36665. o[ 6] = t6;
  36666. o[ 7] = t7;
  36667. o[ 8] = t8;
  36668. o[ 9] = t9;
  36669. o[10] = t10;
  36670. o[11] = t11;
  36671. o[12] = t12;
  36672. o[13] = t13;
  36673. o[14] = t14;
  36674. o[15] = t15;
  36675. }
  36676. function S(o, a) {
  36677. M(o, a, a);
  36678. }
  36679. function inv25519(o, i) {
  36680. var c = gf();
  36681. var a;
  36682. for (a = 0; a < 16; a++) c[a] = i[a];
  36683. for (a = 253; a >= 0; a--) {
  36684. S(c, c);
  36685. if(a !== 2 && a !== 4) M(c, c, i);
  36686. }
  36687. for (a = 0; a < 16; a++) o[a] = c[a];
  36688. }
  36689. function pow2523(o, i) {
  36690. var c = gf();
  36691. var a;
  36692. for (a = 0; a < 16; a++) c[a] = i[a];
  36693. for (a = 250; a >= 0; a--) {
  36694. S(c, c);
  36695. if(a !== 1) M(c, c, i);
  36696. }
  36697. for (a = 0; a < 16; a++) o[a] = c[a];
  36698. }
  36699. function crypto_scalarmult(q, n, p) {
  36700. var z = new Uint8Array(32);
  36701. var x = new Float64Array(80), r, i;
  36702. var a = gf(), b = gf(), c = gf(),
  36703. d = gf(), e = gf(), f = gf();
  36704. for (i = 0; i < 31; i++) z[i] = n[i];
  36705. z[31]=(n[31]&127)|64;
  36706. z[0]&=248;
  36707. unpack25519(x,p);
  36708. for (i = 0; i < 16; i++) {
  36709. b[i]=x[i];
  36710. d[i]=a[i]=c[i]=0;
  36711. }
  36712. a[0]=d[0]=1;
  36713. for (i=254; i>=0; --i) {
  36714. r=(z[i>>>3]>>>(i&7))&1;
  36715. sel25519(a,b,r);
  36716. sel25519(c,d,r);
  36717. A(e,a,c);
  36718. Z(a,a,c);
  36719. A(c,b,d);
  36720. Z(b,b,d);
  36721. S(d,e);
  36722. S(f,a);
  36723. M(a,c,a);
  36724. M(c,b,e);
  36725. A(e,a,c);
  36726. Z(a,a,c);
  36727. S(b,a);
  36728. Z(c,d,f);
  36729. M(a,c,_121665);
  36730. A(a,a,d);
  36731. M(c,c,a);
  36732. M(a,d,f);
  36733. M(d,b,x);
  36734. S(b,e);
  36735. sel25519(a,b,r);
  36736. sel25519(c,d,r);
  36737. }
  36738. for (i = 0; i < 16; i++) {
  36739. x[i+16]=a[i];
  36740. x[i+32]=c[i];
  36741. x[i+48]=b[i];
  36742. x[i+64]=d[i];
  36743. }
  36744. var x32 = x.subarray(32);
  36745. var x16 = x.subarray(16);
  36746. inv25519(x32,x32);
  36747. M(x16,x16,x32);
  36748. pack25519(q,x16);
  36749. return 0;
  36750. }
  36751. function crypto_scalarmult_base(q, n) {
  36752. return crypto_scalarmult(q, n, _9);
  36753. }
  36754. function crypto_box_keypair(y, x) {
  36755. randombytes(x, 32);
  36756. return crypto_scalarmult_base(y, x);
  36757. }
  36758. function crypto_box_beforenm(k, y, x) {
  36759. var s = new Uint8Array(32);
  36760. crypto_scalarmult(s, x, y);
  36761. return crypto_core_hsalsa20(k, _0, s, sigma);
  36762. }
  36763. var crypto_box_afternm = crypto_secretbox;
  36764. var crypto_box_open_afternm = crypto_secretbox_open;
  36765. function crypto_box(c, m, d, n, y, x) {
  36766. var k = new Uint8Array(32);
  36767. crypto_box_beforenm(k, y, x);
  36768. return crypto_box_afternm(c, m, d, n, k);
  36769. }
  36770. function crypto_box_open(m, c, d, n, y, x) {
  36771. var k = new Uint8Array(32);
  36772. crypto_box_beforenm(k, y, x);
  36773. return crypto_box_open_afternm(m, c, d, n, k);
  36774. }
  36775. var K = [
  36776. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36777. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36778. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36779. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36780. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36781. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36782. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36783. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36784. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36785. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36786. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36787. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36788. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36789. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36790. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36791. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36792. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36793. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36794. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36795. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36796. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36797. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36798. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36799. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36800. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36801. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36802. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36803. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36804. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36805. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36806. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36807. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36808. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36809. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36810. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36811. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36812. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36813. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36814. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36815. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36816. ];
  36817. function crypto_hashblocks_hl(hh, hl, m, n) {
  36818. var wh = new Int32Array(16), wl = new Int32Array(16),
  36819. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36820. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36821. th, tl, i, j, h, l, a, b, c, d;
  36822. var ah0 = hh[0],
  36823. ah1 = hh[1],
  36824. ah2 = hh[2],
  36825. ah3 = hh[3],
  36826. ah4 = hh[4],
  36827. ah5 = hh[5],
  36828. ah6 = hh[6],
  36829. ah7 = hh[7],
  36830. al0 = hl[0],
  36831. al1 = hl[1],
  36832. al2 = hl[2],
  36833. al3 = hl[3],
  36834. al4 = hl[4],
  36835. al5 = hl[5],
  36836. al6 = hl[6],
  36837. al7 = hl[7];
  36838. var pos = 0;
  36839. while (n >= 128) {
  36840. for (i = 0; i < 16; i++) {
  36841. j = 8 * i + pos;
  36842. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36843. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36844. }
  36845. for (i = 0; i < 80; i++) {
  36846. bh0 = ah0;
  36847. bh1 = ah1;
  36848. bh2 = ah2;
  36849. bh3 = ah3;
  36850. bh4 = ah4;
  36851. bh5 = ah5;
  36852. bh6 = ah6;
  36853. bh7 = ah7;
  36854. bl0 = al0;
  36855. bl1 = al1;
  36856. bl2 = al2;
  36857. bl3 = al3;
  36858. bl4 = al4;
  36859. bl5 = al5;
  36860. bl6 = al6;
  36861. bl7 = al7;
  36862. // add
  36863. h = ah7;
  36864. l = al7;
  36865. a = l & 0xffff; b = l >>> 16;
  36866. c = h & 0xffff; d = h >>> 16;
  36867. // Sigma1
  36868. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36869. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36870. a += l & 0xffff; b += l >>> 16;
  36871. c += h & 0xffff; d += h >>> 16;
  36872. // Ch
  36873. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36874. l = (al4 & al5) ^ (~al4 & al6);
  36875. a += l & 0xffff; b += l >>> 16;
  36876. c += h & 0xffff; d += h >>> 16;
  36877. // K
  36878. h = K[i*2];
  36879. l = K[i*2+1];
  36880. a += l & 0xffff; b += l >>> 16;
  36881. c += h & 0xffff; d += h >>> 16;
  36882. // w
  36883. h = wh[i%16];
  36884. l = wl[i%16];
  36885. a += l & 0xffff; b += l >>> 16;
  36886. c += h & 0xffff; d += h >>> 16;
  36887. b += a >>> 16;
  36888. c += b >>> 16;
  36889. d += c >>> 16;
  36890. th = c & 0xffff | d << 16;
  36891. tl = a & 0xffff | b << 16;
  36892. // add
  36893. h = th;
  36894. l = tl;
  36895. a = l & 0xffff; b = l >>> 16;
  36896. c = h & 0xffff; d = h >>> 16;
  36897. // Sigma0
  36898. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36899. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36900. a += l & 0xffff; b += l >>> 16;
  36901. c += h & 0xffff; d += h >>> 16;
  36902. // Maj
  36903. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36904. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36905. a += l & 0xffff; b += l >>> 16;
  36906. c += h & 0xffff; d += h >>> 16;
  36907. b += a >>> 16;
  36908. c += b >>> 16;
  36909. d += c >>> 16;
  36910. bh7 = (c & 0xffff) | (d << 16);
  36911. bl7 = (a & 0xffff) | (b << 16);
  36912. // add
  36913. h = bh3;
  36914. l = bl3;
  36915. a = l & 0xffff; b = l >>> 16;
  36916. c = h & 0xffff; d = h >>> 16;
  36917. h = th;
  36918. l = tl;
  36919. a += l & 0xffff; b += l >>> 16;
  36920. c += h & 0xffff; d += h >>> 16;
  36921. b += a >>> 16;
  36922. c += b >>> 16;
  36923. d += c >>> 16;
  36924. bh3 = (c & 0xffff) | (d << 16);
  36925. bl3 = (a & 0xffff) | (b << 16);
  36926. ah1 = bh0;
  36927. ah2 = bh1;
  36928. ah3 = bh2;
  36929. ah4 = bh3;
  36930. ah5 = bh4;
  36931. ah6 = bh5;
  36932. ah7 = bh6;
  36933. ah0 = bh7;
  36934. al1 = bl0;
  36935. al2 = bl1;
  36936. al3 = bl2;
  36937. al4 = bl3;
  36938. al5 = bl4;
  36939. al6 = bl5;
  36940. al7 = bl6;
  36941. al0 = bl7;
  36942. if (i%16 === 15) {
  36943. for (j = 0; j < 16; j++) {
  36944. // add
  36945. h = wh[j];
  36946. l = wl[j];
  36947. a = l & 0xffff; b = l >>> 16;
  36948. c = h & 0xffff; d = h >>> 16;
  36949. h = wh[(j+9)%16];
  36950. l = wl[(j+9)%16];
  36951. a += l & 0xffff; b += l >>> 16;
  36952. c += h & 0xffff; d += h >>> 16;
  36953. // sigma0
  36954. th = wh[(j+1)%16];
  36955. tl = wl[(j+1)%16];
  36956. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36957. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36958. a += l & 0xffff; b += l >>> 16;
  36959. c += h & 0xffff; d += h >>> 16;
  36960. // sigma1
  36961. th = wh[(j+14)%16];
  36962. tl = wl[(j+14)%16];
  36963. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36964. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36965. a += l & 0xffff; b += l >>> 16;
  36966. c += h & 0xffff; d += h >>> 16;
  36967. b += a >>> 16;
  36968. c += b >>> 16;
  36969. d += c >>> 16;
  36970. wh[j] = (c & 0xffff) | (d << 16);
  36971. wl[j] = (a & 0xffff) | (b << 16);
  36972. }
  36973. }
  36974. }
  36975. // add
  36976. h = ah0;
  36977. l = al0;
  36978. a = l & 0xffff; b = l >>> 16;
  36979. c = h & 0xffff; d = h >>> 16;
  36980. h = hh[0];
  36981. l = hl[0];
  36982. a += l & 0xffff; b += l >>> 16;
  36983. c += h & 0xffff; d += h >>> 16;
  36984. b += a >>> 16;
  36985. c += b >>> 16;
  36986. d += c >>> 16;
  36987. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36988. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36989. h = ah1;
  36990. l = al1;
  36991. a = l & 0xffff; b = l >>> 16;
  36992. c = h & 0xffff; d = h >>> 16;
  36993. h = hh[1];
  36994. l = hl[1];
  36995. a += l & 0xffff; b += l >>> 16;
  36996. c += h & 0xffff; d += h >>> 16;
  36997. b += a >>> 16;
  36998. c += b >>> 16;
  36999. d += c >>> 16;
  37000. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37001. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37002. h = ah2;
  37003. l = al2;
  37004. a = l & 0xffff; b = l >>> 16;
  37005. c = h & 0xffff; d = h >>> 16;
  37006. h = hh[2];
  37007. l = hl[2];
  37008. a += l & 0xffff; b += l >>> 16;
  37009. c += h & 0xffff; d += h >>> 16;
  37010. b += a >>> 16;
  37011. c += b >>> 16;
  37012. d += c >>> 16;
  37013. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37014. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37015. h = ah3;
  37016. l = al3;
  37017. a = l & 0xffff; b = l >>> 16;
  37018. c = h & 0xffff; d = h >>> 16;
  37019. h = hh[3];
  37020. l = hl[3];
  37021. a += l & 0xffff; b += l >>> 16;
  37022. c += h & 0xffff; d += h >>> 16;
  37023. b += a >>> 16;
  37024. c += b >>> 16;
  37025. d += c >>> 16;
  37026. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37027. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37028. h = ah4;
  37029. l = al4;
  37030. a = l & 0xffff; b = l >>> 16;
  37031. c = h & 0xffff; d = h >>> 16;
  37032. h = hh[4];
  37033. l = hl[4];
  37034. a += l & 0xffff; b += l >>> 16;
  37035. c += h & 0xffff; d += h >>> 16;
  37036. b += a >>> 16;
  37037. c += b >>> 16;
  37038. d += c >>> 16;
  37039. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37040. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37041. h = ah5;
  37042. l = al5;
  37043. a = l & 0xffff; b = l >>> 16;
  37044. c = h & 0xffff; d = h >>> 16;
  37045. h = hh[5];
  37046. l = hl[5];
  37047. a += l & 0xffff; b += l >>> 16;
  37048. c += h & 0xffff; d += h >>> 16;
  37049. b += a >>> 16;
  37050. c += b >>> 16;
  37051. d += c >>> 16;
  37052. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37053. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37054. h = ah6;
  37055. l = al6;
  37056. a = l & 0xffff; b = l >>> 16;
  37057. c = h & 0xffff; d = h >>> 16;
  37058. h = hh[6];
  37059. l = hl[6];
  37060. a += l & 0xffff; b += l >>> 16;
  37061. c += h & 0xffff; d += h >>> 16;
  37062. b += a >>> 16;
  37063. c += b >>> 16;
  37064. d += c >>> 16;
  37065. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37066. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37067. h = ah7;
  37068. l = al7;
  37069. a = l & 0xffff; b = l >>> 16;
  37070. c = h & 0xffff; d = h >>> 16;
  37071. h = hh[7];
  37072. l = hl[7];
  37073. a += l & 0xffff; b += l >>> 16;
  37074. c += h & 0xffff; d += h >>> 16;
  37075. b += a >>> 16;
  37076. c += b >>> 16;
  37077. d += c >>> 16;
  37078. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37079. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37080. pos += 128;
  37081. n -= 128;
  37082. }
  37083. return n;
  37084. }
  37085. function crypto_hash(out, m, n) {
  37086. var hh = new Int32Array(8),
  37087. hl = new Int32Array(8),
  37088. x = new Uint8Array(256),
  37089. i, b = n;
  37090. hh[0] = 0x6a09e667;
  37091. hh[1] = 0xbb67ae85;
  37092. hh[2] = 0x3c6ef372;
  37093. hh[3] = 0xa54ff53a;
  37094. hh[4] = 0x510e527f;
  37095. hh[5] = 0x9b05688c;
  37096. hh[6] = 0x1f83d9ab;
  37097. hh[7] = 0x5be0cd19;
  37098. hl[0] = 0xf3bcc908;
  37099. hl[1] = 0x84caa73b;
  37100. hl[2] = 0xfe94f82b;
  37101. hl[3] = 0x5f1d36f1;
  37102. hl[4] = 0xade682d1;
  37103. hl[5] = 0x2b3e6c1f;
  37104. hl[6] = 0xfb41bd6b;
  37105. hl[7] = 0x137e2179;
  37106. crypto_hashblocks_hl(hh, hl, m, n);
  37107. n %= 128;
  37108. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37109. x[n] = 128;
  37110. n = 256-128*(n<112?1:0);
  37111. x[n-9] = 0;
  37112. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37113. crypto_hashblocks_hl(hh, hl, x, n);
  37114. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37115. return 0;
  37116. }
  37117. function add(p, q) {
  37118. var a = gf(), b = gf(), c = gf(),
  37119. d = gf(), e = gf(), f = gf(),
  37120. g = gf(), h = gf(), t = gf();
  37121. Z(a, p[1], p[0]);
  37122. Z(t, q[1], q[0]);
  37123. M(a, a, t);
  37124. A(b, p[0], p[1]);
  37125. A(t, q[0], q[1]);
  37126. M(b, b, t);
  37127. M(c, p[3], q[3]);
  37128. M(c, c, D2);
  37129. M(d, p[2], q[2]);
  37130. A(d, d, d);
  37131. Z(e, b, a);
  37132. Z(f, d, c);
  37133. A(g, d, c);
  37134. A(h, b, a);
  37135. M(p[0], e, f);
  37136. M(p[1], h, g);
  37137. M(p[2], g, f);
  37138. M(p[3], e, h);
  37139. }
  37140. function cswap(p, q, b) {
  37141. var i;
  37142. for (i = 0; i < 4; i++) {
  37143. sel25519(p[i], q[i], b);
  37144. }
  37145. }
  37146. function pack(r, p) {
  37147. var tx = gf(), ty = gf(), zi = gf();
  37148. inv25519(zi, p[2]);
  37149. M(tx, p[0], zi);
  37150. M(ty, p[1], zi);
  37151. pack25519(r, ty);
  37152. r[31] ^= par25519(tx) << 7;
  37153. }
  37154. function scalarmult(p, q, s) {
  37155. var b, i;
  37156. set25519(p[0], gf0);
  37157. set25519(p[1], gf1);
  37158. set25519(p[2], gf1);
  37159. set25519(p[3], gf0);
  37160. for (i = 255; i >= 0; --i) {
  37161. b = (s[(i/8)|0] >> (i&7)) & 1;
  37162. cswap(p, q, b);
  37163. add(q, p);
  37164. add(p, p);
  37165. cswap(p, q, b);
  37166. }
  37167. }
  37168. function scalarbase(p, s) {
  37169. var q = [gf(), gf(), gf(), gf()];
  37170. set25519(q[0], X);
  37171. set25519(q[1], Y);
  37172. set25519(q[2], gf1);
  37173. M(q[3], X, Y);
  37174. scalarmult(p, q, s);
  37175. }
  37176. function crypto_sign_keypair(pk, sk, seeded) {
  37177. var d = new Uint8Array(64);
  37178. var p = [gf(), gf(), gf(), gf()];
  37179. var i;
  37180. if (!seeded) randombytes(sk, 32);
  37181. crypto_hash(d, sk, 32);
  37182. d[0] &= 248;
  37183. d[31] &= 127;
  37184. d[31] |= 64;
  37185. scalarbase(p, d);
  37186. pack(pk, p);
  37187. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37188. return 0;
  37189. }
  37190. 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]);
  37191. function modL(r, x) {
  37192. var carry, i, j, k;
  37193. for (i = 63; i >= 32; --i) {
  37194. carry = 0;
  37195. for (j = i - 32, k = i - 12; j < k; ++j) {
  37196. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37197. carry = (x[j] + 128) >> 8;
  37198. x[j] -= carry * 256;
  37199. }
  37200. x[j] += carry;
  37201. x[i] = 0;
  37202. }
  37203. carry = 0;
  37204. for (j = 0; j < 32; j++) {
  37205. x[j] += carry - (x[31] >> 4) * L[j];
  37206. carry = x[j] >> 8;
  37207. x[j] &= 255;
  37208. }
  37209. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37210. for (i = 0; i < 32; i++) {
  37211. x[i+1] += x[i] >> 8;
  37212. r[i] = x[i] & 255;
  37213. }
  37214. }
  37215. function reduce(r) {
  37216. var x = new Float64Array(64), i;
  37217. for (i = 0; i < 64; i++) x[i] = r[i];
  37218. for (i = 0; i < 64; i++) r[i] = 0;
  37219. modL(r, x);
  37220. }
  37221. // Note: difference from C - smlen returned, not passed as argument.
  37222. function crypto_sign(sm, m, n, sk) {
  37223. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37224. var i, j, x = new Float64Array(64);
  37225. var p = [gf(), gf(), gf(), gf()];
  37226. crypto_hash(d, sk, 32);
  37227. d[0] &= 248;
  37228. d[31] &= 127;
  37229. d[31] |= 64;
  37230. var smlen = n + 64;
  37231. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37232. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37233. crypto_hash(r, sm.subarray(32), n+32);
  37234. reduce(r);
  37235. scalarbase(p, r);
  37236. pack(sm, p);
  37237. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37238. crypto_hash(h, sm, n + 64);
  37239. reduce(h);
  37240. for (i = 0; i < 64; i++) x[i] = 0;
  37241. for (i = 0; i < 32; i++) x[i] = r[i];
  37242. for (i = 0; i < 32; i++) {
  37243. for (j = 0; j < 32; j++) {
  37244. x[i+j] += h[i] * d[j];
  37245. }
  37246. }
  37247. modL(sm.subarray(32), x);
  37248. return smlen;
  37249. }
  37250. function unpackneg(r, p) {
  37251. var t = gf(), chk = gf(), num = gf(),
  37252. den = gf(), den2 = gf(), den4 = gf(),
  37253. den6 = gf();
  37254. set25519(r[2], gf1);
  37255. unpack25519(r[1], p);
  37256. S(num, r[1]);
  37257. M(den, num, D);
  37258. Z(num, num, r[2]);
  37259. A(den, r[2], den);
  37260. S(den2, den);
  37261. S(den4, den2);
  37262. M(den6, den4, den2);
  37263. M(t, den6, num);
  37264. M(t, t, den);
  37265. pow2523(t, t);
  37266. M(t, t, num);
  37267. M(t, t, den);
  37268. M(t, t, den);
  37269. M(r[0], t, den);
  37270. S(chk, r[0]);
  37271. M(chk, chk, den);
  37272. if (neq25519(chk, num)) M(r[0], r[0], I);
  37273. S(chk, r[0]);
  37274. M(chk, chk, den);
  37275. if (neq25519(chk, num)) return -1;
  37276. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37277. M(r[3], r[0], r[1]);
  37278. return 0;
  37279. }
  37280. function crypto_sign_open(m, sm, n, pk) {
  37281. var i, mlen;
  37282. var t = new Uint8Array(32), h = new Uint8Array(64);
  37283. var p = [gf(), gf(), gf(), gf()],
  37284. q = [gf(), gf(), gf(), gf()];
  37285. mlen = -1;
  37286. if (n < 64) return -1;
  37287. if (unpackneg(q, pk)) return -1;
  37288. for (i = 0; i < n; i++) m[i] = sm[i];
  37289. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37290. crypto_hash(h, m, n);
  37291. reduce(h);
  37292. scalarmult(p, q, h);
  37293. scalarbase(q, sm.subarray(32));
  37294. add(p, q);
  37295. pack(t, p);
  37296. n -= 64;
  37297. if (crypto_verify_32(sm, 0, t, 0)) {
  37298. for (i = 0; i < n; i++) m[i] = 0;
  37299. return -1;
  37300. }
  37301. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37302. mlen = n;
  37303. return mlen;
  37304. }
  37305. var crypto_secretbox_KEYBYTES = 32,
  37306. crypto_secretbox_NONCEBYTES = 24,
  37307. crypto_secretbox_ZEROBYTES = 32,
  37308. crypto_secretbox_BOXZEROBYTES = 16,
  37309. crypto_scalarmult_BYTES = 32,
  37310. crypto_scalarmult_SCALARBYTES = 32,
  37311. crypto_box_PUBLICKEYBYTES = 32,
  37312. crypto_box_SECRETKEYBYTES = 32,
  37313. crypto_box_BEFORENMBYTES = 32,
  37314. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37315. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37316. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37317. crypto_sign_BYTES = 64,
  37318. crypto_sign_PUBLICKEYBYTES = 32,
  37319. crypto_sign_SECRETKEYBYTES = 64,
  37320. crypto_sign_SEEDBYTES = 32,
  37321. crypto_hash_BYTES = 64;
  37322. nacl.lowlevel = {
  37323. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37324. crypto_stream_xor: crypto_stream_xor,
  37325. crypto_stream: crypto_stream,
  37326. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37327. crypto_stream_salsa20: crypto_stream_salsa20,
  37328. crypto_onetimeauth: crypto_onetimeauth,
  37329. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37330. crypto_verify_16: crypto_verify_16,
  37331. crypto_verify_32: crypto_verify_32,
  37332. crypto_secretbox: crypto_secretbox,
  37333. crypto_secretbox_open: crypto_secretbox_open,
  37334. crypto_scalarmult: crypto_scalarmult,
  37335. crypto_scalarmult_base: crypto_scalarmult_base,
  37336. crypto_box_beforenm: crypto_box_beforenm,
  37337. crypto_box_afternm: crypto_box_afternm,
  37338. crypto_box: crypto_box,
  37339. crypto_box_open: crypto_box_open,
  37340. crypto_box_keypair: crypto_box_keypair,
  37341. crypto_hash: crypto_hash,
  37342. crypto_sign: crypto_sign,
  37343. crypto_sign_keypair: crypto_sign_keypair,
  37344. crypto_sign_open: crypto_sign_open,
  37345. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37346. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37347. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37348. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37349. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37350. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37351. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37352. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37353. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37354. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37355. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37356. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37357. crypto_sign_BYTES: crypto_sign_BYTES,
  37358. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37359. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37360. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37361. crypto_hash_BYTES: crypto_hash_BYTES
  37362. };
  37363. /* High-level API */
  37364. function checkLengths(k, n) {
  37365. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37366. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37367. }
  37368. function checkBoxLengths(pk, sk) {
  37369. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37370. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37371. }
  37372. function checkArrayTypes() {
  37373. for (var i = 0; i < arguments.length; i++) {
  37374. if (!(arguments[i] instanceof Uint8Array))
  37375. throw new TypeError('unexpected type, use Uint8Array');
  37376. }
  37377. }
  37378. function cleanup(arr) {
  37379. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37380. }
  37381. nacl.randomBytes = function(n) {
  37382. var b = new Uint8Array(n);
  37383. randombytes(b, n);
  37384. return b;
  37385. };
  37386. nacl.secretbox = function(msg, nonce, key) {
  37387. checkArrayTypes(msg, nonce, key);
  37388. checkLengths(key, nonce);
  37389. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37390. var c = new Uint8Array(m.length);
  37391. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37392. crypto_secretbox(c, m, m.length, nonce, key);
  37393. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37394. };
  37395. nacl.secretbox.open = function(box, nonce, key) {
  37396. checkArrayTypes(box, nonce, key);
  37397. checkLengths(key, nonce);
  37398. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37399. var m = new Uint8Array(c.length);
  37400. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37401. if (c.length < 32) return null;
  37402. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37403. return m.subarray(crypto_secretbox_ZEROBYTES);
  37404. };
  37405. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37406. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37407. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37408. nacl.scalarMult = function(n, p) {
  37409. checkArrayTypes(n, p);
  37410. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37411. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37412. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37413. crypto_scalarmult(q, n, p);
  37414. return q;
  37415. };
  37416. nacl.scalarMult.base = function(n) {
  37417. checkArrayTypes(n);
  37418. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37419. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37420. crypto_scalarmult_base(q, n);
  37421. return q;
  37422. };
  37423. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37424. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37425. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37426. var k = nacl.box.before(publicKey, secretKey);
  37427. return nacl.secretbox(msg, nonce, k);
  37428. };
  37429. nacl.box.before = function(publicKey, secretKey) {
  37430. checkArrayTypes(publicKey, secretKey);
  37431. checkBoxLengths(publicKey, secretKey);
  37432. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37433. crypto_box_beforenm(k, publicKey, secretKey);
  37434. return k;
  37435. };
  37436. nacl.box.after = nacl.secretbox;
  37437. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37438. var k = nacl.box.before(publicKey, secretKey);
  37439. return nacl.secretbox.open(msg, nonce, k);
  37440. };
  37441. nacl.box.open.after = nacl.secretbox.open;
  37442. nacl.box.keyPair = function() {
  37443. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37444. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37445. crypto_box_keypair(pk, sk);
  37446. return {publicKey: pk, secretKey: sk};
  37447. };
  37448. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37449. checkArrayTypes(secretKey);
  37450. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37451. throw new Error('bad secret key size');
  37452. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37453. crypto_scalarmult_base(pk, secretKey);
  37454. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37455. };
  37456. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37457. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37458. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37459. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37460. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37461. nacl.sign = function(msg, secretKey) {
  37462. checkArrayTypes(msg, secretKey);
  37463. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37464. throw new Error('bad secret key size');
  37465. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37466. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37467. return signedMsg;
  37468. };
  37469. nacl.sign.open = function(signedMsg, publicKey) {
  37470. checkArrayTypes(signedMsg, publicKey);
  37471. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37472. throw new Error('bad public key size');
  37473. var tmp = new Uint8Array(signedMsg.length);
  37474. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37475. if (mlen < 0) return null;
  37476. var m = new Uint8Array(mlen);
  37477. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37478. return m;
  37479. };
  37480. nacl.sign.detached = function(msg, secretKey) {
  37481. var signedMsg = nacl.sign(msg, secretKey);
  37482. var sig = new Uint8Array(crypto_sign_BYTES);
  37483. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37484. return sig;
  37485. };
  37486. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37487. checkArrayTypes(msg, sig, publicKey);
  37488. if (sig.length !== crypto_sign_BYTES)
  37489. throw new Error('bad signature size');
  37490. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37491. throw new Error('bad public key size');
  37492. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37493. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37494. var i;
  37495. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37496. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37497. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37498. };
  37499. nacl.sign.keyPair = function() {
  37500. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37501. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37502. crypto_sign_keypair(pk, sk);
  37503. return {publicKey: pk, secretKey: sk};
  37504. };
  37505. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37506. checkArrayTypes(secretKey);
  37507. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37508. throw new Error('bad secret key size');
  37509. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37510. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37511. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37512. };
  37513. nacl.sign.keyPair.fromSeed = function(seed) {
  37514. checkArrayTypes(seed);
  37515. if (seed.length !== crypto_sign_SEEDBYTES)
  37516. throw new Error('bad seed size');
  37517. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37518. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37519. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37520. crypto_sign_keypair(pk, sk, true);
  37521. return {publicKey: pk, secretKey: sk};
  37522. };
  37523. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37524. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37525. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37526. nacl.sign.signatureLength = crypto_sign_BYTES;
  37527. nacl.hash = function(msg) {
  37528. checkArrayTypes(msg);
  37529. var h = new Uint8Array(crypto_hash_BYTES);
  37530. crypto_hash(h, msg, msg.length);
  37531. return h;
  37532. };
  37533. nacl.hash.hashLength = crypto_hash_BYTES;
  37534. nacl.verify = function(x, y) {
  37535. checkArrayTypes(x, y);
  37536. // Zero length arguments are considered not equal.
  37537. if (x.length === 0 || y.length === 0) return false;
  37538. if (x.length !== y.length) return false;
  37539. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37540. };
  37541. nacl.setPRNG = function(fn) {
  37542. randombytes = fn;
  37543. };
  37544. (function() {
  37545. // Initialize PRNG if environment provides CSPRNG.
  37546. // If not, methods calling randombytes will throw.
  37547. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37548. if (crypto && crypto.getRandomValues) {
  37549. // Browsers.
  37550. var QUOTA = 65536;
  37551. nacl.setPRNG(function(x, n) {
  37552. var i, v = new Uint8Array(n);
  37553. for (i = 0; i < n; i += QUOTA) {
  37554. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37555. }
  37556. for (i = 0; i < n; i++) x[i] = v[i];
  37557. cleanup(v);
  37558. });
  37559. } else if (true) {
  37560. // Node.js.
  37561. crypto = __webpack_require__(3);
  37562. if (crypto && crypto.randomBytes) {
  37563. nacl.setPRNG(function(x, n) {
  37564. var i, v = crypto.randomBytes(n);
  37565. for (i = 0; i < n; i++) x[i] = v[i];
  37566. cleanup(v);
  37567. });
  37568. }
  37569. }
  37570. })();
  37571. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37572. /***/ }),
  37573. /* 1 */
  37574. /***/ (function(module, exports, __webpack_require__) {
  37575. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37576. // Public domain.
  37577. (function(root, f) {
  37578. 'use strict';
  37579. if ( true && module.exports) module.exports = f();
  37580. else if (root.nacl) root.nacl.util = f();
  37581. else {
  37582. root.nacl = {};
  37583. root.nacl.util = f();
  37584. }
  37585. }(this, function() {
  37586. 'use strict';
  37587. var util = {};
  37588. function validateBase64(s) {
  37589. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37590. throw new TypeError('invalid encoding');
  37591. }
  37592. }
  37593. util.decodeUTF8 = function(s) {
  37594. if (typeof s !== 'string') throw new TypeError('expected string');
  37595. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37596. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37597. return b;
  37598. };
  37599. util.encodeUTF8 = function(arr) {
  37600. var i, s = [];
  37601. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37602. return decodeURIComponent(escape(s.join('')));
  37603. };
  37604. if (typeof atob === 'undefined') {
  37605. // Node.js
  37606. if (typeof Buffer.from !== 'undefined') {
  37607. // Node v6 and later
  37608. util.encodeBase64 = function (arr) { // v6 and later
  37609. return Buffer.from(arr).toString('base64');
  37610. };
  37611. util.decodeBase64 = function (s) {
  37612. validateBase64(s);
  37613. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37614. };
  37615. } else {
  37616. // Node earlier than v6
  37617. util.encodeBase64 = function (arr) { // v6 and later
  37618. return (new Buffer(arr)).toString('base64');
  37619. };
  37620. util.decodeBase64 = function(s) {
  37621. validateBase64(s);
  37622. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37623. };
  37624. }
  37625. } else {
  37626. // Browsers
  37627. util.encodeBase64 = function(arr) {
  37628. var i, s = [], len = arr.length;
  37629. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37630. return btoa(s.join(''));
  37631. };
  37632. util.decodeBase64 = function(s) {
  37633. validateBase64(s);
  37634. var i, d = atob(s), b = new Uint8Array(d.length);
  37635. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37636. return b;
  37637. };
  37638. }
  37639. return util;
  37640. }));
  37641. /***/ }),
  37642. /* 2 */
  37643. /***/ (function(module, exports, __webpack_require__) {
  37644. // required so we don't have to do require('pusher').default etc.
  37645. module.exports = __webpack_require__(4).default;
  37646. /***/ }),
  37647. /* 3 */
  37648. /***/ (function(module, exports) {
  37649. /* (ignored) */
  37650. /***/ }),
  37651. /* 4 */
  37652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37653. "use strict";
  37654. __webpack_require__.r(__webpack_exports__);
  37655. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37656. var ScriptReceiverFactory = (function () {
  37657. function ScriptReceiverFactory(prefix, name) {
  37658. this.lastId = 0;
  37659. this.prefix = prefix;
  37660. this.name = name;
  37661. }
  37662. ScriptReceiverFactory.prototype.create = function (callback) {
  37663. this.lastId++;
  37664. var number = this.lastId;
  37665. var id = this.prefix + number;
  37666. var name = this.name + "[" + number + "]";
  37667. var called = false;
  37668. var callbackWrapper = function () {
  37669. if (!called) {
  37670. callback.apply(null, arguments);
  37671. called = true;
  37672. }
  37673. };
  37674. this[number] = callbackWrapper;
  37675. return { number: number, id: id, name: name, callback: callbackWrapper };
  37676. };
  37677. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37678. delete this[receiver.number];
  37679. };
  37680. return ScriptReceiverFactory;
  37681. }());
  37682. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37683. // CONCATENATED MODULE: ./src/core/defaults.ts
  37684. var Defaults = {
  37685. VERSION: "5.0.3",
  37686. PROTOCOL: 7,
  37687. host: 'ws.pusherapp.com',
  37688. ws_port: 80,
  37689. wss_port: 443,
  37690. ws_path: '',
  37691. sockjs_host: 'sockjs.pusher.com',
  37692. sockjs_http_port: 80,
  37693. sockjs_https_port: 443,
  37694. sockjs_path: '/pusher',
  37695. stats_host: 'stats.pusher.com',
  37696. channel_auth_endpoint: '/pusher/auth',
  37697. channel_auth_transport: 'ajax',
  37698. activity_timeout: 120000,
  37699. pong_timeout: 30000,
  37700. unavailable_timeout: 10000,
  37701. cdn_http: "http://js.pusher.com",
  37702. cdn_https: "https://js.pusher.com",
  37703. dependency_suffix: ""
  37704. };
  37705. /* harmony default export */ var defaults = (Defaults);
  37706. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37707. var dependency_loader_DependencyLoader = (function () {
  37708. function DependencyLoader(options) {
  37709. this.options = options;
  37710. this.receivers = options.receivers || ScriptReceivers;
  37711. this.loading = {};
  37712. }
  37713. DependencyLoader.prototype.load = function (name, options, callback) {
  37714. var self = this;
  37715. if (self.loading[name] && self.loading[name].length > 0) {
  37716. self.loading[name].push(callback);
  37717. }
  37718. else {
  37719. self.loading[name] = [callback];
  37720. var request = runtime.createScriptRequest(self.getPath(name, options));
  37721. var receiver = self.receivers.create(function (error) {
  37722. self.receivers.remove(receiver);
  37723. if (self.loading[name]) {
  37724. var callbacks = self.loading[name];
  37725. delete self.loading[name];
  37726. var successCallback = function (wasSuccessful) {
  37727. if (!wasSuccessful) {
  37728. request.cleanup();
  37729. }
  37730. };
  37731. for (var i = 0; i < callbacks.length; i++) {
  37732. callbacks[i](error, successCallback);
  37733. }
  37734. }
  37735. });
  37736. request.send(receiver);
  37737. }
  37738. };
  37739. DependencyLoader.prototype.getRoot = function (options) {
  37740. var cdn;
  37741. var protocol = runtime.getDocument().location.protocol;
  37742. if ((options && options.useTLS) || protocol === "https:") {
  37743. cdn = this.options.cdn_https;
  37744. }
  37745. else {
  37746. cdn = this.options.cdn_http;
  37747. }
  37748. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37749. };
  37750. DependencyLoader.prototype.getPath = function (name, options) {
  37751. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37752. };
  37753. ;
  37754. return DependencyLoader;
  37755. }());
  37756. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37757. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37758. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37759. var Dependencies = new dependency_loader({
  37760. cdn_http: defaults.cdn_http,
  37761. cdn_https: defaults.cdn_https,
  37762. version: defaults.VERSION,
  37763. suffix: defaults.dependency_suffix,
  37764. receivers: DependenciesReceivers
  37765. });
  37766. // CONCATENATED MODULE: ./src/core/base64.ts
  37767. function encode(s) {
  37768. return btoa(utob(s));
  37769. }
  37770. var fromCharCode = String.fromCharCode;
  37771. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37772. var b64tab = {};
  37773. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37774. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37775. }
  37776. var cb_utob = function (c) {
  37777. var cc = c.charCodeAt(0);
  37778. return cc < 0x80
  37779. ? c
  37780. : cc < 0x800
  37781. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37782. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37783. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37784. fromCharCode(0x80 | (cc & 0x3f));
  37785. };
  37786. var utob = function (u) {
  37787. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37788. };
  37789. var cb_encode = function (ccc) {
  37790. var padlen = [0, 2, 1][ccc.length % 3];
  37791. var ord = (ccc.charCodeAt(0) << 16) |
  37792. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37793. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37794. var chars = [
  37795. b64chars.charAt(ord >>> 18),
  37796. b64chars.charAt((ord >>> 12) & 63),
  37797. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37798. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37799. ];
  37800. return chars.join('');
  37801. };
  37802. var btoa = window.btoa ||
  37803. function (b) {
  37804. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37805. };
  37806. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37807. var Timer = (function () {
  37808. function Timer(set, clear, delay, callback) {
  37809. var _this = this;
  37810. this.clear = clear;
  37811. this.timer = set(function () {
  37812. if (_this.timer) {
  37813. _this.timer = callback(_this.timer);
  37814. }
  37815. }, delay);
  37816. }
  37817. Timer.prototype.isRunning = function () {
  37818. return this.timer !== null;
  37819. };
  37820. Timer.prototype.ensureAborted = function () {
  37821. if (this.timer) {
  37822. this.clear(this.timer);
  37823. this.timer = null;
  37824. }
  37825. };
  37826. return Timer;
  37827. }());
  37828. /* harmony default export */ var abstract_timer = (Timer);
  37829. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37830. var __extends = (undefined && undefined.__extends) || (function () {
  37831. var extendStatics = function (d, b) {
  37832. extendStatics = Object.setPrototypeOf ||
  37833. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37834. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37835. return extendStatics(d, b);
  37836. };
  37837. return function (d, b) {
  37838. extendStatics(d, b);
  37839. function __() { this.constructor = d; }
  37840. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37841. };
  37842. })();
  37843. function timers_clearTimeout(timer) {
  37844. window.clearTimeout(timer);
  37845. }
  37846. function timers_clearInterval(timer) {
  37847. window.clearInterval(timer);
  37848. }
  37849. var OneOffTimer = (function (_super) {
  37850. __extends(OneOffTimer, _super);
  37851. function OneOffTimer(delay, callback) {
  37852. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37853. callback();
  37854. return null;
  37855. }) || this;
  37856. }
  37857. return OneOffTimer;
  37858. }(abstract_timer));
  37859. var PeriodicTimer = (function (_super) {
  37860. __extends(PeriodicTimer, _super);
  37861. function PeriodicTimer(delay, callback) {
  37862. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37863. callback();
  37864. return timer;
  37865. }) || this;
  37866. }
  37867. return PeriodicTimer;
  37868. }(abstract_timer));
  37869. // CONCATENATED MODULE: ./src/core/util.ts
  37870. var Util = {
  37871. now: function () {
  37872. if (Date.now) {
  37873. return Date.now();
  37874. }
  37875. else {
  37876. return new Date().valueOf();
  37877. }
  37878. },
  37879. defer: function (callback) {
  37880. return new OneOffTimer(0, callback);
  37881. },
  37882. method: function (name) {
  37883. var args = [];
  37884. for (var _i = 1; _i < arguments.length; _i++) {
  37885. args[_i - 1] = arguments[_i];
  37886. }
  37887. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37888. return function (object) {
  37889. return object[name].apply(object, boundArguments.concat(arguments));
  37890. };
  37891. }
  37892. };
  37893. /* harmony default export */ var util = (Util);
  37894. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37895. function extend(target) {
  37896. var sources = [];
  37897. for (var _i = 1; _i < arguments.length; _i++) {
  37898. sources[_i - 1] = arguments[_i];
  37899. }
  37900. for (var i = 0; i < sources.length; i++) {
  37901. var extensions = sources[i];
  37902. for (var property in extensions) {
  37903. if (extensions[property] && extensions[property].constructor &&
  37904. extensions[property].constructor === Object) {
  37905. target[property] = extend(target[property] || {}, extensions[property]);
  37906. }
  37907. else {
  37908. target[property] = extensions[property];
  37909. }
  37910. }
  37911. }
  37912. return target;
  37913. }
  37914. function stringify() {
  37915. var m = ["Pusher"];
  37916. for (var i = 0; i < arguments.length; i++) {
  37917. if (typeof arguments[i] === "string") {
  37918. m.push(arguments[i]);
  37919. }
  37920. else {
  37921. m.push(safeJSONStringify(arguments[i]));
  37922. }
  37923. }
  37924. return m.join(" : ");
  37925. }
  37926. function arrayIndexOf(array, item) {
  37927. var nativeIndexOf = Array.prototype.indexOf;
  37928. if (array === null) {
  37929. return -1;
  37930. }
  37931. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37932. return array.indexOf(item);
  37933. }
  37934. for (var i = 0, l = array.length; i < l; i++) {
  37935. if (array[i] === item) {
  37936. return i;
  37937. }
  37938. }
  37939. return -1;
  37940. }
  37941. function objectApply(object, f) {
  37942. for (var key in object) {
  37943. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37944. f(object[key], key, object);
  37945. }
  37946. }
  37947. }
  37948. function keys(object) {
  37949. var keys = [];
  37950. objectApply(object, function (_, key) {
  37951. keys.push(key);
  37952. });
  37953. return keys;
  37954. }
  37955. function values(object) {
  37956. var values = [];
  37957. objectApply(object, function (value) {
  37958. values.push(value);
  37959. });
  37960. return values;
  37961. }
  37962. function apply(array, f, context) {
  37963. for (var i = 0; i < array.length; i++) {
  37964. f.call(context || window, array[i], i, array);
  37965. }
  37966. }
  37967. function map(array, f) {
  37968. var result = [];
  37969. for (var i = 0; i < array.length; i++) {
  37970. result.push(f(array[i], i, array, result));
  37971. }
  37972. return result;
  37973. }
  37974. function mapObject(object, f) {
  37975. var result = {};
  37976. objectApply(object, function (value, key) {
  37977. result[key] = f(value);
  37978. });
  37979. return result;
  37980. }
  37981. function filter(array, test) {
  37982. test = test || function (value) { return !!value; };
  37983. var result = [];
  37984. for (var i = 0; i < array.length; i++) {
  37985. if (test(array[i], i, array, result)) {
  37986. result.push(array[i]);
  37987. }
  37988. }
  37989. return result;
  37990. }
  37991. function filterObject(object, test) {
  37992. var result = {};
  37993. objectApply(object, function (value, key) {
  37994. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37995. result[key] = value;
  37996. }
  37997. });
  37998. return result;
  37999. }
  38000. function flatten(object) {
  38001. var result = [];
  38002. objectApply(object, function (value, key) {
  38003. result.push([key, value]);
  38004. });
  38005. return result;
  38006. }
  38007. function any(array, test) {
  38008. for (var i = 0; i < array.length; i++) {
  38009. if (test(array[i], i, array)) {
  38010. return true;
  38011. }
  38012. }
  38013. return false;
  38014. }
  38015. function collections_all(array, test) {
  38016. for (var i = 0; i < array.length; i++) {
  38017. if (!test(array[i], i, array)) {
  38018. return false;
  38019. }
  38020. }
  38021. return true;
  38022. }
  38023. function encodeParamsObject(data) {
  38024. return mapObject(data, function (value) {
  38025. if (typeof value === "object") {
  38026. value = safeJSONStringify(value);
  38027. }
  38028. return encodeURIComponent(encode(value.toString()));
  38029. });
  38030. }
  38031. function buildQueryString(data) {
  38032. var params = filterObject(data, function (value) {
  38033. return value !== undefined;
  38034. });
  38035. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38036. return query;
  38037. }
  38038. function decycleObject(object) {
  38039. var objects = [], paths = [];
  38040. return (function derez(value, path) {
  38041. var i, name, nu;
  38042. switch (typeof value) {
  38043. case 'object':
  38044. if (!value) {
  38045. return null;
  38046. }
  38047. for (i = 0; i < objects.length; i += 1) {
  38048. if (objects[i] === value) {
  38049. return { $ref: paths[i] };
  38050. }
  38051. }
  38052. objects.push(value);
  38053. paths.push(path);
  38054. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38055. nu = [];
  38056. for (i = 0; i < value.length; i += 1) {
  38057. nu[i] = derez(value[i], path + '[' + i + ']');
  38058. }
  38059. }
  38060. else {
  38061. nu = {};
  38062. for (name in value) {
  38063. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38064. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38065. }
  38066. }
  38067. }
  38068. return nu;
  38069. case 'number':
  38070. case 'string':
  38071. case 'boolean':
  38072. return value;
  38073. }
  38074. }(object, '$'));
  38075. }
  38076. function safeJSONStringify(source) {
  38077. try {
  38078. return JSON.stringify(source);
  38079. }
  38080. catch (e) {
  38081. return JSON.stringify(decycleObject(source));
  38082. }
  38083. }
  38084. // CONCATENATED MODULE: ./src/core/logger.ts
  38085. var logger_Logger = (function () {
  38086. function Logger() {
  38087. this.globalLog = function (message) {
  38088. if (window.console && window.console.log) {
  38089. window.console.log(message);
  38090. }
  38091. };
  38092. }
  38093. Logger.prototype.debug = function () {
  38094. var args = [];
  38095. for (var _i = 0; _i < arguments.length; _i++) {
  38096. args[_i] = arguments[_i];
  38097. }
  38098. this.log(this.globalLog, args);
  38099. };
  38100. Logger.prototype.warn = function () {
  38101. var args = [];
  38102. for (var _i = 0; _i < arguments.length; _i++) {
  38103. args[_i] = arguments[_i];
  38104. }
  38105. this.log(this.globalLogWarn, args);
  38106. };
  38107. Logger.prototype.error = function () {
  38108. var args = [];
  38109. for (var _i = 0; _i < arguments.length; _i++) {
  38110. args[_i] = arguments[_i];
  38111. }
  38112. this.log(this.globalLogError, args);
  38113. };
  38114. Logger.prototype.globalLogWarn = function (message) {
  38115. if (window.console && window.console.warn) {
  38116. window.console.warn(message);
  38117. }
  38118. else {
  38119. this.globalLog(message);
  38120. }
  38121. };
  38122. Logger.prototype.globalLogError = function (message) {
  38123. if (window.console && window.console.error) {
  38124. window.console.error(message);
  38125. }
  38126. else {
  38127. this.globalLogWarn(message);
  38128. }
  38129. };
  38130. Logger.prototype.log = function (defaultLoggingFunction) {
  38131. var args = [];
  38132. for (var _i = 1; _i < arguments.length; _i++) {
  38133. args[_i - 1] = arguments[_i];
  38134. }
  38135. var message = stringify.apply(this, arguments);
  38136. if (core_pusher.log) {
  38137. core_pusher.log(message);
  38138. }
  38139. else if (core_pusher.logToConsole) {
  38140. var log = defaultLoggingFunction.bind(this);
  38141. log(message);
  38142. }
  38143. };
  38144. return Logger;
  38145. }());
  38146. /* harmony default export */ var logger = (new logger_Logger());
  38147. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38148. var urlStore = {
  38149. baseUrl: "https://pusher.com",
  38150. urls: {
  38151. authenticationEndpoint: {
  38152. path: "/docs/authenticating_users",
  38153. },
  38154. javascriptQuickStart: {
  38155. path: "/docs/javascript_quick_start"
  38156. },
  38157. triggeringClientEvents: {
  38158. path: "/docs/client_api_guide/client_events#trigger-events"
  38159. }
  38160. }
  38161. };
  38162. var buildLogSuffix = function (key) {
  38163. var urlPrefix = "See:";
  38164. var urlObj = urlStore.urls[key];
  38165. if (!urlObj)
  38166. return "";
  38167. var url;
  38168. if (urlObj.fullUrl) {
  38169. url = urlObj.fullUrl;
  38170. }
  38171. else if (urlObj.path) {
  38172. url = urlStore.baseUrl + urlObj.path;
  38173. }
  38174. if (!url)
  38175. return "";
  38176. return urlPrefix + " " + url;
  38177. };
  38178. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38179. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38180. var ajax = function (context, socketId, callback) {
  38181. var self = this, xhr;
  38182. xhr = runtime.createXHR();
  38183. xhr.open("POST", self.options.authEndpoint, true);
  38184. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38185. for (var headerName in this.authOptions.headers) {
  38186. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38187. }
  38188. xhr.onreadystatechange = function () {
  38189. if (xhr.readyState === 4) {
  38190. if (xhr.status === 200) {
  38191. var data, parsed = false;
  38192. try {
  38193. data = JSON.parse(xhr.responseText);
  38194. parsed = true;
  38195. }
  38196. catch (e) {
  38197. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38198. }
  38199. if (parsed) {
  38200. callback(false, data);
  38201. }
  38202. }
  38203. else {
  38204. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38205. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38206. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38207. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38208. callback(true, xhr.status);
  38209. }
  38210. }
  38211. };
  38212. xhr.send(this.composeQuery(socketId));
  38213. return xhr;
  38214. };
  38215. /* harmony default export */ var xhr_auth = (ajax);
  38216. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38217. var jsonp = function (context, socketId, callback) {
  38218. if (this.authOptions.headers !== undefined) {
  38219. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38220. }
  38221. var callbackName = context.nextAuthCallbackID.toString();
  38222. context.nextAuthCallbackID++;
  38223. var document = context.getDocument();
  38224. var script = document.createElement("script");
  38225. context.auth_callbacks[callbackName] = function (data) {
  38226. callback(false, data);
  38227. };
  38228. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38229. script.src = this.options.authEndpoint +
  38230. '?callback=' +
  38231. encodeURIComponent(callback_name) +
  38232. '&' +
  38233. this.composeQuery(socketId);
  38234. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38235. head.insertBefore(script, head.firstChild);
  38236. };
  38237. /* harmony default export */ var jsonp_auth = (jsonp);
  38238. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38239. var ScriptRequest = (function () {
  38240. function ScriptRequest(src) {
  38241. this.src = src;
  38242. }
  38243. ScriptRequest.prototype.send = function (receiver) {
  38244. var self = this;
  38245. var errorString = "Error loading " + self.src;
  38246. self.script = document.createElement("script");
  38247. self.script.id = receiver.id;
  38248. self.script.src = self.src;
  38249. self.script.type = "text/javascript";
  38250. self.script.charset = "UTF-8";
  38251. if (self.script.addEventListener) {
  38252. self.script.onerror = function () {
  38253. receiver.callback(errorString);
  38254. };
  38255. self.script.onload = function () {
  38256. receiver.callback(null);
  38257. };
  38258. }
  38259. else {
  38260. self.script.onreadystatechange = function () {
  38261. if (self.script.readyState === 'loaded' ||
  38262. self.script.readyState === 'complete') {
  38263. receiver.callback(null);
  38264. }
  38265. };
  38266. }
  38267. if (self.script.async === undefined && document.attachEvent &&
  38268. /opera/i.test(navigator.userAgent)) {
  38269. self.errorScript = document.createElement("script");
  38270. self.errorScript.id = receiver.id + "_error";
  38271. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38272. self.script.async = self.errorScript.async = false;
  38273. }
  38274. else {
  38275. self.script.async = true;
  38276. }
  38277. var head = document.getElementsByTagName('head')[0];
  38278. head.insertBefore(self.script, head.firstChild);
  38279. if (self.errorScript) {
  38280. head.insertBefore(self.errorScript, self.script.nextSibling);
  38281. }
  38282. };
  38283. ScriptRequest.prototype.cleanup = function () {
  38284. if (this.script) {
  38285. this.script.onload = this.script.onerror = null;
  38286. this.script.onreadystatechange = null;
  38287. }
  38288. if (this.script && this.script.parentNode) {
  38289. this.script.parentNode.removeChild(this.script);
  38290. }
  38291. if (this.errorScript && this.errorScript.parentNode) {
  38292. this.errorScript.parentNode.removeChild(this.errorScript);
  38293. }
  38294. this.script = null;
  38295. this.errorScript = null;
  38296. };
  38297. return ScriptRequest;
  38298. }());
  38299. /* harmony default export */ var script_request = (ScriptRequest);
  38300. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38301. var jsonp_request_JSONPRequest = (function () {
  38302. function JSONPRequest(url, data) {
  38303. this.url = url;
  38304. this.data = data;
  38305. }
  38306. JSONPRequest.prototype.send = function (receiver) {
  38307. if (this.request) {
  38308. return;
  38309. }
  38310. var query = buildQueryString(this.data);
  38311. var url = this.url + "/" + receiver.number + "?" + query;
  38312. this.request = runtime.createScriptRequest(url);
  38313. this.request.send(receiver);
  38314. };
  38315. JSONPRequest.prototype.cleanup = function () {
  38316. if (this.request) {
  38317. this.request.cleanup();
  38318. }
  38319. };
  38320. return JSONPRequest;
  38321. }());
  38322. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38323. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38324. var getAgent = function (sender, useTLS) {
  38325. return function (data, callback) {
  38326. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38327. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38328. var request = runtime.createJSONPRequest(url, data);
  38329. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38330. ScriptReceivers.remove(receiver);
  38331. request.cleanup();
  38332. if (result && result.host) {
  38333. sender.host = result.host;
  38334. }
  38335. if (callback) {
  38336. callback(error, result);
  38337. }
  38338. });
  38339. request.send(receiver);
  38340. };
  38341. };
  38342. var jsonp_timeline_jsonp = {
  38343. name: 'jsonp',
  38344. getAgent: getAgent
  38345. };
  38346. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38347. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38348. function getGenericURL(baseScheme, params, path) {
  38349. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38350. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38351. return scheme + "://" + host + path;
  38352. }
  38353. function getGenericPath(key, queryString) {
  38354. var path = "/app/" + key;
  38355. var query = "?protocol=" + defaults.PROTOCOL +
  38356. "&client=js" +
  38357. "&version=" + defaults.VERSION +
  38358. (queryString ? ("&" + queryString) : "");
  38359. return path + query;
  38360. }
  38361. var ws = {
  38362. getInitial: function (key, params) {
  38363. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38364. return getGenericURL("ws", params, path);
  38365. }
  38366. };
  38367. var http = {
  38368. getInitial: function (key, params) {
  38369. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38370. return getGenericURL("http", params, path);
  38371. }
  38372. };
  38373. var sockjs = {
  38374. getInitial: function (key, params) {
  38375. return getGenericURL("http", params, params.httpPath || "/pusher");
  38376. },
  38377. getPath: function (key, params) {
  38378. return getGenericPath(key);
  38379. }
  38380. };
  38381. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38382. var callback_registry_CallbackRegistry = (function () {
  38383. function CallbackRegistry() {
  38384. this._callbacks = {};
  38385. }
  38386. CallbackRegistry.prototype.get = function (name) {
  38387. return this._callbacks[prefix(name)];
  38388. };
  38389. CallbackRegistry.prototype.add = function (name, callback, context) {
  38390. var prefixedEventName = prefix(name);
  38391. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38392. this._callbacks[prefixedEventName].push({
  38393. fn: callback,
  38394. context: context
  38395. });
  38396. };
  38397. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38398. if (!name && !callback && !context) {
  38399. this._callbacks = {};
  38400. return;
  38401. }
  38402. var names = name ? [prefix(name)] : keys(this._callbacks);
  38403. if (callback || context) {
  38404. this.removeCallback(names, callback, context);
  38405. }
  38406. else {
  38407. this.removeAllCallbacks(names);
  38408. }
  38409. };
  38410. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38411. apply(names, function (name) {
  38412. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38413. return (callback && callback !== binding.fn) ||
  38414. (context && context !== binding.context);
  38415. });
  38416. if (this._callbacks[name].length === 0) {
  38417. delete this._callbacks[name];
  38418. }
  38419. }, this);
  38420. };
  38421. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38422. apply(names, function (name) {
  38423. delete this._callbacks[name];
  38424. }, this);
  38425. };
  38426. return CallbackRegistry;
  38427. }());
  38428. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38429. function prefix(name) {
  38430. return "_" + name;
  38431. }
  38432. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38433. var dispatcher_Dispatcher = (function () {
  38434. function Dispatcher(failThrough) {
  38435. this.callbacks = new callback_registry();
  38436. this.global_callbacks = [];
  38437. this.failThrough = failThrough;
  38438. }
  38439. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38440. this.callbacks.add(eventName, callback, context);
  38441. return this;
  38442. };
  38443. Dispatcher.prototype.bind_global = function (callback) {
  38444. this.global_callbacks.push(callback);
  38445. return this;
  38446. };
  38447. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38448. this.callbacks.remove(eventName, callback, context);
  38449. return this;
  38450. };
  38451. Dispatcher.prototype.unbind_global = function (callback) {
  38452. if (!callback) {
  38453. this.global_callbacks = [];
  38454. return this;
  38455. }
  38456. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38457. return this;
  38458. };
  38459. Dispatcher.prototype.unbind_all = function () {
  38460. this.unbind();
  38461. this.unbind_global();
  38462. return this;
  38463. };
  38464. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38465. for (var i = 0; i < this.global_callbacks.length; i++) {
  38466. this.global_callbacks[i](eventName, data);
  38467. }
  38468. var callbacks = this.callbacks.get(eventName);
  38469. var args = [];
  38470. if (metadata) {
  38471. args.push(data, metadata);
  38472. }
  38473. else if (data) {
  38474. args.push(data);
  38475. }
  38476. if (callbacks && callbacks.length > 0) {
  38477. for (var i = 0; i < callbacks.length; i++) {
  38478. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38479. }
  38480. }
  38481. else if (this.failThrough) {
  38482. this.failThrough(eventName, data);
  38483. }
  38484. return this;
  38485. };
  38486. return Dispatcher;
  38487. }());
  38488. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38489. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38490. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38491. var extendStatics = function (d, b) {
  38492. extendStatics = Object.setPrototypeOf ||
  38493. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38494. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38495. return extendStatics(d, b);
  38496. };
  38497. return function (d, b) {
  38498. extendStatics(d, b);
  38499. function __() { this.constructor = d; }
  38500. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38501. };
  38502. })();
  38503. var transport_connection_TransportConnection = (function (_super) {
  38504. transport_connection_extends(TransportConnection, _super);
  38505. function TransportConnection(hooks, name, priority, key, options) {
  38506. var _this = _super.call(this) || this;
  38507. _this.initialize = runtime.transportConnectionInitializer;
  38508. _this.hooks = hooks;
  38509. _this.name = name;
  38510. _this.priority = priority;
  38511. _this.key = key;
  38512. _this.options = options;
  38513. _this.state = "new";
  38514. _this.timeline = options.timeline;
  38515. _this.activityTimeout = options.activityTimeout;
  38516. _this.id = _this.timeline.generateUniqueID();
  38517. return _this;
  38518. }
  38519. TransportConnection.prototype.handlesActivityChecks = function () {
  38520. return Boolean(this.hooks.handlesActivityChecks);
  38521. };
  38522. TransportConnection.prototype.supportsPing = function () {
  38523. return Boolean(this.hooks.supportsPing);
  38524. };
  38525. TransportConnection.prototype.connect = function () {
  38526. var _this = this;
  38527. if (this.socket || this.state !== "initialized") {
  38528. return false;
  38529. }
  38530. var url = this.hooks.urls.getInitial(this.key, this.options);
  38531. try {
  38532. this.socket = this.hooks.getSocket(url, this.options);
  38533. }
  38534. catch (e) {
  38535. util.defer(function () {
  38536. _this.onError(e);
  38537. _this.changeState("closed");
  38538. });
  38539. return false;
  38540. }
  38541. this.bindListeners();
  38542. logger.debug("Connecting", { transport: this.name, url: url });
  38543. this.changeState("connecting");
  38544. return true;
  38545. };
  38546. TransportConnection.prototype.close = function () {
  38547. if (this.socket) {
  38548. this.socket.close();
  38549. return true;
  38550. }
  38551. else {
  38552. return false;
  38553. }
  38554. };
  38555. TransportConnection.prototype.send = function (data) {
  38556. var _this = this;
  38557. if (this.state === "open") {
  38558. util.defer(function () {
  38559. if (_this.socket) {
  38560. _this.socket.send(data);
  38561. }
  38562. });
  38563. return true;
  38564. }
  38565. else {
  38566. return false;
  38567. }
  38568. };
  38569. TransportConnection.prototype.ping = function () {
  38570. if (this.state === "open" && this.supportsPing()) {
  38571. this.socket.ping();
  38572. }
  38573. };
  38574. TransportConnection.prototype.onOpen = function () {
  38575. if (this.hooks.beforeOpen) {
  38576. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38577. }
  38578. this.changeState("open");
  38579. this.socket.onopen = undefined;
  38580. };
  38581. TransportConnection.prototype.onError = function (error) {
  38582. this.emit("error", { type: 'WebSocketError', error: error });
  38583. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38584. };
  38585. TransportConnection.prototype.onClose = function (closeEvent) {
  38586. if (closeEvent) {
  38587. this.changeState("closed", {
  38588. code: closeEvent.code,
  38589. reason: closeEvent.reason,
  38590. wasClean: closeEvent.wasClean
  38591. });
  38592. }
  38593. else {
  38594. this.changeState("closed");
  38595. }
  38596. this.unbindListeners();
  38597. this.socket = undefined;
  38598. };
  38599. TransportConnection.prototype.onMessage = function (message) {
  38600. this.emit("message", message);
  38601. };
  38602. TransportConnection.prototype.onActivity = function () {
  38603. this.emit("activity");
  38604. };
  38605. TransportConnection.prototype.bindListeners = function () {
  38606. var _this = this;
  38607. this.socket.onopen = function () {
  38608. _this.onOpen();
  38609. };
  38610. this.socket.onerror = function (error) {
  38611. _this.onError(error);
  38612. };
  38613. this.socket.onclose = function (closeEvent) {
  38614. _this.onClose(closeEvent);
  38615. };
  38616. this.socket.onmessage = function (message) {
  38617. _this.onMessage(message);
  38618. };
  38619. if (this.supportsPing()) {
  38620. this.socket.onactivity = function () { _this.onActivity(); };
  38621. }
  38622. };
  38623. TransportConnection.prototype.unbindListeners = function () {
  38624. if (this.socket) {
  38625. this.socket.onopen = undefined;
  38626. this.socket.onerror = undefined;
  38627. this.socket.onclose = undefined;
  38628. this.socket.onmessage = undefined;
  38629. if (this.supportsPing()) {
  38630. this.socket.onactivity = undefined;
  38631. }
  38632. }
  38633. };
  38634. TransportConnection.prototype.changeState = function (state, params) {
  38635. this.state = state;
  38636. this.timeline.info(this.buildTimelineMessage({
  38637. state: state,
  38638. params: params
  38639. }));
  38640. this.emit(state, params);
  38641. };
  38642. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38643. return extend({ cid: this.id }, message);
  38644. };
  38645. return TransportConnection;
  38646. }(dispatcher));
  38647. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38648. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38649. var transport_Transport = (function () {
  38650. function Transport(hooks) {
  38651. this.hooks = hooks;
  38652. }
  38653. Transport.prototype.isSupported = function (environment) {
  38654. return this.hooks.isSupported(environment);
  38655. };
  38656. Transport.prototype.createConnection = function (name, priority, key, options) {
  38657. return new transport_connection(this.hooks, name, priority, key, options);
  38658. };
  38659. return Transport;
  38660. }());
  38661. /* harmony default export */ var transports_transport = (transport_Transport);
  38662. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38663. var WSTransport = new transports_transport({
  38664. urls: ws,
  38665. handlesActivityChecks: false,
  38666. supportsPing: false,
  38667. isInitialized: function () {
  38668. return Boolean(runtime.getWebSocketAPI());
  38669. },
  38670. isSupported: function () {
  38671. return Boolean(runtime.getWebSocketAPI());
  38672. },
  38673. getSocket: function (url) {
  38674. return runtime.createWebSocket(url);
  38675. }
  38676. });
  38677. var httpConfiguration = {
  38678. urls: http,
  38679. handlesActivityChecks: false,
  38680. supportsPing: true,
  38681. isInitialized: function () {
  38682. return true;
  38683. }
  38684. };
  38685. var streamingConfiguration = extend({ getSocket: function (url) {
  38686. return runtime.HTTPFactory.createStreamingSocket(url);
  38687. }
  38688. }, httpConfiguration);
  38689. var pollingConfiguration = extend({ getSocket: function (url) {
  38690. return runtime.HTTPFactory.createPollingSocket(url);
  38691. }
  38692. }, httpConfiguration);
  38693. var xhrConfiguration = {
  38694. isSupported: function () {
  38695. return runtime.isXHRSupported();
  38696. }
  38697. };
  38698. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38699. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38700. var Transports = {
  38701. ws: WSTransport,
  38702. xhr_streaming: XHRStreamingTransport,
  38703. xhr_polling: XHRPollingTransport
  38704. };
  38705. /* harmony default export */ var transports = (Transports);
  38706. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38707. var SockJSTransport = new transports_transport({
  38708. file: "sockjs",
  38709. urls: sockjs,
  38710. handlesActivityChecks: true,
  38711. supportsPing: false,
  38712. isSupported: function () {
  38713. return true;
  38714. },
  38715. isInitialized: function () {
  38716. return window.SockJS !== undefined;
  38717. },
  38718. getSocket: function (url, options) {
  38719. return new window.SockJS(url, null, {
  38720. js_path: Dependencies.getPath("sockjs", {
  38721. useTLS: options.useTLS
  38722. }),
  38723. ignore_null_origin: options.ignoreNullOrigin
  38724. });
  38725. },
  38726. beforeOpen: function (socket, path) {
  38727. socket.send(JSON.stringify({
  38728. path: path
  38729. }));
  38730. }
  38731. });
  38732. var xdrConfiguration = {
  38733. isSupported: function (environment) {
  38734. var yes = runtime.isXDRSupported(environment.useTLS);
  38735. return yes;
  38736. }
  38737. };
  38738. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38739. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38740. transports.xdr_streaming = XDRStreamingTransport;
  38741. transports.xdr_polling = XDRPollingTransport;
  38742. transports.sockjs = SockJSTransport;
  38743. /* harmony default export */ var transports_transports = (transports);
  38744. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38745. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38746. var extendStatics = function (d, b) {
  38747. extendStatics = Object.setPrototypeOf ||
  38748. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38749. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38750. return extendStatics(d, b);
  38751. };
  38752. return function (d, b) {
  38753. extendStatics(d, b);
  38754. function __() { this.constructor = d; }
  38755. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38756. };
  38757. })();
  38758. var NetInfo = (function (_super) {
  38759. net_info_extends(NetInfo, _super);
  38760. function NetInfo() {
  38761. var _this = _super.call(this) || this;
  38762. var self = _this;
  38763. if (window.addEventListener !== undefined) {
  38764. window.addEventListener("online", function () {
  38765. self.emit('online');
  38766. }, false);
  38767. window.addEventListener("offline", function () {
  38768. self.emit('offline');
  38769. }, false);
  38770. }
  38771. return _this;
  38772. }
  38773. NetInfo.prototype.isOnline = function () {
  38774. if (window.navigator.onLine === undefined) {
  38775. return true;
  38776. }
  38777. else {
  38778. return window.navigator.onLine;
  38779. }
  38780. };
  38781. return NetInfo;
  38782. }(dispatcher));
  38783. var net_info_Network = new NetInfo();
  38784. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38785. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38786. function AssistantToTheTransportManager(manager, transport, options) {
  38787. this.manager = manager;
  38788. this.transport = transport;
  38789. this.minPingDelay = options.minPingDelay;
  38790. this.maxPingDelay = options.maxPingDelay;
  38791. this.pingDelay = undefined;
  38792. }
  38793. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38794. var _this = this;
  38795. options = extend({}, options, {
  38796. activityTimeout: this.pingDelay
  38797. });
  38798. var connection = this.transport.createConnection(name, priority, key, options);
  38799. var openTimestamp = null;
  38800. var onOpen = function () {
  38801. connection.unbind("open", onOpen);
  38802. connection.bind("closed", onClosed);
  38803. openTimestamp = util.now();
  38804. };
  38805. var onClosed = function (closeEvent) {
  38806. connection.unbind("closed", onClosed);
  38807. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38808. _this.manager.reportDeath();
  38809. }
  38810. else if (!closeEvent.wasClean && openTimestamp) {
  38811. var lifespan = util.now() - openTimestamp;
  38812. if (lifespan < 2 * _this.maxPingDelay) {
  38813. _this.manager.reportDeath();
  38814. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38815. }
  38816. }
  38817. };
  38818. connection.bind("open", onOpen);
  38819. return connection;
  38820. };
  38821. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38822. return this.manager.isAlive() && this.transport.isSupported(environment);
  38823. };
  38824. return AssistantToTheTransportManager;
  38825. }());
  38826. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38827. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38828. var Protocol = {
  38829. decodeMessage: function (messageEvent) {
  38830. try {
  38831. var messageData = JSON.parse(messageEvent.data);
  38832. var pusherEventData = messageData.data;
  38833. if (typeof pusherEventData === 'string') {
  38834. try {
  38835. pusherEventData = JSON.parse(messageData.data);
  38836. }
  38837. catch (e) { }
  38838. }
  38839. var pusherEvent = {
  38840. event: messageData.event,
  38841. channel: messageData.channel,
  38842. data: pusherEventData,
  38843. };
  38844. if (messageData.user_id) {
  38845. pusherEvent.user_id = messageData.user_id;
  38846. }
  38847. return pusherEvent;
  38848. }
  38849. catch (e) {
  38850. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38851. }
  38852. },
  38853. encodeMessage: function (event) {
  38854. return JSON.stringify(event);
  38855. },
  38856. processHandshake: function (messageEvent) {
  38857. var message = Protocol.decodeMessage(messageEvent);
  38858. if (message.event === "pusher:connection_established") {
  38859. if (!message.data.activity_timeout) {
  38860. throw "No activity timeout specified in handshake";
  38861. }
  38862. return {
  38863. action: "connected",
  38864. id: message.data.socket_id,
  38865. activityTimeout: message.data.activity_timeout * 1000
  38866. };
  38867. }
  38868. else if (message.event === "pusher:error") {
  38869. return {
  38870. action: this.getCloseAction(message.data),
  38871. error: this.getCloseError(message.data)
  38872. };
  38873. }
  38874. else {
  38875. throw "Invalid handshake";
  38876. }
  38877. },
  38878. getCloseAction: function (closeEvent) {
  38879. if (closeEvent.code < 4000) {
  38880. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38881. return "backoff";
  38882. }
  38883. else {
  38884. return null;
  38885. }
  38886. }
  38887. else if (closeEvent.code === 4000) {
  38888. return "tls_only";
  38889. }
  38890. else if (closeEvent.code < 4100) {
  38891. return "refused";
  38892. }
  38893. else if (closeEvent.code < 4200) {
  38894. return "backoff";
  38895. }
  38896. else if (closeEvent.code < 4300) {
  38897. return "retry";
  38898. }
  38899. else {
  38900. return "refused";
  38901. }
  38902. },
  38903. getCloseError: function (closeEvent) {
  38904. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38905. return {
  38906. type: 'PusherError',
  38907. data: {
  38908. code: closeEvent.code,
  38909. message: closeEvent.reason || closeEvent.message
  38910. }
  38911. };
  38912. }
  38913. else {
  38914. return null;
  38915. }
  38916. }
  38917. };
  38918. /* harmony default export */ var protocol_protocol = (Protocol);
  38919. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38920. var connection_extends = (undefined && undefined.__extends) || (function () {
  38921. var extendStatics = function (d, b) {
  38922. extendStatics = Object.setPrototypeOf ||
  38923. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38924. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38925. return extendStatics(d, b);
  38926. };
  38927. return function (d, b) {
  38928. extendStatics(d, b);
  38929. function __() { this.constructor = d; }
  38930. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38931. };
  38932. })();
  38933. var connection_Connection = (function (_super) {
  38934. connection_extends(Connection, _super);
  38935. function Connection(id, transport) {
  38936. var _this = _super.call(this) || this;
  38937. _this.id = id;
  38938. _this.transport = transport;
  38939. _this.activityTimeout = transport.activityTimeout;
  38940. _this.bindListeners();
  38941. return _this;
  38942. }
  38943. Connection.prototype.handlesActivityChecks = function () {
  38944. return this.transport.handlesActivityChecks();
  38945. };
  38946. Connection.prototype.send = function (data) {
  38947. return this.transport.send(data);
  38948. };
  38949. Connection.prototype.send_event = function (name, data, channel) {
  38950. var event = { event: name, data: data };
  38951. if (channel) {
  38952. event.channel = channel;
  38953. }
  38954. logger.debug('Event sent', event);
  38955. return this.send(protocol_protocol.encodeMessage(event));
  38956. };
  38957. Connection.prototype.ping = function () {
  38958. if (this.transport.supportsPing()) {
  38959. this.transport.ping();
  38960. }
  38961. else {
  38962. this.send_event('pusher:ping', {});
  38963. }
  38964. };
  38965. Connection.prototype.close = function () {
  38966. this.transport.close();
  38967. };
  38968. Connection.prototype.bindListeners = function () {
  38969. var _this = this;
  38970. var listeners = {
  38971. message: function (messageEvent) {
  38972. var pusherEvent;
  38973. try {
  38974. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38975. }
  38976. catch (e) {
  38977. _this.emit('error', {
  38978. type: 'MessageParseError',
  38979. error: e,
  38980. data: messageEvent.data
  38981. });
  38982. }
  38983. if (pusherEvent !== undefined) {
  38984. logger.debug('Event recd', pusherEvent);
  38985. switch (pusherEvent.event) {
  38986. case 'pusher:error':
  38987. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38988. break;
  38989. case 'pusher:ping':
  38990. _this.emit("ping");
  38991. break;
  38992. case 'pusher:pong':
  38993. _this.emit("pong");
  38994. break;
  38995. }
  38996. _this.emit('message', pusherEvent);
  38997. }
  38998. },
  38999. activity: function () {
  39000. _this.emit("activity");
  39001. },
  39002. error: function (error) {
  39003. _this.emit("error", { type: "WebSocketError", error: error });
  39004. },
  39005. closed: function (closeEvent) {
  39006. unbindListeners();
  39007. if (closeEvent && closeEvent.code) {
  39008. _this.handleCloseEvent(closeEvent);
  39009. }
  39010. _this.transport = null;
  39011. _this.emit("closed");
  39012. }
  39013. };
  39014. var unbindListeners = function () {
  39015. objectApply(listeners, function (listener, event) {
  39016. _this.transport.unbind(event, listener);
  39017. });
  39018. };
  39019. objectApply(listeners, function (listener, event) {
  39020. _this.transport.bind(event, listener);
  39021. });
  39022. };
  39023. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39024. var action = protocol_protocol.getCloseAction(closeEvent);
  39025. var error = protocol_protocol.getCloseError(closeEvent);
  39026. if (error) {
  39027. this.emit('error', error);
  39028. }
  39029. if (action) {
  39030. this.emit(action, { action: action, error: error });
  39031. }
  39032. };
  39033. return Connection;
  39034. }(dispatcher));
  39035. /* harmony default export */ var connection_connection = (connection_Connection);
  39036. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39037. var handshake_Handshake = (function () {
  39038. function Handshake(transport, callback) {
  39039. this.transport = transport;
  39040. this.callback = callback;
  39041. this.bindListeners();
  39042. }
  39043. Handshake.prototype.close = function () {
  39044. this.unbindListeners();
  39045. this.transport.close();
  39046. };
  39047. Handshake.prototype.bindListeners = function () {
  39048. var _this = this;
  39049. this.onMessage = function (m) {
  39050. _this.unbindListeners();
  39051. var result;
  39052. try {
  39053. result = protocol_protocol.processHandshake(m);
  39054. }
  39055. catch (e) {
  39056. _this.finish("error", { error: e });
  39057. _this.transport.close();
  39058. return;
  39059. }
  39060. if (result.action === "connected") {
  39061. _this.finish("connected", {
  39062. connection: new connection_connection(result.id, _this.transport),
  39063. activityTimeout: result.activityTimeout
  39064. });
  39065. }
  39066. else {
  39067. _this.finish(result.action, { error: result.error });
  39068. _this.transport.close();
  39069. }
  39070. };
  39071. this.onClosed = function (closeEvent) {
  39072. _this.unbindListeners();
  39073. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39074. var error = protocol_protocol.getCloseError(closeEvent);
  39075. _this.finish(action, { error: error });
  39076. };
  39077. this.transport.bind("message", this.onMessage);
  39078. this.transport.bind("closed", this.onClosed);
  39079. };
  39080. Handshake.prototype.unbindListeners = function () {
  39081. this.transport.unbind("message", this.onMessage);
  39082. this.transport.unbind("closed", this.onClosed);
  39083. };
  39084. Handshake.prototype.finish = function (action, params) {
  39085. this.callback(extend({ transport: this.transport, action: action }, params));
  39086. };
  39087. return Handshake;
  39088. }());
  39089. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39090. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39091. var pusher_authorizer_PusherAuthorizer = (function () {
  39092. function PusherAuthorizer(channel, options) {
  39093. this.channel = channel;
  39094. var authTransport = options.authTransport;
  39095. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39096. throw "'" + authTransport + "' is not a recognized auth transport";
  39097. }
  39098. this.type = authTransport;
  39099. this.options = options;
  39100. this.authOptions = (options || {}).auth || {};
  39101. }
  39102. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39103. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39104. '&channel_name=' + encodeURIComponent(this.channel.name);
  39105. for (var i in this.authOptions.params) {
  39106. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39107. }
  39108. return query;
  39109. };
  39110. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39111. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39112. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39113. };
  39114. return PusherAuthorizer;
  39115. }());
  39116. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39117. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39118. var timeline_sender_TimelineSender = (function () {
  39119. function TimelineSender(timeline, options) {
  39120. this.timeline = timeline;
  39121. this.options = options || {};
  39122. }
  39123. TimelineSender.prototype.send = function (useTLS, callback) {
  39124. if (this.timeline.isEmpty()) {
  39125. return;
  39126. }
  39127. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39128. };
  39129. return TimelineSender;
  39130. }());
  39131. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39132. // CONCATENATED MODULE: ./src/core/errors.ts
  39133. var errors_extends = (undefined && undefined.__extends) || (function () {
  39134. var extendStatics = function (d, b) {
  39135. extendStatics = Object.setPrototypeOf ||
  39136. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39137. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39138. return extendStatics(d, b);
  39139. };
  39140. return function (d, b) {
  39141. extendStatics(d, b);
  39142. function __() { this.constructor = d; }
  39143. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39144. };
  39145. })();
  39146. var BadEventName = (function (_super) {
  39147. errors_extends(BadEventName, _super);
  39148. function BadEventName(msg) {
  39149. var _newTarget = this.constructor;
  39150. var _this = _super.call(this, msg) || this;
  39151. Object.setPrototypeOf(_this, _newTarget.prototype);
  39152. return _this;
  39153. }
  39154. return BadEventName;
  39155. }(Error));
  39156. var RequestTimedOut = (function (_super) {
  39157. errors_extends(RequestTimedOut, _super);
  39158. function RequestTimedOut(msg) {
  39159. var _newTarget = this.constructor;
  39160. var _this = _super.call(this, msg) || this;
  39161. Object.setPrototypeOf(_this, _newTarget.prototype);
  39162. return _this;
  39163. }
  39164. return RequestTimedOut;
  39165. }(Error));
  39166. var TransportPriorityTooLow = (function (_super) {
  39167. errors_extends(TransportPriorityTooLow, _super);
  39168. function TransportPriorityTooLow(msg) {
  39169. var _newTarget = this.constructor;
  39170. var _this = _super.call(this, msg) || this;
  39171. Object.setPrototypeOf(_this, _newTarget.prototype);
  39172. return _this;
  39173. }
  39174. return TransportPriorityTooLow;
  39175. }(Error));
  39176. var TransportClosed = (function (_super) {
  39177. errors_extends(TransportClosed, _super);
  39178. function TransportClosed(msg) {
  39179. var _newTarget = this.constructor;
  39180. var _this = _super.call(this, msg) || this;
  39181. Object.setPrototypeOf(_this, _newTarget.prototype);
  39182. return _this;
  39183. }
  39184. return TransportClosed;
  39185. }(Error));
  39186. var UnsupportedFeature = (function (_super) {
  39187. errors_extends(UnsupportedFeature, _super);
  39188. function UnsupportedFeature(msg) {
  39189. var _newTarget = this.constructor;
  39190. var _this = _super.call(this, msg) || this;
  39191. Object.setPrototypeOf(_this, _newTarget.prototype);
  39192. return _this;
  39193. }
  39194. return UnsupportedFeature;
  39195. }(Error));
  39196. var UnsupportedTransport = (function (_super) {
  39197. errors_extends(UnsupportedTransport, _super);
  39198. function UnsupportedTransport(msg) {
  39199. var _newTarget = this.constructor;
  39200. var _this = _super.call(this, msg) || this;
  39201. Object.setPrototypeOf(_this, _newTarget.prototype);
  39202. return _this;
  39203. }
  39204. return UnsupportedTransport;
  39205. }(Error));
  39206. var UnsupportedStrategy = (function (_super) {
  39207. errors_extends(UnsupportedStrategy, _super);
  39208. function UnsupportedStrategy(msg) {
  39209. var _newTarget = this.constructor;
  39210. var _this = _super.call(this, msg) || this;
  39211. Object.setPrototypeOf(_this, _newTarget.prototype);
  39212. return _this;
  39213. }
  39214. return UnsupportedStrategy;
  39215. }(Error));
  39216. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39217. var channel_extends = (undefined && undefined.__extends) || (function () {
  39218. var extendStatics = function (d, b) {
  39219. extendStatics = Object.setPrototypeOf ||
  39220. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39221. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39222. return extendStatics(d, b);
  39223. };
  39224. return function (d, b) {
  39225. extendStatics(d, b);
  39226. function __() { this.constructor = d; }
  39227. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39228. };
  39229. })();
  39230. var channel_Channel = (function (_super) {
  39231. channel_extends(Channel, _super);
  39232. function Channel(name, pusher) {
  39233. var _this = _super.call(this, function (event, data) {
  39234. logger.debug('No callbacks on ' + name + ' for ' + event);
  39235. }) || this;
  39236. _this.name = name;
  39237. _this.pusher = pusher;
  39238. _this.subscribed = false;
  39239. _this.subscriptionPending = false;
  39240. _this.subscriptionCancelled = false;
  39241. return _this;
  39242. }
  39243. Channel.prototype.authorize = function (socketId, callback) {
  39244. return callback(false, {});
  39245. };
  39246. Channel.prototype.trigger = function (event, data) {
  39247. if (event.indexOf("client-") !== 0) {
  39248. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39249. }
  39250. if (!this.subscribed) {
  39251. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39252. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39253. }
  39254. return this.pusher.send_event(event, data, this.name);
  39255. };
  39256. Channel.prototype.disconnect = function () {
  39257. this.subscribed = false;
  39258. this.subscriptionPending = false;
  39259. };
  39260. Channel.prototype.handleEvent = function (event) {
  39261. var eventName = event.event;
  39262. var data = event.data;
  39263. if (eventName === "pusher_internal:subscription_succeeded") {
  39264. this.handleSubscriptionSucceededEvent(event);
  39265. }
  39266. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39267. var metadata = {};
  39268. this.emit(eventName, data, metadata);
  39269. }
  39270. };
  39271. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39272. this.subscriptionPending = false;
  39273. this.subscribed = true;
  39274. if (this.subscriptionCancelled) {
  39275. this.pusher.unsubscribe(this.name);
  39276. }
  39277. else {
  39278. this.emit("pusher:subscription_succeeded", event.data);
  39279. }
  39280. };
  39281. Channel.prototype.subscribe = function () {
  39282. var _this = this;
  39283. if (this.subscribed) {
  39284. return;
  39285. }
  39286. this.subscriptionPending = true;
  39287. this.subscriptionCancelled = false;
  39288. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39289. if (error) {
  39290. logger.error(data);
  39291. _this.emit('pusher:subscription_error', data);
  39292. }
  39293. else {
  39294. _this.pusher.send_event('pusher:subscribe', {
  39295. auth: data.auth,
  39296. channel_data: data.channel_data,
  39297. channel: _this.name
  39298. });
  39299. }
  39300. });
  39301. };
  39302. Channel.prototype.unsubscribe = function () {
  39303. this.subscribed = false;
  39304. this.pusher.send_event('pusher:unsubscribe', {
  39305. channel: this.name
  39306. });
  39307. };
  39308. Channel.prototype.cancelSubscription = function () {
  39309. this.subscriptionCancelled = true;
  39310. };
  39311. Channel.prototype.reinstateSubscription = function () {
  39312. this.subscriptionCancelled = false;
  39313. };
  39314. return Channel;
  39315. }(dispatcher));
  39316. /* harmony default export */ var channels_channel = (channel_Channel);
  39317. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39318. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39319. var extendStatics = function (d, b) {
  39320. extendStatics = Object.setPrototypeOf ||
  39321. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39322. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39323. return extendStatics(d, b);
  39324. };
  39325. return function (d, b) {
  39326. extendStatics(d, b);
  39327. function __() { this.constructor = d; }
  39328. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39329. };
  39330. })();
  39331. var private_channel_PrivateChannel = (function (_super) {
  39332. private_channel_extends(PrivateChannel, _super);
  39333. function PrivateChannel() {
  39334. return _super !== null && _super.apply(this, arguments) || this;
  39335. }
  39336. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39337. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39338. return authorizer.authorize(socketId, callback);
  39339. };
  39340. return PrivateChannel;
  39341. }(channels_channel));
  39342. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39343. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39344. var members_Members = (function () {
  39345. function Members() {
  39346. this.reset();
  39347. }
  39348. Members.prototype.get = function (id) {
  39349. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39350. return {
  39351. id: id,
  39352. info: this.members[id]
  39353. };
  39354. }
  39355. else {
  39356. return null;
  39357. }
  39358. };
  39359. Members.prototype.each = function (callback) {
  39360. var _this = this;
  39361. objectApply(this.members, function (member, id) {
  39362. callback(_this.get(id));
  39363. });
  39364. };
  39365. Members.prototype.setMyID = function (id) {
  39366. this.myID = id;
  39367. };
  39368. Members.prototype.onSubscription = function (subscriptionData) {
  39369. this.members = subscriptionData.presence.hash;
  39370. this.count = subscriptionData.presence.count;
  39371. this.me = this.get(this.myID);
  39372. };
  39373. Members.prototype.addMember = function (memberData) {
  39374. if (this.get(memberData.user_id) === null) {
  39375. this.count++;
  39376. }
  39377. this.members[memberData.user_id] = memberData.user_info;
  39378. return this.get(memberData.user_id);
  39379. };
  39380. Members.prototype.removeMember = function (memberData) {
  39381. var member = this.get(memberData.user_id);
  39382. if (member) {
  39383. delete this.members[memberData.user_id];
  39384. this.count--;
  39385. }
  39386. return member;
  39387. };
  39388. Members.prototype.reset = function () {
  39389. this.members = {};
  39390. this.count = 0;
  39391. this.myID = null;
  39392. this.me = null;
  39393. };
  39394. return Members;
  39395. }());
  39396. /* harmony default export */ var members = (members_Members);
  39397. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39398. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39399. var extendStatics = function (d, b) {
  39400. extendStatics = Object.setPrototypeOf ||
  39401. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39402. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39403. return extendStatics(d, b);
  39404. };
  39405. return function (d, b) {
  39406. extendStatics(d, b);
  39407. function __() { this.constructor = d; }
  39408. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39409. };
  39410. })();
  39411. var presence_channel_PresenceChannel = (function (_super) {
  39412. presence_channel_extends(PresenceChannel, _super);
  39413. function PresenceChannel(name, pusher) {
  39414. var _this = _super.call(this, name, pusher) || this;
  39415. _this.members = new members();
  39416. return _this;
  39417. }
  39418. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39419. var _this = this;
  39420. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39421. if (!error) {
  39422. if (authData.channel_data === undefined) {
  39423. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39424. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39425. ("expected 'channel_data' field. " + suffix));
  39426. callback("Invalid auth response");
  39427. return;
  39428. }
  39429. var channelData = JSON.parse(authData.channel_data);
  39430. _this.members.setMyID(channelData.user_id);
  39431. }
  39432. callback(error, authData);
  39433. });
  39434. };
  39435. PresenceChannel.prototype.handleEvent = function (event) {
  39436. var eventName = event.event;
  39437. if (eventName.indexOf("pusher_internal:") === 0) {
  39438. this.handleInternalEvent(event);
  39439. }
  39440. else {
  39441. var data = event.data;
  39442. var metadata = {};
  39443. if (event.user_id) {
  39444. metadata.user_id = event.user_id;
  39445. }
  39446. this.emit(eventName, data, metadata);
  39447. }
  39448. };
  39449. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39450. var eventName = event.event;
  39451. var data = event.data;
  39452. switch (eventName) {
  39453. case "pusher_internal:subscription_succeeded":
  39454. this.handleSubscriptionSucceededEvent(event);
  39455. break;
  39456. case "pusher_internal:member_added":
  39457. var addedMember = this.members.addMember(data);
  39458. this.emit('pusher:member_added', addedMember);
  39459. break;
  39460. case "pusher_internal:member_removed":
  39461. var removedMember = this.members.removeMember(data);
  39462. if (removedMember) {
  39463. this.emit('pusher:member_removed', removedMember);
  39464. }
  39465. break;
  39466. }
  39467. };
  39468. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39469. this.subscriptionPending = false;
  39470. this.subscribed = true;
  39471. if (this.subscriptionCancelled) {
  39472. this.pusher.unsubscribe(this.name);
  39473. }
  39474. else {
  39475. this.members.onSubscription(event.data);
  39476. this.emit("pusher:subscription_succeeded", this.members);
  39477. }
  39478. };
  39479. PresenceChannel.prototype.disconnect = function () {
  39480. this.members.reset();
  39481. _super.prototype.disconnect.call(this);
  39482. };
  39483. return PresenceChannel;
  39484. }(private_channel));
  39485. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39486. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39487. var nacl_fast = __webpack_require__(0);
  39488. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39489. var nacl_util = __webpack_require__(1);
  39490. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39491. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39492. var extendStatics = function (d, b) {
  39493. extendStatics = Object.setPrototypeOf ||
  39494. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39495. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39496. return extendStatics(d, b);
  39497. };
  39498. return function (d, b) {
  39499. extendStatics(d, b);
  39500. function __() { this.constructor = d; }
  39501. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39502. };
  39503. })();
  39504. var encrypted_channel_EncryptedChannel = (function (_super) {
  39505. encrypted_channel_extends(EncryptedChannel, _super);
  39506. function EncryptedChannel() {
  39507. var _this = _super !== null && _super.apply(this, arguments) || this;
  39508. _this.key = null;
  39509. return _this;
  39510. }
  39511. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39512. var _this = this;
  39513. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39514. if (error) {
  39515. callback(true, authData);
  39516. return;
  39517. }
  39518. var sharedSecret = authData["shared_secret"];
  39519. if (!sharedSecret) {
  39520. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39521. callback(true, errorMsg);
  39522. return;
  39523. }
  39524. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39525. delete authData["shared_secret"];
  39526. callback(false, authData);
  39527. });
  39528. };
  39529. EncryptedChannel.prototype.trigger = function (event, data) {
  39530. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39531. };
  39532. EncryptedChannel.prototype.handleEvent = function (event) {
  39533. var eventName = event.event;
  39534. var data = event.data;
  39535. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39536. _super.prototype.handleEvent.call(this, event);
  39537. return;
  39538. }
  39539. this.handleEncryptedEvent(eventName, data);
  39540. };
  39541. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39542. var _this = this;
  39543. if (!this.key) {
  39544. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39545. return;
  39546. }
  39547. if (!data.ciphertext || !data.nonce) {
  39548. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39549. return;
  39550. }
  39551. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39552. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39553. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39554. return;
  39555. }
  39556. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39557. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39558. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39559. return;
  39560. }
  39561. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39562. if (bytes === null) {
  39563. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39564. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39565. if (error) {
  39566. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39567. return;
  39568. }
  39569. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39570. if (bytes === null) {
  39571. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39572. return;
  39573. }
  39574. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39575. return;
  39576. });
  39577. return;
  39578. }
  39579. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39580. };
  39581. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39582. try {
  39583. this.emit(eventName, JSON.parse(data));
  39584. }
  39585. catch (e) {
  39586. this.emit(eventName, data);
  39587. }
  39588. return this;
  39589. };
  39590. return EncryptedChannel;
  39591. }(private_channel));
  39592. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39593. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39594. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39595. var extendStatics = function (d, b) {
  39596. extendStatics = Object.setPrototypeOf ||
  39597. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39598. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39599. return extendStatics(d, b);
  39600. };
  39601. return function (d, b) {
  39602. extendStatics(d, b);
  39603. function __() { this.constructor = d; }
  39604. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39605. };
  39606. })();
  39607. var connection_manager_ConnectionManager = (function (_super) {
  39608. connection_manager_extends(ConnectionManager, _super);
  39609. function ConnectionManager(key, options) {
  39610. var _this = _super.call(this) || this;
  39611. _this.key = key;
  39612. _this.options = options || {};
  39613. _this.state = "initialized";
  39614. _this.connection = null;
  39615. _this.usingTLS = !!options.useTLS;
  39616. _this.timeline = _this.options.timeline;
  39617. _this.errorCallbacks = _this.buildErrorCallbacks();
  39618. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39619. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39620. var Network = runtime.getNetwork();
  39621. Network.bind("online", function () {
  39622. _this.timeline.info({ netinfo: "online" });
  39623. if (_this.state === "connecting" || _this.state === "unavailable") {
  39624. _this.retryIn(0);
  39625. }
  39626. });
  39627. Network.bind("offline", function () {
  39628. _this.timeline.info({ netinfo: "offline" });
  39629. if (_this.connection) {
  39630. _this.sendActivityCheck();
  39631. }
  39632. });
  39633. _this.updateStrategy();
  39634. return _this;
  39635. }
  39636. ConnectionManager.prototype.connect = function () {
  39637. if (this.connection || this.runner) {
  39638. return;
  39639. }
  39640. if (!this.strategy.isSupported()) {
  39641. this.updateState("failed");
  39642. return;
  39643. }
  39644. this.updateState("connecting");
  39645. this.startConnecting();
  39646. this.setUnavailableTimer();
  39647. };
  39648. ;
  39649. ConnectionManager.prototype.send = function (data) {
  39650. if (this.connection) {
  39651. return this.connection.send(data);
  39652. }
  39653. else {
  39654. return false;
  39655. }
  39656. };
  39657. ;
  39658. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39659. if (this.connection) {
  39660. return this.connection.send_event(name, data, channel);
  39661. }
  39662. else {
  39663. return false;
  39664. }
  39665. };
  39666. ;
  39667. ConnectionManager.prototype.disconnect = function () {
  39668. this.disconnectInternally();
  39669. this.updateState("disconnected");
  39670. };
  39671. ;
  39672. ConnectionManager.prototype.isUsingTLS = function () {
  39673. return this.usingTLS;
  39674. };
  39675. ;
  39676. ConnectionManager.prototype.startConnecting = function () {
  39677. var _this = this;
  39678. var callback = function (error, handshake) {
  39679. if (error) {
  39680. _this.runner = _this.strategy.connect(0, callback);
  39681. }
  39682. else {
  39683. if (handshake.action === "error") {
  39684. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39685. _this.timeline.error({ handshakeError: handshake.error });
  39686. }
  39687. else {
  39688. _this.abortConnecting();
  39689. _this.handshakeCallbacks[handshake.action](handshake);
  39690. }
  39691. }
  39692. };
  39693. this.runner = this.strategy.connect(0, callback);
  39694. };
  39695. ;
  39696. ConnectionManager.prototype.abortConnecting = function () {
  39697. if (this.runner) {
  39698. this.runner.abort();
  39699. this.runner = null;
  39700. }
  39701. };
  39702. ;
  39703. ConnectionManager.prototype.disconnectInternally = function () {
  39704. this.abortConnecting();
  39705. this.clearRetryTimer();
  39706. this.clearUnavailableTimer();
  39707. if (this.connection) {
  39708. var connection = this.abandonConnection();
  39709. connection.close();
  39710. }
  39711. };
  39712. ;
  39713. ConnectionManager.prototype.updateStrategy = function () {
  39714. this.strategy = this.options.getStrategy({
  39715. key: this.key,
  39716. timeline: this.timeline,
  39717. useTLS: this.usingTLS
  39718. });
  39719. };
  39720. ;
  39721. ConnectionManager.prototype.retryIn = function (delay) {
  39722. var _this = this;
  39723. this.timeline.info({ action: "retry", delay: delay });
  39724. if (delay > 0) {
  39725. this.emit("connecting_in", Math.round(delay / 1000));
  39726. }
  39727. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39728. _this.disconnectInternally();
  39729. _this.connect();
  39730. });
  39731. };
  39732. ;
  39733. ConnectionManager.prototype.clearRetryTimer = function () {
  39734. if (this.retryTimer) {
  39735. this.retryTimer.ensureAborted();
  39736. this.retryTimer = null;
  39737. }
  39738. };
  39739. ;
  39740. ConnectionManager.prototype.setUnavailableTimer = function () {
  39741. var _this = this;
  39742. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39743. _this.updateState("unavailable");
  39744. });
  39745. };
  39746. ;
  39747. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39748. if (this.unavailableTimer) {
  39749. this.unavailableTimer.ensureAborted();
  39750. }
  39751. };
  39752. ;
  39753. ConnectionManager.prototype.sendActivityCheck = function () {
  39754. var _this = this;
  39755. this.stopActivityCheck();
  39756. this.connection.ping();
  39757. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39758. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39759. _this.retryIn(0);
  39760. });
  39761. };
  39762. ;
  39763. ConnectionManager.prototype.resetActivityCheck = function () {
  39764. var _this = this;
  39765. this.stopActivityCheck();
  39766. if (this.connection && !this.connection.handlesActivityChecks()) {
  39767. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39768. _this.sendActivityCheck();
  39769. });
  39770. }
  39771. };
  39772. ;
  39773. ConnectionManager.prototype.stopActivityCheck = function () {
  39774. if (this.activityTimer) {
  39775. this.activityTimer.ensureAborted();
  39776. }
  39777. };
  39778. ;
  39779. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39780. var _this = this;
  39781. return extend({}, errorCallbacks, {
  39782. message: function (message) {
  39783. _this.resetActivityCheck();
  39784. _this.emit('message', message);
  39785. },
  39786. ping: function () {
  39787. _this.send_event('pusher:pong', {});
  39788. },
  39789. activity: function () {
  39790. _this.resetActivityCheck();
  39791. },
  39792. error: function (error) {
  39793. _this.emit("error", { type: "WebSocketError", error: error });
  39794. },
  39795. closed: function () {
  39796. _this.abandonConnection();
  39797. if (_this.shouldRetry()) {
  39798. _this.retryIn(1000);
  39799. }
  39800. }
  39801. });
  39802. };
  39803. ;
  39804. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39805. var _this = this;
  39806. return extend({}, errorCallbacks, {
  39807. connected: function (handshake) {
  39808. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39809. _this.clearUnavailableTimer();
  39810. _this.setConnection(handshake.connection);
  39811. _this.socket_id = _this.connection.id;
  39812. _this.updateState("connected", { socket_id: _this.socket_id });
  39813. }
  39814. });
  39815. };
  39816. ;
  39817. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39818. var _this = this;
  39819. var withErrorEmitted = function (callback) {
  39820. return function (result) {
  39821. if (result.error) {
  39822. _this.emit("error", { type: "WebSocketError", error: result.error });
  39823. }
  39824. callback(result);
  39825. };
  39826. };
  39827. return {
  39828. tls_only: withErrorEmitted(function () {
  39829. _this.usingTLS = true;
  39830. _this.updateStrategy();
  39831. _this.retryIn(0);
  39832. }),
  39833. refused: withErrorEmitted(function () {
  39834. _this.disconnect();
  39835. }),
  39836. backoff: withErrorEmitted(function () {
  39837. _this.retryIn(1000);
  39838. }),
  39839. retry: withErrorEmitted(function () {
  39840. _this.retryIn(0);
  39841. })
  39842. };
  39843. };
  39844. ;
  39845. ConnectionManager.prototype.setConnection = function (connection) {
  39846. this.connection = connection;
  39847. for (var event in this.connectionCallbacks) {
  39848. this.connection.bind(event, this.connectionCallbacks[event]);
  39849. }
  39850. this.resetActivityCheck();
  39851. };
  39852. ;
  39853. ConnectionManager.prototype.abandonConnection = function () {
  39854. if (!this.connection) {
  39855. return;
  39856. }
  39857. this.stopActivityCheck();
  39858. for (var event in this.connectionCallbacks) {
  39859. this.connection.unbind(event, this.connectionCallbacks[event]);
  39860. }
  39861. var connection = this.connection;
  39862. this.connection = null;
  39863. return connection;
  39864. };
  39865. ConnectionManager.prototype.updateState = function (newState, data) {
  39866. var previousState = this.state;
  39867. this.state = newState;
  39868. if (previousState !== newState) {
  39869. var newStateDescription = newState;
  39870. if (newStateDescription === "connected") {
  39871. newStateDescription += " with new socket ID " + data.socket_id;
  39872. }
  39873. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39874. this.timeline.info({ state: newState, params: data });
  39875. this.emit('state_change', { previous: previousState, current: newState });
  39876. this.emit(newState, data);
  39877. }
  39878. };
  39879. ConnectionManager.prototype.shouldRetry = function () {
  39880. return this.state === "connecting" || this.state === "connected";
  39881. };
  39882. return ConnectionManager;
  39883. }(dispatcher));
  39884. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39885. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39886. var channels_Channels = (function () {
  39887. function Channels() {
  39888. this.channels = {};
  39889. }
  39890. Channels.prototype.add = function (name, pusher) {
  39891. if (!this.channels[name]) {
  39892. this.channels[name] = createChannel(name, pusher);
  39893. }
  39894. return this.channels[name];
  39895. };
  39896. Channels.prototype.all = function () {
  39897. return values(this.channels);
  39898. };
  39899. Channels.prototype.find = function (name) {
  39900. return this.channels[name];
  39901. };
  39902. Channels.prototype.remove = function (name) {
  39903. var channel = this.channels[name];
  39904. delete this.channels[name];
  39905. return channel;
  39906. };
  39907. Channels.prototype.disconnect = function () {
  39908. objectApply(this.channels, function (channel) {
  39909. channel.disconnect();
  39910. });
  39911. };
  39912. return Channels;
  39913. }());
  39914. /* harmony default export */ var channels = (channels_Channels);
  39915. function createChannel(name, pusher) {
  39916. if (name.indexOf('private-encrypted-') === 0) {
  39917. if (false) { var errorMsg; }
  39918. return factory.createEncryptedChannel(name, pusher);
  39919. }
  39920. else if (name.indexOf('private-') === 0) {
  39921. return factory.createPrivateChannel(name, pusher);
  39922. }
  39923. else if (name.indexOf('presence-') === 0) {
  39924. return factory.createPresenceChannel(name, pusher);
  39925. }
  39926. else {
  39927. return factory.createChannel(name, pusher);
  39928. }
  39929. }
  39930. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39931. var Factory = {
  39932. createChannels: function () {
  39933. return new channels();
  39934. },
  39935. createConnectionManager: function (key, options) {
  39936. return new connection_manager(key, options);
  39937. },
  39938. createChannel: function (name, pusher) {
  39939. return new channels_channel(name, pusher);
  39940. },
  39941. createPrivateChannel: function (name, pusher) {
  39942. return new private_channel(name, pusher);
  39943. },
  39944. createPresenceChannel: function (name, pusher) {
  39945. return new presence_channel(name, pusher);
  39946. },
  39947. createEncryptedChannel: function (name, pusher) {
  39948. return new encrypted_channel(name, pusher);
  39949. },
  39950. createTimelineSender: function (timeline, options) {
  39951. return new timeline_sender(timeline, options);
  39952. },
  39953. createAuthorizer: function (channel, options) {
  39954. if (options.authorizer) {
  39955. return options.authorizer(channel, options);
  39956. }
  39957. return new pusher_authorizer(channel, options);
  39958. },
  39959. createHandshake: function (transport, callback) {
  39960. return new connection_handshake(transport, callback);
  39961. },
  39962. createAssistantToTheTransportManager: function (manager, transport, options) {
  39963. return new assistant_to_the_transport_manager(manager, transport, options);
  39964. }
  39965. };
  39966. /* harmony default export */ var factory = (Factory);
  39967. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39968. var transport_manager_TransportManager = (function () {
  39969. function TransportManager(options) {
  39970. this.options = options || {};
  39971. this.livesLeft = this.options.lives || Infinity;
  39972. }
  39973. TransportManager.prototype.getAssistant = function (transport) {
  39974. return factory.createAssistantToTheTransportManager(this, transport, {
  39975. minPingDelay: this.options.minPingDelay,
  39976. maxPingDelay: this.options.maxPingDelay
  39977. });
  39978. };
  39979. TransportManager.prototype.isAlive = function () {
  39980. return this.livesLeft > 0;
  39981. };
  39982. TransportManager.prototype.reportDeath = function () {
  39983. this.livesLeft -= 1;
  39984. };
  39985. return TransportManager;
  39986. }());
  39987. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39988. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39989. var sequential_strategy_SequentialStrategy = (function () {
  39990. function SequentialStrategy(strategies, options) {
  39991. this.strategies = strategies;
  39992. this.loop = Boolean(options.loop);
  39993. this.failFast = Boolean(options.failFast);
  39994. this.timeout = options.timeout;
  39995. this.timeoutLimit = options.timeoutLimit;
  39996. }
  39997. SequentialStrategy.prototype.isSupported = function () {
  39998. return any(this.strategies, util.method("isSupported"));
  39999. };
  40000. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40001. var _this = this;
  40002. var strategies = this.strategies;
  40003. var current = 0;
  40004. var timeout = this.timeout;
  40005. var runner = null;
  40006. var tryNextStrategy = function (error, handshake) {
  40007. if (handshake) {
  40008. callback(null, handshake);
  40009. }
  40010. else {
  40011. current = current + 1;
  40012. if (_this.loop) {
  40013. current = current % strategies.length;
  40014. }
  40015. if (current < strategies.length) {
  40016. if (timeout) {
  40017. timeout = timeout * 2;
  40018. if (_this.timeoutLimit) {
  40019. timeout = Math.min(timeout, _this.timeoutLimit);
  40020. }
  40021. }
  40022. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40023. }
  40024. else {
  40025. callback(true);
  40026. }
  40027. }
  40028. };
  40029. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40030. return {
  40031. abort: function () {
  40032. runner.abort();
  40033. },
  40034. forceMinPriority: function (p) {
  40035. minPriority = p;
  40036. if (runner) {
  40037. runner.forceMinPriority(p);
  40038. }
  40039. }
  40040. };
  40041. };
  40042. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40043. var timer = null;
  40044. var runner = null;
  40045. if (options.timeout > 0) {
  40046. timer = new OneOffTimer(options.timeout, function () {
  40047. runner.abort();
  40048. callback(true);
  40049. });
  40050. }
  40051. runner = strategy.connect(minPriority, function (error, handshake) {
  40052. if (error && timer && timer.isRunning() && !options.failFast) {
  40053. return;
  40054. }
  40055. if (timer) {
  40056. timer.ensureAborted();
  40057. }
  40058. callback(error, handshake);
  40059. });
  40060. return {
  40061. abort: function () {
  40062. if (timer) {
  40063. timer.ensureAborted();
  40064. }
  40065. runner.abort();
  40066. },
  40067. forceMinPriority: function (p) {
  40068. runner.forceMinPriority(p);
  40069. }
  40070. };
  40071. };
  40072. return SequentialStrategy;
  40073. }());
  40074. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40075. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40076. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40077. function BestConnectedEverStrategy(strategies) {
  40078. this.strategies = strategies;
  40079. }
  40080. BestConnectedEverStrategy.prototype.isSupported = function () {
  40081. return any(this.strategies, util.method("isSupported"));
  40082. };
  40083. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40084. return connect(this.strategies, minPriority, function (i, runners) {
  40085. return function (error, handshake) {
  40086. runners[i].error = error;
  40087. if (error) {
  40088. if (allRunnersFailed(runners)) {
  40089. callback(true);
  40090. }
  40091. return;
  40092. }
  40093. apply(runners, function (runner) {
  40094. runner.forceMinPriority(handshake.transport.priority);
  40095. });
  40096. callback(null, handshake);
  40097. };
  40098. });
  40099. };
  40100. return BestConnectedEverStrategy;
  40101. }());
  40102. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40103. function connect(strategies, minPriority, callbackBuilder) {
  40104. var runners = map(strategies, function (strategy, i, _, rs) {
  40105. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40106. });
  40107. return {
  40108. abort: function () {
  40109. apply(runners, abortRunner);
  40110. },
  40111. forceMinPriority: function (p) {
  40112. apply(runners, function (runner) {
  40113. runner.forceMinPriority(p);
  40114. });
  40115. }
  40116. };
  40117. }
  40118. function allRunnersFailed(runners) {
  40119. return collections_all(runners, function (runner) {
  40120. return Boolean(runner.error);
  40121. });
  40122. }
  40123. function abortRunner(runner) {
  40124. if (!runner.error && !runner.aborted) {
  40125. runner.abort();
  40126. runner.aborted = true;
  40127. }
  40128. }
  40129. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40130. var cached_strategy_CachedStrategy = (function () {
  40131. function CachedStrategy(strategy, transports, options) {
  40132. this.strategy = strategy;
  40133. this.transports = transports;
  40134. this.ttl = options.ttl || 1800 * 1000;
  40135. this.usingTLS = options.useTLS;
  40136. this.timeline = options.timeline;
  40137. }
  40138. CachedStrategy.prototype.isSupported = function () {
  40139. return this.strategy.isSupported();
  40140. };
  40141. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40142. var usingTLS = this.usingTLS;
  40143. var info = fetchTransportCache(usingTLS);
  40144. var strategies = [this.strategy];
  40145. if (info && info.timestamp + this.ttl >= util.now()) {
  40146. var transport = this.transports[info.transport];
  40147. if (transport) {
  40148. this.timeline.info({
  40149. cached: true,
  40150. transport: info.transport,
  40151. latency: info.latency
  40152. });
  40153. strategies.push(new sequential_strategy([transport], {
  40154. timeout: info.latency * 2 + 1000,
  40155. failFast: true
  40156. }));
  40157. }
  40158. }
  40159. var startTimestamp = util.now();
  40160. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40161. if (error) {
  40162. flushTransportCache(usingTLS);
  40163. if (strategies.length > 0) {
  40164. startTimestamp = util.now();
  40165. runner = strategies.pop().connect(minPriority, cb);
  40166. }
  40167. else {
  40168. callback(error);
  40169. }
  40170. }
  40171. else {
  40172. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40173. callback(null, handshake);
  40174. }
  40175. });
  40176. return {
  40177. abort: function () {
  40178. runner.abort();
  40179. },
  40180. forceMinPriority: function (p) {
  40181. minPriority = p;
  40182. if (runner) {
  40183. runner.forceMinPriority(p);
  40184. }
  40185. }
  40186. };
  40187. };
  40188. return CachedStrategy;
  40189. }());
  40190. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40191. function getTransportCacheKey(usingTLS) {
  40192. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40193. }
  40194. function fetchTransportCache(usingTLS) {
  40195. var storage = runtime.getLocalStorage();
  40196. if (storage) {
  40197. try {
  40198. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40199. if (serializedCache) {
  40200. return JSON.parse(serializedCache);
  40201. }
  40202. }
  40203. catch (e) {
  40204. flushTransportCache(usingTLS);
  40205. }
  40206. }
  40207. return null;
  40208. }
  40209. function storeTransportCache(usingTLS, transport, latency) {
  40210. var storage = runtime.getLocalStorage();
  40211. if (storage) {
  40212. try {
  40213. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40214. timestamp: util.now(),
  40215. transport: transport,
  40216. latency: latency
  40217. });
  40218. }
  40219. catch (e) {
  40220. }
  40221. }
  40222. }
  40223. function flushTransportCache(usingTLS) {
  40224. var storage = runtime.getLocalStorage();
  40225. if (storage) {
  40226. try {
  40227. delete storage[getTransportCacheKey(usingTLS)];
  40228. }
  40229. catch (e) {
  40230. }
  40231. }
  40232. }
  40233. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40234. var delayed_strategy_DelayedStrategy = (function () {
  40235. function DelayedStrategy(strategy, _a) {
  40236. var number = _a.delay;
  40237. this.strategy = strategy;
  40238. this.options = { delay: number };
  40239. }
  40240. DelayedStrategy.prototype.isSupported = function () {
  40241. return this.strategy.isSupported();
  40242. };
  40243. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40244. var strategy = this.strategy;
  40245. var runner;
  40246. var timer = new OneOffTimer(this.options.delay, function () {
  40247. runner = strategy.connect(minPriority, callback);
  40248. });
  40249. return {
  40250. abort: function () {
  40251. timer.ensureAborted();
  40252. if (runner) {
  40253. runner.abort();
  40254. }
  40255. },
  40256. forceMinPriority: function (p) {
  40257. minPriority = p;
  40258. if (runner) {
  40259. runner.forceMinPriority(p);
  40260. }
  40261. }
  40262. };
  40263. };
  40264. return DelayedStrategy;
  40265. }());
  40266. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40267. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40268. var IfStrategy = (function () {
  40269. function IfStrategy(test, trueBranch, falseBranch) {
  40270. this.test = test;
  40271. this.trueBranch = trueBranch;
  40272. this.falseBranch = falseBranch;
  40273. }
  40274. IfStrategy.prototype.isSupported = function () {
  40275. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40276. return branch.isSupported();
  40277. };
  40278. IfStrategy.prototype.connect = function (minPriority, callback) {
  40279. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40280. return branch.connect(minPriority, callback);
  40281. };
  40282. return IfStrategy;
  40283. }());
  40284. /* harmony default export */ var if_strategy = (IfStrategy);
  40285. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40286. var FirstConnectedStrategy = (function () {
  40287. function FirstConnectedStrategy(strategy) {
  40288. this.strategy = strategy;
  40289. }
  40290. FirstConnectedStrategy.prototype.isSupported = function () {
  40291. return this.strategy.isSupported();
  40292. };
  40293. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40294. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40295. if (handshake) {
  40296. runner.abort();
  40297. }
  40298. callback(error, handshake);
  40299. });
  40300. return runner;
  40301. };
  40302. return FirstConnectedStrategy;
  40303. }());
  40304. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40305. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40306. function testSupportsStrategy(strategy) {
  40307. return function () {
  40308. return strategy.isSupported();
  40309. };
  40310. }
  40311. var getDefaultStrategy = function (config, defineTransport) {
  40312. var definedTransports = {};
  40313. function defineTransportStrategy(name, type, priority, options, manager) {
  40314. var transport = defineTransport(config, name, type, priority, options, manager);
  40315. definedTransports[name] = transport;
  40316. return transport;
  40317. }
  40318. var ws_options = {
  40319. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40320. hostTLS: config.wsHost + ":" + config.wssPort,
  40321. httpPath: config.wsPath
  40322. };
  40323. var wss_options = extend({}, ws_options, {
  40324. useTLS: true
  40325. });
  40326. var sockjs_options = {
  40327. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40328. hostTLS: config.httpHost + ":" + config.httpsPort,
  40329. httpPath: config.httpPath
  40330. };
  40331. var timeouts = {
  40332. loop: true,
  40333. timeout: 15000,
  40334. timeoutLimit: 60000
  40335. };
  40336. var ws_manager = new transport_manager({
  40337. lives: 2,
  40338. minPingDelay: 10000,
  40339. maxPingDelay: config.activity_timeout
  40340. });
  40341. var streaming_manager = new transport_manager({
  40342. lives: 2,
  40343. minPingDelay: 10000,
  40344. maxPingDelay: config.activity_timeout
  40345. });
  40346. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40347. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40348. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40349. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40350. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40351. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40352. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40353. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40354. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40355. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40356. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40357. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40358. 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);
  40359. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40360. var wsStrategy;
  40361. if (config.useTLS) {
  40362. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40363. }
  40364. else {
  40365. wsStrategy = new best_connected_ever_strategy([
  40366. ws_loop,
  40367. new delayed_strategy(wss_loop, { delay: 2000 }),
  40368. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40369. ]);
  40370. }
  40371. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40372. ttl: 1800000,
  40373. timeline: config.timeline,
  40374. useTLS: config.useTLS
  40375. });
  40376. };
  40377. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40378. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40379. /* harmony default export */ var transport_connection_initializer = (function () {
  40380. var self = this;
  40381. self.timeline.info(self.buildTimelineMessage({
  40382. transport: self.name + (self.options.useTLS ? "s" : "")
  40383. }));
  40384. if (self.hooks.isInitialized()) {
  40385. self.changeState("initialized");
  40386. }
  40387. else if (self.hooks.file) {
  40388. self.changeState("initializing");
  40389. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40390. if (self.hooks.isInitialized()) {
  40391. self.changeState("initialized");
  40392. callback(true);
  40393. }
  40394. else {
  40395. if (error) {
  40396. self.onError(error);
  40397. }
  40398. self.onClose();
  40399. callback(false);
  40400. }
  40401. });
  40402. }
  40403. else {
  40404. self.onClose();
  40405. }
  40406. });
  40407. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40408. var http_xdomain_request_hooks = {
  40409. getRequest: function (socket) {
  40410. var xdr = new window.XDomainRequest();
  40411. xdr.ontimeout = function () {
  40412. socket.emit("error", new RequestTimedOut());
  40413. socket.close();
  40414. };
  40415. xdr.onerror = function (e) {
  40416. socket.emit("error", e);
  40417. socket.close();
  40418. };
  40419. xdr.onprogress = function () {
  40420. if (xdr.responseText && xdr.responseText.length > 0) {
  40421. socket.onChunk(200, xdr.responseText);
  40422. }
  40423. };
  40424. xdr.onload = function () {
  40425. if (xdr.responseText && xdr.responseText.length > 0) {
  40426. socket.onChunk(200, xdr.responseText);
  40427. }
  40428. socket.emit("finished", 200);
  40429. socket.close();
  40430. };
  40431. return xdr;
  40432. },
  40433. abortRequest: function (xdr) {
  40434. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40435. xdr.abort();
  40436. }
  40437. };
  40438. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40439. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40440. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40441. var extendStatics = function (d, b) {
  40442. extendStatics = Object.setPrototypeOf ||
  40443. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40444. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40445. return extendStatics(d, b);
  40446. };
  40447. return function (d, b) {
  40448. extendStatics(d, b);
  40449. function __() { this.constructor = d; }
  40450. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40451. };
  40452. })();
  40453. var MAX_BUFFER_LENGTH = 256 * 1024;
  40454. var http_request_HTTPRequest = (function (_super) {
  40455. http_request_extends(HTTPRequest, _super);
  40456. function HTTPRequest(hooks, method, url) {
  40457. var _this = _super.call(this) || this;
  40458. _this.hooks = hooks;
  40459. _this.method = method;
  40460. _this.url = url;
  40461. return _this;
  40462. }
  40463. HTTPRequest.prototype.start = function (payload) {
  40464. var _this = this;
  40465. this.position = 0;
  40466. this.xhr = this.hooks.getRequest(this);
  40467. this.unloader = function () {
  40468. _this.close();
  40469. };
  40470. runtime.addUnloadListener(this.unloader);
  40471. this.xhr.open(this.method, this.url, true);
  40472. if (this.xhr.setRequestHeader) {
  40473. this.xhr.setRequestHeader("Content-Type", "application/json");
  40474. }
  40475. this.xhr.send(payload);
  40476. };
  40477. HTTPRequest.prototype.close = function () {
  40478. if (this.unloader) {
  40479. runtime.removeUnloadListener(this.unloader);
  40480. this.unloader = null;
  40481. }
  40482. if (this.xhr) {
  40483. this.hooks.abortRequest(this.xhr);
  40484. this.xhr = null;
  40485. }
  40486. };
  40487. HTTPRequest.prototype.onChunk = function (status, data) {
  40488. while (true) {
  40489. var chunk = this.advanceBuffer(data);
  40490. if (chunk) {
  40491. this.emit("chunk", { status: status, data: chunk });
  40492. }
  40493. else {
  40494. break;
  40495. }
  40496. }
  40497. if (this.isBufferTooLong(data)) {
  40498. this.emit("buffer_too_long");
  40499. }
  40500. };
  40501. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40502. var unreadData = buffer.slice(this.position);
  40503. var endOfLinePosition = unreadData.indexOf("\n");
  40504. if (endOfLinePosition !== -1) {
  40505. this.position += endOfLinePosition + 1;
  40506. return unreadData.slice(0, endOfLinePosition);
  40507. }
  40508. else {
  40509. return null;
  40510. }
  40511. };
  40512. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40513. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40514. };
  40515. return HTTPRequest;
  40516. }(dispatcher));
  40517. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40518. // CONCATENATED MODULE: ./src/core/http/state.ts
  40519. var State;
  40520. (function (State) {
  40521. State[State["CONNECTING"] = 0] = "CONNECTING";
  40522. State[State["OPEN"] = 1] = "OPEN";
  40523. State[State["CLOSED"] = 3] = "CLOSED";
  40524. })(State || (State = {}));
  40525. /* harmony default export */ var state = (State);
  40526. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40527. var autoIncrement = 1;
  40528. var http_socket_HTTPSocket = (function () {
  40529. function HTTPSocket(hooks, url) {
  40530. this.hooks = hooks;
  40531. this.session = randomNumber(1000) + "/" + randomString(8);
  40532. this.location = getLocation(url);
  40533. this.readyState = state.CONNECTING;
  40534. this.openStream();
  40535. }
  40536. HTTPSocket.prototype.send = function (payload) {
  40537. return this.sendRaw(JSON.stringify([payload]));
  40538. };
  40539. HTTPSocket.prototype.ping = function () {
  40540. this.hooks.sendHeartbeat(this);
  40541. };
  40542. HTTPSocket.prototype.close = function (code, reason) {
  40543. this.onClose(code, reason, true);
  40544. };
  40545. HTTPSocket.prototype.sendRaw = function (payload) {
  40546. if (this.readyState === state.OPEN) {
  40547. try {
  40548. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40549. return true;
  40550. }
  40551. catch (e) {
  40552. return false;
  40553. }
  40554. }
  40555. else {
  40556. return false;
  40557. }
  40558. };
  40559. HTTPSocket.prototype.reconnect = function () {
  40560. this.closeStream();
  40561. this.openStream();
  40562. };
  40563. ;
  40564. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40565. this.closeStream();
  40566. this.readyState = state.CLOSED;
  40567. if (this.onclose) {
  40568. this.onclose({
  40569. code: code,
  40570. reason: reason,
  40571. wasClean: wasClean
  40572. });
  40573. }
  40574. };
  40575. HTTPSocket.prototype.onChunk = function (chunk) {
  40576. if (chunk.status !== 200) {
  40577. return;
  40578. }
  40579. if (this.readyState === state.OPEN) {
  40580. this.onActivity();
  40581. }
  40582. var payload;
  40583. var type = chunk.data.slice(0, 1);
  40584. switch (type) {
  40585. case 'o':
  40586. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40587. this.onOpen(payload);
  40588. break;
  40589. case 'a':
  40590. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40591. for (var i = 0; i < payload.length; i++) {
  40592. this.onEvent(payload[i]);
  40593. }
  40594. break;
  40595. case 'm':
  40596. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40597. this.onEvent(payload);
  40598. break;
  40599. case 'h':
  40600. this.hooks.onHeartbeat(this);
  40601. break;
  40602. case 'c':
  40603. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40604. this.onClose(payload[0], payload[1], true);
  40605. break;
  40606. }
  40607. };
  40608. HTTPSocket.prototype.onOpen = function (options) {
  40609. if (this.readyState === state.CONNECTING) {
  40610. if (options && options.hostname) {
  40611. this.location.base = replaceHost(this.location.base, options.hostname);
  40612. }
  40613. this.readyState = state.OPEN;
  40614. if (this.onopen) {
  40615. this.onopen();
  40616. }
  40617. }
  40618. else {
  40619. this.onClose(1006, "Server lost session", true);
  40620. }
  40621. };
  40622. HTTPSocket.prototype.onEvent = function (event) {
  40623. if (this.readyState === state.OPEN && this.onmessage) {
  40624. this.onmessage({ data: event });
  40625. }
  40626. };
  40627. HTTPSocket.prototype.onActivity = function () {
  40628. if (this.onactivity) {
  40629. this.onactivity();
  40630. }
  40631. };
  40632. HTTPSocket.prototype.onError = function (error) {
  40633. if (this.onerror) {
  40634. this.onerror(error);
  40635. }
  40636. };
  40637. HTTPSocket.prototype.openStream = function () {
  40638. var _this = this;
  40639. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40640. this.stream.bind("chunk", function (chunk) {
  40641. _this.onChunk(chunk);
  40642. });
  40643. this.stream.bind("finished", function (status) {
  40644. _this.hooks.onFinished(_this, status);
  40645. });
  40646. this.stream.bind("buffer_too_long", function () {
  40647. _this.reconnect();
  40648. });
  40649. try {
  40650. this.stream.start();
  40651. }
  40652. catch (error) {
  40653. util.defer(function () {
  40654. _this.onError(error);
  40655. _this.onClose(1006, "Could not start streaming", false);
  40656. });
  40657. }
  40658. };
  40659. HTTPSocket.prototype.closeStream = function () {
  40660. if (this.stream) {
  40661. this.stream.unbind_all();
  40662. this.stream.close();
  40663. this.stream = null;
  40664. }
  40665. };
  40666. return HTTPSocket;
  40667. }());
  40668. function getLocation(url) {
  40669. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40670. return {
  40671. base: parts[1],
  40672. queryString: parts[2]
  40673. };
  40674. }
  40675. function getSendURL(url, session) {
  40676. return url.base + "/" + session + "/xhr_send";
  40677. }
  40678. function getUniqueURL(url) {
  40679. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40680. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40681. }
  40682. function replaceHost(url, hostname) {
  40683. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40684. return urlParts[1] + hostname + urlParts[3];
  40685. }
  40686. function randomNumber(max) {
  40687. return Math.floor(Math.random() * max);
  40688. }
  40689. function randomString(length) {
  40690. var result = [];
  40691. for (var i = 0; i < length; i++) {
  40692. result.push(randomNumber(32).toString(32));
  40693. }
  40694. return result.join('');
  40695. }
  40696. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40697. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40698. var http_streaming_socket_hooks = {
  40699. getReceiveURL: function (url, session) {
  40700. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40701. },
  40702. onHeartbeat: function (socket) {
  40703. socket.sendRaw("[]");
  40704. },
  40705. sendHeartbeat: function (socket) {
  40706. socket.sendRaw("[]");
  40707. },
  40708. onFinished: function (socket, status) {
  40709. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40710. }
  40711. };
  40712. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40713. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40714. var http_polling_socket_hooks = {
  40715. getReceiveURL: function (url, session) {
  40716. return url.base + "/" + session + "/xhr" + url.queryString;
  40717. },
  40718. onHeartbeat: function () {
  40719. },
  40720. sendHeartbeat: function (socket) {
  40721. socket.sendRaw("[]");
  40722. },
  40723. onFinished: function (socket, status) {
  40724. if (status === 200) {
  40725. socket.reconnect();
  40726. }
  40727. else {
  40728. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40729. }
  40730. }
  40731. };
  40732. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40733. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40734. var http_xhr_request_hooks = {
  40735. getRequest: function (socket) {
  40736. var Constructor = runtime.getXHRAPI();
  40737. var xhr = new Constructor();
  40738. xhr.onreadystatechange = xhr.onprogress = function () {
  40739. switch (xhr.readyState) {
  40740. case 3:
  40741. if (xhr.responseText && xhr.responseText.length > 0) {
  40742. socket.onChunk(xhr.status, xhr.responseText);
  40743. }
  40744. break;
  40745. case 4:
  40746. if (xhr.responseText && xhr.responseText.length > 0) {
  40747. socket.onChunk(xhr.status, xhr.responseText);
  40748. }
  40749. socket.emit("finished", xhr.status);
  40750. socket.close();
  40751. break;
  40752. }
  40753. };
  40754. return xhr;
  40755. },
  40756. abortRequest: function (xhr) {
  40757. xhr.onreadystatechange = null;
  40758. xhr.abort();
  40759. }
  40760. };
  40761. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40762. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40763. var HTTP = {
  40764. createStreamingSocket: function (url) {
  40765. return this.createSocket(http_streaming_socket, url);
  40766. },
  40767. createPollingSocket: function (url) {
  40768. return this.createSocket(http_polling_socket, url);
  40769. },
  40770. createSocket: function (hooks, url) {
  40771. return new http_socket(hooks, url);
  40772. },
  40773. createXHR: function (method, url) {
  40774. return this.createRequest(http_xhr_request, method, url);
  40775. },
  40776. createRequest: function (hooks, method, url) {
  40777. return new http_request(hooks, method, url);
  40778. }
  40779. };
  40780. /* harmony default export */ var http_http = (HTTP);
  40781. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40782. http_http.createXDR = function (method, url) {
  40783. return this.createRequest(http_xdomain_request, method, url);
  40784. };
  40785. /* harmony default export */ var web_http_http = (http_http);
  40786. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40787. var Runtime = {
  40788. nextAuthCallbackID: 1,
  40789. auth_callbacks: {},
  40790. ScriptReceivers: ScriptReceivers,
  40791. DependenciesReceivers: DependenciesReceivers,
  40792. getDefaultStrategy: default_strategy,
  40793. Transports: transports_transports,
  40794. transportConnectionInitializer: transport_connection_initializer,
  40795. HTTPFactory: web_http_http,
  40796. TimelineTransport: jsonp_timeline,
  40797. getXHRAPI: function () {
  40798. return window.XMLHttpRequest;
  40799. },
  40800. getWebSocketAPI: function () {
  40801. return window.WebSocket || window.MozWebSocket;
  40802. },
  40803. setup: function (PusherClass) {
  40804. var _this = this;
  40805. window.Pusher = PusherClass;
  40806. var initializeOnDocumentBody = function () {
  40807. _this.onDocumentBody(PusherClass.ready);
  40808. };
  40809. if (!window.JSON) {
  40810. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40811. }
  40812. else {
  40813. initializeOnDocumentBody();
  40814. }
  40815. },
  40816. getDocument: function () {
  40817. return document;
  40818. },
  40819. getProtocol: function () {
  40820. return this.getDocument().location.protocol;
  40821. },
  40822. getAuthorizers: function () {
  40823. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40824. },
  40825. onDocumentBody: function (callback) {
  40826. var _this = this;
  40827. if (document.body) {
  40828. callback();
  40829. }
  40830. else {
  40831. setTimeout(function () {
  40832. _this.onDocumentBody(callback);
  40833. }, 0);
  40834. }
  40835. },
  40836. createJSONPRequest: function (url, data) {
  40837. return new jsonp_request(url, data);
  40838. },
  40839. createScriptRequest: function (src) {
  40840. return new script_request(src);
  40841. },
  40842. getLocalStorage: function () {
  40843. try {
  40844. return window.localStorage;
  40845. }
  40846. catch (e) {
  40847. return undefined;
  40848. }
  40849. },
  40850. createXHR: function () {
  40851. if (this.getXHRAPI()) {
  40852. return this.createXMLHttpRequest();
  40853. }
  40854. else {
  40855. return this.createMicrosoftXHR();
  40856. }
  40857. },
  40858. createXMLHttpRequest: function () {
  40859. var Constructor = this.getXHRAPI();
  40860. return new Constructor();
  40861. },
  40862. createMicrosoftXHR: function () {
  40863. return new ActiveXObject("Microsoft.XMLHTTP");
  40864. },
  40865. getNetwork: function () {
  40866. return net_info_Network;
  40867. },
  40868. createWebSocket: function (url) {
  40869. var Constructor = this.getWebSocketAPI();
  40870. return new Constructor(url);
  40871. },
  40872. createSocketRequest: function (method, url) {
  40873. if (this.isXHRSupported()) {
  40874. return this.HTTPFactory.createXHR(method, url);
  40875. }
  40876. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40877. return this.HTTPFactory.createXDR(method, url);
  40878. }
  40879. else {
  40880. throw "Cross-origin HTTP requests are not supported";
  40881. }
  40882. },
  40883. isXHRSupported: function () {
  40884. var Constructor = this.getXHRAPI();
  40885. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40886. },
  40887. isXDRSupported: function (useTLS) {
  40888. var protocol = useTLS ? "https:" : "http:";
  40889. var documentProtocol = this.getProtocol();
  40890. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40891. },
  40892. addUnloadListener: function (listener) {
  40893. if (window.addEventListener !== undefined) {
  40894. window.addEventListener("unload", listener, false);
  40895. }
  40896. else if (window.attachEvent !== undefined) {
  40897. window.attachEvent("onunload", listener);
  40898. }
  40899. },
  40900. removeUnloadListener: function (listener) {
  40901. if (window.addEventListener !== undefined) {
  40902. window.removeEventListener("unload", listener, false);
  40903. }
  40904. else if (window.detachEvent !== undefined) {
  40905. window.detachEvent("onunload", listener);
  40906. }
  40907. }
  40908. };
  40909. /* harmony default export */ var runtime = (Runtime);
  40910. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40911. var TimelineLevel;
  40912. (function (TimelineLevel) {
  40913. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40914. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40915. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40916. })(TimelineLevel || (TimelineLevel = {}));
  40917. /* harmony default export */ var timeline_level = (TimelineLevel);
  40918. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40919. var timeline_Timeline = (function () {
  40920. function Timeline(key, session, options) {
  40921. this.key = key;
  40922. this.session = session;
  40923. this.events = [];
  40924. this.options = options || {};
  40925. this.sent = 0;
  40926. this.uniqueID = 0;
  40927. }
  40928. Timeline.prototype.log = function (level, event) {
  40929. if (level <= this.options.level) {
  40930. this.events.push(extend({}, event, { timestamp: util.now() }));
  40931. if (this.options.limit && this.events.length > this.options.limit) {
  40932. this.events.shift();
  40933. }
  40934. }
  40935. };
  40936. Timeline.prototype.error = function (event) {
  40937. this.log(timeline_level.ERROR, event);
  40938. };
  40939. Timeline.prototype.info = function (event) {
  40940. this.log(timeline_level.INFO, event);
  40941. };
  40942. Timeline.prototype.debug = function (event) {
  40943. this.log(timeline_level.DEBUG, event);
  40944. };
  40945. Timeline.prototype.isEmpty = function () {
  40946. return this.events.length === 0;
  40947. };
  40948. Timeline.prototype.send = function (sendfn, callback) {
  40949. var _this = this;
  40950. var data = extend({
  40951. session: this.session,
  40952. bundle: this.sent + 1,
  40953. key: this.key,
  40954. lib: "js",
  40955. version: this.options.version,
  40956. cluster: this.options.cluster,
  40957. features: this.options.features,
  40958. timeline: this.events
  40959. }, this.options.params);
  40960. this.events = [];
  40961. sendfn(data, function (error, result) {
  40962. if (!error) {
  40963. _this.sent++;
  40964. }
  40965. if (callback) {
  40966. callback(error, result);
  40967. }
  40968. });
  40969. return true;
  40970. };
  40971. Timeline.prototype.generateUniqueID = function () {
  40972. this.uniqueID++;
  40973. return this.uniqueID;
  40974. };
  40975. return Timeline;
  40976. }());
  40977. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40978. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40979. var transport_strategy_TransportStrategy = (function () {
  40980. function TransportStrategy(name, priority, transport, options) {
  40981. this.name = name;
  40982. this.priority = priority;
  40983. this.transport = transport;
  40984. this.options = options || {};
  40985. }
  40986. TransportStrategy.prototype.isSupported = function () {
  40987. return this.transport.isSupported({
  40988. useTLS: this.options.useTLS
  40989. });
  40990. };
  40991. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40992. var _this = this;
  40993. if (!this.isSupported()) {
  40994. return failAttempt(new UnsupportedStrategy(), callback);
  40995. }
  40996. else if (this.priority < minPriority) {
  40997. return failAttempt(new TransportPriorityTooLow(), callback);
  40998. }
  40999. var connected = false;
  41000. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41001. var handshake = null;
  41002. var onInitialized = function () {
  41003. transport.unbind("initialized", onInitialized);
  41004. transport.connect();
  41005. };
  41006. var onOpen = function () {
  41007. handshake = factory.createHandshake(transport, function (result) {
  41008. connected = true;
  41009. unbindListeners();
  41010. callback(null, result);
  41011. });
  41012. };
  41013. var onError = function (error) {
  41014. unbindListeners();
  41015. callback(error);
  41016. };
  41017. var onClosed = function () {
  41018. unbindListeners();
  41019. var serializedTransport;
  41020. serializedTransport = safeJSONStringify(transport);
  41021. callback(new TransportClosed(serializedTransport));
  41022. };
  41023. var unbindListeners = function () {
  41024. transport.unbind("initialized", onInitialized);
  41025. transport.unbind("open", onOpen);
  41026. transport.unbind("error", onError);
  41027. transport.unbind("closed", onClosed);
  41028. };
  41029. transport.bind("initialized", onInitialized);
  41030. transport.bind("open", onOpen);
  41031. transport.bind("error", onError);
  41032. transport.bind("closed", onClosed);
  41033. transport.initialize();
  41034. return {
  41035. abort: function () {
  41036. if (connected) {
  41037. return;
  41038. }
  41039. unbindListeners();
  41040. if (handshake) {
  41041. handshake.close();
  41042. }
  41043. else {
  41044. transport.close();
  41045. }
  41046. },
  41047. forceMinPriority: function (p) {
  41048. if (connected) {
  41049. return;
  41050. }
  41051. if (_this.priority < p) {
  41052. if (handshake) {
  41053. handshake.close();
  41054. }
  41055. else {
  41056. transport.close();
  41057. }
  41058. }
  41059. }
  41060. };
  41061. };
  41062. return TransportStrategy;
  41063. }());
  41064. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41065. function failAttempt(error, callback) {
  41066. util.defer(function () {
  41067. callback(error);
  41068. });
  41069. return {
  41070. abort: function () { },
  41071. forceMinPriority: function () { }
  41072. };
  41073. }
  41074. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41075. var strategy_builder_Transports = runtime.Transports;
  41076. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41077. var transportClass = strategy_builder_Transports[type];
  41078. if (!transportClass) {
  41079. throw new UnsupportedTransport(type);
  41080. }
  41081. var enabled = (!config.enabledTransports ||
  41082. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41083. (!config.disabledTransports ||
  41084. arrayIndexOf(config.disabledTransports, name) === -1);
  41085. var transport;
  41086. if (enabled) {
  41087. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41088. key: config.key,
  41089. useTLS: config.useTLS,
  41090. timeline: config.timeline,
  41091. ignoreNullOrigin: config.ignoreNullOrigin
  41092. }, options));
  41093. }
  41094. else {
  41095. transport = strategy_builder_UnsupportedStrategy;
  41096. }
  41097. return transport;
  41098. };
  41099. var strategy_builder_UnsupportedStrategy = {
  41100. isSupported: function () {
  41101. return false;
  41102. },
  41103. connect: function (_, callback) {
  41104. var deferred = util.defer(function () {
  41105. callback(new UnsupportedStrategy());
  41106. });
  41107. return {
  41108. abort: function () {
  41109. deferred.ensureAborted();
  41110. },
  41111. forceMinPriority: function () { }
  41112. };
  41113. }
  41114. };
  41115. // CONCATENATED MODULE: ./src/core/config.ts
  41116. var getGlobalConfig = function () {
  41117. return {
  41118. wsHost: defaults.host,
  41119. wsPort: defaults.ws_port,
  41120. wssPort: defaults.wss_port,
  41121. wsPath: defaults.ws_path,
  41122. httpHost: defaults.sockjs_host,
  41123. httpPort: defaults.sockjs_http_port,
  41124. httpsPort: defaults.sockjs_https_port,
  41125. httpPath: defaults.sockjs_path,
  41126. statsHost: defaults.stats_host,
  41127. authEndpoint: defaults.channel_auth_endpoint,
  41128. authTransport: defaults.channel_auth_transport,
  41129. activity_timeout: defaults.activity_timeout,
  41130. pong_timeout: defaults.pong_timeout,
  41131. unavailable_timeout: defaults.unavailable_timeout
  41132. };
  41133. };
  41134. var getClusterConfig = function (clusterName) {
  41135. return {
  41136. wsHost: 'ws-' + clusterName + '.pusher.com',
  41137. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41138. };
  41139. };
  41140. // CONCATENATED MODULE: ./src/core/pusher.ts
  41141. var pusher_Pusher = (function () {
  41142. function Pusher(app_key, options) {
  41143. var _this = this;
  41144. checkAppKey(app_key);
  41145. options = options || {};
  41146. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41147. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41148. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41149. }
  41150. this.key = app_key;
  41151. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41152. this.channels = factory.createChannels();
  41153. this.global_emitter = new dispatcher();
  41154. this.sessionID = Math.floor(Math.random() * 1000000000);
  41155. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41156. cluster: this.config.cluster,
  41157. features: Pusher.getClientFeatures(),
  41158. params: this.config.timelineParams || {},
  41159. limit: 50,
  41160. level: timeline_level.INFO,
  41161. version: defaults.VERSION
  41162. });
  41163. if (!this.config.disableStats) {
  41164. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41165. host: this.config.statsHost,
  41166. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41167. });
  41168. }
  41169. var getStrategy = function (options) {
  41170. var config = extend({}, _this.config, options);
  41171. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41172. };
  41173. this.connection = factory.createConnectionManager(this.key, extend({
  41174. getStrategy: getStrategy,
  41175. timeline: this.timeline,
  41176. activityTimeout: this.config.activity_timeout,
  41177. pongTimeout: this.config.pong_timeout,
  41178. unavailableTimeout: this.config.unavailable_timeout
  41179. }, this.config, { useTLS: this.shouldUseTLS() }));
  41180. this.connection.bind('connected', function () {
  41181. _this.subscribeAll();
  41182. if (_this.timelineSender) {
  41183. _this.timelineSender.send(_this.connection.isUsingTLS());
  41184. }
  41185. });
  41186. this.connection.bind('message', function (event) {
  41187. var eventName = event.event;
  41188. var internal = eventName.indexOf('pusher_internal:') === 0;
  41189. if (event.channel) {
  41190. var channel = _this.channel(event.channel);
  41191. if (channel) {
  41192. channel.handleEvent(event);
  41193. }
  41194. }
  41195. if (!internal) {
  41196. _this.global_emitter.emit(event.event, event.data);
  41197. }
  41198. });
  41199. this.connection.bind('connecting', function () {
  41200. _this.channels.disconnect();
  41201. });
  41202. this.connection.bind('disconnected', function () {
  41203. _this.channels.disconnect();
  41204. });
  41205. this.connection.bind('error', function (err) {
  41206. logger.warn(err);
  41207. });
  41208. Pusher.instances.push(this);
  41209. this.timeline.info({ instances: Pusher.instances.length });
  41210. if (Pusher.isReady) {
  41211. this.connect();
  41212. }
  41213. }
  41214. Pusher.ready = function () {
  41215. Pusher.isReady = true;
  41216. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41217. Pusher.instances[i].connect();
  41218. }
  41219. };
  41220. Pusher.getClientFeatures = function () {
  41221. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41222. return t.isSupported({});
  41223. }));
  41224. };
  41225. Pusher.prototype.channel = function (name) {
  41226. return this.channels.find(name);
  41227. };
  41228. Pusher.prototype.allChannels = function () {
  41229. return this.channels.all();
  41230. };
  41231. Pusher.prototype.connect = function () {
  41232. this.connection.connect();
  41233. if (this.timelineSender) {
  41234. if (!this.timelineSenderTimer) {
  41235. var usingTLS = this.connection.isUsingTLS();
  41236. var timelineSender = this.timelineSender;
  41237. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41238. timelineSender.send(usingTLS);
  41239. });
  41240. }
  41241. }
  41242. };
  41243. Pusher.prototype.disconnect = function () {
  41244. this.connection.disconnect();
  41245. if (this.timelineSenderTimer) {
  41246. this.timelineSenderTimer.ensureAborted();
  41247. this.timelineSenderTimer = null;
  41248. }
  41249. };
  41250. Pusher.prototype.bind = function (event_name, callback, context) {
  41251. this.global_emitter.bind(event_name, callback, context);
  41252. return this;
  41253. };
  41254. Pusher.prototype.unbind = function (event_name, callback, context) {
  41255. this.global_emitter.unbind(event_name, callback, context);
  41256. return this;
  41257. };
  41258. Pusher.prototype.bind_global = function (callback) {
  41259. this.global_emitter.bind_global(callback);
  41260. return this;
  41261. };
  41262. Pusher.prototype.unbind_global = function (callback) {
  41263. this.global_emitter.unbind_global(callback);
  41264. return this;
  41265. };
  41266. Pusher.prototype.unbind_all = function (callback) {
  41267. this.global_emitter.unbind_all();
  41268. return this;
  41269. };
  41270. Pusher.prototype.subscribeAll = function () {
  41271. var channelName;
  41272. for (channelName in this.channels.channels) {
  41273. if (this.channels.channels.hasOwnProperty(channelName)) {
  41274. this.subscribe(channelName);
  41275. }
  41276. }
  41277. };
  41278. Pusher.prototype.subscribe = function (channel_name) {
  41279. var channel = this.channels.add(channel_name, this);
  41280. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41281. channel.reinstateSubscription();
  41282. }
  41283. else if (!channel.subscriptionPending &&
  41284. this.connection.state === 'connected') {
  41285. channel.subscribe();
  41286. }
  41287. return channel;
  41288. };
  41289. Pusher.prototype.unsubscribe = function (channel_name) {
  41290. var channel = this.channels.find(channel_name);
  41291. if (channel && channel.subscriptionPending) {
  41292. channel.cancelSubscription();
  41293. }
  41294. else {
  41295. channel = this.channels.remove(channel_name);
  41296. if (channel && this.connection.state === 'connected') {
  41297. channel.unsubscribe();
  41298. }
  41299. }
  41300. };
  41301. Pusher.prototype.send_event = function (event_name, data, channel) {
  41302. return this.connection.send_event(event_name, data, channel);
  41303. };
  41304. Pusher.prototype.shouldUseTLS = function () {
  41305. if (runtime.getProtocol() === 'https:') {
  41306. return true;
  41307. }
  41308. else if (this.config.forceTLS === true) {
  41309. return true;
  41310. }
  41311. else {
  41312. return Boolean(this.config.encrypted);
  41313. }
  41314. };
  41315. Pusher.instances = [];
  41316. Pusher.isReady = false;
  41317. Pusher.logToConsole = false;
  41318. Pusher.Runtime = runtime;
  41319. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41320. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41321. Pusher.auth_callbacks = runtime.auth_callbacks;
  41322. return Pusher;
  41323. }());
  41324. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41325. function checkAppKey(key) {
  41326. if (key === null || key === undefined) {
  41327. throw 'You must pass your app key when you instantiate Pusher.';
  41328. }
  41329. }
  41330. runtime.setup(pusher_Pusher);
  41331. /***/ })
  41332. /******/ ]);
  41333. });
  41334. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41335. /***/ }),
  41336. /***/ "./node_modules/setimmediate/setImmediate.js":
  41337. /*!***************************************************!*\
  41338. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41339. \***************************************************/
  41340. /*! no static exports found */
  41341. /***/ (function(module, exports, __webpack_require__) {
  41342. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41343. "use strict";
  41344. if (global.setImmediate) {
  41345. return;
  41346. }
  41347. var nextHandle = 1; // Spec says greater than zero
  41348. var tasksByHandle = {};
  41349. var currentlyRunningATask = false;
  41350. var doc = global.document;
  41351. var registerImmediate;
  41352. function setImmediate(callback) {
  41353. // Callback can either be a function or a string
  41354. if (typeof callback !== "function") {
  41355. callback = new Function("" + callback);
  41356. }
  41357. // Copy function arguments
  41358. var args = new Array(arguments.length - 1);
  41359. for (var i = 0; i < args.length; i++) {
  41360. args[i] = arguments[i + 1];
  41361. }
  41362. // Store and register the task
  41363. var task = { callback: callback, args: args };
  41364. tasksByHandle[nextHandle] = task;
  41365. registerImmediate(nextHandle);
  41366. return nextHandle++;
  41367. }
  41368. function clearImmediate(handle) {
  41369. delete tasksByHandle[handle];
  41370. }
  41371. function run(task) {
  41372. var callback = task.callback;
  41373. var args = task.args;
  41374. switch (args.length) {
  41375. case 0:
  41376. callback();
  41377. break;
  41378. case 1:
  41379. callback(args[0]);
  41380. break;
  41381. case 2:
  41382. callback(args[0], args[1]);
  41383. break;
  41384. case 3:
  41385. callback(args[0], args[1], args[2]);
  41386. break;
  41387. default:
  41388. callback.apply(undefined, args);
  41389. break;
  41390. }
  41391. }
  41392. function runIfPresent(handle) {
  41393. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41394. // So if we're currently running a task, we'll need to delay this invocation.
  41395. if (currentlyRunningATask) {
  41396. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41397. // "too much recursion" error.
  41398. setTimeout(runIfPresent, 0, handle);
  41399. } else {
  41400. var task = tasksByHandle[handle];
  41401. if (task) {
  41402. currentlyRunningATask = true;
  41403. try {
  41404. run(task);
  41405. } finally {
  41406. clearImmediate(handle);
  41407. currentlyRunningATask = false;
  41408. }
  41409. }
  41410. }
  41411. }
  41412. function installNextTickImplementation() {
  41413. registerImmediate = function(handle) {
  41414. process.nextTick(function () { runIfPresent(handle); });
  41415. };
  41416. }
  41417. function canUsePostMessage() {
  41418. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41419. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41420. if (global.postMessage && !global.importScripts) {
  41421. var postMessageIsAsynchronous = true;
  41422. var oldOnMessage = global.onmessage;
  41423. global.onmessage = function() {
  41424. postMessageIsAsynchronous = false;
  41425. };
  41426. global.postMessage("", "*");
  41427. global.onmessage = oldOnMessage;
  41428. return postMessageIsAsynchronous;
  41429. }
  41430. }
  41431. function installPostMessageImplementation() {
  41432. // Installs an event handler on `global` for the `message` event: see
  41433. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41434. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41435. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41436. var onGlobalMessage = function(event) {
  41437. if (event.source === global &&
  41438. typeof event.data === "string" &&
  41439. event.data.indexOf(messagePrefix) === 0) {
  41440. runIfPresent(+event.data.slice(messagePrefix.length));
  41441. }
  41442. };
  41443. if (global.addEventListener) {
  41444. global.addEventListener("message", onGlobalMessage, false);
  41445. } else {
  41446. global.attachEvent("onmessage", onGlobalMessage);
  41447. }
  41448. registerImmediate = function(handle) {
  41449. global.postMessage(messagePrefix + handle, "*");
  41450. };
  41451. }
  41452. function installMessageChannelImplementation() {
  41453. var channel = new MessageChannel();
  41454. channel.port1.onmessage = function(event) {
  41455. var handle = event.data;
  41456. runIfPresent(handle);
  41457. };
  41458. registerImmediate = function(handle) {
  41459. channel.port2.postMessage(handle);
  41460. };
  41461. }
  41462. function installReadyStateChangeImplementation() {
  41463. var html = doc.documentElement;
  41464. registerImmediate = function(handle) {
  41465. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41466. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41467. var script = doc.createElement("script");
  41468. script.onreadystatechange = function () {
  41469. runIfPresent(handle);
  41470. script.onreadystatechange = null;
  41471. html.removeChild(script);
  41472. script = null;
  41473. };
  41474. html.appendChild(script);
  41475. };
  41476. }
  41477. function installSetTimeoutImplementation() {
  41478. registerImmediate = function(handle) {
  41479. setTimeout(runIfPresent, 0, handle);
  41480. };
  41481. }
  41482. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41483. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41484. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41485. // Don't get fooled by e.g. browserify environments.
  41486. if ({}.toString.call(global.process) === "[object process]") {
  41487. // For Node.js before 0.9
  41488. installNextTickImplementation();
  41489. } else if (canUsePostMessage()) {
  41490. // For non-IE10 modern browsers
  41491. installPostMessageImplementation();
  41492. } else if (global.MessageChannel) {
  41493. // For web workers, where supported
  41494. installMessageChannelImplementation();
  41495. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41496. // For IE 6–8
  41497. installReadyStateChangeImplementation();
  41498. } else {
  41499. // For older browsers
  41500. installSetTimeoutImplementation();
  41501. }
  41502. attachTo.setImmediate = setImmediate;
  41503. attachTo.clearImmediate = clearImmediate;
  41504. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41505. /* 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")))
  41506. /***/ }),
  41507. /***/ "./node_modules/timers-browserify/main.js":
  41508. /*!************************************************!*\
  41509. !*** ./node_modules/timers-browserify/main.js ***!
  41510. \************************************************/
  41511. /*! no static exports found */
  41512. /***/ (function(module, exports, __webpack_require__) {
  41513. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41514. (typeof self !== "undefined" && self) ||
  41515. window;
  41516. var apply = Function.prototype.apply;
  41517. // DOM APIs, for completeness
  41518. exports.setTimeout = function() {
  41519. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41520. };
  41521. exports.setInterval = function() {
  41522. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41523. };
  41524. exports.clearTimeout =
  41525. exports.clearInterval = function(timeout) {
  41526. if (timeout) {
  41527. timeout.close();
  41528. }
  41529. };
  41530. function Timeout(id, clearFn) {
  41531. this._id = id;
  41532. this._clearFn = clearFn;
  41533. }
  41534. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41535. Timeout.prototype.close = function() {
  41536. this._clearFn.call(scope, this._id);
  41537. };
  41538. // Does not start the time, just sets up the members needed.
  41539. exports.enroll = function(item, msecs) {
  41540. clearTimeout(item._idleTimeoutId);
  41541. item._idleTimeout = msecs;
  41542. };
  41543. exports.unenroll = function(item) {
  41544. clearTimeout(item._idleTimeoutId);
  41545. item._idleTimeout = -1;
  41546. };
  41547. exports._unrefActive = exports.active = function(item) {
  41548. clearTimeout(item._idleTimeoutId);
  41549. var msecs = item._idleTimeout;
  41550. if (msecs >= 0) {
  41551. item._idleTimeoutId = setTimeout(function onTimeout() {
  41552. if (item._onTimeout)
  41553. item._onTimeout();
  41554. }, msecs);
  41555. }
  41556. };
  41557. // setimmediate attaches itself to the global object
  41558. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41559. // On some exotic environments, it's not clear which object `setimmediate` was
  41560. // able to install onto. Search each possibility in the same order as the
  41561. // `setimmediate` library.
  41562. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41563. (typeof global !== "undefined" && global.setImmediate) ||
  41564. (this && this.setImmediate);
  41565. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41566. (typeof global !== "undefined" && global.clearImmediate) ||
  41567. (this && this.clearImmediate);
  41568. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41569. /***/ }),
  41570. /***/ "./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&":
  41571. /*!*******************************************************************************************************************************************************************************************************************!*\
  41572. !*** ./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& ***!
  41573. \*******************************************************************************************************************************************************************************************************************/
  41574. /*! exports provided: render, staticRenderFns */
  41575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41576. "use strict";
  41577. __webpack_require__.r(__webpack_exports__);
  41578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41580. var render = function() {
  41581. var _vm = this
  41582. var _h = _vm.$createElement
  41583. var _c = _vm._self._c || _h
  41584. return _vm._m(0)
  41585. }
  41586. var staticRenderFns = [
  41587. function() {
  41588. var _vm = this
  41589. var _h = _vm.$createElement
  41590. var _c = _vm._self._c || _h
  41591. return _c("div", { staticClass: "container" }, [
  41592. _c("div", { staticClass: "row justify-content-center" }, [
  41593. _c("div", { staticClass: "col-md-8" }, [
  41594. _c("div", { staticClass: "card" }, [
  41595. _c("div", { staticClass: "card-header" }, [
  41596. _vm._v("Example Component")
  41597. ]),
  41598. _vm._v(" "),
  41599. _c("div", { staticClass: "card-body" }, [
  41600. _vm._v(
  41601. "\n I'm an example component.\n "
  41602. )
  41603. ])
  41604. ])
  41605. ])
  41606. ])
  41607. ])
  41608. }
  41609. ]
  41610. render._withStripped = true
  41611. /***/ }),
  41612. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  41613. /*!************************************************************************************************************************************************************************************************************!*\
  41614. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  41615. \************************************************************************************************************************************************************************************************************/
  41616. /*! exports provided: render, staticRenderFns */
  41617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41618. "use strict";
  41619. __webpack_require__.r(__webpack_exports__);
  41620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41622. var render = function() {
  41623. var _vm = this
  41624. var _h = _vm.$createElement
  41625. var _c = _vm._self._c || _h
  41626. return _c("div", [
  41627. _c("h4", { staticClass: "text-center" }, [
  41628. _vm._v(_vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "),
  41629. _c("small", { staticClass: "text-muted" }, [
  41630. _vm._v(_vm._s(this.data.pcnickname))
  41631. ])
  41632. ]),
  41633. _vm._v(" "),
  41634. _c("p", [_vm._v("S/N: " + _vm._s(this.data.pcserial))]),
  41635. _vm._v(" "),
  41636. _c("p", [_vm._v("CPU: " + _vm._s(this.data.pcproc))]),
  41637. _vm._v(" "),
  41638. _c("p", [_vm._v("RAM: " + _vm._s(this.data.pcram))]),
  41639. _vm._v(" "),
  41640. _c("p", [_vm._v("OS: " + _vm._s(this.data.pcos))])
  41641. ])
  41642. }
  41643. var staticRenderFns = []
  41644. render._withStripped = true
  41645. /***/ }),
  41646. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  41647. /*!*********************************************************************************************************************************************************************************************************!*\
  41648. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  41649. \*********************************************************************************************************************************************************************************************************/
  41650. /*! exports provided: render, staticRenderFns */
  41651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41652. "use strict";
  41653. __webpack_require__.r(__webpack_exports__);
  41654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41656. var render = function() {
  41657. var _vm = this
  41658. var _h = _vm.$createElement
  41659. var _c = _vm._self._c || _h
  41660. return _c("div", [
  41661. _c("p", [
  41662. _c("i", { staticClass: "fas fa-info-circle" }),
  41663. _vm._v(" "),
  41664. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  41665. ]),
  41666. _vm._v(" "),
  41667. _c("p", [
  41668. _c("i", { staticClass: "far fa-lightbulb" }),
  41669. _vm._v(" "),
  41670. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  41671. ]),
  41672. _vm._v(" "),
  41673. _c("p", [
  41674. _c("i", { staticClass: "fas fa-paste" }),
  41675. _vm._v(" "),
  41676. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  41677. ]),
  41678. _vm._v(" "),
  41679. _c("p", [
  41680. _c("i", { staticClass: "fas fa-building" }),
  41681. _vm._v(" "),
  41682. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  41683. ]),
  41684. _vm._v(" "),
  41685. _c("p", [
  41686. _c("i", { staticClass: "fas fa-sign-in-alt" }),
  41687. _vm._v(" "),
  41688. _c(
  41689. "span",
  41690. {
  41691. staticClass: "dashed-underline",
  41692. attrs: {
  41693. "data-toggle": "tooltip",
  41694. "data-placement": "bottom",
  41695. title: this.getHRDate(this.data.dropdate)
  41696. }
  41697. },
  41698. [
  41699. _vm._v(
  41700. "\n " +
  41701. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  41702. " days ago\n "
  41703. )
  41704. ]
  41705. )
  41706. ]),
  41707. _vm._v(" "),
  41708. _c("p", [
  41709. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  41710. _vm._v(" "),
  41711. !this.isZero(this.data.pickupdate)
  41712. ? _c(
  41713. "span",
  41714. {
  41715. staticClass: "dashed-underline",
  41716. attrs: {
  41717. "data-toggle": "tooltip",
  41718. "data-placement": "bottom",
  41719. tittle: this.getHRDate(this.data.pickupdate)
  41720. }
  41721. },
  41722. [
  41723. _vm._v(
  41724. "\n " +
  41725. _vm._s(
  41726. Math.floor(this.daysSinceToday(this.data.pickupdate))
  41727. ) +
  41728. " days ago\n "
  41729. )
  41730. ]
  41731. )
  41732. : _vm._e()
  41733. ])
  41734. ])
  41735. }
  41736. var staticRenderFns = []
  41737. render._withStripped = true
  41738. /***/ }),
  41739. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41740. /*!********************************************************************!*\
  41741. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41742. \********************************************************************/
  41743. /*! exports provided: default */
  41744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41745. "use strict";
  41746. __webpack_require__.r(__webpack_exports__);
  41747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41748. /* globals __VUE_SSR_CONTEXT__ */
  41749. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41750. // This module is a runtime utility for cleaner component module output and will
  41751. // be included in the final webpack user bundle.
  41752. function normalizeComponent (
  41753. scriptExports,
  41754. render,
  41755. staticRenderFns,
  41756. functionalTemplate,
  41757. injectStyles,
  41758. scopeId,
  41759. moduleIdentifier, /* server only */
  41760. shadowMode /* vue-cli only */
  41761. ) {
  41762. // Vue.extend constructor export interop
  41763. var options = typeof scriptExports === 'function'
  41764. ? scriptExports.options
  41765. : scriptExports
  41766. // render functions
  41767. if (render) {
  41768. options.render = render
  41769. options.staticRenderFns = staticRenderFns
  41770. options._compiled = true
  41771. }
  41772. // functional template
  41773. if (functionalTemplate) {
  41774. options.functional = true
  41775. }
  41776. // scopedId
  41777. if (scopeId) {
  41778. options._scopeId = 'data-v-' + scopeId
  41779. }
  41780. var hook
  41781. if (moduleIdentifier) { // server build
  41782. hook = function (context) {
  41783. // 2.3 injection
  41784. context =
  41785. context || // cached call
  41786. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41787. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41788. // 2.2 with runInNewContext: true
  41789. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41790. context = __VUE_SSR_CONTEXT__
  41791. }
  41792. // inject component styles
  41793. if (injectStyles) {
  41794. injectStyles.call(this, context)
  41795. }
  41796. // register component module identifier for async chunk inferrence
  41797. if (context && context._registeredComponents) {
  41798. context._registeredComponents.add(moduleIdentifier)
  41799. }
  41800. }
  41801. // used by ssr in case component is cached and beforeCreate
  41802. // never gets called
  41803. options._ssrRegister = hook
  41804. } else if (injectStyles) {
  41805. hook = shadowMode
  41806. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41807. : injectStyles
  41808. }
  41809. if (hook) {
  41810. if (options.functional) {
  41811. // for template-only hot-reload because in that case the render fn doesn't
  41812. // go through the normalizer
  41813. options._injectStyles = hook
  41814. // register for functioal component in vue file
  41815. var originalRender = options.render
  41816. options.render = function renderWithStyleInjection (h, context) {
  41817. hook.call(context)
  41818. return originalRender(h, context)
  41819. }
  41820. } else {
  41821. // inject component registration as beforeCreate hook
  41822. var existing = options.beforeCreate
  41823. options.beforeCreate = existing
  41824. ? [].concat(existing, hook)
  41825. : [hook]
  41826. }
  41827. }
  41828. return {
  41829. exports: scriptExports,
  41830. options: options
  41831. }
  41832. }
  41833. /***/ }),
  41834. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41835. /*!*************************************************!*\
  41836. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41837. \*************************************************/
  41838. /*! no static exports found */
  41839. /***/ (function(module, exports, __webpack_require__) {
  41840. "use strict";
  41841. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41842. * Vue.js v2.6.11
  41843. * (c) 2014-2019 Evan You
  41844. * Released under the MIT License.
  41845. */
  41846. /* */
  41847. var emptyObject = Object.freeze({});
  41848. // These helpers produce better VM code in JS engines due to their
  41849. // explicitness and function inlining.
  41850. function isUndef (v) {
  41851. return v === undefined || v === null
  41852. }
  41853. function isDef (v) {
  41854. return v !== undefined && v !== null
  41855. }
  41856. function isTrue (v) {
  41857. return v === true
  41858. }
  41859. function isFalse (v) {
  41860. return v === false
  41861. }
  41862. /**
  41863. * Check if value is primitive.
  41864. */
  41865. function isPrimitive (value) {
  41866. return (
  41867. typeof value === 'string' ||
  41868. typeof value === 'number' ||
  41869. // $flow-disable-line
  41870. typeof value === 'symbol' ||
  41871. typeof value === 'boolean'
  41872. )
  41873. }
  41874. /**
  41875. * Quick object check - this is primarily used to tell
  41876. * Objects from primitive values when we know the value
  41877. * is a JSON-compliant type.
  41878. */
  41879. function isObject (obj) {
  41880. return obj !== null && typeof obj === 'object'
  41881. }
  41882. /**
  41883. * Get the raw type string of a value, e.g., [object Object].
  41884. */
  41885. var _toString = Object.prototype.toString;
  41886. function toRawType (value) {
  41887. return _toString.call(value).slice(8, -1)
  41888. }
  41889. /**
  41890. * Strict object type check. Only returns true
  41891. * for plain JavaScript objects.
  41892. */
  41893. function isPlainObject (obj) {
  41894. return _toString.call(obj) === '[object Object]'
  41895. }
  41896. function isRegExp (v) {
  41897. return _toString.call(v) === '[object RegExp]'
  41898. }
  41899. /**
  41900. * Check if val is a valid array index.
  41901. */
  41902. function isValidArrayIndex (val) {
  41903. var n = parseFloat(String(val));
  41904. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41905. }
  41906. function isPromise (val) {
  41907. return (
  41908. isDef(val) &&
  41909. typeof val.then === 'function' &&
  41910. typeof val.catch === 'function'
  41911. )
  41912. }
  41913. /**
  41914. * Convert a value to a string that is actually rendered.
  41915. */
  41916. function toString (val) {
  41917. return val == null
  41918. ? ''
  41919. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41920. ? JSON.stringify(val, null, 2)
  41921. : String(val)
  41922. }
  41923. /**
  41924. * Convert an input value to a number for persistence.
  41925. * If the conversion fails, return original string.
  41926. */
  41927. function toNumber (val) {
  41928. var n = parseFloat(val);
  41929. return isNaN(n) ? val : n
  41930. }
  41931. /**
  41932. * Make a map and return a function for checking if a key
  41933. * is in that map.
  41934. */
  41935. function makeMap (
  41936. str,
  41937. expectsLowerCase
  41938. ) {
  41939. var map = Object.create(null);
  41940. var list = str.split(',');
  41941. for (var i = 0; i < list.length; i++) {
  41942. map[list[i]] = true;
  41943. }
  41944. return expectsLowerCase
  41945. ? function (val) { return map[val.toLowerCase()]; }
  41946. : function (val) { return map[val]; }
  41947. }
  41948. /**
  41949. * Check if a tag is a built-in tag.
  41950. */
  41951. var isBuiltInTag = makeMap('slot,component', true);
  41952. /**
  41953. * Check if an attribute is a reserved attribute.
  41954. */
  41955. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41956. /**
  41957. * Remove an item from an array.
  41958. */
  41959. function remove (arr, item) {
  41960. if (arr.length) {
  41961. var index = arr.indexOf(item);
  41962. if (index > -1) {
  41963. return arr.splice(index, 1)
  41964. }
  41965. }
  41966. }
  41967. /**
  41968. * Check whether an object has the property.
  41969. */
  41970. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41971. function hasOwn (obj, key) {
  41972. return hasOwnProperty.call(obj, key)
  41973. }
  41974. /**
  41975. * Create a cached version of a pure function.
  41976. */
  41977. function cached (fn) {
  41978. var cache = Object.create(null);
  41979. return (function cachedFn (str) {
  41980. var hit = cache[str];
  41981. return hit || (cache[str] = fn(str))
  41982. })
  41983. }
  41984. /**
  41985. * Camelize a hyphen-delimited string.
  41986. */
  41987. var camelizeRE = /-(\w)/g;
  41988. var camelize = cached(function (str) {
  41989. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41990. });
  41991. /**
  41992. * Capitalize a string.
  41993. */
  41994. var capitalize = cached(function (str) {
  41995. return str.charAt(0).toUpperCase() + str.slice(1)
  41996. });
  41997. /**
  41998. * Hyphenate a camelCase string.
  41999. */
  42000. var hyphenateRE = /\B([A-Z])/g;
  42001. var hyphenate = cached(function (str) {
  42002. return str.replace(hyphenateRE, '-$1').toLowerCase()
  42003. });
  42004. /**
  42005. * Simple bind polyfill for environments that do not support it,
  42006. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  42007. * since native bind is now performant enough in most browsers.
  42008. * But removing it would mean breaking code that was able to run in
  42009. * PhantomJS 1.x, so this must be kept for backward compatibility.
  42010. */
  42011. /* istanbul ignore next */
  42012. function polyfillBind (fn, ctx) {
  42013. function boundFn (a) {
  42014. var l = arguments.length;
  42015. return l
  42016. ? l > 1
  42017. ? fn.apply(ctx, arguments)
  42018. : fn.call(ctx, a)
  42019. : fn.call(ctx)
  42020. }
  42021. boundFn._length = fn.length;
  42022. return boundFn
  42023. }
  42024. function nativeBind (fn, ctx) {
  42025. return fn.bind(ctx)
  42026. }
  42027. var bind = Function.prototype.bind
  42028. ? nativeBind
  42029. : polyfillBind;
  42030. /**
  42031. * Convert an Array-like object to a real Array.
  42032. */
  42033. function toArray (list, start) {
  42034. start = start || 0;
  42035. var i = list.length - start;
  42036. var ret = new Array(i);
  42037. while (i--) {
  42038. ret[i] = list[i + start];
  42039. }
  42040. return ret
  42041. }
  42042. /**
  42043. * Mix properties into target object.
  42044. */
  42045. function extend (to, _from) {
  42046. for (var key in _from) {
  42047. to[key] = _from[key];
  42048. }
  42049. return to
  42050. }
  42051. /**
  42052. * Merge an Array of Objects into a single Object.
  42053. */
  42054. function toObject (arr) {
  42055. var res = {};
  42056. for (var i = 0; i < arr.length; i++) {
  42057. if (arr[i]) {
  42058. extend(res, arr[i]);
  42059. }
  42060. }
  42061. return res
  42062. }
  42063. /* eslint-disable no-unused-vars */
  42064. /**
  42065. * Perform no operation.
  42066. * Stubbing args to make Flow happy without leaving useless transpiled code
  42067. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  42068. */
  42069. function noop (a, b, c) {}
  42070. /**
  42071. * Always return false.
  42072. */
  42073. var no = function (a, b, c) { return false; };
  42074. /* eslint-enable no-unused-vars */
  42075. /**
  42076. * Return the same value.
  42077. */
  42078. var identity = function (_) { return _; };
  42079. /**
  42080. * Generate a string containing static keys from compiler modules.
  42081. */
  42082. function genStaticKeys (modules) {
  42083. return modules.reduce(function (keys, m) {
  42084. return keys.concat(m.staticKeys || [])
  42085. }, []).join(',')
  42086. }
  42087. /**
  42088. * Check if two values are loosely equal - that is,
  42089. * if they are plain objects, do they have the same shape?
  42090. */
  42091. function looseEqual (a, b) {
  42092. if (a === b) { return true }
  42093. var isObjectA = isObject(a);
  42094. var isObjectB = isObject(b);
  42095. if (isObjectA && isObjectB) {
  42096. try {
  42097. var isArrayA = Array.isArray(a);
  42098. var isArrayB = Array.isArray(b);
  42099. if (isArrayA && isArrayB) {
  42100. return a.length === b.length && a.every(function (e, i) {
  42101. return looseEqual(e, b[i])
  42102. })
  42103. } else if (a instanceof Date && b instanceof Date) {
  42104. return a.getTime() === b.getTime()
  42105. } else if (!isArrayA && !isArrayB) {
  42106. var keysA = Object.keys(a);
  42107. var keysB = Object.keys(b);
  42108. return keysA.length === keysB.length && keysA.every(function (key) {
  42109. return looseEqual(a[key], b[key])
  42110. })
  42111. } else {
  42112. /* istanbul ignore next */
  42113. return false
  42114. }
  42115. } catch (e) {
  42116. /* istanbul ignore next */
  42117. return false
  42118. }
  42119. } else if (!isObjectA && !isObjectB) {
  42120. return String(a) === String(b)
  42121. } else {
  42122. return false
  42123. }
  42124. }
  42125. /**
  42126. * Return the first index at which a loosely equal value can be
  42127. * found in the array (if value is a plain object, the array must
  42128. * contain an object of the same shape), or -1 if it is not present.
  42129. */
  42130. function looseIndexOf (arr, val) {
  42131. for (var i = 0; i < arr.length; i++) {
  42132. if (looseEqual(arr[i], val)) { return i }
  42133. }
  42134. return -1
  42135. }
  42136. /**
  42137. * Ensure a function is called only once.
  42138. */
  42139. function once (fn) {
  42140. var called = false;
  42141. return function () {
  42142. if (!called) {
  42143. called = true;
  42144. fn.apply(this, arguments);
  42145. }
  42146. }
  42147. }
  42148. var SSR_ATTR = 'data-server-rendered';
  42149. var ASSET_TYPES = [
  42150. 'component',
  42151. 'directive',
  42152. 'filter'
  42153. ];
  42154. var LIFECYCLE_HOOKS = [
  42155. 'beforeCreate',
  42156. 'created',
  42157. 'beforeMount',
  42158. 'mounted',
  42159. 'beforeUpdate',
  42160. 'updated',
  42161. 'beforeDestroy',
  42162. 'destroyed',
  42163. 'activated',
  42164. 'deactivated',
  42165. 'errorCaptured',
  42166. 'serverPrefetch'
  42167. ];
  42168. /* */
  42169. var config = ({
  42170. /**
  42171. * Option merge strategies (used in core/util/options)
  42172. */
  42173. // $flow-disable-line
  42174. optionMergeStrategies: Object.create(null),
  42175. /**
  42176. * Whether to suppress warnings.
  42177. */
  42178. silent: false,
  42179. /**
  42180. * Show production mode tip message on boot?
  42181. */
  42182. productionTip: "development" !== 'production',
  42183. /**
  42184. * Whether to enable devtools
  42185. */
  42186. devtools: "development" !== 'production',
  42187. /**
  42188. * Whether to record perf
  42189. */
  42190. performance: false,
  42191. /**
  42192. * Error handler for watcher errors
  42193. */
  42194. errorHandler: null,
  42195. /**
  42196. * Warn handler for watcher warns
  42197. */
  42198. warnHandler: null,
  42199. /**
  42200. * Ignore certain custom elements
  42201. */
  42202. ignoredElements: [],
  42203. /**
  42204. * Custom user key aliases for v-on
  42205. */
  42206. // $flow-disable-line
  42207. keyCodes: Object.create(null),
  42208. /**
  42209. * Check if a tag is reserved so that it cannot be registered as a
  42210. * component. This is platform-dependent and may be overwritten.
  42211. */
  42212. isReservedTag: no,
  42213. /**
  42214. * Check if an attribute is reserved so that it cannot be used as a component
  42215. * prop. This is platform-dependent and may be overwritten.
  42216. */
  42217. isReservedAttr: no,
  42218. /**
  42219. * Check if a tag is an unknown element.
  42220. * Platform-dependent.
  42221. */
  42222. isUnknownElement: no,
  42223. /**
  42224. * Get the namespace of an element
  42225. */
  42226. getTagNamespace: noop,
  42227. /**
  42228. * Parse the real tag name for the specific platform.
  42229. */
  42230. parsePlatformTagName: identity,
  42231. /**
  42232. * Check if an attribute must be bound using property, e.g. value
  42233. * Platform-dependent.
  42234. */
  42235. mustUseProp: no,
  42236. /**
  42237. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42238. * This will significantly reduce performance if set to false.
  42239. */
  42240. async: true,
  42241. /**
  42242. * Exposed for legacy reasons
  42243. */
  42244. _lifecycleHooks: LIFECYCLE_HOOKS
  42245. });
  42246. /* */
  42247. /**
  42248. * unicode letters used for parsing html tags, component names and property paths.
  42249. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42250. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42251. */
  42252. 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/;
  42253. /**
  42254. * Check if a string starts with $ or _
  42255. */
  42256. function isReserved (str) {
  42257. var c = (str + '').charCodeAt(0);
  42258. return c === 0x24 || c === 0x5F
  42259. }
  42260. /**
  42261. * Define a property.
  42262. */
  42263. function def (obj, key, val, enumerable) {
  42264. Object.defineProperty(obj, key, {
  42265. value: val,
  42266. enumerable: !!enumerable,
  42267. writable: true,
  42268. configurable: true
  42269. });
  42270. }
  42271. /**
  42272. * Parse simple path.
  42273. */
  42274. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42275. function parsePath (path) {
  42276. if (bailRE.test(path)) {
  42277. return
  42278. }
  42279. var segments = path.split('.');
  42280. return function (obj) {
  42281. for (var i = 0; i < segments.length; i++) {
  42282. if (!obj) { return }
  42283. obj = obj[segments[i]];
  42284. }
  42285. return obj
  42286. }
  42287. }
  42288. /* */
  42289. // can we use __proto__?
  42290. var hasProto = '__proto__' in {};
  42291. // Browser environment sniffing
  42292. var inBrowser = typeof window !== 'undefined';
  42293. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42294. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42295. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42296. var isIE = UA && /msie|trident/.test(UA);
  42297. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42298. var isEdge = UA && UA.indexOf('edge/') > 0;
  42299. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42300. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42301. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42302. var isPhantomJS = UA && /phantomjs/.test(UA);
  42303. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42304. // Firefox has a "watch" function on Object.prototype...
  42305. var nativeWatch = ({}).watch;
  42306. var supportsPassive = false;
  42307. if (inBrowser) {
  42308. try {
  42309. var opts = {};
  42310. Object.defineProperty(opts, 'passive', ({
  42311. get: function get () {
  42312. /* istanbul ignore next */
  42313. supportsPassive = true;
  42314. }
  42315. })); // https://github.com/facebook/flow/issues/285
  42316. window.addEventListener('test-passive', null, opts);
  42317. } catch (e) {}
  42318. }
  42319. // this needs to be lazy-evaled because vue may be required before
  42320. // vue-server-renderer can set VUE_ENV
  42321. var _isServer;
  42322. var isServerRendering = function () {
  42323. if (_isServer === undefined) {
  42324. /* istanbul ignore if */
  42325. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42326. // detect presence of vue-server-renderer and avoid
  42327. // Webpack shimming the process
  42328. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42329. } else {
  42330. _isServer = false;
  42331. }
  42332. }
  42333. return _isServer
  42334. };
  42335. // detect devtools
  42336. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42337. /* istanbul ignore next */
  42338. function isNative (Ctor) {
  42339. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42340. }
  42341. var hasSymbol =
  42342. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42343. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42344. var _Set;
  42345. /* istanbul ignore if */ // $flow-disable-line
  42346. if (typeof Set !== 'undefined' && isNative(Set)) {
  42347. // use native Set when available.
  42348. _Set = Set;
  42349. } else {
  42350. // a non-standard Set polyfill that only works with primitive keys.
  42351. _Set = /*@__PURE__*/(function () {
  42352. function Set () {
  42353. this.set = Object.create(null);
  42354. }
  42355. Set.prototype.has = function has (key) {
  42356. return this.set[key] === true
  42357. };
  42358. Set.prototype.add = function add (key) {
  42359. this.set[key] = true;
  42360. };
  42361. Set.prototype.clear = function clear () {
  42362. this.set = Object.create(null);
  42363. };
  42364. return Set;
  42365. }());
  42366. }
  42367. /* */
  42368. var warn = noop;
  42369. var tip = noop;
  42370. var generateComponentTrace = (noop); // work around flow check
  42371. var formatComponentName = (noop);
  42372. {
  42373. var hasConsole = typeof console !== 'undefined';
  42374. var classifyRE = /(?:^|[-_])(\w)/g;
  42375. var classify = function (str) { return str
  42376. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42377. .replace(/[-_]/g, ''); };
  42378. warn = function (msg, vm) {
  42379. var trace = vm ? generateComponentTrace(vm) : '';
  42380. if (config.warnHandler) {
  42381. config.warnHandler.call(null, msg, vm, trace);
  42382. } else if (hasConsole && (!config.silent)) {
  42383. console.error(("[Vue warn]: " + msg + trace));
  42384. }
  42385. };
  42386. tip = function (msg, vm) {
  42387. if (hasConsole && (!config.silent)) {
  42388. console.warn("[Vue tip]: " + msg + (
  42389. vm ? generateComponentTrace(vm) : ''
  42390. ));
  42391. }
  42392. };
  42393. formatComponentName = function (vm, includeFile) {
  42394. if (vm.$root === vm) {
  42395. return '<Root>'
  42396. }
  42397. var options = typeof vm === 'function' && vm.cid != null
  42398. ? vm.options
  42399. : vm._isVue
  42400. ? vm.$options || vm.constructor.options
  42401. : vm;
  42402. var name = options.name || options._componentTag;
  42403. var file = options.__file;
  42404. if (!name && file) {
  42405. var match = file.match(/([^/\\]+)\.vue$/);
  42406. name = match && match[1];
  42407. }
  42408. return (
  42409. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42410. (file && includeFile !== false ? (" at " + file) : '')
  42411. )
  42412. };
  42413. var repeat = function (str, n) {
  42414. var res = '';
  42415. while (n) {
  42416. if (n % 2 === 1) { res += str; }
  42417. if (n > 1) { str += str; }
  42418. n >>= 1;
  42419. }
  42420. return res
  42421. };
  42422. generateComponentTrace = function (vm) {
  42423. if (vm._isVue && vm.$parent) {
  42424. var tree = [];
  42425. var currentRecursiveSequence = 0;
  42426. while (vm) {
  42427. if (tree.length > 0) {
  42428. var last = tree[tree.length - 1];
  42429. if (last.constructor === vm.constructor) {
  42430. currentRecursiveSequence++;
  42431. vm = vm.$parent;
  42432. continue
  42433. } else if (currentRecursiveSequence > 0) {
  42434. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42435. currentRecursiveSequence = 0;
  42436. }
  42437. }
  42438. tree.push(vm);
  42439. vm = vm.$parent;
  42440. }
  42441. return '\n\nfound in\n\n' + tree
  42442. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42443. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42444. : formatComponentName(vm))); })
  42445. .join('\n')
  42446. } else {
  42447. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42448. }
  42449. };
  42450. }
  42451. /* */
  42452. var uid = 0;
  42453. /**
  42454. * A dep is an observable that can have multiple
  42455. * directives subscribing to it.
  42456. */
  42457. var Dep = function Dep () {
  42458. this.id = uid++;
  42459. this.subs = [];
  42460. };
  42461. Dep.prototype.addSub = function addSub (sub) {
  42462. this.subs.push(sub);
  42463. };
  42464. Dep.prototype.removeSub = function removeSub (sub) {
  42465. remove(this.subs, sub);
  42466. };
  42467. Dep.prototype.depend = function depend () {
  42468. if (Dep.target) {
  42469. Dep.target.addDep(this);
  42470. }
  42471. };
  42472. Dep.prototype.notify = function notify () {
  42473. // stabilize the subscriber list first
  42474. var subs = this.subs.slice();
  42475. if (!config.async) {
  42476. // subs aren't sorted in scheduler if not running async
  42477. // we need to sort them now to make sure they fire in correct
  42478. // order
  42479. subs.sort(function (a, b) { return a.id - b.id; });
  42480. }
  42481. for (var i = 0, l = subs.length; i < l; i++) {
  42482. subs[i].update();
  42483. }
  42484. };
  42485. // The current target watcher being evaluated.
  42486. // This is globally unique because only one watcher
  42487. // can be evaluated at a time.
  42488. Dep.target = null;
  42489. var targetStack = [];
  42490. function pushTarget (target) {
  42491. targetStack.push(target);
  42492. Dep.target = target;
  42493. }
  42494. function popTarget () {
  42495. targetStack.pop();
  42496. Dep.target = targetStack[targetStack.length - 1];
  42497. }
  42498. /* */
  42499. var VNode = function VNode (
  42500. tag,
  42501. data,
  42502. children,
  42503. text,
  42504. elm,
  42505. context,
  42506. componentOptions,
  42507. asyncFactory
  42508. ) {
  42509. this.tag = tag;
  42510. this.data = data;
  42511. this.children = children;
  42512. this.text = text;
  42513. this.elm = elm;
  42514. this.ns = undefined;
  42515. this.context = context;
  42516. this.fnContext = undefined;
  42517. this.fnOptions = undefined;
  42518. this.fnScopeId = undefined;
  42519. this.key = data && data.key;
  42520. this.componentOptions = componentOptions;
  42521. this.componentInstance = undefined;
  42522. this.parent = undefined;
  42523. this.raw = false;
  42524. this.isStatic = false;
  42525. this.isRootInsert = true;
  42526. this.isComment = false;
  42527. this.isCloned = false;
  42528. this.isOnce = false;
  42529. this.asyncFactory = asyncFactory;
  42530. this.asyncMeta = undefined;
  42531. this.isAsyncPlaceholder = false;
  42532. };
  42533. var prototypeAccessors = { child: { configurable: true } };
  42534. // DEPRECATED: alias for componentInstance for backwards compat.
  42535. /* istanbul ignore next */
  42536. prototypeAccessors.child.get = function () {
  42537. return this.componentInstance
  42538. };
  42539. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42540. var createEmptyVNode = function (text) {
  42541. if ( text === void 0 ) text = '';
  42542. var node = new VNode();
  42543. node.text = text;
  42544. node.isComment = true;
  42545. return node
  42546. };
  42547. function createTextVNode (val) {
  42548. return new VNode(undefined, undefined, undefined, String(val))
  42549. }
  42550. // optimized shallow clone
  42551. // used for static nodes and slot nodes because they may be reused across
  42552. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42553. // on their elm reference.
  42554. function cloneVNode (vnode) {
  42555. var cloned = new VNode(
  42556. vnode.tag,
  42557. vnode.data,
  42558. // #7975
  42559. // clone children array to avoid mutating original in case of cloning
  42560. // a child.
  42561. vnode.children && vnode.children.slice(),
  42562. vnode.text,
  42563. vnode.elm,
  42564. vnode.context,
  42565. vnode.componentOptions,
  42566. vnode.asyncFactory
  42567. );
  42568. cloned.ns = vnode.ns;
  42569. cloned.isStatic = vnode.isStatic;
  42570. cloned.key = vnode.key;
  42571. cloned.isComment = vnode.isComment;
  42572. cloned.fnContext = vnode.fnContext;
  42573. cloned.fnOptions = vnode.fnOptions;
  42574. cloned.fnScopeId = vnode.fnScopeId;
  42575. cloned.asyncMeta = vnode.asyncMeta;
  42576. cloned.isCloned = true;
  42577. return cloned
  42578. }
  42579. /*
  42580. * not type checking this file because flow doesn't play well with
  42581. * dynamically accessing methods on Array prototype
  42582. */
  42583. var arrayProto = Array.prototype;
  42584. var arrayMethods = Object.create(arrayProto);
  42585. var methodsToPatch = [
  42586. 'push',
  42587. 'pop',
  42588. 'shift',
  42589. 'unshift',
  42590. 'splice',
  42591. 'sort',
  42592. 'reverse'
  42593. ];
  42594. /**
  42595. * Intercept mutating methods and emit events
  42596. */
  42597. methodsToPatch.forEach(function (method) {
  42598. // cache original method
  42599. var original = arrayProto[method];
  42600. def(arrayMethods, method, function mutator () {
  42601. var args = [], len = arguments.length;
  42602. while ( len-- ) args[ len ] = arguments[ len ];
  42603. var result = original.apply(this, args);
  42604. var ob = this.__ob__;
  42605. var inserted;
  42606. switch (method) {
  42607. case 'push':
  42608. case 'unshift':
  42609. inserted = args;
  42610. break
  42611. case 'splice':
  42612. inserted = args.slice(2);
  42613. break
  42614. }
  42615. if (inserted) { ob.observeArray(inserted); }
  42616. // notify change
  42617. ob.dep.notify();
  42618. return result
  42619. });
  42620. });
  42621. /* */
  42622. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42623. /**
  42624. * In some cases we may want to disable observation inside a component's
  42625. * update computation.
  42626. */
  42627. var shouldObserve = true;
  42628. function toggleObserving (value) {
  42629. shouldObserve = value;
  42630. }
  42631. /**
  42632. * Observer class that is attached to each observed
  42633. * object. Once attached, the observer converts the target
  42634. * object's property keys into getter/setters that
  42635. * collect dependencies and dispatch updates.
  42636. */
  42637. var Observer = function Observer (value) {
  42638. this.value = value;
  42639. this.dep = new Dep();
  42640. this.vmCount = 0;
  42641. def(value, '__ob__', this);
  42642. if (Array.isArray(value)) {
  42643. if (hasProto) {
  42644. protoAugment(value, arrayMethods);
  42645. } else {
  42646. copyAugment(value, arrayMethods, arrayKeys);
  42647. }
  42648. this.observeArray(value);
  42649. } else {
  42650. this.walk(value);
  42651. }
  42652. };
  42653. /**
  42654. * Walk through all properties and convert them into
  42655. * getter/setters. This method should only be called when
  42656. * value type is Object.
  42657. */
  42658. Observer.prototype.walk = function walk (obj) {
  42659. var keys = Object.keys(obj);
  42660. for (var i = 0; i < keys.length; i++) {
  42661. defineReactive$$1(obj, keys[i]);
  42662. }
  42663. };
  42664. /**
  42665. * Observe a list of Array items.
  42666. */
  42667. Observer.prototype.observeArray = function observeArray (items) {
  42668. for (var i = 0, l = items.length; i < l; i++) {
  42669. observe(items[i]);
  42670. }
  42671. };
  42672. // helpers
  42673. /**
  42674. * Augment a target Object or Array by intercepting
  42675. * the prototype chain using __proto__
  42676. */
  42677. function protoAugment (target, src) {
  42678. /* eslint-disable no-proto */
  42679. target.__proto__ = src;
  42680. /* eslint-enable no-proto */
  42681. }
  42682. /**
  42683. * Augment a target Object or Array by defining
  42684. * hidden properties.
  42685. */
  42686. /* istanbul ignore next */
  42687. function copyAugment (target, src, keys) {
  42688. for (var i = 0, l = keys.length; i < l; i++) {
  42689. var key = keys[i];
  42690. def(target, key, src[key]);
  42691. }
  42692. }
  42693. /**
  42694. * Attempt to create an observer instance for a value,
  42695. * returns the new observer if successfully observed,
  42696. * or the existing observer if the value already has one.
  42697. */
  42698. function observe (value, asRootData) {
  42699. if (!isObject(value) || value instanceof VNode) {
  42700. return
  42701. }
  42702. var ob;
  42703. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42704. ob = value.__ob__;
  42705. } else if (
  42706. shouldObserve &&
  42707. !isServerRendering() &&
  42708. (Array.isArray(value) || isPlainObject(value)) &&
  42709. Object.isExtensible(value) &&
  42710. !value._isVue
  42711. ) {
  42712. ob = new Observer(value);
  42713. }
  42714. if (asRootData && ob) {
  42715. ob.vmCount++;
  42716. }
  42717. return ob
  42718. }
  42719. /**
  42720. * Define a reactive property on an Object.
  42721. */
  42722. function defineReactive$$1 (
  42723. obj,
  42724. key,
  42725. val,
  42726. customSetter,
  42727. shallow
  42728. ) {
  42729. var dep = new Dep();
  42730. var property = Object.getOwnPropertyDescriptor(obj, key);
  42731. if (property && property.configurable === false) {
  42732. return
  42733. }
  42734. // cater for pre-defined getter/setters
  42735. var getter = property && property.get;
  42736. var setter = property && property.set;
  42737. if ((!getter || setter) && arguments.length === 2) {
  42738. val = obj[key];
  42739. }
  42740. var childOb = !shallow && observe(val);
  42741. Object.defineProperty(obj, key, {
  42742. enumerable: true,
  42743. configurable: true,
  42744. get: function reactiveGetter () {
  42745. var value = getter ? getter.call(obj) : val;
  42746. if (Dep.target) {
  42747. dep.depend();
  42748. if (childOb) {
  42749. childOb.dep.depend();
  42750. if (Array.isArray(value)) {
  42751. dependArray(value);
  42752. }
  42753. }
  42754. }
  42755. return value
  42756. },
  42757. set: function reactiveSetter (newVal) {
  42758. var value = getter ? getter.call(obj) : val;
  42759. /* eslint-disable no-self-compare */
  42760. if (newVal === value || (newVal !== newVal && value !== value)) {
  42761. return
  42762. }
  42763. /* eslint-enable no-self-compare */
  42764. if (customSetter) {
  42765. customSetter();
  42766. }
  42767. // #7981: for accessor properties without setter
  42768. if (getter && !setter) { return }
  42769. if (setter) {
  42770. setter.call(obj, newVal);
  42771. } else {
  42772. val = newVal;
  42773. }
  42774. childOb = !shallow && observe(newVal);
  42775. dep.notify();
  42776. }
  42777. });
  42778. }
  42779. /**
  42780. * Set a property on an object. Adds the new property and
  42781. * triggers change notification if the property doesn't
  42782. * already exist.
  42783. */
  42784. function set (target, key, val) {
  42785. if (isUndef(target) || isPrimitive(target)
  42786. ) {
  42787. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42788. }
  42789. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42790. target.length = Math.max(target.length, key);
  42791. target.splice(key, 1, val);
  42792. return val
  42793. }
  42794. if (key in target && !(key in Object.prototype)) {
  42795. target[key] = val;
  42796. return val
  42797. }
  42798. var ob = (target).__ob__;
  42799. if (target._isVue || (ob && ob.vmCount)) {
  42800. warn(
  42801. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42802. 'at runtime - declare it upfront in the data option.'
  42803. );
  42804. return val
  42805. }
  42806. if (!ob) {
  42807. target[key] = val;
  42808. return val
  42809. }
  42810. defineReactive$$1(ob.value, key, val);
  42811. ob.dep.notify();
  42812. return val
  42813. }
  42814. /**
  42815. * Delete a property and trigger change if necessary.
  42816. */
  42817. function del (target, key) {
  42818. if (isUndef(target) || isPrimitive(target)
  42819. ) {
  42820. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42821. }
  42822. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42823. target.splice(key, 1);
  42824. return
  42825. }
  42826. var ob = (target).__ob__;
  42827. if (target._isVue || (ob && ob.vmCount)) {
  42828. warn(
  42829. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42830. '- just set it to null.'
  42831. );
  42832. return
  42833. }
  42834. if (!hasOwn(target, key)) {
  42835. return
  42836. }
  42837. delete target[key];
  42838. if (!ob) {
  42839. return
  42840. }
  42841. ob.dep.notify();
  42842. }
  42843. /**
  42844. * Collect dependencies on array elements when the array is touched, since
  42845. * we cannot intercept array element access like property getters.
  42846. */
  42847. function dependArray (value) {
  42848. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42849. e = value[i];
  42850. e && e.__ob__ && e.__ob__.dep.depend();
  42851. if (Array.isArray(e)) {
  42852. dependArray(e);
  42853. }
  42854. }
  42855. }
  42856. /* */
  42857. /**
  42858. * Option overwriting strategies are functions that handle
  42859. * how to merge a parent option value and a child option
  42860. * value into the final value.
  42861. */
  42862. var strats = config.optionMergeStrategies;
  42863. /**
  42864. * Options with restrictions
  42865. */
  42866. {
  42867. strats.el = strats.propsData = function (parent, child, vm, key) {
  42868. if (!vm) {
  42869. warn(
  42870. "option \"" + key + "\" can only be used during instance " +
  42871. 'creation with the `new` keyword.'
  42872. );
  42873. }
  42874. return defaultStrat(parent, child)
  42875. };
  42876. }
  42877. /**
  42878. * Helper that recursively merges two data objects together.
  42879. */
  42880. function mergeData (to, from) {
  42881. if (!from) { return to }
  42882. var key, toVal, fromVal;
  42883. var keys = hasSymbol
  42884. ? Reflect.ownKeys(from)
  42885. : Object.keys(from);
  42886. for (var i = 0; i < keys.length; i++) {
  42887. key = keys[i];
  42888. // in case the object is already observed...
  42889. if (key === '__ob__') { continue }
  42890. toVal = to[key];
  42891. fromVal = from[key];
  42892. if (!hasOwn(to, key)) {
  42893. set(to, key, fromVal);
  42894. } else if (
  42895. toVal !== fromVal &&
  42896. isPlainObject(toVal) &&
  42897. isPlainObject(fromVal)
  42898. ) {
  42899. mergeData(toVal, fromVal);
  42900. }
  42901. }
  42902. return to
  42903. }
  42904. /**
  42905. * Data
  42906. */
  42907. function mergeDataOrFn (
  42908. parentVal,
  42909. childVal,
  42910. vm
  42911. ) {
  42912. if (!vm) {
  42913. // in a Vue.extend merge, both should be functions
  42914. if (!childVal) {
  42915. return parentVal
  42916. }
  42917. if (!parentVal) {
  42918. return childVal
  42919. }
  42920. // when parentVal & childVal are both present,
  42921. // we need to return a function that returns the
  42922. // merged result of both functions... no need to
  42923. // check if parentVal is a function here because
  42924. // it has to be a function to pass previous merges.
  42925. return function mergedDataFn () {
  42926. return mergeData(
  42927. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42928. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42929. )
  42930. }
  42931. } else {
  42932. return function mergedInstanceDataFn () {
  42933. // instance merge
  42934. var instanceData = typeof childVal === 'function'
  42935. ? childVal.call(vm, vm)
  42936. : childVal;
  42937. var defaultData = typeof parentVal === 'function'
  42938. ? parentVal.call(vm, vm)
  42939. : parentVal;
  42940. if (instanceData) {
  42941. return mergeData(instanceData, defaultData)
  42942. } else {
  42943. return defaultData
  42944. }
  42945. }
  42946. }
  42947. }
  42948. strats.data = function (
  42949. parentVal,
  42950. childVal,
  42951. vm
  42952. ) {
  42953. if (!vm) {
  42954. if (childVal && typeof childVal !== 'function') {
  42955. warn(
  42956. 'The "data" option should be a function ' +
  42957. 'that returns a per-instance value in component ' +
  42958. 'definitions.',
  42959. vm
  42960. );
  42961. return parentVal
  42962. }
  42963. return mergeDataOrFn(parentVal, childVal)
  42964. }
  42965. return mergeDataOrFn(parentVal, childVal, vm)
  42966. };
  42967. /**
  42968. * Hooks and props are merged as arrays.
  42969. */
  42970. function mergeHook (
  42971. parentVal,
  42972. childVal
  42973. ) {
  42974. var res = childVal
  42975. ? parentVal
  42976. ? parentVal.concat(childVal)
  42977. : Array.isArray(childVal)
  42978. ? childVal
  42979. : [childVal]
  42980. : parentVal;
  42981. return res
  42982. ? dedupeHooks(res)
  42983. : res
  42984. }
  42985. function dedupeHooks (hooks) {
  42986. var res = [];
  42987. for (var i = 0; i < hooks.length; i++) {
  42988. if (res.indexOf(hooks[i]) === -1) {
  42989. res.push(hooks[i]);
  42990. }
  42991. }
  42992. return res
  42993. }
  42994. LIFECYCLE_HOOKS.forEach(function (hook) {
  42995. strats[hook] = mergeHook;
  42996. });
  42997. /**
  42998. * Assets
  42999. *
  43000. * When a vm is present (instance creation), we need to do
  43001. * a three-way merge between constructor options, instance
  43002. * options and parent options.
  43003. */
  43004. function mergeAssets (
  43005. parentVal,
  43006. childVal,
  43007. vm,
  43008. key
  43009. ) {
  43010. var res = Object.create(parentVal || null);
  43011. if (childVal) {
  43012. assertObjectType(key, childVal, vm);
  43013. return extend(res, childVal)
  43014. } else {
  43015. return res
  43016. }
  43017. }
  43018. ASSET_TYPES.forEach(function (type) {
  43019. strats[type + 's'] = mergeAssets;
  43020. });
  43021. /**
  43022. * Watchers.
  43023. *
  43024. * Watchers hashes should not overwrite one
  43025. * another, so we merge them as arrays.
  43026. */
  43027. strats.watch = function (
  43028. parentVal,
  43029. childVal,
  43030. vm,
  43031. key
  43032. ) {
  43033. // work around Firefox's Object.prototype.watch...
  43034. if (parentVal === nativeWatch) { parentVal = undefined; }
  43035. if (childVal === nativeWatch) { childVal = undefined; }
  43036. /* istanbul ignore if */
  43037. if (!childVal) { return Object.create(parentVal || null) }
  43038. {
  43039. assertObjectType(key, childVal, vm);
  43040. }
  43041. if (!parentVal) { return childVal }
  43042. var ret = {};
  43043. extend(ret, parentVal);
  43044. for (var key$1 in childVal) {
  43045. var parent = ret[key$1];
  43046. var child = childVal[key$1];
  43047. if (parent && !Array.isArray(parent)) {
  43048. parent = [parent];
  43049. }
  43050. ret[key$1] = parent
  43051. ? parent.concat(child)
  43052. : Array.isArray(child) ? child : [child];
  43053. }
  43054. return ret
  43055. };
  43056. /**
  43057. * Other object hashes.
  43058. */
  43059. strats.props =
  43060. strats.methods =
  43061. strats.inject =
  43062. strats.computed = function (
  43063. parentVal,
  43064. childVal,
  43065. vm,
  43066. key
  43067. ) {
  43068. if (childVal && "development" !== 'production') {
  43069. assertObjectType(key, childVal, vm);
  43070. }
  43071. if (!parentVal) { return childVal }
  43072. var ret = Object.create(null);
  43073. extend(ret, parentVal);
  43074. if (childVal) { extend(ret, childVal); }
  43075. return ret
  43076. };
  43077. strats.provide = mergeDataOrFn;
  43078. /**
  43079. * Default strategy.
  43080. */
  43081. var defaultStrat = function (parentVal, childVal) {
  43082. return childVal === undefined
  43083. ? parentVal
  43084. : childVal
  43085. };
  43086. /**
  43087. * Validate component names
  43088. */
  43089. function checkComponents (options) {
  43090. for (var key in options.components) {
  43091. validateComponentName(key);
  43092. }
  43093. }
  43094. function validateComponentName (name) {
  43095. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  43096. warn(
  43097. 'Invalid component name: "' + name + '". Component names ' +
  43098. 'should conform to valid custom element name in html5 specification.'
  43099. );
  43100. }
  43101. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  43102. warn(
  43103. 'Do not use built-in or reserved HTML elements as component ' +
  43104. 'id: ' + name
  43105. );
  43106. }
  43107. }
  43108. /**
  43109. * Ensure all props option syntax are normalized into the
  43110. * Object-based format.
  43111. */
  43112. function normalizeProps (options, vm) {
  43113. var props = options.props;
  43114. if (!props) { return }
  43115. var res = {};
  43116. var i, val, name;
  43117. if (Array.isArray(props)) {
  43118. i = props.length;
  43119. while (i--) {
  43120. val = props[i];
  43121. if (typeof val === 'string') {
  43122. name = camelize(val);
  43123. res[name] = { type: null };
  43124. } else {
  43125. warn('props must be strings when using array syntax.');
  43126. }
  43127. }
  43128. } else if (isPlainObject(props)) {
  43129. for (var key in props) {
  43130. val = props[key];
  43131. name = camelize(key);
  43132. res[name] = isPlainObject(val)
  43133. ? val
  43134. : { type: val };
  43135. }
  43136. } else {
  43137. warn(
  43138. "Invalid value for option \"props\": expected an Array or an Object, " +
  43139. "but got " + (toRawType(props)) + ".",
  43140. vm
  43141. );
  43142. }
  43143. options.props = res;
  43144. }
  43145. /**
  43146. * Normalize all injections into Object-based format
  43147. */
  43148. function normalizeInject (options, vm) {
  43149. var inject = options.inject;
  43150. if (!inject) { return }
  43151. var normalized = options.inject = {};
  43152. if (Array.isArray(inject)) {
  43153. for (var i = 0; i < inject.length; i++) {
  43154. normalized[inject[i]] = { from: inject[i] };
  43155. }
  43156. } else if (isPlainObject(inject)) {
  43157. for (var key in inject) {
  43158. var val = inject[key];
  43159. normalized[key] = isPlainObject(val)
  43160. ? extend({ from: key }, val)
  43161. : { from: val };
  43162. }
  43163. } else {
  43164. warn(
  43165. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43166. "but got " + (toRawType(inject)) + ".",
  43167. vm
  43168. );
  43169. }
  43170. }
  43171. /**
  43172. * Normalize raw function directives into object format.
  43173. */
  43174. function normalizeDirectives (options) {
  43175. var dirs = options.directives;
  43176. if (dirs) {
  43177. for (var key in dirs) {
  43178. var def$$1 = dirs[key];
  43179. if (typeof def$$1 === 'function') {
  43180. dirs[key] = { bind: def$$1, update: def$$1 };
  43181. }
  43182. }
  43183. }
  43184. }
  43185. function assertObjectType (name, value, vm) {
  43186. if (!isPlainObject(value)) {
  43187. warn(
  43188. "Invalid value for option \"" + name + "\": expected an Object, " +
  43189. "but got " + (toRawType(value)) + ".",
  43190. vm
  43191. );
  43192. }
  43193. }
  43194. /**
  43195. * Merge two option objects into a new one.
  43196. * Core utility used in both instantiation and inheritance.
  43197. */
  43198. function mergeOptions (
  43199. parent,
  43200. child,
  43201. vm
  43202. ) {
  43203. {
  43204. checkComponents(child);
  43205. }
  43206. if (typeof child === 'function') {
  43207. child = child.options;
  43208. }
  43209. normalizeProps(child, vm);
  43210. normalizeInject(child, vm);
  43211. normalizeDirectives(child);
  43212. // Apply extends and mixins on the child options,
  43213. // but only if it is a raw options object that isn't
  43214. // the result of another mergeOptions call.
  43215. // Only merged options has the _base property.
  43216. if (!child._base) {
  43217. if (child.extends) {
  43218. parent = mergeOptions(parent, child.extends, vm);
  43219. }
  43220. if (child.mixins) {
  43221. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43222. parent = mergeOptions(parent, child.mixins[i], vm);
  43223. }
  43224. }
  43225. }
  43226. var options = {};
  43227. var key;
  43228. for (key in parent) {
  43229. mergeField(key);
  43230. }
  43231. for (key in child) {
  43232. if (!hasOwn(parent, key)) {
  43233. mergeField(key);
  43234. }
  43235. }
  43236. function mergeField (key) {
  43237. var strat = strats[key] || defaultStrat;
  43238. options[key] = strat(parent[key], child[key], vm, key);
  43239. }
  43240. return options
  43241. }
  43242. /**
  43243. * Resolve an asset.
  43244. * This function is used because child instances need access
  43245. * to assets defined in its ancestor chain.
  43246. */
  43247. function resolveAsset (
  43248. options,
  43249. type,
  43250. id,
  43251. warnMissing
  43252. ) {
  43253. /* istanbul ignore if */
  43254. if (typeof id !== 'string') {
  43255. return
  43256. }
  43257. var assets = options[type];
  43258. // check local registration variations first
  43259. if (hasOwn(assets, id)) { return assets[id] }
  43260. var camelizedId = camelize(id);
  43261. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43262. var PascalCaseId = capitalize(camelizedId);
  43263. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43264. // fallback to prototype chain
  43265. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43266. if (warnMissing && !res) {
  43267. warn(
  43268. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43269. options
  43270. );
  43271. }
  43272. return res
  43273. }
  43274. /* */
  43275. function validateProp (
  43276. key,
  43277. propOptions,
  43278. propsData,
  43279. vm
  43280. ) {
  43281. var prop = propOptions[key];
  43282. var absent = !hasOwn(propsData, key);
  43283. var value = propsData[key];
  43284. // boolean casting
  43285. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43286. if (booleanIndex > -1) {
  43287. if (absent && !hasOwn(prop, 'default')) {
  43288. value = false;
  43289. } else if (value === '' || value === hyphenate(key)) {
  43290. // only cast empty string / same name to boolean if
  43291. // boolean has higher priority
  43292. var stringIndex = getTypeIndex(String, prop.type);
  43293. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43294. value = true;
  43295. }
  43296. }
  43297. }
  43298. // check default value
  43299. if (value === undefined) {
  43300. value = getPropDefaultValue(vm, prop, key);
  43301. // since the default value is a fresh copy,
  43302. // make sure to observe it.
  43303. var prevShouldObserve = shouldObserve;
  43304. toggleObserving(true);
  43305. observe(value);
  43306. toggleObserving(prevShouldObserve);
  43307. }
  43308. {
  43309. assertProp(prop, key, value, vm, absent);
  43310. }
  43311. return value
  43312. }
  43313. /**
  43314. * Get the default value of a prop.
  43315. */
  43316. function getPropDefaultValue (vm, prop, key) {
  43317. // no default, return undefined
  43318. if (!hasOwn(prop, 'default')) {
  43319. return undefined
  43320. }
  43321. var def = prop.default;
  43322. // warn against non-factory defaults for Object & Array
  43323. if (isObject(def)) {
  43324. warn(
  43325. 'Invalid default value for prop "' + key + '": ' +
  43326. 'Props with type Object/Array must use a factory function ' +
  43327. 'to return the default value.',
  43328. vm
  43329. );
  43330. }
  43331. // the raw prop value was also undefined from previous render,
  43332. // return previous default value to avoid unnecessary watcher trigger
  43333. if (vm && vm.$options.propsData &&
  43334. vm.$options.propsData[key] === undefined &&
  43335. vm._props[key] !== undefined
  43336. ) {
  43337. return vm._props[key]
  43338. }
  43339. // call factory function for non-Function types
  43340. // a value is Function if its prototype is function even across different execution context
  43341. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43342. ? def.call(vm)
  43343. : def
  43344. }
  43345. /**
  43346. * Assert whether a prop is valid.
  43347. */
  43348. function assertProp (
  43349. prop,
  43350. name,
  43351. value,
  43352. vm,
  43353. absent
  43354. ) {
  43355. if (prop.required && absent) {
  43356. warn(
  43357. 'Missing required prop: "' + name + '"',
  43358. vm
  43359. );
  43360. return
  43361. }
  43362. if (value == null && !prop.required) {
  43363. return
  43364. }
  43365. var type = prop.type;
  43366. var valid = !type || type === true;
  43367. var expectedTypes = [];
  43368. if (type) {
  43369. if (!Array.isArray(type)) {
  43370. type = [type];
  43371. }
  43372. for (var i = 0; i < type.length && !valid; i++) {
  43373. var assertedType = assertType(value, type[i]);
  43374. expectedTypes.push(assertedType.expectedType || '');
  43375. valid = assertedType.valid;
  43376. }
  43377. }
  43378. if (!valid) {
  43379. warn(
  43380. getInvalidTypeMessage(name, value, expectedTypes),
  43381. vm
  43382. );
  43383. return
  43384. }
  43385. var validator = prop.validator;
  43386. if (validator) {
  43387. if (!validator(value)) {
  43388. warn(
  43389. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43390. vm
  43391. );
  43392. }
  43393. }
  43394. }
  43395. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43396. function assertType (value, type) {
  43397. var valid;
  43398. var expectedType = getType(type);
  43399. if (simpleCheckRE.test(expectedType)) {
  43400. var t = typeof value;
  43401. valid = t === expectedType.toLowerCase();
  43402. // for primitive wrapper objects
  43403. if (!valid && t === 'object') {
  43404. valid = value instanceof type;
  43405. }
  43406. } else if (expectedType === 'Object') {
  43407. valid = isPlainObject(value);
  43408. } else if (expectedType === 'Array') {
  43409. valid = Array.isArray(value);
  43410. } else {
  43411. valid = value instanceof type;
  43412. }
  43413. return {
  43414. valid: valid,
  43415. expectedType: expectedType
  43416. }
  43417. }
  43418. /**
  43419. * Use function string name to check built-in types,
  43420. * because a simple equality check will fail when running
  43421. * across different vms / iframes.
  43422. */
  43423. function getType (fn) {
  43424. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43425. return match ? match[1] : ''
  43426. }
  43427. function isSameType (a, b) {
  43428. return getType(a) === getType(b)
  43429. }
  43430. function getTypeIndex (type, expectedTypes) {
  43431. if (!Array.isArray(expectedTypes)) {
  43432. return isSameType(expectedTypes, type) ? 0 : -1
  43433. }
  43434. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43435. if (isSameType(expectedTypes[i], type)) {
  43436. return i
  43437. }
  43438. }
  43439. return -1
  43440. }
  43441. function getInvalidTypeMessage (name, value, expectedTypes) {
  43442. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43443. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43444. var expectedType = expectedTypes[0];
  43445. var receivedType = toRawType(value);
  43446. var expectedValue = styleValue(value, expectedType);
  43447. var receivedValue = styleValue(value, receivedType);
  43448. // check if we need to specify expected value
  43449. if (expectedTypes.length === 1 &&
  43450. isExplicable(expectedType) &&
  43451. !isBoolean(expectedType, receivedType)) {
  43452. message += " with value " + expectedValue;
  43453. }
  43454. message += ", got " + receivedType + " ";
  43455. // check if we need to specify received value
  43456. if (isExplicable(receivedType)) {
  43457. message += "with value " + receivedValue + ".";
  43458. }
  43459. return message
  43460. }
  43461. function styleValue (value, type) {
  43462. if (type === 'String') {
  43463. return ("\"" + value + "\"")
  43464. } else if (type === 'Number') {
  43465. return ("" + (Number(value)))
  43466. } else {
  43467. return ("" + value)
  43468. }
  43469. }
  43470. function isExplicable (value) {
  43471. var explicitTypes = ['string', 'number', 'boolean'];
  43472. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43473. }
  43474. function isBoolean () {
  43475. var args = [], len = arguments.length;
  43476. while ( len-- ) args[ len ] = arguments[ len ];
  43477. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43478. }
  43479. /* */
  43480. function handleError (err, vm, info) {
  43481. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43482. // See: https://github.com/vuejs/vuex/issues/1505
  43483. pushTarget();
  43484. try {
  43485. if (vm) {
  43486. var cur = vm;
  43487. while ((cur = cur.$parent)) {
  43488. var hooks = cur.$options.errorCaptured;
  43489. if (hooks) {
  43490. for (var i = 0; i < hooks.length; i++) {
  43491. try {
  43492. var capture = hooks[i].call(cur, err, vm, info) === false;
  43493. if (capture) { return }
  43494. } catch (e) {
  43495. globalHandleError(e, cur, 'errorCaptured hook');
  43496. }
  43497. }
  43498. }
  43499. }
  43500. }
  43501. globalHandleError(err, vm, info);
  43502. } finally {
  43503. popTarget();
  43504. }
  43505. }
  43506. function invokeWithErrorHandling (
  43507. handler,
  43508. context,
  43509. args,
  43510. vm,
  43511. info
  43512. ) {
  43513. var res;
  43514. try {
  43515. res = args ? handler.apply(context, args) : handler.call(context);
  43516. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43517. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43518. // issue #9511
  43519. // avoid catch triggering multiple times when nested calls
  43520. res._handled = true;
  43521. }
  43522. } catch (e) {
  43523. handleError(e, vm, info);
  43524. }
  43525. return res
  43526. }
  43527. function globalHandleError (err, vm, info) {
  43528. if (config.errorHandler) {
  43529. try {
  43530. return config.errorHandler.call(null, err, vm, info)
  43531. } catch (e) {
  43532. // if the user intentionally throws the original error in the handler,
  43533. // do not log it twice
  43534. if (e !== err) {
  43535. logError(e, null, 'config.errorHandler');
  43536. }
  43537. }
  43538. }
  43539. logError(err, vm, info);
  43540. }
  43541. function logError (err, vm, info) {
  43542. {
  43543. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43544. }
  43545. /* istanbul ignore else */
  43546. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43547. console.error(err);
  43548. } else {
  43549. throw err
  43550. }
  43551. }
  43552. /* */
  43553. var isUsingMicroTask = false;
  43554. var callbacks = [];
  43555. var pending = false;
  43556. function flushCallbacks () {
  43557. pending = false;
  43558. var copies = callbacks.slice(0);
  43559. callbacks.length = 0;
  43560. for (var i = 0; i < copies.length; i++) {
  43561. copies[i]();
  43562. }
  43563. }
  43564. // Here we have async deferring wrappers using microtasks.
  43565. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43566. // However, it has subtle problems when state is changed right before repaint
  43567. // (e.g. #6813, out-in transitions).
  43568. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43569. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43570. // So we now use microtasks everywhere, again.
  43571. // A major drawback of this tradeoff is that there are some scenarios
  43572. // where microtasks have too high a priority and fire in between supposedly
  43573. // sequential events (e.g. #4521, #6690, which have workarounds)
  43574. // or even between bubbling of the same event (#6566).
  43575. var timerFunc;
  43576. // The nextTick behavior leverages the microtask queue, which can be accessed
  43577. // via either native Promise.then or MutationObserver.
  43578. // MutationObserver has wider support, however it is seriously bugged in
  43579. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43580. // completely stops working after triggering a few times... so, if native
  43581. // Promise is available, we will use it:
  43582. /* istanbul ignore next, $flow-disable-line */
  43583. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43584. var p = Promise.resolve();
  43585. timerFunc = function () {
  43586. p.then(flushCallbacks);
  43587. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43588. // it can get stuck in a weird state where callbacks are pushed into the
  43589. // microtask queue but the queue isn't being flushed, until the browser
  43590. // needs to do some other work, e.g. handle a timer. Therefore we can
  43591. // "force" the microtask queue to be flushed by adding an empty timer.
  43592. if (isIOS) { setTimeout(noop); }
  43593. };
  43594. isUsingMicroTask = true;
  43595. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43596. isNative(MutationObserver) ||
  43597. // PhantomJS and iOS 7.x
  43598. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43599. )) {
  43600. // Use MutationObserver where native Promise is not available,
  43601. // e.g. PhantomJS, iOS7, Android 4.4
  43602. // (#6466 MutationObserver is unreliable in IE11)
  43603. var counter = 1;
  43604. var observer = new MutationObserver(flushCallbacks);
  43605. var textNode = document.createTextNode(String(counter));
  43606. observer.observe(textNode, {
  43607. characterData: true
  43608. });
  43609. timerFunc = function () {
  43610. counter = (counter + 1) % 2;
  43611. textNode.data = String(counter);
  43612. };
  43613. isUsingMicroTask = true;
  43614. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43615. // Fallback to setImmediate.
  43616. // Technically it leverages the (macro) task queue,
  43617. // but it is still a better choice than setTimeout.
  43618. timerFunc = function () {
  43619. setImmediate(flushCallbacks);
  43620. };
  43621. } else {
  43622. // Fallback to setTimeout.
  43623. timerFunc = function () {
  43624. setTimeout(flushCallbacks, 0);
  43625. };
  43626. }
  43627. function nextTick (cb, ctx) {
  43628. var _resolve;
  43629. callbacks.push(function () {
  43630. if (cb) {
  43631. try {
  43632. cb.call(ctx);
  43633. } catch (e) {
  43634. handleError(e, ctx, 'nextTick');
  43635. }
  43636. } else if (_resolve) {
  43637. _resolve(ctx);
  43638. }
  43639. });
  43640. if (!pending) {
  43641. pending = true;
  43642. timerFunc();
  43643. }
  43644. // $flow-disable-line
  43645. if (!cb && typeof Promise !== 'undefined') {
  43646. return new Promise(function (resolve) {
  43647. _resolve = resolve;
  43648. })
  43649. }
  43650. }
  43651. /* */
  43652. var mark;
  43653. var measure;
  43654. {
  43655. var perf = inBrowser && window.performance;
  43656. /* istanbul ignore if */
  43657. if (
  43658. perf &&
  43659. perf.mark &&
  43660. perf.measure &&
  43661. perf.clearMarks &&
  43662. perf.clearMeasures
  43663. ) {
  43664. mark = function (tag) { return perf.mark(tag); };
  43665. measure = function (name, startTag, endTag) {
  43666. perf.measure(name, startTag, endTag);
  43667. perf.clearMarks(startTag);
  43668. perf.clearMarks(endTag);
  43669. // perf.clearMeasures(name)
  43670. };
  43671. }
  43672. }
  43673. /* not type checking this file because flow doesn't play well with Proxy */
  43674. var initProxy;
  43675. {
  43676. var allowedGlobals = makeMap(
  43677. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43678. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43679. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43680. 'require' // for Webpack/Browserify
  43681. );
  43682. var warnNonPresent = function (target, key) {
  43683. warn(
  43684. "Property or method \"" + key + "\" is not defined on the instance but " +
  43685. 'referenced during render. Make sure that this property is reactive, ' +
  43686. 'either in the data option, or for class-based components, by ' +
  43687. 'initializing the property. ' +
  43688. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43689. target
  43690. );
  43691. };
  43692. var warnReservedPrefix = function (target, key) {
  43693. warn(
  43694. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43695. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43696. 'prevent conflicts with Vue internals. ' +
  43697. 'See: https://vuejs.org/v2/api/#data',
  43698. target
  43699. );
  43700. };
  43701. var hasProxy =
  43702. typeof Proxy !== 'undefined' && isNative(Proxy);
  43703. if (hasProxy) {
  43704. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43705. config.keyCodes = new Proxy(config.keyCodes, {
  43706. set: function set (target, key, value) {
  43707. if (isBuiltInModifier(key)) {
  43708. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43709. return false
  43710. } else {
  43711. target[key] = value;
  43712. return true
  43713. }
  43714. }
  43715. });
  43716. }
  43717. var hasHandler = {
  43718. has: function has (target, key) {
  43719. var has = key in target;
  43720. var isAllowed = allowedGlobals(key) ||
  43721. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43722. if (!has && !isAllowed) {
  43723. if (key in target.$data) { warnReservedPrefix(target, key); }
  43724. else { warnNonPresent(target, key); }
  43725. }
  43726. return has || !isAllowed
  43727. }
  43728. };
  43729. var getHandler = {
  43730. get: function get (target, key) {
  43731. if (typeof key === 'string' && !(key in target)) {
  43732. if (key in target.$data) { warnReservedPrefix(target, key); }
  43733. else { warnNonPresent(target, key); }
  43734. }
  43735. return target[key]
  43736. }
  43737. };
  43738. initProxy = function initProxy (vm) {
  43739. if (hasProxy) {
  43740. // determine which proxy handler to use
  43741. var options = vm.$options;
  43742. var handlers = options.render && options.render._withStripped
  43743. ? getHandler
  43744. : hasHandler;
  43745. vm._renderProxy = new Proxy(vm, handlers);
  43746. } else {
  43747. vm._renderProxy = vm;
  43748. }
  43749. };
  43750. }
  43751. /* */
  43752. var seenObjects = new _Set();
  43753. /**
  43754. * Recursively traverse an object to evoke all converted
  43755. * getters, so that every nested property inside the object
  43756. * is collected as a "deep" dependency.
  43757. */
  43758. function traverse (val) {
  43759. _traverse(val, seenObjects);
  43760. seenObjects.clear();
  43761. }
  43762. function _traverse (val, seen) {
  43763. var i, keys;
  43764. var isA = Array.isArray(val);
  43765. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43766. return
  43767. }
  43768. if (val.__ob__) {
  43769. var depId = val.__ob__.dep.id;
  43770. if (seen.has(depId)) {
  43771. return
  43772. }
  43773. seen.add(depId);
  43774. }
  43775. if (isA) {
  43776. i = val.length;
  43777. while (i--) { _traverse(val[i], seen); }
  43778. } else {
  43779. keys = Object.keys(val);
  43780. i = keys.length;
  43781. while (i--) { _traverse(val[keys[i]], seen); }
  43782. }
  43783. }
  43784. /* */
  43785. var normalizeEvent = cached(function (name) {
  43786. var passive = name.charAt(0) === '&';
  43787. name = passive ? name.slice(1) : name;
  43788. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43789. name = once$$1 ? name.slice(1) : name;
  43790. var capture = name.charAt(0) === '!';
  43791. name = capture ? name.slice(1) : name;
  43792. return {
  43793. name: name,
  43794. once: once$$1,
  43795. capture: capture,
  43796. passive: passive
  43797. }
  43798. });
  43799. function createFnInvoker (fns, vm) {
  43800. function invoker () {
  43801. var arguments$1 = arguments;
  43802. var fns = invoker.fns;
  43803. if (Array.isArray(fns)) {
  43804. var cloned = fns.slice();
  43805. for (var i = 0; i < cloned.length; i++) {
  43806. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43807. }
  43808. } else {
  43809. // return handler return value for single handlers
  43810. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43811. }
  43812. }
  43813. invoker.fns = fns;
  43814. return invoker
  43815. }
  43816. function updateListeners (
  43817. on,
  43818. oldOn,
  43819. add,
  43820. remove$$1,
  43821. createOnceHandler,
  43822. vm
  43823. ) {
  43824. var name, def$$1, cur, old, event;
  43825. for (name in on) {
  43826. def$$1 = cur = on[name];
  43827. old = oldOn[name];
  43828. event = normalizeEvent(name);
  43829. if (isUndef(cur)) {
  43830. warn(
  43831. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43832. vm
  43833. );
  43834. } else if (isUndef(old)) {
  43835. if (isUndef(cur.fns)) {
  43836. cur = on[name] = createFnInvoker(cur, vm);
  43837. }
  43838. if (isTrue(event.once)) {
  43839. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43840. }
  43841. add(event.name, cur, event.capture, event.passive, event.params);
  43842. } else if (cur !== old) {
  43843. old.fns = cur;
  43844. on[name] = old;
  43845. }
  43846. }
  43847. for (name in oldOn) {
  43848. if (isUndef(on[name])) {
  43849. event = normalizeEvent(name);
  43850. remove$$1(event.name, oldOn[name], event.capture);
  43851. }
  43852. }
  43853. }
  43854. /* */
  43855. function mergeVNodeHook (def, hookKey, hook) {
  43856. if (def instanceof VNode) {
  43857. def = def.data.hook || (def.data.hook = {});
  43858. }
  43859. var invoker;
  43860. var oldHook = def[hookKey];
  43861. function wrappedHook () {
  43862. hook.apply(this, arguments);
  43863. // important: remove merged hook to ensure it's called only once
  43864. // and prevent memory leak
  43865. remove(invoker.fns, wrappedHook);
  43866. }
  43867. if (isUndef(oldHook)) {
  43868. // no existing hook
  43869. invoker = createFnInvoker([wrappedHook]);
  43870. } else {
  43871. /* istanbul ignore if */
  43872. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43873. // already a merged invoker
  43874. invoker = oldHook;
  43875. invoker.fns.push(wrappedHook);
  43876. } else {
  43877. // existing plain hook
  43878. invoker = createFnInvoker([oldHook, wrappedHook]);
  43879. }
  43880. }
  43881. invoker.merged = true;
  43882. def[hookKey] = invoker;
  43883. }
  43884. /* */
  43885. function extractPropsFromVNodeData (
  43886. data,
  43887. Ctor,
  43888. tag
  43889. ) {
  43890. // we are only extracting raw values here.
  43891. // validation and default values are handled in the child
  43892. // component itself.
  43893. var propOptions = Ctor.options.props;
  43894. if (isUndef(propOptions)) {
  43895. return
  43896. }
  43897. var res = {};
  43898. var attrs = data.attrs;
  43899. var props = data.props;
  43900. if (isDef(attrs) || isDef(props)) {
  43901. for (var key in propOptions) {
  43902. var altKey = hyphenate(key);
  43903. {
  43904. var keyInLowerCase = key.toLowerCase();
  43905. if (
  43906. key !== keyInLowerCase &&
  43907. attrs && hasOwn(attrs, keyInLowerCase)
  43908. ) {
  43909. tip(
  43910. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43911. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43912. " \"" + key + "\". " +
  43913. "Note that HTML attributes are case-insensitive and camelCased " +
  43914. "props need to use their kebab-case equivalents when using in-DOM " +
  43915. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43916. );
  43917. }
  43918. }
  43919. checkProp(res, props, key, altKey, true) ||
  43920. checkProp(res, attrs, key, altKey, false);
  43921. }
  43922. }
  43923. return res
  43924. }
  43925. function checkProp (
  43926. res,
  43927. hash,
  43928. key,
  43929. altKey,
  43930. preserve
  43931. ) {
  43932. if (isDef(hash)) {
  43933. if (hasOwn(hash, key)) {
  43934. res[key] = hash[key];
  43935. if (!preserve) {
  43936. delete hash[key];
  43937. }
  43938. return true
  43939. } else if (hasOwn(hash, altKey)) {
  43940. res[key] = hash[altKey];
  43941. if (!preserve) {
  43942. delete hash[altKey];
  43943. }
  43944. return true
  43945. }
  43946. }
  43947. return false
  43948. }
  43949. /* */
  43950. // The template compiler attempts to minimize the need for normalization by
  43951. // statically analyzing the template at compile time.
  43952. //
  43953. // For plain HTML markup, normalization can be completely skipped because the
  43954. // generated render function is guaranteed to return Array<VNode>. There are
  43955. // two cases where extra normalization is needed:
  43956. // 1. When the children contains components - because a functional component
  43957. // may return an Array instead of a single root. In this case, just a simple
  43958. // normalization is needed - if any child is an Array, we flatten the whole
  43959. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43960. // because functional components already normalize their own children.
  43961. function simpleNormalizeChildren (children) {
  43962. for (var i = 0; i < children.length; i++) {
  43963. if (Array.isArray(children[i])) {
  43964. return Array.prototype.concat.apply([], children)
  43965. }
  43966. }
  43967. return children
  43968. }
  43969. // 2. When the children contains constructs that always generated nested Arrays,
  43970. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43971. // with hand-written render functions / JSX. In such cases a full normalization
  43972. // is needed to cater to all possible types of children values.
  43973. function normalizeChildren (children) {
  43974. return isPrimitive(children)
  43975. ? [createTextVNode(children)]
  43976. : Array.isArray(children)
  43977. ? normalizeArrayChildren(children)
  43978. : undefined
  43979. }
  43980. function isTextNode (node) {
  43981. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43982. }
  43983. function normalizeArrayChildren (children, nestedIndex) {
  43984. var res = [];
  43985. var i, c, lastIndex, last;
  43986. for (i = 0; i < children.length; i++) {
  43987. c = children[i];
  43988. if (isUndef(c) || typeof c === 'boolean') { continue }
  43989. lastIndex = res.length - 1;
  43990. last = res[lastIndex];
  43991. // nested
  43992. if (Array.isArray(c)) {
  43993. if (c.length > 0) {
  43994. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43995. // merge adjacent text nodes
  43996. if (isTextNode(c[0]) && isTextNode(last)) {
  43997. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43998. c.shift();
  43999. }
  44000. res.push.apply(res, c);
  44001. }
  44002. } else if (isPrimitive(c)) {
  44003. if (isTextNode(last)) {
  44004. // merge adjacent text nodes
  44005. // this is necessary for SSR hydration because text nodes are
  44006. // essentially merged when rendered to HTML strings
  44007. res[lastIndex] = createTextVNode(last.text + c);
  44008. } else if (c !== '') {
  44009. // convert primitive to vnode
  44010. res.push(createTextVNode(c));
  44011. }
  44012. } else {
  44013. if (isTextNode(c) && isTextNode(last)) {
  44014. // merge adjacent text nodes
  44015. res[lastIndex] = createTextVNode(last.text + c.text);
  44016. } else {
  44017. // default key for nested array children (likely generated by v-for)
  44018. if (isTrue(children._isVList) &&
  44019. isDef(c.tag) &&
  44020. isUndef(c.key) &&
  44021. isDef(nestedIndex)) {
  44022. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  44023. }
  44024. res.push(c);
  44025. }
  44026. }
  44027. }
  44028. return res
  44029. }
  44030. /* */
  44031. function initProvide (vm) {
  44032. var provide = vm.$options.provide;
  44033. if (provide) {
  44034. vm._provided = typeof provide === 'function'
  44035. ? provide.call(vm)
  44036. : provide;
  44037. }
  44038. }
  44039. function initInjections (vm) {
  44040. var result = resolveInject(vm.$options.inject, vm);
  44041. if (result) {
  44042. toggleObserving(false);
  44043. Object.keys(result).forEach(function (key) {
  44044. /* istanbul ignore else */
  44045. {
  44046. defineReactive$$1(vm, key, result[key], function () {
  44047. warn(
  44048. "Avoid mutating an injected value directly since the changes will be " +
  44049. "overwritten whenever the provided component re-renders. " +
  44050. "injection being mutated: \"" + key + "\"",
  44051. vm
  44052. );
  44053. });
  44054. }
  44055. });
  44056. toggleObserving(true);
  44057. }
  44058. }
  44059. function resolveInject (inject, vm) {
  44060. if (inject) {
  44061. // inject is :any because flow is not smart enough to figure out cached
  44062. var result = Object.create(null);
  44063. var keys = hasSymbol
  44064. ? Reflect.ownKeys(inject)
  44065. : Object.keys(inject);
  44066. for (var i = 0; i < keys.length; i++) {
  44067. var key = keys[i];
  44068. // #6574 in case the inject object is observed...
  44069. if (key === '__ob__') { continue }
  44070. var provideKey = inject[key].from;
  44071. var source = vm;
  44072. while (source) {
  44073. if (source._provided && hasOwn(source._provided, provideKey)) {
  44074. result[key] = source._provided[provideKey];
  44075. break
  44076. }
  44077. source = source.$parent;
  44078. }
  44079. if (!source) {
  44080. if ('default' in inject[key]) {
  44081. var provideDefault = inject[key].default;
  44082. result[key] = typeof provideDefault === 'function'
  44083. ? provideDefault.call(vm)
  44084. : provideDefault;
  44085. } else {
  44086. warn(("Injection \"" + key + "\" not found"), vm);
  44087. }
  44088. }
  44089. }
  44090. return result
  44091. }
  44092. }
  44093. /* */
  44094. /**
  44095. * Runtime helper for resolving raw children VNodes into a slot object.
  44096. */
  44097. function resolveSlots (
  44098. children,
  44099. context
  44100. ) {
  44101. if (!children || !children.length) {
  44102. return {}
  44103. }
  44104. var slots = {};
  44105. for (var i = 0, l = children.length; i < l; i++) {
  44106. var child = children[i];
  44107. var data = child.data;
  44108. // remove slot attribute if the node is resolved as a Vue slot node
  44109. if (data && data.attrs && data.attrs.slot) {
  44110. delete data.attrs.slot;
  44111. }
  44112. // named slots should only be respected if the vnode was rendered in the
  44113. // same context.
  44114. if ((child.context === context || child.fnContext === context) &&
  44115. data && data.slot != null
  44116. ) {
  44117. var name = data.slot;
  44118. var slot = (slots[name] || (slots[name] = []));
  44119. if (child.tag === 'template') {
  44120. slot.push.apply(slot, child.children || []);
  44121. } else {
  44122. slot.push(child);
  44123. }
  44124. } else {
  44125. (slots.default || (slots.default = [])).push(child);
  44126. }
  44127. }
  44128. // ignore slots that contains only whitespace
  44129. for (var name$1 in slots) {
  44130. if (slots[name$1].every(isWhitespace)) {
  44131. delete slots[name$1];
  44132. }
  44133. }
  44134. return slots
  44135. }
  44136. function isWhitespace (node) {
  44137. return (node.isComment && !node.asyncFactory) || node.text === ' '
  44138. }
  44139. /* */
  44140. function normalizeScopedSlots (
  44141. slots,
  44142. normalSlots,
  44143. prevSlots
  44144. ) {
  44145. var res;
  44146. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44147. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44148. var key = slots && slots.$key;
  44149. if (!slots) {
  44150. res = {};
  44151. } else if (slots._normalized) {
  44152. // fast path 1: child component re-render only, parent did not change
  44153. return slots._normalized
  44154. } else if (
  44155. isStable &&
  44156. prevSlots &&
  44157. prevSlots !== emptyObject &&
  44158. key === prevSlots.$key &&
  44159. !hasNormalSlots &&
  44160. !prevSlots.$hasNormal
  44161. ) {
  44162. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44163. // only need to normalize once
  44164. return prevSlots
  44165. } else {
  44166. res = {};
  44167. for (var key$1 in slots) {
  44168. if (slots[key$1] && key$1[0] !== '$') {
  44169. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44170. }
  44171. }
  44172. }
  44173. // expose normal slots on scopedSlots
  44174. for (var key$2 in normalSlots) {
  44175. if (!(key$2 in res)) {
  44176. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44177. }
  44178. }
  44179. // avoriaz seems to mock a non-extensible $scopedSlots object
  44180. // and when that is passed down this would cause an error
  44181. if (slots && Object.isExtensible(slots)) {
  44182. (slots)._normalized = res;
  44183. }
  44184. def(res, '$stable', isStable);
  44185. def(res, '$key', key);
  44186. def(res, '$hasNormal', hasNormalSlots);
  44187. return res
  44188. }
  44189. function normalizeScopedSlot(normalSlots, key, fn) {
  44190. var normalized = function () {
  44191. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44192. res = res && typeof res === 'object' && !Array.isArray(res)
  44193. ? [res] // single vnode
  44194. : normalizeChildren(res);
  44195. return res && (
  44196. res.length === 0 ||
  44197. (res.length === 1 && res[0].isComment) // #9658
  44198. ) ? undefined
  44199. : res
  44200. };
  44201. // this is a slot using the new v-slot syntax without scope. although it is
  44202. // compiled as a scoped slot, render fn users would expect it to be present
  44203. // on this.$slots because the usage is semantically a normal slot.
  44204. if (fn.proxy) {
  44205. Object.defineProperty(normalSlots, key, {
  44206. get: normalized,
  44207. enumerable: true,
  44208. configurable: true
  44209. });
  44210. }
  44211. return normalized
  44212. }
  44213. function proxyNormalSlot(slots, key) {
  44214. return function () { return slots[key]; }
  44215. }
  44216. /* */
  44217. /**
  44218. * Runtime helper for rendering v-for lists.
  44219. */
  44220. function renderList (
  44221. val,
  44222. render
  44223. ) {
  44224. var ret, i, l, keys, key;
  44225. if (Array.isArray(val) || typeof val === 'string') {
  44226. ret = new Array(val.length);
  44227. for (i = 0, l = val.length; i < l; i++) {
  44228. ret[i] = render(val[i], i);
  44229. }
  44230. } else if (typeof val === 'number') {
  44231. ret = new Array(val);
  44232. for (i = 0; i < val; i++) {
  44233. ret[i] = render(i + 1, i);
  44234. }
  44235. } else if (isObject(val)) {
  44236. if (hasSymbol && val[Symbol.iterator]) {
  44237. ret = [];
  44238. var iterator = val[Symbol.iterator]();
  44239. var result = iterator.next();
  44240. while (!result.done) {
  44241. ret.push(render(result.value, ret.length));
  44242. result = iterator.next();
  44243. }
  44244. } else {
  44245. keys = Object.keys(val);
  44246. ret = new Array(keys.length);
  44247. for (i = 0, l = keys.length; i < l; i++) {
  44248. key = keys[i];
  44249. ret[i] = render(val[key], key, i);
  44250. }
  44251. }
  44252. }
  44253. if (!isDef(ret)) {
  44254. ret = [];
  44255. }
  44256. (ret)._isVList = true;
  44257. return ret
  44258. }
  44259. /* */
  44260. /**
  44261. * Runtime helper for rendering <slot>
  44262. */
  44263. function renderSlot (
  44264. name,
  44265. fallback,
  44266. props,
  44267. bindObject
  44268. ) {
  44269. var scopedSlotFn = this.$scopedSlots[name];
  44270. var nodes;
  44271. if (scopedSlotFn) { // scoped slot
  44272. props = props || {};
  44273. if (bindObject) {
  44274. if (!isObject(bindObject)) {
  44275. warn(
  44276. 'slot v-bind without argument expects an Object',
  44277. this
  44278. );
  44279. }
  44280. props = extend(extend({}, bindObject), props);
  44281. }
  44282. nodes = scopedSlotFn(props) || fallback;
  44283. } else {
  44284. nodes = this.$slots[name] || fallback;
  44285. }
  44286. var target = props && props.slot;
  44287. if (target) {
  44288. return this.$createElement('template', { slot: target }, nodes)
  44289. } else {
  44290. return nodes
  44291. }
  44292. }
  44293. /* */
  44294. /**
  44295. * Runtime helper for resolving filters
  44296. */
  44297. function resolveFilter (id) {
  44298. return resolveAsset(this.$options, 'filters', id, true) || identity
  44299. }
  44300. /* */
  44301. function isKeyNotMatch (expect, actual) {
  44302. if (Array.isArray(expect)) {
  44303. return expect.indexOf(actual) === -1
  44304. } else {
  44305. return expect !== actual
  44306. }
  44307. }
  44308. /**
  44309. * Runtime helper for checking keyCodes from config.
  44310. * exposed as Vue.prototype._k
  44311. * passing in eventKeyName as last argument separately for backwards compat
  44312. */
  44313. function checkKeyCodes (
  44314. eventKeyCode,
  44315. key,
  44316. builtInKeyCode,
  44317. eventKeyName,
  44318. builtInKeyName
  44319. ) {
  44320. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44321. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44322. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44323. } else if (mappedKeyCode) {
  44324. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44325. } else if (eventKeyName) {
  44326. return hyphenate(eventKeyName) !== key
  44327. }
  44328. }
  44329. /* */
  44330. /**
  44331. * Runtime helper for merging v-bind="object" into a VNode's data.
  44332. */
  44333. function bindObjectProps (
  44334. data,
  44335. tag,
  44336. value,
  44337. asProp,
  44338. isSync
  44339. ) {
  44340. if (value) {
  44341. if (!isObject(value)) {
  44342. warn(
  44343. 'v-bind without argument expects an Object or Array value',
  44344. this
  44345. );
  44346. } else {
  44347. if (Array.isArray(value)) {
  44348. value = toObject(value);
  44349. }
  44350. var hash;
  44351. var loop = function ( key ) {
  44352. if (
  44353. key === 'class' ||
  44354. key === 'style' ||
  44355. isReservedAttribute(key)
  44356. ) {
  44357. hash = data;
  44358. } else {
  44359. var type = data.attrs && data.attrs.type;
  44360. hash = asProp || config.mustUseProp(tag, type, key)
  44361. ? data.domProps || (data.domProps = {})
  44362. : data.attrs || (data.attrs = {});
  44363. }
  44364. var camelizedKey = camelize(key);
  44365. var hyphenatedKey = hyphenate(key);
  44366. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44367. hash[key] = value[key];
  44368. if (isSync) {
  44369. var on = data.on || (data.on = {});
  44370. on[("update:" + key)] = function ($event) {
  44371. value[key] = $event;
  44372. };
  44373. }
  44374. }
  44375. };
  44376. for (var key in value) loop( key );
  44377. }
  44378. }
  44379. return data
  44380. }
  44381. /* */
  44382. /**
  44383. * Runtime helper for rendering static trees.
  44384. */
  44385. function renderStatic (
  44386. index,
  44387. isInFor
  44388. ) {
  44389. var cached = this._staticTrees || (this._staticTrees = []);
  44390. var tree = cached[index];
  44391. // if has already-rendered static tree and not inside v-for,
  44392. // we can reuse the same tree.
  44393. if (tree && !isInFor) {
  44394. return tree
  44395. }
  44396. // otherwise, render a fresh tree.
  44397. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44398. this._renderProxy,
  44399. null,
  44400. this // for render fns generated for functional component templates
  44401. );
  44402. markStatic(tree, ("__static__" + index), false);
  44403. return tree
  44404. }
  44405. /**
  44406. * Runtime helper for v-once.
  44407. * Effectively it means marking the node as static with a unique key.
  44408. */
  44409. function markOnce (
  44410. tree,
  44411. index,
  44412. key
  44413. ) {
  44414. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44415. return tree
  44416. }
  44417. function markStatic (
  44418. tree,
  44419. key,
  44420. isOnce
  44421. ) {
  44422. if (Array.isArray(tree)) {
  44423. for (var i = 0; i < tree.length; i++) {
  44424. if (tree[i] && typeof tree[i] !== 'string') {
  44425. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44426. }
  44427. }
  44428. } else {
  44429. markStaticNode(tree, key, isOnce);
  44430. }
  44431. }
  44432. function markStaticNode (node, key, isOnce) {
  44433. node.isStatic = true;
  44434. node.key = key;
  44435. node.isOnce = isOnce;
  44436. }
  44437. /* */
  44438. function bindObjectListeners (data, value) {
  44439. if (value) {
  44440. if (!isPlainObject(value)) {
  44441. warn(
  44442. 'v-on without argument expects an Object value',
  44443. this
  44444. );
  44445. } else {
  44446. var on = data.on = data.on ? extend({}, data.on) : {};
  44447. for (var key in value) {
  44448. var existing = on[key];
  44449. var ours = value[key];
  44450. on[key] = existing ? [].concat(existing, ours) : ours;
  44451. }
  44452. }
  44453. }
  44454. return data
  44455. }
  44456. /* */
  44457. function resolveScopedSlots (
  44458. fns, // see flow/vnode
  44459. res,
  44460. // the following are added in 2.6
  44461. hasDynamicKeys,
  44462. contentHashKey
  44463. ) {
  44464. res = res || { $stable: !hasDynamicKeys };
  44465. for (var i = 0; i < fns.length; i++) {
  44466. var slot = fns[i];
  44467. if (Array.isArray(slot)) {
  44468. resolveScopedSlots(slot, res, hasDynamicKeys);
  44469. } else if (slot) {
  44470. // marker for reverse proxying v-slot without scope on this.$slots
  44471. if (slot.proxy) {
  44472. slot.fn.proxy = true;
  44473. }
  44474. res[slot.key] = slot.fn;
  44475. }
  44476. }
  44477. if (contentHashKey) {
  44478. (res).$key = contentHashKey;
  44479. }
  44480. return res
  44481. }
  44482. /* */
  44483. function bindDynamicKeys (baseObj, values) {
  44484. for (var i = 0; i < values.length; i += 2) {
  44485. var key = values[i];
  44486. if (typeof key === 'string' && key) {
  44487. baseObj[values[i]] = values[i + 1];
  44488. } else if (key !== '' && key !== null) {
  44489. // null is a special value for explicitly removing a binding
  44490. warn(
  44491. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44492. this
  44493. );
  44494. }
  44495. }
  44496. return baseObj
  44497. }
  44498. // helper to dynamically append modifier runtime markers to event names.
  44499. // ensure only append when value is already string, otherwise it will be cast
  44500. // to string and cause the type check to miss.
  44501. function prependModifier (value, symbol) {
  44502. return typeof value === 'string' ? symbol + value : value
  44503. }
  44504. /* */
  44505. function installRenderHelpers (target) {
  44506. target._o = markOnce;
  44507. target._n = toNumber;
  44508. target._s = toString;
  44509. target._l = renderList;
  44510. target._t = renderSlot;
  44511. target._q = looseEqual;
  44512. target._i = looseIndexOf;
  44513. target._m = renderStatic;
  44514. target._f = resolveFilter;
  44515. target._k = checkKeyCodes;
  44516. target._b = bindObjectProps;
  44517. target._v = createTextVNode;
  44518. target._e = createEmptyVNode;
  44519. target._u = resolveScopedSlots;
  44520. target._g = bindObjectListeners;
  44521. target._d = bindDynamicKeys;
  44522. target._p = prependModifier;
  44523. }
  44524. /* */
  44525. function FunctionalRenderContext (
  44526. data,
  44527. props,
  44528. children,
  44529. parent,
  44530. Ctor
  44531. ) {
  44532. var this$1 = this;
  44533. var options = Ctor.options;
  44534. // ensure the createElement function in functional components
  44535. // gets a unique context - this is necessary for correct named slot check
  44536. var contextVm;
  44537. if (hasOwn(parent, '_uid')) {
  44538. contextVm = Object.create(parent);
  44539. // $flow-disable-line
  44540. contextVm._original = parent;
  44541. } else {
  44542. // the context vm passed in is a functional context as well.
  44543. // in this case we want to make sure we are able to get a hold to the
  44544. // real context instance.
  44545. contextVm = parent;
  44546. // $flow-disable-line
  44547. parent = parent._original;
  44548. }
  44549. var isCompiled = isTrue(options._compiled);
  44550. var needNormalization = !isCompiled;
  44551. this.data = data;
  44552. this.props = props;
  44553. this.children = children;
  44554. this.parent = parent;
  44555. this.listeners = data.on || emptyObject;
  44556. this.injections = resolveInject(options.inject, parent);
  44557. this.slots = function () {
  44558. if (!this$1.$slots) {
  44559. normalizeScopedSlots(
  44560. data.scopedSlots,
  44561. this$1.$slots = resolveSlots(children, parent)
  44562. );
  44563. }
  44564. return this$1.$slots
  44565. };
  44566. Object.defineProperty(this, 'scopedSlots', ({
  44567. enumerable: true,
  44568. get: function get () {
  44569. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44570. }
  44571. }));
  44572. // support for compiled functional template
  44573. if (isCompiled) {
  44574. // exposing $options for renderStatic()
  44575. this.$options = options;
  44576. // pre-resolve slots for renderSlot()
  44577. this.$slots = this.slots();
  44578. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44579. }
  44580. if (options._scopeId) {
  44581. this._c = function (a, b, c, d) {
  44582. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44583. if (vnode && !Array.isArray(vnode)) {
  44584. vnode.fnScopeId = options._scopeId;
  44585. vnode.fnContext = parent;
  44586. }
  44587. return vnode
  44588. };
  44589. } else {
  44590. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44591. }
  44592. }
  44593. installRenderHelpers(FunctionalRenderContext.prototype);
  44594. function createFunctionalComponent (
  44595. Ctor,
  44596. propsData,
  44597. data,
  44598. contextVm,
  44599. children
  44600. ) {
  44601. var options = Ctor.options;
  44602. var props = {};
  44603. var propOptions = options.props;
  44604. if (isDef(propOptions)) {
  44605. for (var key in propOptions) {
  44606. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44607. }
  44608. } else {
  44609. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44610. if (isDef(data.props)) { mergeProps(props, data.props); }
  44611. }
  44612. var renderContext = new FunctionalRenderContext(
  44613. data,
  44614. props,
  44615. children,
  44616. contextVm,
  44617. Ctor
  44618. );
  44619. var vnode = options.render.call(null, renderContext._c, renderContext);
  44620. if (vnode instanceof VNode) {
  44621. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44622. } else if (Array.isArray(vnode)) {
  44623. var vnodes = normalizeChildren(vnode) || [];
  44624. var res = new Array(vnodes.length);
  44625. for (var i = 0; i < vnodes.length; i++) {
  44626. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44627. }
  44628. return res
  44629. }
  44630. }
  44631. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44632. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44633. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44634. // that should not be matched to match.
  44635. var clone = cloneVNode(vnode);
  44636. clone.fnContext = contextVm;
  44637. clone.fnOptions = options;
  44638. {
  44639. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44640. }
  44641. if (data.slot) {
  44642. (clone.data || (clone.data = {})).slot = data.slot;
  44643. }
  44644. return clone
  44645. }
  44646. function mergeProps (to, from) {
  44647. for (var key in from) {
  44648. to[camelize(key)] = from[key];
  44649. }
  44650. }
  44651. /* */
  44652. /* */
  44653. /* */
  44654. /* */
  44655. // inline hooks to be invoked on component VNodes during patch
  44656. var componentVNodeHooks = {
  44657. init: function init (vnode, hydrating) {
  44658. if (
  44659. vnode.componentInstance &&
  44660. !vnode.componentInstance._isDestroyed &&
  44661. vnode.data.keepAlive
  44662. ) {
  44663. // kept-alive components, treat as a patch
  44664. var mountedNode = vnode; // work around flow
  44665. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44666. } else {
  44667. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44668. vnode,
  44669. activeInstance
  44670. );
  44671. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44672. }
  44673. },
  44674. prepatch: function prepatch (oldVnode, vnode) {
  44675. var options = vnode.componentOptions;
  44676. var child = vnode.componentInstance = oldVnode.componentInstance;
  44677. updateChildComponent(
  44678. child,
  44679. options.propsData, // updated props
  44680. options.listeners, // updated listeners
  44681. vnode, // new parent vnode
  44682. options.children // new children
  44683. );
  44684. },
  44685. insert: function insert (vnode) {
  44686. var context = vnode.context;
  44687. var componentInstance = vnode.componentInstance;
  44688. if (!componentInstance._isMounted) {
  44689. componentInstance._isMounted = true;
  44690. callHook(componentInstance, 'mounted');
  44691. }
  44692. if (vnode.data.keepAlive) {
  44693. if (context._isMounted) {
  44694. // vue-router#1212
  44695. // During updates, a kept-alive component's child components may
  44696. // change, so directly walking the tree here may call activated hooks
  44697. // on incorrect children. Instead we push them into a queue which will
  44698. // be processed after the whole patch process ended.
  44699. queueActivatedComponent(componentInstance);
  44700. } else {
  44701. activateChildComponent(componentInstance, true /* direct */);
  44702. }
  44703. }
  44704. },
  44705. destroy: function destroy (vnode) {
  44706. var componentInstance = vnode.componentInstance;
  44707. if (!componentInstance._isDestroyed) {
  44708. if (!vnode.data.keepAlive) {
  44709. componentInstance.$destroy();
  44710. } else {
  44711. deactivateChildComponent(componentInstance, true /* direct */);
  44712. }
  44713. }
  44714. }
  44715. };
  44716. var hooksToMerge = Object.keys(componentVNodeHooks);
  44717. function createComponent (
  44718. Ctor,
  44719. data,
  44720. context,
  44721. children,
  44722. tag
  44723. ) {
  44724. if (isUndef(Ctor)) {
  44725. return
  44726. }
  44727. var baseCtor = context.$options._base;
  44728. // plain options object: turn it into a constructor
  44729. if (isObject(Ctor)) {
  44730. Ctor = baseCtor.extend(Ctor);
  44731. }
  44732. // if at this stage it's not a constructor or an async component factory,
  44733. // reject.
  44734. if (typeof Ctor !== 'function') {
  44735. {
  44736. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44737. }
  44738. return
  44739. }
  44740. // async component
  44741. var asyncFactory;
  44742. if (isUndef(Ctor.cid)) {
  44743. asyncFactory = Ctor;
  44744. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44745. if (Ctor === undefined) {
  44746. // return a placeholder node for async component, which is rendered
  44747. // as a comment node but preserves all the raw information for the node.
  44748. // the information will be used for async server-rendering and hydration.
  44749. return createAsyncPlaceholder(
  44750. asyncFactory,
  44751. data,
  44752. context,
  44753. children,
  44754. tag
  44755. )
  44756. }
  44757. }
  44758. data = data || {};
  44759. // resolve constructor options in case global mixins are applied after
  44760. // component constructor creation
  44761. resolveConstructorOptions(Ctor);
  44762. // transform component v-model data into props & events
  44763. if (isDef(data.model)) {
  44764. transformModel(Ctor.options, data);
  44765. }
  44766. // extract props
  44767. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44768. // functional component
  44769. if (isTrue(Ctor.options.functional)) {
  44770. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44771. }
  44772. // extract listeners, since these needs to be treated as
  44773. // child component listeners instead of DOM listeners
  44774. var listeners = data.on;
  44775. // replace with listeners with .native modifier
  44776. // so it gets processed during parent component patch.
  44777. data.on = data.nativeOn;
  44778. if (isTrue(Ctor.options.abstract)) {
  44779. // abstract components do not keep anything
  44780. // other than props & listeners & slot
  44781. // work around flow
  44782. var slot = data.slot;
  44783. data = {};
  44784. if (slot) {
  44785. data.slot = slot;
  44786. }
  44787. }
  44788. // install component management hooks onto the placeholder node
  44789. installComponentHooks(data);
  44790. // return a placeholder vnode
  44791. var name = Ctor.options.name || tag;
  44792. var vnode = new VNode(
  44793. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44794. data, undefined, undefined, undefined, context,
  44795. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44796. asyncFactory
  44797. );
  44798. return vnode
  44799. }
  44800. function createComponentInstanceForVnode (
  44801. vnode, // we know it's MountedComponentVNode but flow doesn't
  44802. parent // activeInstance in lifecycle state
  44803. ) {
  44804. var options = {
  44805. _isComponent: true,
  44806. _parentVnode: vnode,
  44807. parent: parent
  44808. };
  44809. // check inline-template render functions
  44810. var inlineTemplate = vnode.data.inlineTemplate;
  44811. if (isDef(inlineTemplate)) {
  44812. options.render = inlineTemplate.render;
  44813. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44814. }
  44815. return new vnode.componentOptions.Ctor(options)
  44816. }
  44817. function installComponentHooks (data) {
  44818. var hooks = data.hook || (data.hook = {});
  44819. for (var i = 0; i < hooksToMerge.length; i++) {
  44820. var key = hooksToMerge[i];
  44821. var existing = hooks[key];
  44822. var toMerge = componentVNodeHooks[key];
  44823. if (existing !== toMerge && !(existing && existing._merged)) {
  44824. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44825. }
  44826. }
  44827. }
  44828. function mergeHook$1 (f1, f2) {
  44829. var merged = function (a, b) {
  44830. // flow complains about extra args which is why we use any
  44831. f1(a, b);
  44832. f2(a, b);
  44833. };
  44834. merged._merged = true;
  44835. return merged
  44836. }
  44837. // transform component v-model info (value and callback) into
  44838. // prop and event handler respectively.
  44839. function transformModel (options, data) {
  44840. var prop = (options.model && options.model.prop) || 'value';
  44841. var event = (options.model && options.model.event) || 'input'
  44842. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44843. var on = data.on || (data.on = {});
  44844. var existing = on[event];
  44845. var callback = data.model.callback;
  44846. if (isDef(existing)) {
  44847. if (
  44848. Array.isArray(existing)
  44849. ? existing.indexOf(callback) === -1
  44850. : existing !== callback
  44851. ) {
  44852. on[event] = [callback].concat(existing);
  44853. }
  44854. } else {
  44855. on[event] = callback;
  44856. }
  44857. }
  44858. /* */
  44859. var SIMPLE_NORMALIZE = 1;
  44860. var ALWAYS_NORMALIZE = 2;
  44861. // wrapper function for providing a more flexible interface
  44862. // without getting yelled at by flow
  44863. function createElement (
  44864. context,
  44865. tag,
  44866. data,
  44867. children,
  44868. normalizationType,
  44869. alwaysNormalize
  44870. ) {
  44871. if (Array.isArray(data) || isPrimitive(data)) {
  44872. normalizationType = children;
  44873. children = data;
  44874. data = undefined;
  44875. }
  44876. if (isTrue(alwaysNormalize)) {
  44877. normalizationType = ALWAYS_NORMALIZE;
  44878. }
  44879. return _createElement(context, tag, data, children, normalizationType)
  44880. }
  44881. function _createElement (
  44882. context,
  44883. tag,
  44884. data,
  44885. children,
  44886. normalizationType
  44887. ) {
  44888. if (isDef(data) && isDef((data).__ob__)) {
  44889. warn(
  44890. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44891. 'Always create fresh vnode data objects in each render!',
  44892. context
  44893. );
  44894. return createEmptyVNode()
  44895. }
  44896. // object syntax in v-bind
  44897. if (isDef(data) && isDef(data.is)) {
  44898. tag = data.is;
  44899. }
  44900. if (!tag) {
  44901. // in case of component :is set to falsy value
  44902. return createEmptyVNode()
  44903. }
  44904. // warn against non-primitive key
  44905. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44906. ) {
  44907. {
  44908. warn(
  44909. 'Avoid using non-primitive value as key, ' +
  44910. 'use string/number value instead.',
  44911. context
  44912. );
  44913. }
  44914. }
  44915. // support single function children as default scoped slot
  44916. if (Array.isArray(children) &&
  44917. typeof children[0] === 'function'
  44918. ) {
  44919. data = data || {};
  44920. data.scopedSlots = { default: children[0] };
  44921. children.length = 0;
  44922. }
  44923. if (normalizationType === ALWAYS_NORMALIZE) {
  44924. children = normalizeChildren(children);
  44925. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44926. children = simpleNormalizeChildren(children);
  44927. }
  44928. var vnode, ns;
  44929. if (typeof tag === 'string') {
  44930. var Ctor;
  44931. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44932. if (config.isReservedTag(tag)) {
  44933. // platform built-in elements
  44934. if (isDef(data) && isDef(data.nativeOn)) {
  44935. warn(
  44936. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44937. context
  44938. );
  44939. }
  44940. vnode = new VNode(
  44941. config.parsePlatformTagName(tag), data, children,
  44942. undefined, undefined, context
  44943. );
  44944. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44945. // component
  44946. vnode = createComponent(Ctor, data, context, children, tag);
  44947. } else {
  44948. // unknown or unlisted namespaced elements
  44949. // check at runtime because it may get assigned a namespace when its
  44950. // parent normalizes children
  44951. vnode = new VNode(
  44952. tag, data, children,
  44953. undefined, undefined, context
  44954. );
  44955. }
  44956. } else {
  44957. // direct component options / constructor
  44958. vnode = createComponent(tag, data, context, children);
  44959. }
  44960. if (Array.isArray(vnode)) {
  44961. return vnode
  44962. } else if (isDef(vnode)) {
  44963. if (isDef(ns)) { applyNS(vnode, ns); }
  44964. if (isDef(data)) { registerDeepBindings(data); }
  44965. return vnode
  44966. } else {
  44967. return createEmptyVNode()
  44968. }
  44969. }
  44970. function applyNS (vnode, ns, force) {
  44971. vnode.ns = ns;
  44972. if (vnode.tag === 'foreignObject') {
  44973. // use default namespace inside foreignObject
  44974. ns = undefined;
  44975. force = true;
  44976. }
  44977. if (isDef(vnode.children)) {
  44978. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44979. var child = vnode.children[i];
  44980. if (isDef(child.tag) && (
  44981. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44982. applyNS(child, ns, force);
  44983. }
  44984. }
  44985. }
  44986. }
  44987. // ref #5318
  44988. // necessary to ensure parent re-render when deep bindings like :style and
  44989. // :class are used on slot nodes
  44990. function registerDeepBindings (data) {
  44991. if (isObject(data.style)) {
  44992. traverse(data.style);
  44993. }
  44994. if (isObject(data.class)) {
  44995. traverse(data.class);
  44996. }
  44997. }
  44998. /* */
  44999. function initRender (vm) {
  45000. vm._vnode = null; // the root of the child tree
  45001. vm._staticTrees = null; // v-once cached trees
  45002. var options = vm.$options;
  45003. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  45004. var renderContext = parentVnode && parentVnode.context;
  45005. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  45006. vm.$scopedSlots = emptyObject;
  45007. // bind the createElement fn to this instance
  45008. // so that we get proper render context inside it.
  45009. // args order: tag, data, children, normalizationType, alwaysNormalize
  45010. // internal version is used by render functions compiled from templates
  45011. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  45012. // normalization is always applied for the public version, used in
  45013. // user-written render functions.
  45014. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  45015. // $attrs & $listeners are exposed for easier HOC creation.
  45016. // they need to be reactive so that HOCs using them are always updated
  45017. var parentData = parentVnode && parentVnode.data;
  45018. /* istanbul ignore else */
  45019. {
  45020. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  45021. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  45022. }, true);
  45023. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  45024. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  45025. }, true);
  45026. }
  45027. }
  45028. var currentRenderingInstance = null;
  45029. function renderMixin (Vue) {
  45030. // install runtime convenience helpers
  45031. installRenderHelpers(Vue.prototype);
  45032. Vue.prototype.$nextTick = function (fn) {
  45033. return nextTick(fn, this)
  45034. };
  45035. Vue.prototype._render = function () {
  45036. var vm = this;
  45037. var ref = vm.$options;
  45038. var render = ref.render;
  45039. var _parentVnode = ref._parentVnode;
  45040. if (_parentVnode) {
  45041. vm.$scopedSlots = normalizeScopedSlots(
  45042. _parentVnode.data.scopedSlots,
  45043. vm.$slots,
  45044. vm.$scopedSlots
  45045. );
  45046. }
  45047. // set parent vnode. this allows render functions to have access
  45048. // to the data on the placeholder node.
  45049. vm.$vnode = _parentVnode;
  45050. // render self
  45051. var vnode;
  45052. try {
  45053. // There's no need to maintain a stack because all render fns are called
  45054. // separately from one another. Nested component's render fns are called
  45055. // when parent component is patched.
  45056. currentRenderingInstance = vm;
  45057. vnode = render.call(vm._renderProxy, vm.$createElement);
  45058. } catch (e) {
  45059. handleError(e, vm, "render");
  45060. // return error render result,
  45061. // or previous vnode to prevent render error causing blank component
  45062. /* istanbul ignore else */
  45063. if (vm.$options.renderError) {
  45064. try {
  45065. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  45066. } catch (e) {
  45067. handleError(e, vm, "renderError");
  45068. vnode = vm._vnode;
  45069. }
  45070. } else {
  45071. vnode = vm._vnode;
  45072. }
  45073. } finally {
  45074. currentRenderingInstance = null;
  45075. }
  45076. // if the returned array contains only a single node, allow it
  45077. if (Array.isArray(vnode) && vnode.length === 1) {
  45078. vnode = vnode[0];
  45079. }
  45080. // return empty vnode in case the render function errored out
  45081. if (!(vnode instanceof VNode)) {
  45082. if (Array.isArray(vnode)) {
  45083. warn(
  45084. 'Multiple root nodes returned from render function. Render function ' +
  45085. 'should return a single root node.',
  45086. vm
  45087. );
  45088. }
  45089. vnode = createEmptyVNode();
  45090. }
  45091. // set parent
  45092. vnode.parent = _parentVnode;
  45093. return vnode
  45094. };
  45095. }
  45096. /* */
  45097. function ensureCtor (comp, base) {
  45098. if (
  45099. comp.__esModule ||
  45100. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  45101. ) {
  45102. comp = comp.default;
  45103. }
  45104. return isObject(comp)
  45105. ? base.extend(comp)
  45106. : comp
  45107. }
  45108. function createAsyncPlaceholder (
  45109. factory,
  45110. data,
  45111. context,
  45112. children,
  45113. tag
  45114. ) {
  45115. var node = createEmptyVNode();
  45116. node.asyncFactory = factory;
  45117. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  45118. return node
  45119. }
  45120. function resolveAsyncComponent (
  45121. factory,
  45122. baseCtor
  45123. ) {
  45124. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  45125. return factory.errorComp
  45126. }
  45127. if (isDef(factory.resolved)) {
  45128. return factory.resolved
  45129. }
  45130. var owner = currentRenderingInstance;
  45131. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  45132. // already pending
  45133. factory.owners.push(owner);
  45134. }
  45135. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  45136. return factory.loadingComp
  45137. }
  45138. if (owner && !isDef(factory.owners)) {
  45139. var owners = factory.owners = [owner];
  45140. var sync = true;
  45141. var timerLoading = null;
  45142. var timerTimeout = null
  45143. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45144. var forceRender = function (renderCompleted) {
  45145. for (var i = 0, l = owners.length; i < l; i++) {
  45146. (owners[i]).$forceUpdate();
  45147. }
  45148. if (renderCompleted) {
  45149. owners.length = 0;
  45150. if (timerLoading !== null) {
  45151. clearTimeout(timerLoading);
  45152. timerLoading = null;
  45153. }
  45154. if (timerTimeout !== null) {
  45155. clearTimeout(timerTimeout);
  45156. timerTimeout = null;
  45157. }
  45158. }
  45159. };
  45160. var resolve = once(function (res) {
  45161. // cache resolved
  45162. factory.resolved = ensureCtor(res, baseCtor);
  45163. // invoke callbacks only if this is not a synchronous resolve
  45164. // (async resolves are shimmed as synchronous during SSR)
  45165. if (!sync) {
  45166. forceRender(true);
  45167. } else {
  45168. owners.length = 0;
  45169. }
  45170. });
  45171. var reject = once(function (reason) {
  45172. warn(
  45173. "Failed to resolve async component: " + (String(factory)) +
  45174. (reason ? ("\nReason: " + reason) : '')
  45175. );
  45176. if (isDef(factory.errorComp)) {
  45177. factory.error = true;
  45178. forceRender(true);
  45179. }
  45180. });
  45181. var res = factory(resolve, reject);
  45182. if (isObject(res)) {
  45183. if (isPromise(res)) {
  45184. // () => Promise
  45185. if (isUndef(factory.resolved)) {
  45186. res.then(resolve, reject);
  45187. }
  45188. } else if (isPromise(res.component)) {
  45189. res.component.then(resolve, reject);
  45190. if (isDef(res.error)) {
  45191. factory.errorComp = ensureCtor(res.error, baseCtor);
  45192. }
  45193. if (isDef(res.loading)) {
  45194. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45195. if (res.delay === 0) {
  45196. factory.loading = true;
  45197. } else {
  45198. timerLoading = setTimeout(function () {
  45199. timerLoading = null;
  45200. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45201. factory.loading = true;
  45202. forceRender(false);
  45203. }
  45204. }, res.delay || 200);
  45205. }
  45206. }
  45207. if (isDef(res.timeout)) {
  45208. timerTimeout = setTimeout(function () {
  45209. timerTimeout = null;
  45210. if (isUndef(factory.resolved)) {
  45211. reject(
  45212. "timeout (" + (res.timeout) + "ms)"
  45213. );
  45214. }
  45215. }, res.timeout);
  45216. }
  45217. }
  45218. }
  45219. sync = false;
  45220. // return in case resolved synchronously
  45221. return factory.loading
  45222. ? factory.loadingComp
  45223. : factory.resolved
  45224. }
  45225. }
  45226. /* */
  45227. function isAsyncPlaceholder (node) {
  45228. return node.isComment && node.asyncFactory
  45229. }
  45230. /* */
  45231. function getFirstComponentChild (children) {
  45232. if (Array.isArray(children)) {
  45233. for (var i = 0; i < children.length; i++) {
  45234. var c = children[i];
  45235. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45236. return c
  45237. }
  45238. }
  45239. }
  45240. }
  45241. /* */
  45242. /* */
  45243. function initEvents (vm) {
  45244. vm._events = Object.create(null);
  45245. vm._hasHookEvent = false;
  45246. // init parent attached events
  45247. var listeners = vm.$options._parentListeners;
  45248. if (listeners) {
  45249. updateComponentListeners(vm, listeners);
  45250. }
  45251. }
  45252. var target;
  45253. function add (event, fn) {
  45254. target.$on(event, fn);
  45255. }
  45256. function remove$1 (event, fn) {
  45257. target.$off(event, fn);
  45258. }
  45259. function createOnceHandler (event, fn) {
  45260. var _target = target;
  45261. return function onceHandler () {
  45262. var res = fn.apply(null, arguments);
  45263. if (res !== null) {
  45264. _target.$off(event, onceHandler);
  45265. }
  45266. }
  45267. }
  45268. function updateComponentListeners (
  45269. vm,
  45270. listeners,
  45271. oldListeners
  45272. ) {
  45273. target = vm;
  45274. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45275. target = undefined;
  45276. }
  45277. function eventsMixin (Vue) {
  45278. var hookRE = /^hook:/;
  45279. Vue.prototype.$on = function (event, fn) {
  45280. var vm = this;
  45281. if (Array.isArray(event)) {
  45282. for (var i = 0, l = event.length; i < l; i++) {
  45283. vm.$on(event[i], fn);
  45284. }
  45285. } else {
  45286. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45287. // optimize hook:event cost by using a boolean flag marked at registration
  45288. // instead of a hash lookup
  45289. if (hookRE.test(event)) {
  45290. vm._hasHookEvent = true;
  45291. }
  45292. }
  45293. return vm
  45294. };
  45295. Vue.prototype.$once = function (event, fn) {
  45296. var vm = this;
  45297. function on () {
  45298. vm.$off(event, on);
  45299. fn.apply(vm, arguments);
  45300. }
  45301. on.fn = fn;
  45302. vm.$on(event, on);
  45303. return vm
  45304. };
  45305. Vue.prototype.$off = function (event, fn) {
  45306. var vm = this;
  45307. // all
  45308. if (!arguments.length) {
  45309. vm._events = Object.create(null);
  45310. return vm
  45311. }
  45312. // array of events
  45313. if (Array.isArray(event)) {
  45314. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45315. vm.$off(event[i$1], fn);
  45316. }
  45317. return vm
  45318. }
  45319. // specific event
  45320. var cbs = vm._events[event];
  45321. if (!cbs) {
  45322. return vm
  45323. }
  45324. if (!fn) {
  45325. vm._events[event] = null;
  45326. return vm
  45327. }
  45328. // specific handler
  45329. var cb;
  45330. var i = cbs.length;
  45331. while (i--) {
  45332. cb = cbs[i];
  45333. if (cb === fn || cb.fn === fn) {
  45334. cbs.splice(i, 1);
  45335. break
  45336. }
  45337. }
  45338. return vm
  45339. };
  45340. Vue.prototype.$emit = function (event) {
  45341. var vm = this;
  45342. {
  45343. var lowerCaseEvent = event.toLowerCase();
  45344. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45345. tip(
  45346. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45347. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45348. "Note that HTML attributes are case-insensitive and you cannot use " +
  45349. "v-on to listen to camelCase events when using in-DOM templates. " +
  45350. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45351. );
  45352. }
  45353. }
  45354. var cbs = vm._events[event];
  45355. if (cbs) {
  45356. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45357. var args = toArray(arguments, 1);
  45358. var info = "event handler for \"" + event + "\"";
  45359. for (var i = 0, l = cbs.length; i < l; i++) {
  45360. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45361. }
  45362. }
  45363. return vm
  45364. };
  45365. }
  45366. /* */
  45367. var activeInstance = null;
  45368. var isUpdatingChildComponent = false;
  45369. function setActiveInstance(vm) {
  45370. var prevActiveInstance = activeInstance;
  45371. activeInstance = vm;
  45372. return function () {
  45373. activeInstance = prevActiveInstance;
  45374. }
  45375. }
  45376. function initLifecycle (vm) {
  45377. var options = vm.$options;
  45378. // locate first non-abstract parent
  45379. var parent = options.parent;
  45380. if (parent && !options.abstract) {
  45381. while (parent.$options.abstract && parent.$parent) {
  45382. parent = parent.$parent;
  45383. }
  45384. parent.$children.push(vm);
  45385. }
  45386. vm.$parent = parent;
  45387. vm.$root = parent ? parent.$root : vm;
  45388. vm.$children = [];
  45389. vm.$refs = {};
  45390. vm._watcher = null;
  45391. vm._inactive = null;
  45392. vm._directInactive = false;
  45393. vm._isMounted = false;
  45394. vm._isDestroyed = false;
  45395. vm._isBeingDestroyed = false;
  45396. }
  45397. function lifecycleMixin (Vue) {
  45398. Vue.prototype._update = function (vnode, hydrating) {
  45399. var vm = this;
  45400. var prevEl = vm.$el;
  45401. var prevVnode = vm._vnode;
  45402. var restoreActiveInstance = setActiveInstance(vm);
  45403. vm._vnode = vnode;
  45404. // Vue.prototype.__patch__ is injected in entry points
  45405. // based on the rendering backend used.
  45406. if (!prevVnode) {
  45407. // initial render
  45408. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45409. } else {
  45410. // updates
  45411. vm.$el = vm.__patch__(prevVnode, vnode);
  45412. }
  45413. restoreActiveInstance();
  45414. // update __vue__ reference
  45415. if (prevEl) {
  45416. prevEl.__vue__ = null;
  45417. }
  45418. if (vm.$el) {
  45419. vm.$el.__vue__ = vm;
  45420. }
  45421. // if parent is an HOC, update its $el as well
  45422. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45423. vm.$parent.$el = vm.$el;
  45424. }
  45425. // updated hook is called by the scheduler to ensure that children are
  45426. // updated in a parent's updated hook.
  45427. };
  45428. Vue.prototype.$forceUpdate = function () {
  45429. var vm = this;
  45430. if (vm._watcher) {
  45431. vm._watcher.update();
  45432. }
  45433. };
  45434. Vue.prototype.$destroy = function () {
  45435. var vm = this;
  45436. if (vm._isBeingDestroyed) {
  45437. return
  45438. }
  45439. callHook(vm, 'beforeDestroy');
  45440. vm._isBeingDestroyed = true;
  45441. // remove self from parent
  45442. var parent = vm.$parent;
  45443. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45444. remove(parent.$children, vm);
  45445. }
  45446. // teardown watchers
  45447. if (vm._watcher) {
  45448. vm._watcher.teardown();
  45449. }
  45450. var i = vm._watchers.length;
  45451. while (i--) {
  45452. vm._watchers[i].teardown();
  45453. }
  45454. // remove reference from data ob
  45455. // frozen object may not have observer.
  45456. if (vm._data.__ob__) {
  45457. vm._data.__ob__.vmCount--;
  45458. }
  45459. // call the last hook...
  45460. vm._isDestroyed = true;
  45461. // invoke destroy hooks on current rendered tree
  45462. vm.__patch__(vm._vnode, null);
  45463. // fire destroyed hook
  45464. callHook(vm, 'destroyed');
  45465. // turn off all instance listeners.
  45466. vm.$off();
  45467. // remove __vue__ reference
  45468. if (vm.$el) {
  45469. vm.$el.__vue__ = null;
  45470. }
  45471. // release circular reference (#6759)
  45472. if (vm.$vnode) {
  45473. vm.$vnode.parent = null;
  45474. }
  45475. };
  45476. }
  45477. function mountComponent (
  45478. vm,
  45479. el,
  45480. hydrating
  45481. ) {
  45482. vm.$el = el;
  45483. if (!vm.$options.render) {
  45484. vm.$options.render = createEmptyVNode;
  45485. {
  45486. /* istanbul ignore if */
  45487. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45488. vm.$options.el || el) {
  45489. warn(
  45490. 'You are using the runtime-only build of Vue where the template ' +
  45491. 'compiler is not available. Either pre-compile the templates into ' +
  45492. 'render functions, or use the compiler-included build.',
  45493. vm
  45494. );
  45495. } else {
  45496. warn(
  45497. 'Failed to mount component: template or render function not defined.',
  45498. vm
  45499. );
  45500. }
  45501. }
  45502. }
  45503. callHook(vm, 'beforeMount');
  45504. var updateComponent;
  45505. /* istanbul ignore if */
  45506. if (config.performance && mark) {
  45507. updateComponent = function () {
  45508. var name = vm._name;
  45509. var id = vm._uid;
  45510. var startTag = "vue-perf-start:" + id;
  45511. var endTag = "vue-perf-end:" + id;
  45512. mark(startTag);
  45513. var vnode = vm._render();
  45514. mark(endTag);
  45515. measure(("vue " + name + " render"), startTag, endTag);
  45516. mark(startTag);
  45517. vm._update(vnode, hydrating);
  45518. mark(endTag);
  45519. measure(("vue " + name + " patch"), startTag, endTag);
  45520. };
  45521. } else {
  45522. updateComponent = function () {
  45523. vm._update(vm._render(), hydrating);
  45524. };
  45525. }
  45526. // we set this to vm._watcher inside the watcher's constructor
  45527. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45528. // component's mounted hook), which relies on vm._watcher being already defined
  45529. new Watcher(vm, updateComponent, noop, {
  45530. before: function before () {
  45531. if (vm._isMounted && !vm._isDestroyed) {
  45532. callHook(vm, 'beforeUpdate');
  45533. }
  45534. }
  45535. }, true /* isRenderWatcher */);
  45536. hydrating = false;
  45537. // manually mounted instance, call mounted on self
  45538. // mounted is called for render-created child components in its inserted hook
  45539. if (vm.$vnode == null) {
  45540. vm._isMounted = true;
  45541. callHook(vm, 'mounted');
  45542. }
  45543. return vm
  45544. }
  45545. function updateChildComponent (
  45546. vm,
  45547. propsData,
  45548. listeners,
  45549. parentVnode,
  45550. renderChildren
  45551. ) {
  45552. {
  45553. isUpdatingChildComponent = true;
  45554. }
  45555. // determine whether component has slot children
  45556. // we need to do this before overwriting $options._renderChildren.
  45557. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45558. // dynamic slot names). Static scoped slots compiled from template has the
  45559. // "$stable" marker.
  45560. var newScopedSlots = parentVnode.data.scopedSlots;
  45561. var oldScopedSlots = vm.$scopedSlots;
  45562. var hasDynamicScopedSlot = !!(
  45563. (newScopedSlots && !newScopedSlots.$stable) ||
  45564. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45565. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45566. );
  45567. // Any static slot children from the parent may have changed during parent's
  45568. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45569. // update is necessary to ensure correctness.
  45570. var needsForceUpdate = !!(
  45571. renderChildren || // has new static slots
  45572. vm.$options._renderChildren || // has old static slots
  45573. hasDynamicScopedSlot
  45574. );
  45575. vm.$options._parentVnode = parentVnode;
  45576. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45577. if (vm._vnode) { // update child tree's parent
  45578. vm._vnode.parent = parentVnode;
  45579. }
  45580. vm.$options._renderChildren = renderChildren;
  45581. // update $attrs and $listeners hash
  45582. // these are also reactive so they may trigger child update if the child
  45583. // used them during render
  45584. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45585. vm.$listeners = listeners || emptyObject;
  45586. // update props
  45587. if (propsData && vm.$options.props) {
  45588. toggleObserving(false);
  45589. var props = vm._props;
  45590. var propKeys = vm.$options._propKeys || [];
  45591. for (var i = 0; i < propKeys.length; i++) {
  45592. var key = propKeys[i];
  45593. var propOptions = vm.$options.props; // wtf flow?
  45594. props[key] = validateProp(key, propOptions, propsData, vm);
  45595. }
  45596. toggleObserving(true);
  45597. // keep a copy of raw propsData
  45598. vm.$options.propsData = propsData;
  45599. }
  45600. // update listeners
  45601. listeners = listeners || emptyObject;
  45602. var oldListeners = vm.$options._parentListeners;
  45603. vm.$options._parentListeners = listeners;
  45604. updateComponentListeners(vm, listeners, oldListeners);
  45605. // resolve slots + force update if has children
  45606. if (needsForceUpdate) {
  45607. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45608. vm.$forceUpdate();
  45609. }
  45610. {
  45611. isUpdatingChildComponent = false;
  45612. }
  45613. }
  45614. function isInInactiveTree (vm) {
  45615. while (vm && (vm = vm.$parent)) {
  45616. if (vm._inactive) { return true }
  45617. }
  45618. return false
  45619. }
  45620. function activateChildComponent (vm, direct) {
  45621. if (direct) {
  45622. vm._directInactive = false;
  45623. if (isInInactiveTree(vm)) {
  45624. return
  45625. }
  45626. } else if (vm._directInactive) {
  45627. return
  45628. }
  45629. if (vm._inactive || vm._inactive === null) {
  45630. vm._inactive = false;
  45631. for (var i = 0; i < vm.$children.length; i++) {
  45632. activateChildComponent(vm.$children[i]);
  45633. }
  45634. callHook(vm, 'activated');
  45635. }
  45636. }
  45637. function deactivateChildComponent (vm, direct) {
  45638. if (direct) {
  45639. vm._directInactive = true;
  45640. if (isInInactiveTree(vm)) {
  45641. return
  45642. }
  45643. }
  45644. if (!vm._inactive) {
  45645. vm._inactive = true;
  45646. for (var i = 0; i < vm.$children.length; i++) {
  45647. deactivateChildComponent(vm.$children[i]);
  45648. }
  45649. callHook(vm, 'deactivated');
  45650. }
  45651. }
  45652. function callHook (vm, hook) {
  45653. // #7573 disable dep collection when invoking lifecycle hooks
  45654. pushTarget();
  45655. var handlers = vm.$options[hook];
  45656. var info = hook + " hook";
  45657. if (handlers) {
  45658. for (var i = 0, j = handlers.length; i < j; i++) {
  45659. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45660. }
  45661. }
  45662. if (vm._hasHookEvent) {
  45663. vm.$emit('hook:' + hook);
  45664. }
  45665. popTarget();
  45666. }
  45667. /* */
  45668. var MAX_UPDATE_COUNT = 100;
  45669. var queue = [];
  45670. var activatedChildren = [];
  45671. var has = {};
  45672. var circular = {};
  45673. var waiting = false;
  45674. var flushing = false;
  45675. var index = 0;
  45676. /**
  45677. * Reset the scheduler's state.
  45678. */
  45679. function resetSchedulerState () {
  45680. index = queue.length = activatedChildren.length = 0;
  45681. has = {};
  45682. {
  45683. circular = {};
  45684. }
  45685. waiting = flushing = false;
  45686. }
  45687. // Async edge case #6566 requires saving the timestamp when event listeners are
  45688. // attached. However, calling performance.now() has a perf overhead especially
  45689. // if the page has thousands of event listeners. Instead, we take a timestamp
  45690. // every time the scheduler flushes and use that for all event listeners
  45691. // attached during that flush.
  45692. var currentFlushTimestamp = 0;
  45693. // Async edge case fix requires storing an event listener's attach timestamp.
  45694. var getNow = Date.now;
  45695. // Determine what event timestamp the browser is using. Annoyingly, the
  45696. // timestamp can either be hi-res (relative to page load) or low-res
  45697. // (relative to UNIX epoch), so in order to compare time we have to use the
  45698. // same timestamp type when saving the flush timestamp.
  45699. // All IE versions use low-res event timestamps, and have problematic clock
  45700. // implementations (#9632)
  45701. if (inBrowser && !isIE) {
  45702. var performance = window.performance;
  45703. if (
  45704. performance &&
  45705. typeof performance.now === 'function' &&
  45706. getNow() > document.createEvent('Event').timeStamp
  45707. ) {
  45708. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45709. // smaller than it, it means the event is using a hi-res timestamp,
  45710. // and we need to use the hi-res version for event listener timestamps as
  45711. // well.
  45712. getNow = function () { return performance.now(); };
  45713. }
  45714. }
  45715. /**
  45716. * Flush both queues and run the watchers.
  45717. */
  45718. function flushSchedulerQueue () {
  45719. currentFlushTimestamp = getNow();
  45720. flushing = true;
  45721. var watcher, id;
  45722. // Sort queue before flush.
  45723. // This ensures that:
  45724. // 1. Components are updated from parent to child. (because parent is always
  45725. // created before the child)
  45726. // 2. A component's user watchers are run before its render watcher (because
  45727. // user watchers are created before the render watcher)
  45728. // 3. If a component is destroyed during a parent component's watcher run,
  45729. // its watchers can be skipped.
  45730. queue.sort(function (a, b) { return a.id - b.id; });
  45731. // do not cache length because more watchers might be pushed
  45732. // as we run existing watchers
  45733. for (index = 0; index < queue.length; index++) {
  45734. watcher = queue[index];
  45735. if (watcher.before) {
  45736. watcher.before();
  45737. }
  45738. id = watcher.id;
  45739. has[id] = null;
  45740. watcher.run();
  45741. // in dev build, check and stop circular updates.
  45742. if (has[id] != null) {
  45743. circular[id] = (circular[id] || 0) + 1;
  45744. if (circular[id] > MAX_UPDATE_COUNT) {
  45745. warn(
  45746. 'You may have an infinite update loop ' + (
  45747. watcher.user
  45748. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45749. : "in a component render function."
  45750. ),
  45751. watcher.vm
  45752. );
  45753. break
  45754. }
  45755. }
  45756. }
  45757. // keep copies of post queues before resetting state
  45758. var activatedQueue = activatedChildren.slice();
  45759. var updatedQueue = queue.slice();
  45760. resetSchedulerState();
  45761. // call component updated and activated hooks
  45762. callActivatedHooks(activatedQueue);
  45763. callUpdatedHooks(updatedQueue);
  45764. // devtool hook
  45765. /* istanbul ignore if */
  45766. if (devtools && config.devtools) {
  45767. devtools.emit('flush');
  45768. }
  45769. }
  45770. function callUpdatedHooks (queue) {
  45771. var i = queue.length;
  45772. while (i--) {
  45773. var watcher = queue[i];
  45774. var vm = watcher.vm;
  45775. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45776. callHook(vm, 'updated');
  45777. }
  45778. }
  45779. }
  45780. /**
  45781. * Queue a kept-alive component that was activated during patch.
  45782. * The queue will be processed after the entire tree has been patched.
  45783. */
  45784. function queueActivatedComponent (vm) {
  45785. // setting _inactive to false here so that a render function can
  45786. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45787. vm._inactive = false;
  45788. activatedChildren.push(vm);
  45789. }
  45790. function callActivatedHooks (queue) {
  45791. for (var i = 0; i < queue.length; i++) {
  45792. queue[i]._inactive = true;
  45793. activateChildComponent(queue[i], true /* true */);
  45794. }
  45795. }
  45796. /**
  45797. * Push a watcher into the watcher queue.
  45798. * Jobs with duplicate IDs will be skipped unless it's
  45799. * pushed when the queue is being flushed.
  45800. */
  45801. function queueWatcher (watcher) {
  45802. var id = watcher.id;
  45803. if (has[id] == null) {
  45804. has[id] = true;
  45805. if (!flushing) {
  45806. queue.push(watcher);
  45807. } else {
  45808. // if already flushing, splice the watcher based on its id
  45809. // if already past its id, it will be run next immediately.
  45810. var i = queue.length - 1;
  45811. while (i > index && queue[i].id > watcher.id) {
  45812. i--;
  45813. }
  45814. queue.splice(i + 1, 0, watcher);
  45815. }
  45816. // queue the flush
  45817. if (!waiting) {
  45818. waiting = true;
  45819. if (!config.async) {
  45820. flushSchedulerQueue();
  45821. return
  45822. }
  45823. nextTick(flushSchedulerQueue);
  45824. }
  45825. }
  45826. }
  45827. /* */
  45828. var uid$2 = 0;
  45829. /**
  45830. * A watcher parses an expression, collects dependencies,
  45831. * and fires callback when the expression value changes.
  45832. * This is used for both the $watch() api and directives.
  45833. */
  45834. var Watcher = function Watcher (
  45835. vm,
  45836. expOrFn,
  45837. cb,
  45838. options,
  45839. isRenderWatcher
  45840. ) {
  45841. this.vm = vm;
  45842. if (isRenderWatcher) {
  45843. vm._watcher = this;
  45844. }
  45845. vm._watchers.push(this);
  45846. // options
  45847. if (options) {
  45848. this.deep = !!options.deep;
  45849. this.user = !!options.user;
  45850. this.lazy = !!options.lazy;
  45851. this.sync = !!options.sync;
  45852. this.before = options.before;
  45853. } else {
  45854. this.deep = this.user = this.lazy = this.sync = false;
  45855. }
  45856. this.cb = cb;
  45857. this.id = ++uid$2; // uid for batching
  45858. this.active = true;
  45859. this.dirty = this.lazy; // for lazy watchers
  45860. this.deps = [];
  45861. this.newDeps = [];
  45862. this.depIds = new _Set();
  45863. this.newDepIds = new _Set();
  45864. this.expression = expOrFn.toString();
  45865. // parse expression for getter
  45866. if (typeof expOrFn === 'function') {
  45867. this.getter = expOrFn;
  45868. } else {
  45869. this.getter = parsePath(expOrFn);
  45870. if (!this.getter) {
  45871. this.getter = noop;
  45872. warn(
  45873. "Failed watching path: \"" + expOrFn + "\" " +
  45874. 'Watcher only accepts simple dot-delimited paths. ' +
  45875. 'For full control, use a function instead.',
  45876. vm
  45877. );
  45878. }
  45879. }
  45880. this.value = this.lazy
  45881. ? undefined
  45882. : this.get();
  45883. };
  45884. /**
  45885. * Evaluate the getter, and re-collect dependencies.
  45886. */
  45887. Watcher.prototype.get = function get () {
  45888. pushTarget(this);
  45889. var value;
  45890. var vm = this.vm;
  45891. try {
  45892. value = this.getter.call(vm, vm);
  45893. } catch (e) {
  45894. if (this.user) {
  45895. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45896. } else {
  45897. throw e
  45898. }
  45899. } finally {
  45900. // "touch" every property so they are all tracked as
  45901. // dependencies for deep watching
  45902. if (this.deep) {
  45903. traverse(value);
  45904. }
  45905. popTarget();
  45906. this.cleanupDeps();
  45907. }
  45908. return value
  45909. };
  45910. /**
  45911. * Add a dependency to this directive.
  45912. */
  45913. Watcher.prototype.addDep = function addDep (dep) {
  45914. var id = dep.id;
  45915. if (!this.newDepIds.has(id)) {
  45916. this.newDepIds.add(id);
  45917. this.newDeps.push(dep);
  45918. if (!this.depIds.has(id)) {
  45919. dep.addSub(this);
  45920. }
  45921. }
  45922. };
  45923. /**
  45924. * Clean up for dependency collection.
  45925. */
  45926. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45927. var i = this.deps.length;
  45928. while (i--) {
  45929. var dep = this.deps[i];
  45930. if (!this.newDepIds.has(dep.id)) {
  45931. dep.removeSub(this);
  45932. }
  45933. }
  45934. var tmp = this.depIds;
  45935. this.depIds = this.newDepIds;
  45936. this.newDepIds = tmp;
  45937. this.newDepIds.clear();
  45938. tmp = this.deps;
  45939. this.deps = this.newDeps;
  45940. this.newDeps = tmp;
  45941. this.newDeps.length = 0;
  45942. };
  45943. /**
  45944. * Subscriber interface.
  45945. * Will be called when a dependency changes.
  45946. */
  45947. Watcher.prototype.update = function update () {
  45948. /* istanbul ignore else */
  45949. if (this.lazy) {
  45950. this.dirty = true;
  45951. } else if (this.sync) {
  45952. this.run();
  45953. } else {
  45954. queueWatcher(this);
  45955. }
  45956. };
  45957. /**
  45958. * Scheduler job interface.
  45959. * Will be called by the scheduler.
  45960. */
  45961. Watcher.prototype.run = function run () {
  45962. if (this.active) {
  45963. var value = this.get();
  45964. if (
  45965. value !== this.value ||
  45966. // Deep watchers and watchers on Object/Arrays should fire even
  45967. // when the value is the same, because the value may
  45968. // have mutated.
  45969. isObject(value) ||
  45970. this.deep
  45971. ) {
  45972. // set new value
  45973. var oldValue = this.value;
  45974. this.value = value;
  45975. if (this.user) {
  45976. try {
  45977. this.cb.call(this.vm, value, oldValue);
  45978. } catch (e) {
  45979. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45980. }
  45981. } else {
  45982. this.cb.call(this.vm, value, oldValue);
  45983. }
  45984. }
  45985. }
  45986. };
  45987. /**
  45988. * Evaluate the value of the watcher.
  45989. * This only gets called for lazy watchers.
  45990. */
  45991. Watcher.prototype.evaluate = function evaluate () {
  45992. this.value = this.get();
  45993. this.dirty = false;
  45994. };
  45995. /**
  45996. * Depend on all deps collected by this watcher.
  45997. */
  45998. Watcher.prototype.depend = function depend () {
  45999. var i = this.deps.length;
  46000. while (i--) {
  46001. this.deps[i].depend();
  46002. }
  46003. };
  46004. /**
  46005. * Remove self from all dependencies' subscriber list.
  46006. */
  46007. Watcher.prototype.teardown = function teardown () {
  46008. if (this.active) {
  46009. // remove self from vm's watcher list
  46010. // this is a somewhat expensive operation so we skip it
  46011. // if the vm is being destroyed.
  46012. if (!this.vm._isBeingDestroyed) {
  46013. remove(this.vm._watchers, this);
  46014. }
  46015. var i = this.deps.length;
  46016. while (i--) {
  46017. this.deps[i].removeSub(this);
  46018. }
  46019. this.active = false;
  46020. }
  46021. };
  46022. /* */
  46023. var sharedPropertyDefinition = {
  46024. enumerable: true,
  46025. configurable: true,
  46026. get: noop,
  46027. set: noop
  46028. };
  46029. function proxy (target, sourceKey, key) {
  46030. sharedPropertyDefinition.get = function proxyGetter () {
  46031. return this[sourceKey][key]
  46032. };
  46033. sharedPropertyDefinition.set = function proxySetter (val) {
  46034. this[sourceKey][key] = val;
  46035. };
  46036. Object.defineProperty(target, key, sharedPropertyDefinition);
  46037. }
  46038. function initState (vm) {
  46039. vm._watchers = [];
  46040. var opts = vm.$options;
  46041. if (opts.props) { initProps(vm, opts.props); }
  46042. if (opts.methods) { initMethods(vm, opts.methods); }
  46043. if (opts.data) {
  46044. initData(vm);
  46045. } else {
  46046. observe(vm._data = {}, true /* asRootData */);
  46047. }
  46048. if (opts.computed) { initComputed(vm, opts.computed); }
  46049. if (opts.watch && opts.watch !== nativeWatch) {
  46050. initWatch(vm, opts.watch);
  46051. }
  46052. }
  46053. function initProps (vm, propsOptions) {
  46054. var propsData = vm.$options.propsData || {};
  46055. var props = vm._props = {};
  46056. // cache prop keys so that future props updates can iterate using Array
  46057. // instead of dynamic object key enumeration.
  46058. var keys = vm.$options._propKeys = [];
  46059. var isRoot = !vm.$parent;
  46060. // root instance props should be converted
  46061. if (!isRoot) {
  46062. toggleObserving(false);
  46063. }
  46064. var loop = function ( key ) {
  46065. keys.push(key);
  46066. var value = validateProp(key, propsOptions, propsData, vm);
  46067. /* istanbul ignore else */
  46068. {
  46069. var hyphenatedKey = hyphenate(key);
  46070. if (isReservedAttribute(hyphenatedKey) ||
  46071. config.isReservedAttr(hyphenatedKey)) {
  46072. warn(
  46073. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  46074. vm
  46075. );
  46076. }
  46077. defineReactive$$1(props, key, value, function () {
  46078. if (!isRoot && !isUpdatingChildComponent) {
  46079. warn(
  46080. "Avoid mutating a prop directly since the value will be " +
  46081. "overwritten whenever the parent component re-renders. " +
  46082. "Instead, use a data or computed property based on the prop's " +
  46083. "value. Prop being mutated: \"" + key + "\"",
  46084. vm
  46085. );
  46086. }
  46087. });
  46088. }
  46089. // static props are already proxied on the component's prototype
  46090. // during Vue.extend(). We only need to proxy props defined at
  46091. // instantiation here.
  46092. if (!(key in vm)) {
  46093. proxy(vm, "_props", key);
  46094. }
  46095. };
  46096. for (var key in propsOptions) loop( key );
  46097. toggleObserving(true);
  46098. }
  46099. function initData (vm) {
  46100. var data = vm.$options.data;
  46101. data = vm._data = typeof data === 'function'
  46102. ? getData(data, vm)
  46103. : data || {};
  46104. if (!isPlainObject(data)) {
  46105. data = {};
  46106. warn(
  46107. 'data functions should return an object:\n' +
  46108. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  46109. vm
  46110. );
  46111. }
  46112. // proxy data on instance
  46113. var keys = Object.keys(data);
  46114. var props = vm.$options.props;
  46115. var methods = vm.$options.methods;
  46116. var i = keys.length;
  46117. while (i--) {
  46118. var key = keys[i];
  46119. {
  46120. if (methods && hasOwn(methods, key)) {
  46121. warn(
  46122. ("Method \"" + key + "\" has already been defined as a data property."),
  46123. vm
  46124. );
  46125. }
  46126. }
  46127. if (props && hasOwn(props, key)) {
  46128. warn(
  46129. "The data property \"" + key + "\" is already declared as a prop. " +
  46130. "Use prop default value instead.",
  46131. vm
  46132. );
  46133. } else if (!isReserved(key)) {
  46134. proxy(vm, "_data", key);
  46135. }
  46136. }
  46137. // observe data
  46138. observe(data, true /* asRootData */);
  46139. }
  46140. function getData (data, vm) {
  46141. // #7573 disable dep collection when invoking data getters
  46142. pushTarget();
  46143. try {
  46144. return data.call(vm, vm)
  46145. } catch (e) {
  46146. handleError(e, vm, "data()");
  46147. return {}
  46148. } finally {
  46149. popTarget();
  46150. }
  46151. }
  46152. var computedWatcherOptions = { lazy: true };
  46153. function initComputed (vm, computed) {
  46154. // $flow-disable-line
  46155. var watchers = vm._computedWatchers = Object.create(null);
  46156. // computed properties are just getters during SSR
  46157. var isSSR = isServerRendering();
  46158. for (var key in computed) {
  46159. var userDef = computed[key];
  46160. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46161. if (getter == null) {
  46162. warn(
  46163. ("Getter is missing for computed property \"" + key + "\"."),
  46164. vm
  46165. );
  46166. }
  46167. if (!isSSR) {
  46168. // create internal watcher for the computed property.
  46169. watchers[key] = new Watcher(
  46170. vm,
  46171. getter || noop,
  46172. noop,
  46173. computedWatcherOptions
  46174. );
  46175. }
  46176. // component-defined computed properties are already defined on the
  46177. // component prototype. We only need to define computed properties defined
  46178. // at instantiation here.
  46179. if (!(key in vm)) {
  46180. defineComputed(vm, key, userDef);
  46181. } else {
  46182. if (key in vm.$data) {
  46183. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46184. } else if (vm.$options.props && key in vm.$options.props) {
  46185. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46186. }
  46187. }
  46188. }
  46189. }
  46190. function defineComputed (
  46191. target,
  46192. key,
  46193. userDef
  46194. ) {
  46195. var shouldCache = !isServerRendering();
  46196. if (typeof userDef === 'function') {
  46197. sharedPropertyDefinition.get = shouldCache
  46198. ? createComputedGetter(key)
  46199. : createGetterInvoker(userDef);
  46200. sharedPropertyDefinition.set = noop;
  46201. } else {
  46202. sharedPropertyDefinition.get = userDef.get
  46203. ? shouldCache && userDef.cache !== false
  46204. ? createComputedGetter(key)
  46205. : createGetterInvoker(userDef.get)
  46206. : noop;
  46207. sharedPropertyDefinition.set = userDef.set || noop;
  46208. }
  46209. if (sharedPropertyDefinition.set === noop) {
  46210. sharedPropertyDefinition.set = function () {
  46211. warn(
  46212. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46213. this
  46214. );
  46215. };
  46216. }
  46217. Object.defineProperty(target, key, sharedPropertyDefinition);
  46218. }
  46219. function createComputedGetter (key) {
  46220. return function computedGetter () {
  46221. var watcher = this._computedWatchers && this._computedWatchers[key];
  46222. if (watcher) {
  46223. if (watcher.dirty) {
  46224. watcher.evaluate();
  46225. }
  46226. if (Dep.target) {
  46227. watcher.depend();
  46228. }
  46229. return watcher.value
  46230. }
  46231. }
  46232. }
  46233. function createGetterInvoker(fn) {
  46234. return function computedGetter () {
  46235. return fn.call(this, this)
  46236. }
  46237. }
  46238. function initMethods (vm, methods) {
  46239. var props = vm.$options.props;
  46240. for (var key in methods) {
  46241. {
  46242. if (typeof methods[key] !== 'function') {
  46243. warn(
  46244. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46245. "Did you reference the function correctly?",
  46246. vm
  46247. );
  46248. }
  46249. if (props && hasOwn(props, key)) {
  46250. warn(
  46251. ("Method \"" + key + "\" has already been defined as a prop."),
  46252. vm
  46253. );
  46254. }
  46255. if ((key in vm) && isReserved(key)) {
  46256. warn(
  46257. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46258. "Avoid defining component methods that start with _ or $."
  46259. );
  46260. }
  46261. }
  46262. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46263. }
  46264. }
  46265. function initWatch (vm, watch) {
  46266. for (var key in watch) {
  46267. var handler = watch[key];
  46268. if (Array.isArray(handler)) {
  46269. for (var i = 0; i < handler.length; i++) {
  46270. createWatcher(vm, key, handler[i]);
  46271. }
  46272. } else {
  46273. createWatcher(vm, key, handler);
  46274. }
  46275. }
  46276. }
  46277. function createWatcher (
  46278. vm,
  46279. expOrFn,
  46280. handler,
  46281. options
  46282. ) {
  46283. if (isPlainObject(handler)) {
  46284. options = handler;
  46285. handler = handler.handler;
  46286. }
  46287. if (typeof handler === 'string') {
  46288. handler = vm[handler];
  46289. }
  46290. return vm.$watch(expOrFn, handler, options)
  46291. }
  46292. function stateMixin (Vue) {
  46293. // flow somehow has problems with directly declared definition object
  46294. // when using Object.defineProperty, so we have to procedurally build up
  46295. // the object here.
  46296. var dataDef = {};
  46297. dataDef.get = function () { return this._data };
  46298. var propsDef = {};
  46299. propsDef.get = function () { return this._props };
  46300. {
  46301. dataDef.set = function () {
  46302. warn(
  46303. 'Avoid replacing instance root $data. ' +
  46304. 'Use nested data properties instead.',
  46305. this
  46306. );
  46307. };
  46308. propsDef.set = function () {
  46309. warn("$props is readonly.", this);
  46310. };
  46311. }
  46312. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46313. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46314. Vue.prototype.$set = set;
  46315. Vue.prototype.$delete = del;
  46316. Vue.prototype.$watch = function (
  46317. expOrFn,
  46318. cb,
  46319. options
  46320. ) {
  46321. var vm = this;
  46322. if (isPlainObject(cb)) {
  46323. return createWatcher(vm, expOrFn, cb, options)
  46324. }
  46325. options = options || {};
  46326. options.user = true;
  46327. var watcher = new Watcher(vm, expOrFn, cb, options);
  46328. if (options.immediate) {
  46329. try {
  46330. cb.call(vm, watcher.value);
  46331. } catch (error) {
  46332. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46333. }
  46334. }
  46335. return function unwatchFn () {
  46336. watcher.teardown();
  46337. }
  46338. };
  46339. }
  46340. /* */
  46341. var uid$3 = 0;
  46342. function initMixin (Vue) {
  46343. Vue.prototype._init = function (options) {
  46344. var vm = this;
  46345. // a uid
  46346. vm._uid = uid$3++;
  46347. var startTag, endTag;
  46348. /* istanbul ignore if */
  46349. if (config.performance && mark) {
  46350. startTag = "vue-perf-start:" + (vm._uid);
  46351. endTag = "vue-perf-end:" + (vm._uid);
  46352. mark(startTag);
  46353. }
  46354. // a flag to avoid this being observed
  46355. vm._isVue = true;
  46356. // merge options
  46357. if (options && options._isComponent) {
  46358. // optimize internal component instantiation
  46359. // since dynamic options merging is pretty slow, and none of the
  46360. // internal component options needs special treatment.
  46361. initInternalComponent(vm, options);
  46362. } else {
  46363. vm.$options = mergeOptions(
  46364. resolveConstructorOptions(vm.constructor),
  46365. options || {},
  46366. vm
  46367. );
  46368. }
  46369. /* istanbul ignore else */
  46370. {
  46371. initProxy(vm);
  46372. }
  46373. // expose real self
  46374. vm._self = vm;
  46375. initLifecycle(vm);
  46376. initEvents(vm);
  46377. initRender(vm);
  46378. callHook(vm, 'beforeCreate');
  46379. initInjections(vm); // resolve injections before data/props
  46380. initState(vm);
  46381. initProvide(vm); // resolve provide after data/props
  46382. callHook(vm, 'created');
  46383. /* istanbul ignore if */
  46384. if (config.performance && mark) {
  46385. vm._name = formatComponentName(vm, false);
  46386. mark(endTag);
  46387. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46388. }
  46389. if (vm.$options.el) {
  46390. vm.$mount(vm.$options.el);
  46391. }
  46392. };
  46393. }
  46394. function initInternalComponent (vm, options) {
  46395. var opts = vm.$options = Object.create(vm.constructor.options);
  46396. // doing this because it's faster than dynamic enumeration.
  46397. var parentVnode = options._parentVnode;
  46398. opts.parent = options.parent;
  46399. opts._parentVnode = parentVnode;
  46400. var vnodeComponentOptions = parentVnode.componentOptions;
  46401. opts.propsData = vnodeComponentOptions.propsData;
  46402. opts._parentListeners = vnodeComponentOptions.listeners;
  46403. opts._renderChildren = vnodeComponentOptions.children;
  46404. opts._componentTag = vnodeComponentOptions.tag;
  46405. if (options.render) {
  46406. opts.render = options.render;
  46407. opts.staticRenderFns = options.staticRenderFns;
  46408. }
  46409. }
  46410. function resolveConstructorOptions (Ctor) {
  46411. var options = Ctor.options;
  46412. if (Ctor.super) {
  46413. var superOptions = resolveConstructorOptions(Ctor.super);
  46414. var cachedSuperOptions = Ctor.superOptions;
  46415. if (superOptions !== cachedSuperOptions) {
  46416. // super option changed,
  46417. // need to resolve new options.
  46418. Ctor.superOptions = superOptions;
  46419. // check if there are any late-modified/attached options (#4976)
  46420. var modifiedOptions = resolveModifiedOptions(Ctor);
  46421. // update base extend options
  46422. if (modifiedOptions) {
  46423. extend(Ctor.extendOptions, modifiedOptions);
  46424. }
  46425. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46426. if (options.name) {
  46427. options.components[options.name] = Ctor;
  46428. }
  46429. }
  46430. }
  46431. return options
  46432. }
  46433. function resolveModifiedOptions (Ctor) {
  46434. var modified;
  46435. var latest = Ctor.options;
  46436. var sealed = Ctor.sealedOptions;
  46437. for (var key in latest) {
  46438. if (latest[key] !== sealed[key]) {
  46439. if (!modified) { modified = {}; }
  46440. modified[key] = latest[key];
  46441. }
  46442. }
  46443. return modified
  46444. }
  46445. function Vue (options) {
  46446. if (!(this instanceof Vue)
  46447. ) {
  46448. warn('Vue is a constructor and should be called with the `new` keyword');
  46449. }
  46450. this._init(options);
  46451. }
  46452. initMixin(Vue);
  46453. stateMixin(Vue);
  46454. eventsMixin(Vue);
  46455. lifecycleMixin(Vue);
  46456. renderMixin(Vue);
  46457. /* */
  46458. function initUse (Vue) {
  46459. Vue.use = function (plugin) {
  46460. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46461. if (installedPlugins.indexOf(plugin) > -1) {
  46462. return this
  46463. }
  46464. // additional parameters
  46465. var args = toArray(arguments, 1);
  46466. args.unshift(this);
  46467. if (typeof plugin.install === 'function') {
  46468. plugin.install.apply(plugin, args);
  46469. } else if (typeof plugin === 'function') {
  46470. plugin.apply(null, args);
  46471. }
  46472. installedPlugins.push(plugin);
  46473. return this
  46474. };
  46475. }
  46476. /* */
  46477. function initMixin$1 (Vue) {
  46478. Vue.mixin = function (mixin) {
  46479. this.options = mergeOptions(this.options, mixin);
  46480. return this
  46481. };
  46482. }
  46483. /* */
  46484. function initExtend (Vue) {
  46485. /**
  46486. * Each instance constructor, including Vue, has a unique
  46487. * cid. This enables us to create wrapped "child
  46488. * constructors" for prototypal inheritance and cache them.
  46489. */
  46490. Vue.cid = 0;
  46491. var cid = 1;
  46492. /**
  46493. * Class inheritance
  46494. */
  46495. Vue.extend = function (extendOptions) {
  46496. extendOptions = extendOptions || {};
  46497. var Super = this;
  46498. var SuperId = Super.cid;
  46499. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46500. if (cachedCtors[SuperId]) {
  46501. return cachedCtors[SuperId]
  46502. }
  46503. var name = extendOptions.name || Super.options.name;
  46504. if (name) {
  46505. validateComponentName(name);
  46506. }
  46507. var Sub = function VueComponent (options) {
  46508. this._init(options);
  46509. };
  46510. Sub.prototype = Object.create(Super.prototype);
  46511. Sub.prototype.constructor = Sub;
  46512. Sub.cid = cid++;
  46513. Sub.options = mergeOptions(
  46514. Super.options,
  46515. extendOptions
  46516. );
  46517. Sub['super'] = Super;
  46518. // For props and computed properties, we define the proxy getters on
  46519. // the Vue instances at extension time, on the extended prototype. This
  46520. // avoids Object.defineProperty calls for each instance created.
  46521. if (Sub.options.props) {
  46522. initProps$1(Sub);
  46523. }
  46524. if (Sub.options.computed) {
  46525. initComputed$1(Sub);
  46526. }
  46527. // allow further extension/mixin/plugin usage
  46528. Sub.extend = Super.extend;
  46529. Sub.mixin = Super.mixin;
  46530. Sub.use = Super.use;
  46531. // create asset registers, so extended classes
  46532. // can have their private assets too.
  46533. ASSET_TYPES.forEach(function (type) {
  46534. Sub[type] = Super[type];
  46535. });
  46536. // enable recursive self-lookup
  46537. if (name) {
  46538. Sub.options.components[name] = Sub;
  46539. }
  46540. // keep a reference to the super options at extension time.
  46541. // later at instantiation we can check if Super's options have
  46542. // been updated.
  46543. Sub.superOptions = Super.options;
  46544. Sub.extendOptions = extendOptions;
  46545. Sub.sealedOptions = extend({}, Sub.options);
  46546. // cache constructor
  46547. cachedCtors[SuperId] = Sub;
  46548. return Sub
  46549. };
  46550. }
  46551. function initProps$1 (Comp) {
  46552. var props = Comp.options.props;
  46553. for (var key in props) {
  46554. proxy(Comp.prototype, "_props", key);
  46555. }
  46556. }
  46557. function initComputed$1 (Comp) {
  46558. var computed = Comp.options.computed;
  46559. for (var key in computed) {
  46560. defineComputed(Comp.prototype, key, computed[key]);
  46561. }
  46562. }
  46563. /* */
  46564. function initAssetRegisters (Vue) {
  46565. /**
  46566. * Create asset registration methods.
  46567. */
  46568. ASSET_TYPES.forEach(function (type) {
  46569. Vue[type] = function (
  46570. id,
  46571. definition
  46572. ) {
  46573. if (!definition) {
  46574. return this.options[type + 's'][id]
  46575. } else {
  46576. /* istanbul ignore if */
  46577. if (type === 'component') {
  46578. validateComponentName(id);
  46579. }
  46580. if (type === 'component' && isPlainObject(definition)) {
  46581. definition.name = definition.name || id;
  46582. definition = this.options._base.extend(definition);
  46583. }
  46584. if (type === 'directive' && typeof definition === 'function') {
  46585. definition = { bind: definition, update: definition };
  46586. }
  46587. this.options[type + 's'][id] = definition;
  46588. return definition
  46589. }
  46590. };
  46591. });
  46592. }
  46593. /* */
  46594. function getComponentName (opts) {
  46595. return opts && (opts.Ctor.options.name || opts.tag)
  46596. }
  46597. function matches (pattern, name) {
  46598. if (Array.isArray(pattern)) {
  46599. return pattern.indexOf(name) > -1
  46600. } else if (typeof pattern === 'string') {
  46601. return pattern.split(',').indexOf(name) > -1
  46602. } else if (isRegExp(pattern)) {
  46603. return pattern.test(name)
  46604. }
  46605. /* istanbul ignore next */
  46606. return false
  46607. }
  46608. function pruneCache (keepAliveInstance, filter) {
  46609. var cache = keepAliveInstance.cache;
  46610. var keys = keepAliveInstance.keys;
  46611. var _vnode = keepAliveInstance._vnode;
  46612. for (var key in cache) {
  46613. var cachedNode = cache[key];
  46614. if (cachedNode) {
  46615. var name = getComponentName(cachedNode.componentOptions);
  46616. if (name && !filter(name)) {
  46617. pruneCacheEntry(cache, key, keys, _vnode);
  46618. }
  46619. }
  46620. }
  46621. }
  46622. function pruneCacheEntry (
  46623. cache,
  46624. key,
  46625. keys,
  46626. current
  46627. ) {
  46628. var cached$$1 = cache[key];
  46629. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46630. cached$$1.componentInstance.$destroy();
  46631. }
  46632. cache[key] = null;
  46633. remove(keys, key);
  46634. }
  46635. var patternTypes = [String, RegExp, Array];
  46636. var KeepAlive = {
  46637. name: 'keep-alive',
  46638. abstract: true,
  46639. props: {
  46640. include: patternTypes,
  46641. exclude: patternTypes,
  46642. max: [String, Number]
  46643. },
  46644. created: function created () {
  46645. this.cache = Object.create(null);
  46646. this.keys = [];
  46647. },
  46648. destroyed: function destroyed () {
  46649. for (var key in this.cache) {
  46650. pruneCacheEntry(this.cache, key, this.keys);
  46651. }
  46652. },
  46653. mounted: function mounted () {
  46654. var this$1 = this;
  46655. this.$watch('include', function (val) {
  46656. pruneCache(this$1, function (name) { return matches(val, name); });
  46657. });
  46658. this.$watch('exclude', function (val) {
  46659. pruneCache(this$1, function (name) { return !matches(val, name); });
  46660. });
  46661. },
  46662. render: function render () {
  46663. var slot = this.$slots.default;
  46664. var vnode = getFirstComponentChild(slot);
  46665. var componentOptions = vnode && vnode.componentOptions;
  46666. if (componentOptions) {
  46667. // check pattern
  46668. var name = getComponentName(componentOptions);
  46669. var ref = this;
  46670. var include = ref.include;
  46671. var exclude = ref.exclude;
  46672. if (
  46673. // not included
  46674. (include && (!name || !matches(include, name))) ||
  46675. // excluded
  46676. (exclude && name && matches(exclude, name))
  46677. ) {
  46678. return vnode
  46679. }
  46680. var ref$1 = this;
  46681. var cache = ref$1.cache;
  46682. var keys = ref$1.keys;
  46683. var key = vnode.key == null
  46684. // same constructor may get registered as different local components
  46685. // so cid alone is not enough (#3269)
  46686. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46687. : vnode.key;
  46688. if (cache[key]) {
  46689. vnode.componentInstance = cache[key].componentInstance;
  46690. // make current key freshest
  46691. remove(keys, key);
  46692. keys.push(key);
  46693. } else {
  46694. cache[key] = vnode;
  46695. keys.push(key);
  46696. // prune oldest entry
  46697. if (this.max && keys.length > parseInt(this.max)) {
  46698. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46699. }
  46700. }
  46701. vnode.data.keepAlive = true;
  46702. }
  46703. return vnode || (slot && slot[0])
  46704. }
  46705. };
  46706. var builtInComponents = {
  46707. KeepAlive: KeepAlive
  46708. };
  46709. /* */
  46710. function initGlobalAPI (Vue) {
  46711. // config
  46712. var configDef = {};
  46713. configDef.get = function () { return config; };
  46714. {
  46715. configDef.set = function () {
  46716. warn(
  46717. 'Do not replace the Vue.config object, set individual fields instead.'
  46718. );
  46719. };
  46720. }
  46721. Object.defineProperty(Vue, 'config', configDef);
  46722. // exposed util methods.
  46723. // NOTE: these are not considered part of the public API - avoid relying on
  46724. // them unless you are aware of the risk.
  46725. Vue.util = {
  46726. warn: warn,
  46727. extend: extend,
  46728. mergeOptions: mergeOptions,
  46729. defineReactive: defineReactive$$1
  46730. };
  46731. Vue.set = set;
  46732. Vue.delete = del;
  46733. Vue.nextTick = nextTick;
  46734. // 2.6 explicit observable API
  46735. Vue.observable = function (obj) {
  46736. observe(obj);
  46737. return obj
  46738. };
  46739. Vue.options = Object.create(null);
  46740. ASSET_TYPES.forEach(function (type) {
  46741. Vue.options[type + 's'] = Object.create(null);
  46742. });
  46743. // this is used to identify the "base" constructor to extend all plain-object
  46744. // components with in Weex's multi-instance scenarios.
  46745. Vue.options._base = Vue;
  46746. extend(Vue.options.components, builtInComponents);
  46747. initUse(Vue);
  46748. initMixin$1(Vue);
  46749. initExtend(Vue);
  46750. initAssetRegisters(Vue);
  46751. }
  46752. initGlobalAPI(Vue);
  46753. Object.defineProperty(Vue.prototype, '$isServer', {
  46754. get: isServerRendering
  46755. });
  46756. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46757. get: function get () {
  46758. /* istanbul ignore next */
  46759. return this.$vnode && this.$vnode.ssrContext
  46760. }
  46761. });
  46762. // expose FunctionalRenderContext for ssr runtime helper installation
  46763. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46764. value: FunctionalRenderContext
  46765. });
  46766. Vue.version = '2.6.11';
  46767. /* */
  46768. // these are reserved for web because they are directly compiled away
  46769. // during template compilation
  46770. var isReservedAttr = makeMap('style,class');
  46771. // attributes that should be using props for binding
  46772. var acceptValue = makeMap('input,textarea,option,select,progress');
  46773. var mustUseProp = function (tag, type, attr) {
  46774. return (
  46775. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46776. (attr === 'selected' && tag === 'option') ||
  46777. (attr === 'checked' && tag === 'input') ||
  46778. (attr === 'muted' && tag === 'video')
  46779. )
  46780. };
  46781. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46782. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46783. var convertEnumeratedValue = function (key, value) {
  46784. return isFalsyAttrValue(value) || value === 'false'
  46785. ? 'false'
  46786. // allow arbitrary string value for contenteditable
  46787. : key === 'contenteditable' && isValidContentEditableValue(value)
  46788. ? value
  46789. : 'true'
  46790. };
  46791. var isBooleanAttr = makeMap(
  46792. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46793. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46794. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46795. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46796. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46797. 'truespeed,typemustmatch,visible'
  46798. );
  46799. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46800. var isXlink = function (name) {
  46801. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46802. };
  46803. var getXlinkProp = function (name) {
  46804. return isXlink(name) ? name.slice(6, name.length) : ''
  46805. };
  46806. var isFalsyAttrValue = function (val) {
  46807. return val == null || val === false
  46808. };
  46809. /* */
  46810. function genClassForVnode (vnode) {
  46811. var data = vnode.data;
  46812. var parentNode = vnode;
  46813. var childNode = vnode;
  46814. while (isDef(childNode.componentInstance)) {
  46815. childNode = childNode.componentInstance._vnode;
  46816. if (childNode && childNode.data) {
  46817. data = mergeClassData(childNode.data, data);
  46818. }
  46819. }
  46820. while (isDef(parentNode = parentNode.parent)) {
  46821. if (parentNode && parentNode.data) {
  46822. data = mergeClassData(data, parentNode.data);
  46823. }
  46824. }
  46825. return renderClass(data.staticClass, data.class)
  46826. }
  46827. function mergeClassData (child, parent) {
  46828. return {
  46829. staticClass: concat(child.staticClass, parent.staticClass),
  46830. class: isDef(child.class)
  46831. ? [child.class, parent.class]
  46832. : parent.class
  46833. }
  46834. }
  46835. function renderClass (
  46836. staticClass,
  46837. dynamicClass
  46838. ) {
  46839. if (isDef(staticClass) || isDef(dynamicClass)) {
  46840. return concat(staticClass, stringifyClass(dynamicClass))
  46841. }
  46842. /* istanbul ignore next */
  46843. return ''
  46844. }
  46845. function concat (a, b) {
  46846. return a ? b ? (a + ' ' + b) : a : (b || '')
  46847. }
  46848. function stringifyClass (value) {
  46849. if (Array.isArray(value)) {
  46850. return stringifyArray(value)
  46851. }
  46852. if (isObject(value)) {
  46853. return stringifyObject(value)
  46854. }
  46855. if (typeof value === 'string') {
  46856. return value
  46857. }
  46858. /* istanbul ignore next */
  46859. return ''
  46860. }
  46861. function stringifyArray (value) {
  46862. var res = '';
  46863. var stringified;
  46864. for (var i = 0, l = value.length; i < l; i++) {
  46865. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46866. if (res) { res += ' '; }
  46867. res += stringified;
  46868. }
  46869. }
  46870. return res
  46871. }
  46872. function stringifyObject (value) {
  46873. var res = '';
  46874. for (var key in value) {
  46875. if (value[key]) {
  46876. if (res) { res += ' '; }
  46877. res += key;
  46878. }
  46879. }
  46880. return res
  46881. }
  46882. /* */
  46883. var namespaceMap = {
  46884. svg: 'http://www.w3.org/2000/svg',
  46885. math: 'http://www.w3.org/1998/Math/MathML'
  46886. };
  46887. var isHTMLTag = makeMap(
  46888. 'html,body,base,head,link,meta,style,title,' +
  46889. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46890. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46891. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46892. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46893. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46894. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46895. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46896. 'output,progress,select,textarea,' +
  46897. 'details,dialog,menu,menuitem,summary,' +
  46898. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46899. );
  46900. // this map is intentionally selective, only covering SVG elements that may
  46901. // contain child elements.
  46902. var isSVG = makeMap(
  46903. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46904. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46905. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46906. true
  46907. );
  46908. var isPreTag = function (tag) { return tag === 'pre'; };
  46909. var isReservedTag = function (tag) {
  46910. return isHTMLTag(tag) || isSVG(tag)
  46911. };
  46912. function getTagNamespace (tag) {
  46913. if (isSVG(tag)) {
  46914. return 'svg'
  46915. }
  46916. // basic support for MathML
  46917. // note it doesn't support other MathML elements being component roots
  46918. if (tag === 'math') {
  46919. return 'math'
  46920. }
  46921. }
  46922. var unknownElementCache = Object.create(null);
  46923. function isUnknownElement (tag) {
  46924. /* istanbul ignore if */
  46925. if (!inBrowser) {
  46926. return true
  46927. }
  46928. if (isReservedTag(tag)) {
  46929. return false
  46930. }
  46931. tag = tag.toLowerCase();
  46932. /* istanbul ignore if */
  46933. if (unknownElementCache[tag] != null) {
  46934. return unknownElementCache[tag]
  46935. }
  46936. var el = document.createElement(tag);
  46937. if (tag.indexOf('-') > -1) {
  46938. // http://stackoverflow.com/a/28210364/1070244
  46939. return (unknownElementCache[tag] = (
  46940. el.constructor === window.HTMLUnknownElement ||
  46941. el.constructor === window.HTMLElement
  46942. ))
  46943. } else {
  46944. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46945. }
  46946. }
  46947. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46948. /* */
  46949. /**
  46950. * Query an element selector if it's not an element already.
  46951. */
  46952. function query (el) {
  46953. if (typeof el === 'string') {
  46954. var selected = document.querySelector(el);
  46955. if (!selected) {
  46956. warn(
  46957. 'Cannot find element: ' + el
  46958. );
  46959. return document.createElement('div')
  46960. }
  46961. return selected
  46962. } else {
  46963. return el
  46964. }
  46965. }
  46966. /* */
  46967. function createElement$1 (tagName, vnode) {
  46968. var elm = document.createElement(tagName);
  46969. if (tagName !== 'select') {
  46970. return elm
  46971. }
  46972. // false or null will remove the attribute but undefined will not
  46973. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46974. elm.setAttribute('multiple', 'multiple');
  46975. }
  46976. return elm
  46977. }
  46978. function createElementNS (namespace, tagName) {
  46979. return document.createElementNS(namespaceMap[namespace], tagName)
  46980. }
  46981. function createTextNode (text) {
  46982. return document.createTextNode(text)
  46983. }
  46984. function createComment (text) {
  46985. return document.createComment(text)
  46986. }
  46987. function insertBefore (parentNode, newNode, referenceNode) {
  46988. parentNode.insertBefore(newNode, referenceNode);
  46989. }
  46990. function removeChild (node, child) {
  46991. node.removeChild(child);
  46992. }
  46993. function appendChild (node, child) {
  46994. node.appendChild(child);
  46995. }
  46996. function parentNode (node) {
  46997. return node.parentNode
  46998. }
  46999. function nextSibling (node) {
  47000. return node.nextSibling
  47001. }
  47002. function tagName (node) {
  47003. return node.tagName
  47004. }
  47005. function setTextContent (node, text) {
  47006. node.textContent = text;
  47007. }
  47008. function setStyleScope (node, scopeId) {
  47009. node.setAttribute(scopeId, '');
  47010. }
  47011. var nodeOps = /*#__PURE__*/Object.freeze({
  47012. createElement: createElement$1,
  47013. createElementNS: createElementNS,
  47014. createTextNode: createTextNode,
  47015. createComment: createComment,
  47016. insertBefore: insertBefore,
  47017. removeChild: removeChild,
  47018. appendChild: appendChild,
  47019. parentNode: parentNode,
  47020. nextSibling: nextSibling,
  47021. tagName: tagName,
  47022. setTextContent: setTextContent,
  47023. setStyleScope: setStyleScope
  47024. });
  47025. /* */
  47026. var ref = {
  47027. create: function create (_, vnode) {
  47028. registerRef(vnode);
  47029. },
  47030. update: function update (oldVnode, vnode) {
  47031. if (oldVnode.data.ref !== vnode.data.ref) {
  47032. registerRef(oldVnode, true);
  47033. registerRef(vnode);
  47034. }
  47035. },
  47036. destroy: function destroy (vnode) {
  47037. registerRef(vnode, true);
  47038. }
  47039. };
  47040. function registerRef (vnode, isRemoval) {
  47041. var key = vnode.data.ref;
  47042. if (!isDef(key)) { return }
  47043. var vm = vnode.context;
  47044. var ref = vnode.componentInstance || vnode.elm;
  47045. var refs = vm.$refs;
  47046. if (isRemoval) {
  47047. if (Array.isArray(refs[key])) {
  47048. remove(refs[key], ref);
  47049. } else if (refs[key] === ref) {
  47050. refs[key] = undefined;
  47051. }
  47052. } else {
  47053. if (vnode.data.refInFor) {
  47054. if (!Array.isArray(refs[key])) {
  47055. refs[key] = [ref];
  47056. } else if (refs[key].indexOf(ref) < 0) {
  47057. // $flow-disable-line
  47058. refs[key].push(ref);
  47059. }
  47060. } else {
  47061. refs[key] = ref;
  47062. }
  47063. }
  47064. }
  47065. /**
  47066. * Virtual DOM patching algorithm based on Snabbdom by
  47067. * Simon Friis Vindum (@paldepind)
  47068. * Licensed under the MIT License
  47069. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  47070. *
  47071. * modified by Evan You (@yyx990803)
  47072. *
  47073. * Not type-checking this because this file is perf-critical and the cost
  47074. * of making flow understand it is not worth it.
  47075. */
  47076. var emptyNode = new VNode('', {}, []);
  47077. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  47078. function sameVnode (a, b) {
  47079. return (
  47080. a.key === b.key && (
  47081. (
  47082. a.tag === b.tag &&
  47083. a.isComment === b.isComment &&
  47084. isDef(a.data) === isDef(b.data) &&
  47085. sameInputType(a, b)
  47086. ) || (
  47087. isTrue(a.isAsyncPlaceholder) &&
  47088. a.asyncFactory === b.asyncFactory &&
  47089. isUndef(b.asyncFactory.error)
  47090. )
  47091. )
  47092. )
  47093. }
  47094. function sameInputType (a, b) {
  47095. if (a.tag !== 'input') { return true }
  47096. var i;
  47097. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  47098. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  47099. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  47100. }
  47101. function createKeyToOldIdx (children, beginIdx, endIdx) {
  47102. var i, key;
  47103. var map = {};
  47104. for (i = beginIdx; i <= endIdx; ++i) {
  47105. key = children[i].key;
  47106. if (isDef(key)) { map[key] = i; }
  47107. }
  47108. return map
  47109. }
  47110. function createPatchFunction (backend) {
  47111. var i, j;
  47112. var cbs = {};
  47113. var modules = backend.modules;
  47114. var nodeOps = backend.nodeOps;
  47115. for (i = 0; i < hooks.length; ++i) {
  47116. cbs[hooks[i]] = [];
  47117. for (j = 0; j < modules.length; ++j) {
  47118. if (isDef(modules[j][hooks[i]])) {
  47119. cbs[hooks[i]].push(modules[j][hooks[i]]);
  47120. }
  47121. }
  47122. }
  47123. function emptyNodeAt (elm) {
  47124. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  47125. }
  47126. function createRmCb (childElm, listeners) {
  47127. function remove$$1 () {
  47128. if (--remove$$1.listeners === 0) {
  47129. removeNode(childElm);
  47130. }
  47131. }
  47132. remove$$1.listeners = listeners;
  47133. return remove$$1
  47134. }
  47135. function removeNode (el) {
  47136. var parent = nodeOps.parentNode(el);
  47137. // element may have already been removed due to v-html / v-text
  47138. if (isDef(parent)) {
  47139. nodeOps.removeChild(parent, el);
  47140. }
  47141. }
  47142. function isUnknownElement$$1 (vnode, inVPre) {
  47143. return (
  47144. !inVPre &&
  47145. !vnode.ns &&
  47146. !(
  47147. config.ignoredElements.length &&
  47148. config.ignoredElements.some(function (ignore) {
  47149. return isRegExp(ignore)
  47150. ? ignore.test(vnode.tag)
  47151. : ignore === vnode.tag
  47152. })
  47153. ) &&
  47154. config.isUnknownElement(vnode.tag)
  47155. )
  47156. }
  47157. var creatingElmInVPre = 0;
  47158. function createElm (
  47159. vnode,
  47160. insertedVnodeQueue,
  47161. parentElm,
  47162. refElm,
  47163. nested,
  47164. ownerArray,
  47165. index
  47166. ) {
  47167. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47168. // This vnode was used in a previous render!
  47169. // now it's used as a new node, overwriting its elm would cause
  47170. // potential patch errors down the road when it's used as an insertion
  47171. // reference node. Instead, we clone the node on-demand before creating
  47172. // associated DOM element for it.
  47173. vnode = ownerArray[index] = cloneVNode(vnode);
  47174. }
  47175. vnode.isRootInsert = !nested; // for transition enter check
  47176. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47177. return
  47178. }
  47179. var data = vnode.data;
  47180. var children = vnode.children;
  47181. var tag = vnode.tag;
  47182. if (isDef(tag)) {
  47183. {
  47184. if (data && data.pre) {
  47185. creatingElmInVPre++;
  47186. }
  47187. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47188. warn(
  47189. 'Unknown custom element: <' + tag + '> - did you ' +
  47190. 'register the component correctly? For recursive components, ' +
  47191. 'make sure to provide the "name" option.',
  47192. vnode.context
  47193. );
  47194. }
  47195. }
  47196. vnode.elm = vnode.ns
  47197. ? nodeOps.createElementNS(vnode.ns, tag)
  47198. : nodeOps.createElement(tag, vnode);
  47199. setScope(vnode);
  47200. /* istanbul ignore if */
  47201. {
  47202. createChildren(vnode, children, insertedVnodeQueue);
  47203. if (isDef(data)) {
  47204. invokeCreateHooks(vnode, insertedVnodeQueue);
  47205. }
  47206. insert(parentElm, vnode.elm, refElm);
  47207. }
  47208. if (data && data.pre) {
  47209. creatingElmInVPre--;
  47210. }
  47211. } else if (isTrue(vnode.isComment)) {
  47212. vnode.elm = nodeOps.createComment(vnode.text);
  47213. insert(parentElm, vnode.elm, refElm);
  47214. } else {
  47215. vnode.elm = nodeOps.createTextNode(vnode.text);
  47216. insert(parentElm, vnode.elm, refElm);
  47217. }
  47218. }
  47219. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47220. var i = vnode.data;
  47221. if (isDef(i)) {
  47222. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47223. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47224. i(vnode, false /* hydrating */);
  47225. }
  47226. // after calling the init hook, if the vnode is a child component
  47227. // it should've created a child instance and mounted it. the child
  47228. // component also has set the placeholder vnode's elm.
  47229. // in that case we can just return the element and be done.
  47230. if (isDef(vnode.componentInstance)) {
  47231. initComponent(vnode, insertedVnodeQueue);
  47232. insert(parentElm, vnode.elm, refElm);
  47233. if (isTrue(isReactivated)) {
  47234. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47235. }
  47236. return true
  47237. }
  47238. }
  47239. }
  47240. function initComponent (vnode, insertedVnodeQueue) {
  47241. if (isDef(vnode.data.pendingInsert)) {
  47242. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47243. vnode.data.pendingInsert = null;
  47244. }
  47245. vnode.elm = vnode.componentInstance.$el;
  47246. if (isPatchable(vnode)) {
  47247. invokeCreateHooks(vnode, insertedVnodeQueue);
  47248. setScope(vnode);
  47249. } else {
  47250. // empty component root.
  47251. // skip all element-related modules except for ref (#3455)
  47252. registerRef(vnode);
  47253. // make sure to invoke the insert hook
  47254. insertedVnodeQueue.push(vnode);
  47255. }
  47256. }
  47257. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47258. var i;
  47259. // hack for #4339: a reactivated component with inner transition
  47260. // does not trigger because the inner node's created hooks are not called
  47261. // again. It's not ideal to involve module-specific logic in here but
  47262. // there doesn't seem to be a better way to do it.
  47263. var innerNode = vnode;
  47264. while (innerNode.componentInstance) {
  47265. innerNode = innerNode.componentInstance._vnode;
  47266. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47267. for (i = 0; i < cbs.activate.length; ++i) {
  47268. cbs.activate[i](emptyNode, innerNode);
  47269. }
  47270. insertedVnodeQueue.push(innerNode);
  47271. break
  47272. }
  47273. }
  47274. // unlike a newly created component,
  47275. // a reactivated keep-alive component doesn't insert itself
  47276. insert(parentElm, vnode.elm, refElm);
  47277. }
  47278. function insert (parent, elm, ref$$1) {
  47279. if (isDef(parent)) {
  47280. if (isDef(ref$$1)) {
  47281. if (nodeOps.parentNode(ref$$1) === parent) {
  47282. nodeOps.insertBefore(parent, elm, ref$$1);
  47283. }
  47284. } else {
  47285. nodeOps.appendChild(parent, elm);
  47286. }
  47287. }
  47288. }
  47289. function createChildren (vnode, children, insertedVnodeQueue) {
  47290. if (Array.isArray(children)) {
  47291. {
  47292. checkDuplicateKeys(children);
  47293. }
  47294. for (var i = 0; i < children.length; ++i) {
  47295. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47296. }
  47297. } else if (isPrimitive(vnode.text)) {
  47298. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47299. }
  47300. }
  47301. function isPatchable (vnode) {
  47302. while (vnode.componentInstance) {
  47303. vnode = vnode.componentInstance._vnode;
  47304. }
  47305. return isDef(vnode.tag)
  47306. }
  47307. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47308. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47309. cbs.create[i$1](emptyNode, vnode);
  47310. }
  47311. i = vnode.data.hook; // Reuse variable
  47312. if (isDef(i)) {
  47313. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47314. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47315. }
  47316. }
  47317. // set scope id attribute for scoped CSS.
  47318. // this is implemented as a special case to avoid the overhead
  47319. // of going through the normal attribute patching process.
  47320. function setScope (vnode) {
  47321. var i;
  47322. if (isDef(i = vnode.fnScopeId)) {
  47323. nodeOps.setStyleScope(vnode.elm, i);
  47324. } else {
  47325. var ancestor = vnode;
  47326. while (ancestor) {
  47327. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47328. nodeOps.setStyleScope(vnode.elm, i);
  47329. }
  47330. ancestor = ancestor.parent;
  47331. }
  47332. }
  47333. // for slot content they should also get the scopeId from the host instance.
  47334. if (isDef(i = activeInstance) &&
  47335. i !== vnode.context &&
  47336. i !== vnode.fnContext &&
  47337. isDef(i = i.$options._scopeId)
  47338. ) {
  47339. nodeOps.setStyleScope(vnode.elm, i);
  47340. }
  47341. }
  47342. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47343. for (; startIdx <= endIdx; ++startIdx) {
  47344. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47345. }
  47346. }
  47347. function invokeDestroyHook (vnode) {
  47348. var i, j;
  47349. var data = vnode.data;
  47350. if (isDef(data)) {
  47351. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47352. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47353. }
  47354. if (isDef(i = vnode.children)) {
  47355. for (j = 0; j < vnode.children.length; ++j) {
  47356. invokeDestroyHook(vnode.children[j]);
  47357. }
  47358. }
  47359. }
  47360. function removeVnodes (vnodes, startIdx, endIdx) {
  47361. for (; startIdx <= endIdx; ++startIdx) {
  47362. var ch = vnodes[startIdx];
  47363. if (isDef(ch)) {
  47364. if (isDef(ch.tag)) {
  47365. removeAndInvokeRemoveHook(ch);
  47366. invokeDestroyHook(ch);
  47367. } else { // Text node
  47368. removeNode(ch.elm);
  47369. }
  47370. }
  47371. }
  47372. }
  47373. function removeAndInvokeRemoveHook (vnode, rm) {
  47374. if (isDef(rm) || isDef(vnode.data)) {
  47375. var i;
  47376. var listeners = cbs.remove.length + 1;
  47377. if (isDef(rm)) {
  47378. // we have a recursively passed down rm callback
  47379. // increase the listeners count
  47380. rm.listeners += listeners;
  47381. } else {
  47382. // directly removing
  47383. rm = createRmCb(vnode.elm, listeners);
  47384. }
  47385. // recursively invoke hooks on child component root node
  47386. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47387. removeAndInvokeRemoveHook(i, rm);
  47388. }
  47389. for (i = 0; i < cbs.remove.length; ++i) {
  47390. cbs.remove[i](vnode, rm);
  47391. }
  47392. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47393. i(vnode, rm);
  47394. } else {
  47395. rm();
  47396. }
  47397. } else {
  47398. removeNode(vnode.elm);
  47399. }
  47400. }
  47401. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47402. var oldStartIdx = 0;
  47403. var newStartIdx = 0;
  47404. var oldEndIdx = oldCh.length - 1;
  47405. var oldStartVnode = oldCh[0];
  47406. var oldEndVnode = oldCh[oldEndIdx];
  47407. var newEndIdx = newCh.length - 1;
  47408. var newStartVnode = newCh[0];
  47409. var newEndVnode = newCh[newEndIdx];
  47410. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47411. // removeOnly is a special flag used only by <transition-group>
  47412. // to ensure removed elements stay in correct relative positions
  47413. // during leaving transitions
  47414. var canMove = !removeOnly;
  47415. {
  47416. checkDuplicateKeys(newCh);
  47417. }
  47418. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47419. if (isUndef(oldStartVnode)) {
  47420. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47421. } else if (isUndef(oldEndVnode)) {
  47422. oldEndVnode = oldCh[--oldEndIdx];
  47423. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47424. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47425. oldStartVnode = oldCh[++oldStartIdx];
  47426. newStartVnode = newCh[++newStartIdx];
  47427. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47428. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47429. oldEndVnode = oldCh[--oldEndIdx];
  47430. newEndVnode = newCh[--newEndIdx];
  47431. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47432. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47433. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47434. oldStartVnode = oldCh[++oldStartIdx];
  47435. newEndVnode = newCh[--newEndIdx];
  47436. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47437. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47438. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47439. oldEndVnode = oldCh[--oldEndIdx];
  47440. newStartVnode = newCh[++newStartIdx];
  47441. } else {
  47442. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47443. idxInOld = isDef(newStartVnode.key)
  47444. ? oldKeyToIdx[newStartVnode.key]
  47445. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47446. if (isUndef(idxInOld)) { // New element
  47447. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47448. } else {
  47449. vnodeToMove = oldCh[idxInOld];
  47450. if (sameVnode(vnodeToMove, newStartVnode)) {
  47451. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47452. oldCh[idxInOld] = undefined;
  47453. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47454. } else {
  47455. // same key but different element. treat as new element
  47456. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47457. }
  47458. }
  47459. newStartVnode = newCh[++newStartIdx];
  47460. }
  47461. }
  47462. if (oldStartIdx > oldEndIdx) {
  47463. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47464. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47465. } else if (newStartIdx > newEndIdx) {
  47466. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47467. }
  47468. }
  47469. function checkDuplicateKeys (children) {
  47470. var seenKeys = {};
  47471. for (var i = 0; i < children.length; i++) {
  47472. var vnode = children[i];
  47473. var key = vnode.key;
  47474. if (isDef(key)) {
  47475. if (seenKeys[key]) {
  47476. warn(
  47477. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47478. vnode.context
  47479. );
  47480. } else {
  47481. seenKeys[key] = true;
  47482. }
  47483. }
  47484. }
  47485. }
  47486. function findIdxInOld (node, oldCh, start, end) {
  47487. for (var i = start; i < end; i++) {
  47488. var c = oldCh[i];
  47489. if (isDef(c) && sameVnode(node, c)) { return i }
  47490. }
  47491. }
  47492. function patchVnode (
  47493. oldVnode,
  47494. vnode,
  47495. insertedVnodeQueue,
  47496. ownerArray,
  47497. index,
  47498. removeOnly
  47499. ) {
  47500. if (oldVnode === vnode) {
  47501. return
  47502. }
  47503. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47504. // clone reused vnode
  47505. vnode = ownerArray[index] = cloneVNode(vnode);
  47506. }
  47507. var elm = vnode.elm = oldVnode.elm;
  47508. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47509. if (isDef(vnode.asyncFactory.resolved)) {
  47510. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47511. } else {
  47512. vnode.isAsyncPlaceholder = true;
  47513. }
  47514. return
  47515. }
  47516. // reuse element for static trees.
  47517. // note we only do this if the vnode is cloned -
  47518. // if the new node is not cloned it means the render functions have been
  47519. // reset by the hot-reload-api and we need to do a proper re-render.
  47520. if (isTrue(vnode.isStatic) &&
  47521. isTrue(oldVnode.isStatic) &&
  47522. vnode.key === oldVnode.key &&
  47523. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47524. ) {
  47525. vnode.componentInstance = oldVnode.componentInstance;
  47526. return
  47527. }
  47528. var i;
  47529. var data = vnode.data;
  47530. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47531. i(oldVnode, vnode);
  47532. }
  47533. var oldCh = oldVnode.children;
  47534. var ch = vnode.children;
  47535. if (isDef(data) && isPatchable(vnode)) {
  47536. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47537. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47538. }
  47539. if (isUndef(vnode.text)) {
  47540. if (isDef(oldCh) && isDef(ch)) {
  47541. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47542. } else if (isDef(ch)) {
  47543. {
  47544. checkDuplicateKeys(ch);
  47545. }
  47546. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47547. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47548. } else if (isDef(oldCh)) {
  47549. removeVnodes(oldCh, 0, oldCh.length - 1);
  47550. } else if (isDef(oldVnode.text)) {
  47551. nodeOps.setTextContent(elm, '');
  47552. }
  47553. } else if (oldVnode.text !== vnode.text) {
  47554. nodeOps.setTextContent(elm, vnode.text);
  47555. }
  47556. if (isDef(data)) {
  47557. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47558. }
  47559. }
  47560. function invokeInsertHook (vnode, queue, initial) {
  47561. // delay insert hooks for component root nodes, invoke them after the
  47562. // element is really inserted
  47563. if (isTrue(initial) && isDef(vnode.parent)) {
  47564. vnode.parent.data.pendingInsert = queue;
  47565. } else {
  47566. for (var i = 0; i < queue.length; ++i) {
  47567. queue[i].data.hook.insert(queue[i]);
  47568. }
  47569. }
  47570. }
  47571. var hydrationBailed = false;
  47572. // list of modules that can skip create hook during hydration because they
  47573. // are already rendered on the client or has no need for initialization
  47574. // Note: style is excluded because it relies on initial clone for future
  47575. // deep updates (#7063).
  47576. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47577. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47578. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47579. var i;
  47580. var tag = vnode.tag;
  47581. var data = vnode.data;
  47582. var children = vnode.children;
  47583. inVPre = inVPre || (data && data.pre);
  47584. vnode.elm = elm;
  47585. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47586. vnode.isAsyncPlaceholder = true;
  47587. return true
  47588. }
  47589. // assert node match
  47590. {
  47591. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47592. return false
  47593. }
  47594. }
  47595. if (isDef(data)) {
  47596. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47597. if (isDef(i = vnode.componentInstance)) {
  47598. // child component. it should have hydrated its own tree.
  47599. initComponent(vnode, insertedVnodeQueue);
  47600. return true
  47601. }
  47602. }
  47603. if (isDef(tag)) {
  47604. if (isDef(children)) {
  47605. // empty element, allow client to pick up and populate children
  47606. if (!elm.hasChildNodes()) {
  47607. createChildren(vnode, children, insertedVnodeQueue);
  47608. } else {
  47609. // v-html and domProps: innerHTML
  47610. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47611. if (i !== elm.innerHTML) {
  47612. /* istanbul ignore if */
  47613. if (typeof console !== 'undefined' &&
  47614. !hydrationBailed
  47615. ) {
  47616. hydrationBailed = true;
  47617. console.warn('Parent: ', elm);
  47618. console.warn('server innerHTML: ', i);
  47619. console.warn('client innerHTML: ', elm.innerHTML);
  47620. }
  47621. return false
  47622. }
  47623. } else {
  47624. // iterate and compare children lists
  47625. var childrenMatch = true;
  47626. var childNode = elm.firstChild;
  47627. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47628. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47629. childrenMatch = false;
  47630. break
  47631. }
  47632. childNode = childNode.nextSibling;
  47633. }
  47634. // if childNode is not null, it means the actual childNodes list is
  47635. // longer than the virtual children list.
  47636. if (!childrenMatch || childNode) {
  47637. /* istanbul ignore if */
  47638. if (typeof console !== 'undefined' &&
  47639. !hydrationBailed
  47640. ) {
  47641. hydrationBailed = true;
  47642. console.warn('Parent: ', elm);
  47643. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47644. }
  47645. return false
  47646. }
  47647. }
  47648. }
  47649. }
  47650. if (isDef(data)) {
  47651. var fullInvoke = false;
  47652. for (var key in data) {
  47653. if (!isRenderedModule(key)) {
  47654. fullInvoke = true;
  47655. invokeCreateHooks(vnode, insertedVnodeQueue);
  47656. break
  47657. }
  47658. }
  47659. if (!fullInvoke && data['class']) {
  47660. // ensure collecting deps for deep class bindings for future updates
  47661. traverse(data['class']);
  47662. }
  47663. }
  47664. } else if (elm.data !== vnode.text) {
  47665. elm.data = vnode.text;
  47666. }
  47667. return true
  47668. }
  47669. function assertNodeMatch (node, vnode, inVPre) {
  47670. if (isDef(vnode.tag)) {
  47671. return vnode.tag.indexOf('vue-component') === 0 || (
  47672. !isUnknownElement$$1(vnode, inVPre) &&
  47673. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47674. )
  47675. } else {
  47676. return node.nodeType === (vnode.isComment ? 8 : 3)
  47677. }
  47678. }
  47679. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47680. if (isUndef(vnode)) {
  47681. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47682. return
  47683. }
  47684. var isInitialPatch = false;
  47685. var insertedVnodeQueue = [];
  47686. if (isUndef(oldVnode)) {
  47687. // empty mount (likely as component), create new root element
  47688. isInitialPatch = true;
  47689. createElm(vnode, insertedVnodeQueue);
  47690. } else {
  47691. var isRealElement = isDef(oldVnode.nodeType);
  47692. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47693. // patch existing root node
  47694. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47695. } else {
  47696. if (isRealElement) {
  47697. // mounting to a real element
  47698. // check if this is server-rendered content and if we can perform
  47699. // a successful hydration.
  47700. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47701. oldVnode.removeAttribute(SSR_ATTR);
  47702. hydrating = true;
  47703. }
  47704. if (isTrue(hydrating)) {
  47705. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47706. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47707. return oldVnode
  47708. } else {
  47709. warn(
  47710. 'The client-side rendered virtual DOM tree is not matching ' +
  47711. 'server-rendered content. This is likely caused by incorrect ' +
  47712. 'HTML markup, for example nesting block-level elements inside ' +
  47713. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47714. 'full client-side render.'
  47715. );
  47716. }
  47717. }
  47718. // either not server-rendered, or hydration failed.
  47719. // create an empty node and replace it
  47720. oldVnode = emptyNodeAt(oldVnode);
  47721. }
  47722. // replacing existing element
  47723. var oldElm = oldVnode.elm;
  47724. var parentElm = nodeOps.parentNode(oldElm);
  47725. // create new node
  47726. createElm(
  47727. vnode,
  47728. insertedVnodeQueue,
  47729. // extremely rare edge case: do not insert if old element is in a
  47730. // leaving transition. Only happens when combining transition +
  47731. // keep-alive + HOCs. (#4590)
  47732. oldElm._leaveCb ? null : parentElm,
  47733. nodeOps.nextSibling(oldElm)
  47734. );
  47735. // update parent placeholder node element, recursively
  47736. if (isDef(vnode.parent)) {
  47737. var ancestor = vnode.parent;
  47738. var patchable = isPatchable(vnode);
  47739. while (ancestor) {
  47740. for (var i = 0; i < cbs.destroy.length; ++i) {
  47741. cbs.destroy[i](ancestor);
  47742. }
  47743. ancestor.elm = vnode.elm;
  47744. if (patchable) {
  47745. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47746. cbs.create[i$1](emptyNode, ancestor);
  47747. }
  47748. // #6513
  47749. // invoke insert hooks that may have been merged by create hooks.
  47750. // e.g. for directives that uses the "inserted" hook.
  47751. var insert = ancestor.data.hook.insert;
  47752. if (insert.merged) {
  47753. // start at index 1 to avoid re-invoking component mounted hook
  47754. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47755. insert.fns[i$2]();
  47756. }
  47757. }
  47758. } else {
  47759. registerRef(ancestor);
  47760. }
  47761. ancestor = ancestor.parent;
  47762. }
  47763. }
  47764. // destroy old node
  47765. if (isDef(parentElm)) {
  47766. removeVnodes([oldVnode], 0, 0);
  47767. } else if (isDef(oldVnode.tag)) {
  47768. invokeDestroyHook(oldVnode);
  47769. }
  47770. }
  47771. }
  47772. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47773. return vnode.elm
  47774. }
  47775. }
  47776. /* */
  47777. var directives = {
  47778. create: updateDirectives,
  47779. update: updateDirectives,
  47780. destroy: function unbindDirectives (vnode) {
  47781. updateDirectives(vnode, emptyNode);
  47782. }
  47783. };
  47784. function updateDirectives (oldVnode, vnode) {
  47785. if (oldVnode.data.directives || vnode.data.directives) {
  47786. _update(oldVnode, vnode);
  47787. }
  47788. }
  47789. function _update (oldVnode, vnode) {
  47790. var isCreate = oldVnode === emptyNode;
  47791. var isDestroy = vnode === emptyNode;
  47792. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47793. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47794. var dirsWithInsert = [];
  47795. var dirsWithPostpatch = [];
  47796. var key, oldDir, dir;
  47797. for (key in newDirs) {
  47798. oldDir = oldDirs[key];
  47799. dir = newDirs[key];
  47800. if (!oldDir) {
  47801. // new directive, bind
  47802. callHook$1(dir, 'bind', vnode, oldVnode);
  47803. if (dir.def && dir.def.inserted) {
  47804. dirsWithInsert.push(dir);
  47805. }
  47806. } else {
  47807. // existing directive, update
  47808. dir.oldValue = oldDir.value;
  47809. dir.oldArg = oldDir.arg;
  47810. callHook$1(dir, 'update', vnode, oldVnode);
  47811. if (dir.def && dir.def.componentUpdated) {
  47812. dirsWithPostpatch.push(dir);
  47813. }
  47814. }
  47815. }
  47816. if (dirsWithInsert.length) {
  47817. var callInsert = function () {
  47818. for (var i = 0; i < dirsWithInsert.length; i++) {
  47819. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47820. }
  47821. };
  47822. if (isCreate) {
  47823. mergeVNodeHook(vnode, 'insert', callInsert);
  47824. } else {
  47825. callInsert();
  47826. }
  47827. }
  47828. if (dirsWithPostpatch.length) {
  47829. mergeVNodeHook(vnode, 'postpatch', function () {
  47830. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47831. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47832. }
  47833. });
  47834. }
  47835. if (!isCreate) {
  47836. for (key in oldDirs) {
  47837. if (!newDirs[key]) {
  47838. // no longer present, unbind
  47839. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47840. }
  47841. }
  47842. }
  47843. }
  47844. var emptyModifiers = Object.create(null);
  47845. function normalizeDirectives$1 (
  47846. dirs,
  47847. vm
  47848. ) {
  47849. var res = Object.create(null);
  47850. if (!dirs) {
  47851. // $flow-disable-line
  47852. return res
  47853. }
  47854. var i, dir;
  47855. for (i = 0; i < dirs.length; i++) {
  47856. dir = dirs[i];
  47857. if (!dir.modifiers) {
  47858. // $flow-disable-line
  47859. dir.modifiers = emptyModifiers;
  47860. }
  47861. res[getRawDirName(dir)] = dir;
  47862. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47863. }
  47864. // $flow-disable-line
  47865. return res
  47866. }
  47867. function getRawDirName (dir) {
  47868. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47869. }
  47870. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47871. var fn = dir.def && dir.def[hook];
  47872. if (fn) {
  47873. try {
  47874. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47875. } catch (e) {
  47876. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47877. }
  47878. }
  47879. }
  47880. var baseModules = [
  47881. ref,
  47882. directives
  47883. ];
  47884. /* */
  47885. function updateAttrs (oldVnode, vnode) {
  47886. var opts = vnode.componentOptions;
  47887. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47888. return
  47889. }
  47890. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47891. return
  47892. }
  47893. var key, cur, old;
  47894. var elm = vnode.elm;
  47895. var oldAttrs = oldVnode.data.attrs || {};
  47896. var attrs = vnode.data.attrs || {};
  47897. // clone observed objects, as the user probably wants to mutate it
  47898. if (isDef(attrs.__ob__)) {
  47899. attrs = vnode.data.attrs = extend({}, attrs);
  47900. }
  47901. for (key in attrs) {
  47902. cur = attrs[key];
  47903. old = oldAttrs[key];
  47904. if (old !== cur) {
  47905. setAttr(elm, key, cur);
  47906. }
  47907. }
  47908. // #4391: in IE9, setting type can reset value for input[type=radio]
  47909. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47910. /* istanbul ignore if */
  47911. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47912. setAttr(elm, 'value', attrs.value);
  47913. }
  47914. for (key in oldAttrs) {
  47915. if (isUndef(attrs[key])) {
  47916. if (isXlink(key)) {
  47917. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47918. } else if (!isEnumeratedAttr(key)) {
  47919. elm.removeAttribute(key);
  47920. }
  47921. }
  47922. }
  47923. }
  47924. function setAttr (el, key, value) {
  47925. if (el.tagName.indexOf('-') > -1) {
  47926. baseSetAttr(el, key, value);
  47927. } else if (isBooleanAttr(key)) {
  47928. // set attribute for blank value
  47929. // e.g. <option disabled>Select one</option>
  47930. if (isFalsyAttrValue(value)) {
  47931. el.removeAttribute(key);
  47932. } else {
  47933. // technically allowfullscreen is a boolean attribute for <iframe>,
  47934. // but Flash expects a value of "true" when used on <embed> tag
  47935. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47936. ? 'true'
  47937. : key;
  47938. el.setAttribute(key, value);
  47939. }
  47940. } else if (isEnumeratedAttr(key)) {
  47941. el.setAttribute(key, convertEnumeratedValue(key, value));
  47942. } else if (isXlink(key)) {
  47943. if (isFalsyAttrValue(value)) {
  47944. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47945. } else {
  47946. el.setAttributeNS(xlinkNS, key, value);
  47947. }
  47948. } else {
  47949. baseSetAttr(el, key, value);
  47950. }
  47951. }
  47952. function baseSetAttr (el, key, value) {
  47953. if (isFalsyAttrValue(value)) {
  47954. el.removeAttribute(key);
  47955. } else {
  47956. // #7138: IE10 & 11 fires input event when setting placeholder on
  47957. // <textarea>... block the first input event and remove the blocker
  47958. // immediately.
  47959. /* istanbul ignore if */
  47960. if (
  47961. isIE && !isIE9 &&
  47962. el.tagName === 'TEXTAREA' &&
  47963. key === 'placeholder' && value !== '' && !el.__ieph
  47964. ) {
  47965. var blocker = function (e) {
  47966. e.stopImmediatePropagation();
  47967. el.removeEventListener('input', blocker);
  47968. };
  47969. el.addEventListener('input', blocker);
  47970. // $flow-disable-line
  47971. el.__ieph = true; /* IE placeholder patched */
  47972. }
  47973. el.setAttribute(key, value);
  47974. }
  47975. }
  47976. var attrs = {
  47977. create: updateAttrs,
  47978. update: updateAttrs
  47979. };
  47980. /* */
  47981. function updateClass (oldVnode, vnode) {
  47982. var el = vnode.elm;
  47983. var data = vnode.data;
  47984. var oldData = oldVnode.data;
  47985. if (
  47986. isUndef(data.staticClass) &&
  47987. isUndef(data.class) && (
  47988. isUndef(oldData) || (
  47989. isUndef(oldData.staticClass) &&
  47990. isUndef(oldData.class)
  47991. )
  47992. )
  47993. ) {
  47994. return
  47995. }
  47996. var cls = genClassForVnode(vnode);
  47997. // handle transition classes
  47998. var transitionClass = el._transitionClasses;
  47999. if (isDef(transitionClass)) {
  48000. cls = concat(cls, stringifyClass(transitionClass));
  48001. }
  48002. // set the class
  48003. if (cls !== el._prevClass) {
  48004. el.setAttribute('class', cls);
  48005. el._prevClass = cls;
  48006. }
  48007. }
  48008. var klass = {
  48009. create: updateClass,
  48010. update: updateClass
  48011. };
  48012. /* */
  48013. var validDivisionCharRE = /[\w).+\-_$\]]/;
  48014. function parseFilters (exp) {
  48015. var inSingle = false;
  48016. var inDouble = false;
  48017. var inTemplateString = false;
  48018. var inRegex = false;
  48019. var curly = 0;
  48020. var square = 0;
  48021. var paren = 0;
  48022. var lastFilterIndex = 0;
  48023. var c, prev, i, expression, filters;
  48024. for (i = 0; i < exp.length; i++) {
  48025. prev = c;
  48026. c = exp.charCodeAt(i);
  48027. if (inSingle) {
  48028. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  48029. } else if (inDouble) {
  48030. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  48031. } else if (inTemplateString) {
  48032. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  48033. } else if (inRegex) {
  48034. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  48035. } else if (
  48036. c === 0x7C && // pipe
  48037. exp.charCodeAt(i + 1) !== 0x7C &&
  48038. exp.charCodeAt(i - 1) !== 0x7C &&
  48039. !curly && !square && !paren
  48040. ) {
  48041. if (expression === undefined) {
  48042. // first filter, end of expression
  48043. lastFilterIndex = i + 1;
  48044. expression = exp.slice(0, i).trim();
  48045. } else {
  48046. pushFilter();
  48047. }
  48048. } else {
  48049. switch (c) {
  48050. case 0x22: inDouble = true; break // "
  48051. case 0x27: inSingle = true; break // '
  48052. case 0x60: inTemplateString = true; break // `
  48053. case 0x28: paren++; break // (
  48054. case 0x29: paren--; break // )
  48055. case 0x5B: square++; break // [
  48056. case 0x5D: square--; break // ]
  48057. case 0x7B: curly++; break // {
  48058. case 0x7D: curly--; break // }
  48059. }
  48060. if (c === 0x2f) { // /
  48061. var j = i - 1;
  48062. var p = (void 0);
  48063. // find first non-whitespace prev char
  48064. for (; j >= 0; j--) {
  48065. p = exp.charAt(j);
  48066. if (p !== ' ') { break }
  48067. }
  48068. if (!p || !validDivisionCharRE.test(p)) {
  48069. inRegex = true;
  48070. }
  48071. }
  48072. }
  48073. }
  48074. if (expression === undefined) {
  48075. expression = exp.slice(0, i).trim();
  48076. } else if (lastFilterIndex !== 0) {
  48077. pushFilter();
  48078. }
  48079. function pushFilter () {
  48080. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  48081. lastFilterIndex = i + 1;
  48082. }
  48083. if (filters) {
  48084. for (i = 0; i < filters.length; i++) {
  48085. expression = wrapFilter(expression, filters[i]);
  48086. }
  48087. }
  48088. return expression
  48089. }
  48090. function wrapFilter (exp, filter) {
  48091. var i = filter.indexOf('(');
  48092. if (i < 0) {
  48093. // _f: resolveFilter
  48094. return ("_f(\"" + filter + "\")(" + exp + ")")
  48095. } else {
  48096. var name = filter.slice(0, i);
  48097. var args = filter.slice(i + 1);
  48098. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  48099. }
  48100. }
  48101. /* */
  48102. /* eslint-disable no-unused-vars */
  48103. function baseWarn (msg, range) {
  48104. console.error(("[Vue compiler]: " + msg));
  48105. }
  48106. /* eslint-enable no-unused-vars */
  48107. function pluckModuleFunction (
  48108. modules,
  48109. key
  48110. ) {
  48111. return modules
  48112. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  48113. : []
  48114. }
  48115. function addProp (el, name, value, range, dynamic) {
  48116. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48117. el.plain = false;
  48118. }
  48119. function addAttr (el, name, value, range, dynamic) {
  48120. var attrs = dynamic
  48121. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  48122. : (el.attrs || (el.attrs = []));
  48123. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48124. el.plain = false;
  48125. }
  48126. // add a raw attr (use this in preTransforms)
  48127. function addRawAttr (el, name, value, range) {
  48128. el.attrsMap[name] = value;
  48129. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  48130. }
  48131. function addDirective (
  48132. el,
  48133. name,
  48134. rawName,
  48135. value,
  48136. arg,
  48137. isDynamicArg,
  48138. modifiers,
  48139. range
  48140. ) {
  48141. (el.directives || (el.directives = [])).push(rangeSetItem({
  48142. name: name,
  48143. rawName: rawName,
  48144. value: value,
  48145. arg: arg,
  48146. isDynamicArg: isDynamicArg,
  48147. modifiers: modifiers
  48148. }, range));
  48149. el.plain = false;
  48150. }
  48151. function prependModifierMarker (symbol, name, dynamic) {
  48152. return dynamic
  48153. ? ("_p(" + name + ",\"" + symbol + "\")")
  48154. : symbol + name // mark the event as captured
  48155. }
  48156. function addHandler (
  48157. el,
  48158. name,
  48159. value,
  48160. modifiers,
  48161. important,
  48162. warn,
  48163. range,
  48164. dynamic
  48165. ) {
  48166. modifiers = modifiers || emptyObject;
  48167. // warn prevent and passive modifier
  48168. /* istanbul ignore if */
  48169. if (
  48170. warn &&
  48171. modifiers.prevent && modifiers.passive
  48172. ) {
  48173. warn(
  48174. 'passive and prevent can\'t be used together. ' +
  48175. 'Passive handler can\'t prevent default event.',
  48176. range
  48177. );
  48178. }
  48179. // normalize click.right and click.middle since they don't actually fire
  48180. // this is technically browser-specific, but at least for now browsers are
  48181. // the only target envs that have right/middle clicks.
  48182. if (modifiers.right) {
  48183. if (dynamic) {
  48184. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48185. } else if (name === 'click') {
  48186. name = 'contextmenu';
  48187. delete modifiers.right;
  48188. }
  48189. } else if (modifiers.middle) {
  48190. if (dynamic) {
  48191. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48192. } else if (name === 'click') {
  48193. name = 'mouseup';
  48194. }
  48195. }
  48196. // check capture modifier
  48197. if (modifiers.capture) {
  48198. delete modifiers.capture;
  48199. name = prependModifierMarker('!', name, dynamic);
  48200. }
  48201. if (modifiers.once) {
  48202. delete modifiers.once;
  48203. name = prependModifierMarker('~', name, dynamic);
  48204. }
  48205. /* istanbul ignore if */
  48206. if (modifiers.passive) {
  48207. delete modifiers.passive;
  48208. name = prependModifierMarker('&', name, dynamic);
  48209. }
  48210. var events;
  48211. if (modifiers.native) {
  48212. delete modifiers.native;
  48213. events = el.nativeEvents || (el.nativeEvents = {});
  48214. } else {
  48215. events = el.events || (el.events = {});
  48216. }
  48217. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48218. if (modifiers !== emptyObject) {
  48219. newHandler.modifiers = modifiers;
  48220. }
  48221. var handlers = events[name];
  48222. /* istanbul ignore if */
  48223. if (Array.isArray(handlers)) {
  48224. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48225. } else if (handlers) {
  48226. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48227. } else {
  48228. events[name] = newHandler;
  48229. }
  48230. el.plain = false;
  48231. }
  48232. function getRawBindingAttr (
  48233. el,
  48234. name
  48235. ) {
  48236. return el.rawAttrsMap[':' + name] ||
  48237. el.rawAttrsMap['v-bind:' + name] ||
  48238. el.rawAttrsMap[name]
  48239. }
  48240. function getBindingAttr (
  48241. el,
  48242. name,
  48243. getStatic
  48244. ) {
  48245. var dynamicValue =
  48246. getAndRemoveAttr(el, ':' + name) ||
  48247. getAndRemoveAttr(el, 'v-bind:' + name);
  48248. if (dynamicValue != null) {
  48249. return parseFilters(dynamicValue)
  48250. } else if (getStatic !== false) {
  48251. var staticValue = getAndRemoveAttr(el, name);
  48252. if (staticValue != null) {
  48253. return JSON.stringify(staticValue)
  48254. }
  48255. }
  48256. }
  48257. // note: this only removes the attr from the Array (attrsList) so that it
  48258. // doesn't get processed by processAttrs.
  48259. // By default it does NOT remove it from the map (attrsMap) because the map is
  48260. // needed during codegen.
  48261. function getAndRemoveAttr (
  48262. el,
  48263. name,
  48264. removeFromMap
  48265. ) {
  48266. var val;
  48267. if ((val = el.attrsMap[name]) != null) {
  48268. var list = el.attrsList;
  48269. for (var i = 0, l = list.length; i < l; i++) {
  48270. if (list[i].name === name) {
  48271. list.splice(i, 1);
  48272. break
  48273. }
  48274. }
  48275. }
  48276. if (removeFromMap) {
  48277. delete el.attrsMap[name];
  48278. }
  48279. return val
  48280. }
  48281. function getAndRemoveAttrByRegex (
  48282. el,
  48283. name
  48284. ) {
  48285. var list = el.attrsList;
  48286. for (var i = 0, l = list.length; i < l; i++) {
  48287. var attr = list[i];
  48288. if (name.test(attr.name)) {
  48289. list.splice(i, 1);
  48290. return attr
  48291. }
  48292. }
  48293. }
  48294. function rangeSetItem (
  48295. item,
  48296. range
  48297. ) {
  48298. if (range) {
  48299. if (range.start != null) {
  48300. item.start = range.start;
  48301. }
  48302. if (range.end != null) {
  48303. item.end = range.end;
  48304. }
  48305. }
  48306. return item
  48307. }
  48308. /* */
  48309. /**
  48310. * Cross-platform code generation for component v-model
  48311. */
  48312. function genComponentModel (
  48313. el,
  48314. value,
  48315. modifiers
  48316. ) {
  48317. var ref = modifiers || {};
  48318. var number = ref.number;
  48319. var trim = ref.trim;
  48320. var baseValueExpression = '$$v';
  48321. var valueExpression = baseValueExpression;
  48322. if (trim) {
  48323. valueExpression =
  48324. "(typeof " + baseValueExpression + " === 'string'" +
  48325. "? " + baseValueExpression + ".trim()" +
  48326. ": " + baseValueExpression + ")";
  48327. }
  48328. if (number) {
  48329. valueExpression = "_n(" + valueExpression + ")";
  48330. }
  48331. var assignment = genAssignmentCode(value, valueExpression);
  48332. el.model = {
  48333. value: ("(" + value + ")"),
  48334. expression: JSON.stringify(value),
  48335. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48336. };
  48337. }
  48338. /**
  48339. * Cross-platform codegen helper for generating v-model value assignment code.
  48340. */
  48341. function genAssignmentCode (
  48342. value,
  48343. assignment
  48344. ) {
  48345. var res = parseModel(value);
  48346. if (res.key === null) {
  48347. return (value + "=" + assignment)
  48348. } else {
  48349. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48350. }
  48351. }
  48352. /**
  48353. * Parse a v-model expression into a base path and a final key segment.
  48354. * Handles both dot-path and possible square brackets.
  48355. *
  48356. * Possible cases:
  48357. *
  48358. * - test
  48359. * - test[key]
  48360. * - test[test1[key]]
  48361. * - test["a"][key]
  48362. * - xxx.test[a[a].test1[key]]
  48363. * - test.xxx.a["asa"][test1[key]]
  48364. *
  48365. */
  48366. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48367. function parseModel (val) {
  48368. // Fix https://github.com/vuejs/vue/pull/7730
  48369. // allow v-model="obj.val " (trailing whitespace)
  48370. val = val.trim();
  48371. len = val.length;
  48372. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48373. index$1 = val.lastIndexOf('.');
  48374. if (index$1 > -1) {
  48375. return {
  48376. exp: val.slice(0, index$1),
  48377. key: '"' + val.slice(index$1 + 1) + '"'
  48378. }
  48379. } else {
  48380. return {
  48381. exp: val,
  48382. key: null
  48383. }
  48384. }
  48385. }
  48386. str = val;
  48387. index$1 = expressionPos = expressionEndPos = 0;
  48388. while (!eof()) {
  48389. chr = next();
  48390. /* istanbul ignore if */
  48391. if (isStringStart(chr)) {
  48392. parseString(chr);
  48393. } else if (chr === 0x5B) {
  48394. parseBracket(chr);
  48395. }
  48396. }
  48397. return {
  48398. exp: val.slice(0, expressionPos),
  48399. key: val.slice(expressionPos + 1, expressionEndPos)
  48400. }
  48401. }
  48402. function next () {
  48403. return str.charCodeAt(++index$1)
  48404. }
  48405. function eof () {
  48406. return index$1 >= len
  48407. }
  48408. function isStringStart (chr) {
  48409. return chr === 0x22 || chr === 0x27
  48410. }
  48411. function parseBracket (chr) {
  48412. var inBracket = 1;
  48413. expressionPos = index$1;
  48414. while (!eof()) {
  48415. chr = next();
  48416. if (isStringStart(chr)) {
  48417. parseString(chr);
  48418. continue
  48419. }
  48420. if (chr === 0x5B) { inBracket++; }
  48421. if (chr === 0x5D) { inBracket--; }
  48422. if (inBracket === 0) {
  48423. expressionEndPos = index$1;
  48424. break
  48425. }
  48426. }
  48427. }
  48428. function parseString (chr) {
  48429. var stringQuote = chr;
  48430. while (!eof()) {
  48431. chr = next();
  48432. if (chr === stringQuote) {
  48433. break
  48434. }
  48435. }
  48436. }
  48437. /* */
  48438. var warn$1;
  48439. // in some cases, the event used has to be determined at runtime
  48440. // so we used some reserved tokens during compile.
  48441. var RANGE_TOKEN = '__r';
  48442. var CHECKBOX_RADIO_TOKEN = '__c';
  48443. function model (
  48444. el,
  48445. dir,
  48446. _warn
  48447. ) {
  48448. warn$1 = _warn;
  48449. var value = dir.value;
  48450. var modifiers = dir.modifiers;
  48451. var tag = el.tag;
  48452. var type = el.attrsMap.type;
  48453. {
  48454. // inputs with type="file" are read only and setting the input's
  48455. // value will throw an error.
  48456. if (tag === 'input' && type === 'file') {
  48457. warn$1(
  48458. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48459. "File inputs are read only. Use a v-on:change listener instead.",
  48460. el.rawAttrsMap['v-model']
  48461. );
  48462. }
  48463. }
  48464. if (el.component) {
  48465. genComponentModel(el, value, modifiers);
  48466. // component v-model doesn't need extra runtime
  48467. return false
  48468. } else if (tag === 'select') {
  48469. genSelect(el, value, modifiers);
  48470. } else if (tag === 'input' && type === 'checkbox') {
  48471. genCheckboxModel(el, value, modifiers);
  48472. } else if (tag === 'input' && type === 'radio') {
  48473. genRadioModel(el, value, modifiers);
  48474. } else if (tag === 'input' || tag === 'textarea') {
  48475. genDefaultModel(el, value, modifiers);
  48476. } else if (!config.isReservedTag(tag)) {
  48477. genComponentModel(el, value, modifiers);
  48478. // component v-model doesn't need extra runtime
  48479. return false
  48480. } else {
  48481. warn$1(
  48482. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48483. "v-model is not supported on this element type. " +
  48484. 'If you are working with contenteditable, it\'s recommended to ' +
  48485. 'wrap a library dedicated for that purpose inside a custom component.',
  48486. el.rawAttrsMap['v-model']
  48487. );
  48488. }
  48489. // ensure runtime directive metadata
  48490. return true
  48491. }
  48492. function genCheckboxModel (
  48493. el,
  48494. value,
  48495. modifiers
  48496. ) {
  48497. var number = modifiers && modifiers.number;
  48498. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48499. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48500. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48501. addProp(el, 'checked',
  48502. "Array.isArray(" + value + ")" +
  48503. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48504. trueValueBinding === 'true'
  48505. ? (":(" + value + ")")
  48506. : (":_q(" + value + "," + trueValueBinding + ")")
  48507. )
  48508. );
  48509. addHandler(el, 'change',
  48510. "var $$a=" + value + "," +
  48511. '$$el=$event.target,' +
  48512. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48513. 'if(Array.isArray($$a)){' +
  48514. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48515. '$$i=_i($$a,$$v);' +
  48516. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48517. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48518. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48519. null, true
  48520. );
  48521. }
  48522. function genRadioModel (
  48523. el,
  48524. value,
  48525. modifiers
  48526. ) {
  48527. var number = modifiers && modifiers.number;
  48528. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48529. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48530. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48531. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48532. }
  48533. function genSelect (
  48534. el,
  48535. value,
  48536. modifiers
  48537. ) {
  48538. var number = modifiers && modifiers.number;
  48539. var selectedVal = "Array.prototype.filter" +
  48540. ".call($event.target.options,function(o){return o.selected})" +
  48541. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48542. "return " + (number ? '_n(val)' : 'val') + "})";
  48543. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48544. var code = "var $$selectedVal = " + selectedVal + ";";
  48545. code = code + " " + (genAssignmentCode(value, assignment));
  48546. addHandler(el, 'change', code, null, true);
  48547. }
  48548. function genDefaultModel (
  48549. el,
  48550. value,
  48551. modifiers
  48552. ) {
  48553. var type = el.attrsMap.type;
  48554. // warn if v-bind:value conflicts with v-model
  48555. // except for inputs with v-bind:type
  48556. {
  48557. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48558. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48559. if (value$1 && !typeBinding) {
  48560. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48561. warn$1(
  48562. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48563. 'because the latter already expands to a value binding internally',
  48564. el.rawAttrsMap[binding]
  48565. );
  48566. }
  48567. }
  48568. var ref = modifiers || {};
  48569. var lazy = ref.lazy;
  48570. var number = ref.number;
  48571. var trim = ref.trim;
  48572. var needCompositionGuard = !lazy && type !== 'range';
  48573. var event = lazy
  48574. ? 'change'
  48575. : type === 'range'
  48576. ? RANGE_TOKEN
  48577. : 'input';
  48578. var valueExpression = '$event.target.value';
  48579. if (trim) {
  48580. valueExpression = "$event.target.value.trim()";
  48581. }
  48582. if (number) {
  48583. valueExpression = "_n(" + valueExpression + ")";
  48584. }
  48585. var code = genAssignmentCode(value, valueExpression);
  48586. if (needCompositionGuard) {
  48587. code = "if($event.target.composing)return;" + code;
  48588. }
  48589. addProp(el, 'value', ("(" + value + ")"));
  48590. addHandler(el, event, code, null, true);
  48591. if (trim || number) {
  48592. addHandler(el, 'blur', '$forceUpdate()');
  48593. }
  48594. }
  48595. /* */
  48596. // normalize v-model event tokens that can only be determined at runtime.
  48597. // it's important to place the event as the first in the array because
  48598. // the whole point is ensuring the v-model callback gets called before
  48599. // user-attached handlers.
  48600. function normalizeEvents (on) {
  48601. /* istanbul ignore if */
  48602. if (isDef(on[RANGE_TOKEN])) {
  48603. // IE input[type=range] only supports `change` event
  48604. var event = isIE ? 'change' : 'input';
  48605. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48606. delete on[RANGE_TOKEN];
  48607. }
  48608. // This was originally intended to fix #4521 but no longer necessary
  48609. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48610. /* istanbul ignore if */
  48611. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48612. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48613. delete on[CHECKBOX_RADIO_TOKEN];
  48614. }
  48615. }
  48616. var target$1;
  48617. function createOnceHandler$1 (event, handler, capture) {
  48618. var _target = target$1; // save current target element in closure
  48619. return function onceHandler () {
  48620. var res = handler.apply(null, arguments);
  48621. if (res !== null) {
  48622. remove$2(event, onceHandler, capture, _target);
  48623. }
  48624. }
  48625. }
  48626. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48627. // implementation and does not fire microtasks in between event propagation, so
  48628. // safe to exclude.
  48629. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48630. function add$1 (
  48631. name,
  48632. handler,
  48633. capture,
  48634. passive
  48635. ) {
  48636. // async edge case #6566: inner click event triggers patch, event handler
  48637. // attached to outer element during patch, and triggered again. This
  48638. // happens because browsers fire microtask ticks between event propagation.
  48639. // the solution is simple: we save the timestamp when a handler is attached,
  48640. // and the handler would only fire if the event passed to it was fired
  48641. // AFTER it was attached.
  48642. if (useMicrotaskFix) {
  48643. var attachedTimestamp = currentFlushTimestamp;
  48644. var original = handler;
  48645. handler = original._wrapper = function (e) {
  48646. if (
  48647. // no bubbling, should always fire.
  48648. // this is just a safety net in case event.timeStamp is unreliable in
  48649. // certain weird environments...
  48650. e.target === e.currentTarget ||
  48651. // event is fired after handler attachment
  48652. e.timeStamp >= attachedTimestamp ||
  48653. // bail for environments that have buggy event.timeStamp implementations
  48654. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48655. // #9681 QtWebEngine event.timeStamp is negative value
  48656. e.timeStamp <= 0 ||
  48657. // #9448 bail if event is fired in another document in a multi-page
  48658. // electron/nw.js app, since event.timeStamp will be using a different
  48659. // starting reference
  48660. e.target.ownerDocument !== document
  48661. ) {
  48662. return original.apply(this, arguments)
  48663. }
  48664. };
  48665. }
  48666. target$1.addEventListener(
  48667. name,
  48668. handler,
  48669. supportsPassive
  48670. ? { capture: capture, passive: passive }
  48671. : capture
  48672. );
  48673. }
  48674. function remove$2 (
  48675. name,
  48676. handler,
  48677. capture,
  48678. _target
  48679. ) {
  48680. (_target || target$1).removeEventListener(
  48681. name,
  48682. handler._wrapper || handler,
  48683. capture
  48684. );
  48685. }
  48686. function updateDOMListeners (oldVnode, vnode) {
  48687. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48688. return
  48689. }
  48690. var on = vnode.data.on || {};
  48691. var oldOn = oldVnode.data.on || {};
  48692. target$1 = vnode.elm;
  48693. normalizeEvents(on);
  48694. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48695. target$1 = undefined;
  48696. }
  48697. var events = {
  48698. create: updateDOMListeners,
  48699. update: updateDOMListeners
  48700. };
  48701. /* */
  48702. var svgContainer;
  48703. function updateDOMProps (oldVnode, vnode) {
  48704. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48705. return
  48706. }
  48707. var key, cur;
  48708. var elm = vnode.elm;
  48709. var oldProps = oldVnode.data.domProps || {};
  48710. var props = vnode.data.domProps || {};
  48711. // clone observed objects, as the user probably wants to mutate it
  48712. if (isDef(props.__ob__)) {
  48713. props = vnode.data.domProps = extend({}, props);
  48714. }
  48715. for (key in oldProps) {
  48716. if (!(key in props)) {
  48717. elm[key] = '';
  48718. }
  48719. }
  48720. for (key in props) {
  48721. cur = props[key];
  48722. // ignore children if the node has textContent or innerHTML,
  48723. // as these will throw away existing DOM nodes and cause removal errors
  48724. // on subsequent patches (#3360)
  48725. if (key === 'textContent' || key === 'innerHTML') {
  48726. if (vnode.children) { vnode.children.length = 0; }
  48727. if (cur === oldProps[key]) { continue }
  48728. // #6601 work around Chrome version <= 55 bug where single textNode
  48729. // replaced by innerHTML/textContent retains its parentNode property
  48730. if (elm.childNodes.length === 1) {
  48731. elm.removeChild(elm.childNodes[0]);
  48732. }
  48733. }
  48734. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48735. // store value as _value as well since
  48736. // non-string values will be stringified
  48737. elm._value = cur;
  48738. // avoid resetting cursor position when value is the same
  48739. var strCur = isUndef(cur) ? '' : String(cur);
  48740. if (shouldUpdateValue(elm, strCur)) {
  48741. elm.value = strCur;
  48742. }
  48743. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48744. // IE doesn't support innerHTML for SVG elements
  48745. svgContainer = svgContainer || document.createElement('div');
  48746. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48747. var svg = svgContainer.firstChild;
  48748. while (elm.firstChild) {
  48749. elm.removeChild(elm.firstChild);
  48750. }
  48751. while (svg.firstChild) {
  48752. elm.appendChild(svg.firstChild);
  48753. }
  48754. } else if (
  48755. // skip the update if old and new VDOM state is the same.
  48756. // `value` is handled separately because the DOM value may be temporarily
  48757. // out of sync with VDOM state due to focus, composition and modifiers.
  48758. // This #4521 by skipping the unnecesarry `checked` update.
  48759. cur !== oldProps[key]
  48760. ) {
  48761. // some property updates can throw
  48762. // e.g. `value` on <progress> w/ non-finite value
  48763. try {
  48764. elm[key] = cur;
  48765. } catch (e) {}
  48766. }
  48767. }
  48768. }
  48769. // check platforms/web/util/attrs.js acceptValue
  48770. function shouldUpdateValue (elm, checkVal) {
  48771. return (!elm.composing && (
  48772. elm.tagName === 'OPTION' ||
  48773. isNotInFocusAndDirty(elm, checkVal) ||
  48774. isDirtyWithModifiers(elm, checkVal)
  48775. ))
  48776. }
  48777. function isNotInFocusAndDirty (elm, checkVal) {
  48778. // return true when textbox (.number and .trim) loses focus and its value is
  48779. // not equal to the updated value
  48780. var notInFocus = true;
  48781. // #6157
  48782. // work around IE bug when accessing document.activeElement in an iframe
  48783. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48784. return notInFocus && elm.value !== checkVal
  48785. }
  48786. function isDirtyWithModifiers (elm, newVal) {
  48787. var value = elm.value;
  48788. var modifiers = elm._vModifiers; // injected by v-model runtime
  48789. if (isDef(modifiers)) {
  48790. if (modifiers.number) {
  48791. return toNumber(value) !== toNumber(newVal)
  48792. }
  48793. if (modifiers.trim) {
  48794. return value.trim() !== newVal.trim()
  48795. }
  48796. }
  48797. return value !== newVal
  48798. }
  48799. var domProps = {
  48800. create: updateDOMProps,
  48801. update: updateDOMProps
  48802. };
  48803. /* */
  48804. var parseStyleText = cached(function (cssText) {
  48805. var res = {};
  48806. var listDelimiter = /;(?![^(]*\))/g;
  48807. var propertyDelimiter = /:(.+)/;
  48808. cssText.split(listDelimiter).forEach(function (item) {
  48809. if (item) {
  48810. var tmp = item.split(propertyDelimiter);
  48811. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48812. }
  48813. });
  48814. return res
  48815. });
  48816. // merge static and dynamic style data on the same vnode
  48817. function normalizeStyleData (data) {
  48818. var style = normalizeStyleBinding(data.style);
  48819. // static style is pre-processed into an object during compilation
  48820. // and is always a fresh object, so it's safe to merge into it
  48821. return data.staticStyle
  48822. ? extend(data.staticStyle, style)
  48823. : style
  48824. }
  48825. // normalize possible array / string values into Object
  48826. function normalizeStyleBinding (bindingStyle) {
  48827. if (Array.isArray(bindingStyle)) {
  48828. return toObject(bindingStyle)
  48829. }
  48830. if (typeof bindingStyle === 'string') {
  48831. return parseStyleText(bindingStyle)
  48832. }
  48833. return bindingStyle
  48834. }
  48835. /**
  48836. * parent component style should be after child's
  48837. * so that parent component's style could override it
  48838. */
  48839. function getStyle (vnode, checkChild) {
  48840. var res = {};
  48841. var styleData;
  48842. if (checkChild) {
  48843. var childNode = vnode;
  48844. while (childNode.componentInstance) {
  48845. childNode = childNode.componentInstance._vnode;
  48846. if (
  48847. childNode && childNode.data &&
  48848. (styleData = normalizeStyleData(childNode.data))
  48849. ) {
  48850. extend(res, styleData);
  48851. }
  48852. }
  48853. }
  48854. if ((styleData = normalizeStyleData(vnode.data))) {
  48855. extend(res, styleData);
  48856. }
  48857. var parentNode = vnode;
  48858. while ((parentNode = parentNode.parent)) {
  48859. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48860. extend(res, styleData);
  48861. }
  48862. }
  48863. return res
  48864. }
  48865. /* */
  48866. var cssVarRE = /^--/;
  48867. var importantRE = /\s*!important$/;
  48868. var setProp = function (el, name, val) {
  48869. /* istanbul ignore if */
  48870. if (cssVarRE.test(name)) {
  48871. el.style.setProperty(name, val);
  48872. } else if (importantRE.test(val)) {
  48873. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48874. } else {
  48875. var normalizedName = normalize(name);
  48876. if (Array.isArray(val)) {
  48877. // Support values array created by autoprefixer, e.g.
  48878. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48879. // Set them one by one, and the browser will only set those it can recognize
  48880. for (var i = 0, len = val.length; i < len; i++) {
  48881. el.style[normalizedName] = val[i];
  48882. }
  48883. } else {
  48884. el.style[normalizedName] = val;
  48885. }
  48886. }
  48887. };
  48888. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48889. var emptyStyle;
  48890. var normalize = cached(function (prop) {
  48891. emptyStyle = emptyStyle || document.createElement('div').style;
  48892. prop = camelize(prop);
  48893. if (prop !== 'filter' && (prop in emptyStyle)) {
  48894. return prop
  48895. }
  48896. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48897. for (var i = 0; i < vendorNames.length; i++) {
  48898. var name = vendorNames[i] + capName;
  48899. if (name in emptyStyle) {
  48900. return name
  48901. }
  48902. }
  48903. });
  48904. function updateStyle (oldVnode, vnode) {
  48905. var data = vnode.data;
  48906. var oldData = oldVnode.data;
  48907. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48908. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48909. ) {
  48910. return
  48911. }
  48912. var cur, name;
  48913. var el = vnode.elm;
  48914. var oldStaticStyle = oldData.staticStyle;
  48915. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48916. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48917. var oldStyle = oldStaticStyle || oldStyleBinding;
  48918. var style = normalizeStyleBinding(vnode.data.style) || {};
  48919. // store normalized style under a different key for next diff
  48920. // make sure to clone it if it's reactive, since the user likely wants
  48921. // to mutate it.
  48922. vnode.data.normalizedStyle = isDef(style.__ob__)
  48923. ? extend({}, style)
  48924. : style;
  48925. var newStyle = getStyle(vnode, true);
  48926. for (name in oldStyle) {
  48927. if (isUndef(newStyle[name])) {
  48928. setProp(el, name, '');
  48929. }
  48930. }
  48931. for (name in newStyle) {
  48932. cur = newStyle[name];
  48933. if (cur !== oldStyle[name]) {
  48934. // ie9 setting to null has no effect, must use empty string
  48935. setProp(el, name, cur == null ? '' : cur);
  48936. }
  48937. }
  48938. }
  48939. var style = {
  48940. create: updateStyle,
  48941. update: updateStyle
  48942. };
  48943. /* */
  48944. var whitespaceRE = /\s+/;
  48945. /**
  48946. * Add class with compatibility for SVG since classList is not supported on
  48947. * SVG elements in IE
  48948. */
  48949. function addClass (el, cls) {
  48950. /* istanbul ignore if */
  48951. if (!cls || !(cls = cls.trim())) {
  48952. return
  48953. }
  48954. /* istanbul ignore else */
  48955. if (el.classList) {
  48956. if (cls.indexOf(' ') > -1) {
  48957. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48958. } else {
  48959. el.classList.add(cls);
  48960. }
  48961. } else {
  48962. var cur = " " + (el.getAttribute('class') || '') + " ";
  48963. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48964. el.setAttribute('class', (cur + cls).trim());
  48965. }
  48966. }
  48967. }
  48968. /**
  48969. * Remove class with compatibility for SVG since classList is not supported on
  48970. * SVG elements in IE
  48971. */
  48972. function removeClass (el, cls) {
  48973. /* istanbul ignore if */
  48974. if (!cls || !(cls = cls.trim())) {
  48975. return
  48976. }
  48977. /* istanbul ignore else */
  48978. if (el.classList) {
  48979. if (cls.indexOf(' ') > -1) {
  48980. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48981. } else {
  48982. el.classList.remove(cls);
  48983. }
  48984. if (!el.classList.length) {
  48985. el.removeAttribute('class');
  48986. }
  48987. } else {
  48988. var cur = " " + (el.getAttribute('class') || '') + " ";
  48989. var tar = ' ' + cls + ' ';
  48990. while (cur.indexOf(tar) >= 0) {
  48991. cur = cur.replace(tar, ' ');
  48992. }
  48993. cur = cur.trim();
  48994. if (cur) {
  48995. el.setAttribute('class', cur);
  48996. } else {
  48997. el.removeAttribute('class');
  48998. }
  48999. }
  49000. }
  49001. /* */
  49002. function resolveTransition (def$$1) {
  49003. if (!def$$1) {
  49004. return
  49005. }
  49006. /* istanbul ignore else */
  49007. if (typeof def$$1 === 'object') {
  49008. var res = {};
  49009. if (def$$1.css !== false) {
  49010. extend(res, autoCssTransition(def$$1.name || 'v'));
  49011. }
  49012. extend(res, def$$1);
  49013. return res
  49014. } else if (typeof def$$1 === 'string') {
  49015. return autoCssTransition(def$$1)
  49016. }
  49017. }
  49018. var autoCssTransition = cached(function (name) {
  49019. return {
  49020. enterClass: (name + "-enter"),
  49021. enterToClass: (name + "-enter-to"),
  49022. enterActiveClass: (name + "-enter-active"),
  49023. leaveClass: (name + "-leave"),
  49024. leaveToClass: (name + "-leave-to"),
  49025. leaveActiveClass: (name + "-leave-active")
  49026. }
  49027. });
  49028. var hasTransition = inBrowser && !isIE9;
  49029. var TRANSITION = 'transition';
  49030. var ANIMATION = 'animation';
  49031. // Transition property/event sniffing
  49032. var transitionProp = 'transition';
  49033. var transitionEndEvent = 'transitionend';
  49034. var animationProp = 'animation';
  49035. var animationEndEvent = 'animationend';
  49036. if (hasTransition) {
  49037. /* istanbul ignore if */
  49038. if (window.ontransitionend === undefined &&
  49039. window.onwebkittransitionend !== undefined
  49040. ) {
  49041. transitionProp = 'WebkitTransition';
  49042. transitionEndEvent = 'webkitTransitionEnd';
  49043. }
  49044. if (window.onanimationend === undefined &&
  49045. window.onwebkitanimationend !== undefined
  49046. ) {
  49047. animationProp = 'WebkitAnimation';
  49048. animationEndEvent = 'webkitAnimationEnd';
  49049. }
  49050. }
  49051. // binding to window is necessary to make hot reload work in IE in strict mode
  49052. var raf = inBrowser
  49053. ? window.requestAnimationFrame
  49054. ? window.requestAnimationFrame.bind(window)
  49055. : setTimeout
  49056. : /* istanbul ignore next */ function (fn) { return fn(); };
  49057. function nextFrame (fn) {
  49058. raf(function () {
  49059. raf(fn);
  49060. });
  49061. }
  49062. function addTransitionClass (el, cls) {
  49063. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  49064. if (transitionClasses.indexOf(cls) < 0) {
  49065. transitionClasses.push(cls);
  49066. addClass(el, cls);
  49067. }
  49068. }
  49069. function removeTransitionClass (el, cls) {
  49070. if (el._transitionClasses) {
  49071. remove(el._transitionClasses, cls);
  49072. }
  49073. removeClass(el, cls);
  49074. }
  49075. function whenTransitionEnds (
  49076. el,
  49077. expectedType,
  49078. cb
  49079. ) {
  49080. var ref = getTransitionInfo(el, expectedType);
  49081. var type = ref.type;
  49082. var timeout = ref.timeout;
  49083. var propCount = ref.propCount;
  49084. if (!type) { return cb() }
  49085. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  49086. var ended = 0;
  49087. var end = function () {
  49088. el.removeEventListener(event, onEnd);
  49089. cb();
  49090. };
  49091. var onEnd = function (e) {
  49092. if (e.target === el) {
  49093. if (++ended >= propCount) {
  49094. end();
  49095. }
  49096. }
  49097. };
  49098. setTimeout(function () {
  49099. if (ended < propCount) {
  49100. end();
  49101. }
  49102. }, timeout + 1);
  49103. el.addEventListener(event, onEnd);
  49104. }
  49105. var transformRE = /\b(transform|all)(,|$)/;
  49106. function getTransitionInfo (el, expectedType) {
  49107. var styles = window.getComputedStyle(el);
  49108. // JSDOM may return undefined for transition properties
  49109. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  49110. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  49111. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  49112. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  49113. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  49114. var animationTimeout = getTimeout(animationDelays, animationDurations);
  49115. var type;
  49116. var timeout = 0;
  49117. var propCount = 0;
  49118. /* istanbul ignore if */
  49119. if (expectedType === TRANSITION) {
  49120. if (transitionTimeout > 0) {
  49121. type = TRANSITION;
  49122. timeout = transitionTimeout;
  49123. propCount = transitionDurations.length;
  49124. }
  49125. } else if (expectedType === ANIMATION) {
  49126. if (animationTimeout > 0) {
  49127. type = ANIMATION;
  49128. timeout = animationTimeout;
  49129. propCount = animationDurations.length;
  49130. }
  49131. } else {
  49132. timeout = Math.max(transitionTimeout, animationTimeout);
  49133. type = timeout > 0
  49134. ? transitionTimeout > animationTimeout
  49135. ? TRANSITION
  49136. : ANIMATION
  49137. : null;
  49138. propCount = type
  49139. ? type === TRANSITION
  49140. ? transitionDurations.length
  49141. : animationDurations.length
  49142. : 0;
  49143. }
  49144. var hasTransform =
  49145. type === TRANSITION &&
  49146. transformRE.test(styles[transitionProp + 'Property']);
  49147. return {
  49148. type: type,
  49149. timeout: timeout,
  49150. propCount: propCount,
  49151. hasTransform: hasTransform
  49152. }
  49153. }
  49154. function getTimeout (delays, durations) {
  49155. /* istanbul ignore next */
  49156. while (delays.length < durations.length) {
  49157. delays = delays.concat(delays);
  49158. }
  49159. return Math.max.apply(null, durations.map(function (d, i) {
  49160. return toMs(d) + toMs(delays[i])
  49161. }))
  49162. }
  49163. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49164. // in a locale-dependent way, using a comma instead of a dot.
  49165. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49166. // as a floor function) causing unexpected behaviors
  49167. function toMs (s) {
  49168. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49169. }
  49170. /* */
  49171. function enter (vnode, toggleDisplay) {
  49172. var el = vnode.elm;
  49173. // call leave callback now
  49174. if (isDef(el._leaveCb)) {
  49175. el._leaveCb.cancelled = true;
  49176. el._leaveCb();
  49177. }
  49178. var data = resolveTransition(vnode.data.transition);
  49179. if (isUndef(data)) {
  49180. return
  49181. }
  49182. /* istanbul ignore if */
  49183. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49184. return
  49185. }
  49186. var css = data.css;
  49187. var type = data.type;
  49188. var enterClass = data.enterClass;
  49189. var enterToClass = data.enterToClass;
  49190. var enterActiveClass = data.enterActiveClass;
  49191. var appearClass = data.appearClass;
  49192. var appearToClass = data.appearToClass;
  49193. var appearActiveClass = data.appearActiveClass;
  49194. var beforeEnter = data.beforeEnter;
  49195. var enter = data.enter;
  49196. var afterEnter = data.afterEnter;
  49197. var enterCancelled = data.enterCancelled;
  49198. var beforeAppear = data.beforeAppear;
  49199. var appear = data.appear;
  49200. var afterAppear = data.afterAppear;
  49201. var appearCancelled = data.appearCancelled;
  49202. var duration = data.duration;
  49203. // activeInstance will always be the <transition> component managing this
  49204. // transition. One edge case to check is when the <transition> is placed
  49205. // as the root node of a child component. In that case we need to check
  49206. // <transition>'s parent for appear check.
  49207. var context = activeInstance;
  49208. var transitionNode = activeInstance.$vnode;
  49209. while (transitionNode && transitionNode.parent) {
  49210. context = transitionNode.context;
  49211. transitionNode = transitionNode.parent;
  49212. }
  49213. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49214. if (isAppear && !appear && appear !== '') {
  49215. return
  49216. }
  49217. var startClass = isAppear && appearClass
  49218. ? appearClass
  49219. : enterClass;
  49220. var activeClass = isAppear && appearActiveClass
  49221. ? appearActiveClass
  49222. : enterActiveClass;
  49223. var toClass = isAppear && appearToClass
  49224. ? appearToClass
  49225. : enterToClass;
  49226. var beforeEnterHook = isAppear
  49227. ? (beforeAppear || beforeEnter)
  49228. : beforeEnter;
  49229. var enterHook = isAppear
  49230. ? (typeof appear === 'function' ? appear : enter)
  49231. : enter;
  49232. var afterEnterHook = isAppear
  49233. ? (afterAppear || afterEnter)
  49234. : afterEnter;
  49235. var enterCancelledHook = isAppear
  49236. ? (appearCancelled || enterCancelled)
  49237. : enterCancelled;
  49238. var explicitEnterDuration = toNumber(
  49239. isObject(duration)
  49240. ? duration.enter
  49241. : duration
  49242. );
  49243. if (explicitEnterDuration != null) {
  49244. checkDuration(explicitEnterDuration, 'enter', vnode);
  49245. }
  49246. var expectsCSS = css !== false && !isIE9;
  49247. var userWantsControl = getHookArgumentsLength(enterHook);
  49248. var cb = el._enterCb = once(function () {
  49249. if (expectsCSS) {
  49250. removeTransitionClass(el, toClass);
  49251. removeTransitionClass(el, activeClass);
  49252. }
  49253. if (cb.cancelled) {
  49254. if (expectsCSS) {
  49255. removeTransitionClass(el, startClass);
  49256. }
  49257. enterCancelledHook && enterCancelledHook(el);
  49258. } else {
  49259. afterEnterHook && afterEnterHook(el);
  49260. }
  49261. el._enterCb = null;
  49262. });
  49263. if (!vnode.data.show) {
  49264. // remove pending leave element on enter by injecting an insert hook
  49265. mergeVNodeHook(vnode, 'insert', function () {
  49266. var parent = el.parentNode;
  49267. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49268. if (pendingNode &&
  49269. pendingNode.tag === vnode.tag &&
  49270. pendingNode.elm._leaveCb
  49271. ) {
  49272. pendingNode.elm._leaveCb();
  49273. }
  49274. enterHook && enterHook(el, cb);
  49275. });
  49276. }
  49277. // start enter transition
  49278. beforeEnterHook && beforeEnterHook(el);
  49279. if (expectsCSS) {
  49280. addTransitionClass(el, startClass);
  49281. addTransitionClass(el, activeClass);
  49282. nextFrame(function () {
  49283. removeTransitionClass(el, startClass);
  49284. if (!cb.cancelled) {
  49285. addTransitionClass(el, toClass);
  49286. if (!userWantsControl) {
  49287. if (isValidDuration(explicitEnterDuration)) {
  49288. setTimeout(cb, explicitEnterDuration);
  49289. } else {
  49290. whenTransitionEnds(el, type, cb);
  49291. }
  49292. }
  49293. }
  49294. });
  49295. }
  49296. if (vnode.data.show) {
  49297. toggleDisplay && toggleDisplay();
  49298. enterHook && enterHook(el, cb);
  49299. }
  49300. if (!expectsCSS && !userWantsControl) {
  49301. cb();
  49302. }
  49303. }
  49304. function leave (vnode, rm) {
  49305. var el = vnode.elm;
  49306. // call enter callback now
  49307. if (isDef(el._enterCb)) {
  49308. el._enterCb.cancelled = true;
  49309. el._enterCb();
  49310. }
  49311. var data = resolveTransition(vnode.data.transition);
  49312. if (isUndef(data) || el.nodeType !== 1) {
  49313. return rm()
  49314. }
  49315. /* istanbul ignore if */
  49316. if (isDef(el._leaveCb)) {
  49317. return
  49318. }
  49319. var css = data.css;
  49320. var type = data.type;
  49321. var leaveClass = data.leaveClass;
  49322. var leaveToClass = data.leaveToClass;
  49323. var leaveActiveClass = data.leaveActiveClass;
  49324. var beforeLeave = data.beforeLeave;
  49325. var leave = data.leave;
  49326. var afterLeave = data.afterLeave;
  49327. var leaveCancelled = data.leaveCancelled;
  49328. var delayLeave = data.delayLeave;
  49329. var duration = data.duration;
  49330. var expectsCSS = css !== false && !isIE9;
  49331. var userWantsControl = getHookArgumentsLength(leave);
  49332. var explicitLeaveDuration = toNumber(
  49333. isObject(duration)
  49334. ? duration.leave
  49335. : duration
  49336. );
  49337. if (isDef(explicitLeaveDuration)) {
  49338. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49339. }
  49340. var cb = el._leaveCb = once(function () {
  49341. if (el.parentNode && el.parentNode._pending) {
  49342. el.parentNode._pending[vnode.key] = null;
  49343. }
  49344. if (expectsCSS) {
  49345. removeTransitionClass(el, leaveToClass);
  49346. removeTransitionClass(el, leaveActiveClass);
  49347. }
  49348. if (cb.cancelled) {
  49349. if (expectsCSS) {
  49350. removeTransitionClass(el, leaveClass);
  49351. }
  49352. leaveCancelled && leaveCancelled(el);
  49353. } else {
  49354. rm();
  49355. afterLeave && afterLeave(el);
  49356. }
  49357. el._leaveCb = null;
  49358. });
  49359. if (delayLeave) {
  49360. delayLeave(performLeave);
  49361. } else {
  49362. performLeave();
  49363. }
  49364. function performLeave () {
  49365. // the delayed leave may have already been cancelled
  49366. if (cb.cancelled) {
  49367. return
  49368. }
  49369. // record leaving element
  49370. if (!vnode.data.show && el.parentNode) {
  49371. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49372. }
  49373. beforeLeave && beforeLeave(el);
  49374. if (expectsCSS) {
  49375. addTransitionClass(el, leaveClass);
  49376. addTransitionClass(el, leaveActiveClass);
  49377. nextFrame(function () {
  49378. removeTransitionClass(el, leaveClass);
  49379. if (!cb.cancelled) {
  49380. addTransitionClass(el, leaveToClass);
  49381. if (!userWantsControl) {
  49382. if (isValidDuration(explicitLeaveDuration)) {
  49383. setTimeout(cb, explicitLeaveDuration);
  49384. } else {
  49385. whenTransitionEnds(el, type, cb);
  49386. }
  49387. }
  49388. }
  49389. });
  49390. }
  49391. leave && leave(el, cb);
  49392. if (!expectsCSS && !userWantsControl) {
  49393. cb();
  49394. }
  49395. }
  49396. }
  49397. // only used in dev mode
  49398. function checkDuration (val, name, vnode) {
  49399. if (typeof val !== 'number') {
  49400. warn(
  49401. "<transition> explicit " + name + " duration is not a valid number - " +
  49402. "got " + (JSON.stringify(val)) + ".",
  49403. vnode.context
  49404. );
  49405. } else if (isNaN(val)) {
  49406. warn(
  49407. "<transition> explicit " + name + " duration is NaN - " +
  49408. 'the duration expression might be incorrect.',
  49409. vnode.context
  49410. );
  49411. }
  49412. }
  49413. function isValidDuration (val) {
  49414. return typeof val === 'number' && !isNaN(val)
  49415. }
  49416. /**
  49417. * Normalize a transition hook's argument length. The hook may be:
  49418. * - a merged hook (invoker) with the original in .fns
  49419. * - a wrapped component method (check ._length)
  49420. * - a plain function (.length)
  49421. */
  49422. function getHookArgumentsLength (fn) {
  49423. if (isUndef(fn)) {
  49424. return false
  49425. }
  49426. var invokerFns = fn.fns;
  49427. if (isDef(invokerFns)) {
  49428. // invoker
  49429. return getHookArgumentsLength(
  49430. Array.isArray(invokerFns)
  49431. ? invokerFns[0]
  49432. : invokerFns
  49433. )
  49434. } else {
  49435. return (fn._length || fn.length) > 1
  49436. }
  49437. }
  49438. function _enter (_, vnode) {
  49439. if (vnode.data.show !== true) {
  49440. enter(vnode);
  49441. }
  49442. }
  49443. var transition = inBrowser ? {
  49444. create: _enter,
  49445. activate: _enter,
  49446. remove: function remove$$1 (vnode, rm) {
  49447. /* istanbul ignore else */
  49448. if (vnode.data.show !== true) {
  49449. leave(vnode, rm);
  49450. } else {
  49451. rm();
  49452. }
  49453. }
  49454. } : {};
  49455. var platformModules = [
  49456. attrs,
  49457. klass,
  49458. events,
  49459. domProps,
  49460. style,
  49461. transition
  49462. ];
  49463. /* */
  49464. // the directive module should be applied last, after all
  49465. // built-in modules have been applied.
  49466. var modules = platformModules.concat(baseModules);
  49467. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49468. /**
  49469. * Not type checking this file because flow doesn't like attaching
  49470. * properties to Elements.
  49471. */
  49472. /* istanbul ignore if */
  49473. if (isIE9) {
  49474. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49475. document.addEventListener('selectionchange', function () {
  49476. var el = document.activeElement;
  49477. if (el && el.vmodel) {
  49478. trigger(el, 'input');
  49479. }
  49480. });
  49481. }
  49482. var directive = {
  49483. inserted: function inserted (el, binding, vnode, oldVnode) {
  49484. if (vnode.tag === 'select') {
  49485. // #6903
  49486. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49487. mergeVNodeHook(vnode, 'postpatch', function () {
  49488. directive.componentUpdated(el, binding, vnode);
  49489. });
  49490. } else {
  49491. setSelected(el, binding, vnode.context);
  49492. }
  49493. el._vOptions = [].map.call(el.options, getValue);
  49494. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49495. el._vModifiers = binding.modifiers;
  49496. if (!binding.modifiers.lazy) {
  49497. el.addEventListener('compositionstart', onCompositionStart);
  49498. el.addEventListener('compositionend', onCompositionEnd);
  49499. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49500. // switching focus before confirming composition choice
  49501. // this also fixes the issue where some browsers e.g. iOS Chrome
  49502. // fires "change" instead of "input" on autocomplete.
  49503. el.addEventListener('change', onCompositionEnd);
  49504. /* istanbul ignore if */
  49505. if (isIE9) {
  49506. el.vmodel = true;
  49507. }
  49508. }
  49509. }
  49510. },
  49511. componentUpdated: function componentUpdated (el, binding, vnode) {
  49512. if (vnode.tag === 'select') {
  49513. setSelected(el, binding, vnode.context);
  49514. // in case the options rendered by v-for have changed,
  49515. // it's possible that the value is out-of-sync with the rendered options.
  49516. // detect such cases and filter out values that no longer has a matching
  49517. // option in the DOM.
  49518. var prevOptions = el._vOptions;
  49519. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49520. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49521. // trigger change event if
  49522. // no matching option found for at least one value
  49523. var needReset = el.multiple
  49524. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49525. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49526. if (needReset) {
  49527. trigger(el, 'change');
  49528. }
  49529. }
  49530. }
  49531. }
  49532. };
  49533. function setSelected (el, binding, vm) {
  49534. actuallySetSelected(el, binding, vm);
  49535. /* istanbul ignore if */
  49536. if (isIE || isEdge) {
  49537. setTimeout(function () {
  49538. actuallySetSelected(el, binding, vm);
  49539. }, 0);
  49540. }
  49541. }
  49542. function actuallySetSelected (el, binding, vm) {
  49543. var value = binding.value;
  49544. var isMultiple = el.multiple;
  49545. if (isMultiple && !Array.isArray(value)) {
  49546. warn(
  49547. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49548. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49549. vm
  49550. );
  49551. return
  49552. }
  49553. var selected, option;
  49554. for (var i = 0, l = el.options.length; i < l; i++) {
  49555. option = el.options[i];
  49556. if (isMultiple) {
  49557. selected = looseIndexOf(value, getValue(option)) > -1;
  49558. if (option.selected !== selected) {
  49559. option.selected = selected;
  49560. }
  49561. } else {
  49562. if (looseEqual(getValue(option), value)) {
  49563. if (el.selectedIndex !== i) {
  49564. el.selectedIndex = i;
  49565. }
  49566. return
  49567. }
  49568. }
  49569. }
  49570. if (!isMultiple) {
  49571. el.selectedIndex = -1;
  49572. }
  49573. }
  49574. function hasNoMatchingOption (value, options) {
  49575. return options.every(function (o) { return !looseEqual(o, value); })
  49576. }
  49577. function getValue (option) {
  49578. return '_value' in option
  49579. ? option._value
  49580. : option.value
  49581. }
  49582. function onCompositionStart (e) {
  49583. e.target.composing = true;
  49584. }
  49585. function onCompositionEnd (e) {
  49586. // prevent triggering an input event for no reason
  49587. if (!e.target.composing) { return }
  49588. e.target.composing = false;
  49589. trigger(e.target, 'input');
  49590. }
  49591. function trigger (el, type) {
  49592. var e = document.createEvent('HTMLEvents');
  49593. e.initEvent(type, true, true);
  49594. el.dispatchEvent(e);
  49595. }
  49596. /* */
  49597. // recursively search for possible transition defined inside the component root
  49598. function locateNode (vnode) {
  49599. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49600. ? locateNode(vnode.componentInstance._vnode)
  49601. : vnode
  49602. }
  49603. var show = {
  49604. bind: function bind (el, ref, vnode) {
  49605. var value = ref.value;
  49606. vnode = locateNode(vnode);
  49607. var transition$$1 = vnode.data && vnode.data.transition;
  49608. var originalDisplay = el.__vOriginalDisplay =
  49609. el.style.display === 'none' ? '' : el.style.display;
  49610. if (value && transition$$1) {
  49611. vnode.data.show = true;
  49612. enter(vnode, function () {
  49613. el.style.display = originalDisplay;
  49614. });
  49615. } else {
  49616. el.style.display = value ? originalDisplay : 'none';
  49617. }
  49618. },
  49619. update: function update (el, ref, vnode) {
  49620. var value = ref.value;
  49621. var oldValue = ref.oldValue;
  49622. /* istanbul ignore if */
  49623. if (!value === !oldValue) { return }
  49624. vnode = locateNode(vnode);
  49625. var transition$$1 = vnode.data && vnode.data.transition;
  49626. if (transition$$1) {
  49627. vnode.data.show = true;
  49628. if (value) {
  49629. enter(vnode, function () {
  49630. el.style.display = el.__vOriginalDisplay;
  49631. });
  49632. } else {
  49633. leave(vnode, function () {
  49634. el.style.display = 'none';
  49635. });
  49636. }
  49637. } else {
  49638. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49639. }
  49640. },
  49641. unbind: function unbind (
  49642. el,
  49643. binding,
  49644. vnode,
  49645. oldVnode,
  49646. isDestroy
  49647. ) {
  49648. if (!isDestroy) {
  49649. el.style.display = el.__vOriginalDisplay;
  49650. }
  49651. }
  49652. };
  49653. var platformDirectives = {
  49654. model: directive,
  49655. show: show
  49656. };
  49657. /* */
  49658. var transitionProps = {
  49659. name: String,
  49660. appear: Boolean,
  49661. css: Boolean,
  49662. mode: String,
  49663. type: String,
  49664. enterClass: String,
  49665. leaveClass: String,
  49666. enterToClass: String,
  49667. leaveToClass: String,
  49668. enterActiveClass: String,
  49669. leaveActiveClass: String,
  49670. appearClass: String,
  49671. appearActiveClass: String,
  49672. appearToClass: String,
  49673. duration: [Number, String, Object]
  49674. };
  49675. // in case the child is also an abstract component, e.g. <keep-alive>
  49676. // we want to recursively retrieve the real component to be rendered
  49677. function getRealChild (vnode) {
  49678. var compOptions = vnode && vnode.componentOptions;
  49679. if (compOptions && compOptions.Ctor.options.abstract) {
  49680. return getRealChild(getFirstComponentChild(compOptions.children))
  49681. } else {
  49682. return vnode
  49683. }
  49684. }
  49685. function extractTransitionData (comp) {
  49686. var data = {};
  49687. var options = comp.$options;
  49688. // props
  49689. for (var key in options.propsData) {
  49690. data[key] = comp[key];
  49691. }
  49692. // events.
  49693. // extract listeners and pass them directly to the transition methods
  49694. var listeners = options._parentListeners;
  49695. for (var key$1 in listeners) {
  49696. data[camelize(key$1)] = listeners[key$1];
  49697. }
  49698. return data
  49699. }
  49700. function placeholder (h, rawChild) {
  49701. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49702. return h('keep-alive', {
  49703. props: rawChild.componentOptions.propsData
  49704. })
  49705. }
  49706. }
  49707. function hasParentTransition (vnode) {
  49708. while ((vnode = vnode.parent)) {
  49709. if (vnode.data.transition) {
  49710. return true
  49711. }
  49712. }
  49713. }
  49714. function isSameChild (child, oldChild) {
  49715. return oldChild.key === child.key && oldChild.tag === child.tag
  49716. }
  49717. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49718. var isVShowDirective = function (d) { return d.name === 'show'; };
  49719. var Transition = {
  49720. name: 'transition',
  49721. props: transitionProps,
  49722. abstract: true,
  49723. render: function render (h) {
  49724. var this$1 = this;
  49725. var children = this.$slots.default;
  49726. if (!children) {
  49727. return
  49728. }
  49729. // filter out text nodes (possible whitespaces)
  49730. children = children.filter(isNotTextNode);
  49731. /* istanbul ignore if */
  49732. if (!children.length) {
  49733. return
  49734. }
  49735. // warn multiple elements
  49736. if (children.length > 1) {
  49737. warn(
  49738. '<transition> can only be used on a single element. Use ' +
  49739. '<transition-group> for lists.',
  49740. this.$parent
  49741. );
  49742. }
  49743. var mode = this.mode;
  49744. // warn invalid mode
  49745. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49746. ) {
  49747. warn(
  49748. 'invalid <transition> mode: ' + mode,
  49749. this.$parent
  49750. );
  49751. }
  49752. var rawChild = children[0];
  49753. // if this is a component root node and the component's
  49754. // parent container node also has transition, skip.
  49755. if (hasParentTransition(this.$vnode)) {
  49756. return rawChild
  49757. }
  49758. // apply transition data to child
  49759. // use getRealChild() to ignore abstract components e.g. keep-alive
  49760. var child = getRealChild(rawChild);
  49761. /* istanbul ignore if */
  49762. if (!child) {
  49763. return rawChild
  49764. }
  49765. if (this._leaving) {
  49766. return placeholder(h, rawChild)
  49767. }
  49768. // ensure a key that is unique to the vnode type and to this transition
  49769. // component instance. This key will be used to remove pending leaving nodes
  49770. // during entering.
  49771. var id = "__transition-" + (this._uid) + "-";
  49772. child.key = child.key == null
  49773. ? child.isComment
  49774. ? id + 'comment'
  49775. : id + child.tag
  49776. : isPrimitive(child.key)
  49777. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49778. : child.key;
  49779. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49780. var oldRawChild = this._vnode;
  49781. var oldChild = getRealChild(oldRawChild);
  49782. // mark v-show
  49783. // so that the transition module can hand over the control to the directive
  49784. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49785. child.data.show = true;
  49786. }
  49787. if (
  49788. oldChild &&
  49789. oldChild.data &&
  49790. !isSameChild(child, oldChild) &&
  49791. !isAsyncPlaceholder(oldChild) &&
  49792. // #6687 component root is a comment node
  49793. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49794. ) {
  49795. // replace old child transition data with fresh one
  49796. // important for dynamic transitions!
  49797. var oldData = oldChild.data.transition = extend({}, data);
  49798. // handle transition mode
  49799. if (mode === 'out-in') {
  49800. // return placeholder node and queue update when leave finishes
  49801. this._leaving = true;
  49802. mergeVNodeHook(oldData, 'afterLeave', function () {
  49803. this$1._leaving = false;
  49804. this$1.$forceUpdate();
  49805. });
  49806. return placeholder(h, rawChild)
  49807. } else if (mode === 'in-out') {
  49808. if (isAsyncPlaceholder(child)) {
  49809. return oldRawChild
  49810. }
  49811. var delayedLeave;
  49812. var performLeave = function () { delayedLeave(); };
  49813. mergeVNodeHook(data, 'afterEnter', performLeave);
  49814. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49815. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49816. }
  49817. }
  49818. return rawChild
  49819. }
  49820. };
  49821. /* */
  49822. var props = extend({
  49823. tag: String,
  49824. moveClass: String
  49825. }, transitionProps);
  49826. delete props.mode;
  49827. var TransitionGroup = {
  49828. props: props,
  49829. beforeMount: function beforeMount () {
  49830. var this$1 = this;
  49831. var update = this._update;
  49832. this._update = function (vnode, hydrating) {
  49833. var restoreActiveInstance = setActiveInstance(this$1);
  49834. // force removing pass
  49835. this$1.__patch__(
  49836. this$1._vnode,
  49837. this$1.kept,
  49838. false, // hydrating
  49839. true // removeOnly (!important, avoids unnecessary moves)
  49840. );
  49841. this$1._vnode = this$1.kept;
  49842. restoreActiveInstance();
  49843. update.call(this$1, vnode, hydrating);
  49844. };
  49845. },
  49846. render: function render (h) {
  49847. var tag = this.tag || this.$vnode.data.tag || 'span';
  49848. var map = Object.create(null);
  49849. var prevChildren = this.prevChildren = this.children;
  49850. var rawChildren = this.$slots.default || [];
  49851. var children = this.children = [];
  49852. var transitionData = extractTransitionData(this);
  49853. for (var i = 0; i < rawChildren.length; i++) {
  49854. var c = rawChildren[i];
  49855. if (c.tag) {
  49856. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49857. children.push(c);
  49858. map[c.key] = c
  49859. ;(c.data || (c.data = {})).transition = transitionData;
  49860. } else {
  49861. var opts = c.componentOptions;
  49862. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49863. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49864. }
  49865. }
  49866. }
  49867. if (prevChildren) {
  49868. var kept = [];
  49869. var removed = [];
  49870. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49871. var c$1 = prevChildren[i$1];
  49872. c$1.data.transition = transitionData;
  49873. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49874. if (map[c$1.key]) {
  49875. kept.push(c$1);
  49876. } else {
  49877. removed.push(c$1);
  49878. }
  49879. }
  49880. this.kept = h(tag, null, kept);
  49881. this.removed = removed;
  49882. }
  49883. return h(tag, null, children)
  49884. },
  49885. updated: function updated () {
  49886. var children = this.prevChildren;
  49887. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49888. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49889. return
  49890. }
  49891. // we divide the work into three loops to avoid mixing DOM reads and writes
  49892. // in each iteration - which helps prevent layout thrashing.
  49893. children.forEach(callPendingCbs);
  49894. children.forEach(recordPosition);
  49895. children.forEach(applyTranslation);
  49896. // force reflow to put everything in position
  49897. // assign to this to avoid being removed in tree-shaking
  49898. // $flow-disable-line
  49899. this._reflow = document.body.offsetHeight;
  49900. children.forEach(function (c) {
  49901. if (c.data.moved) {
  49902. var el = c.elm;
  49903. var s = el.style;
  49904. addTransitionClass(el, moveClass);
  49905. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49906. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49907. if (e && e.target !== el) {
  49908. return
  49909. }
  49910. if (!e || /transform$/.test(e.propertyName)) {
  49911. el.removeEventListener(transitionEndEvent, cb);
  49912. el._moveCb = null;
  49913. removeTransitionClass(el, moveClass);
  49914. }
  49915. });
  49916. }
  49917. });
  49918. },
  49919. methods: {
  49920. hasMove: function hasMove (el, moveClass) {
  49921. /* istanbul ignore if */
  49922. if (!hasTransition) {
  49923. return false
  49924. }
  49925. /* istanbul ignore if */
  49926. if (this._hasMove) {
  49927. return this._hasMove
  49928. }
  49929. // Detect whether an element with the move class applied has
  49930. // CSS transitions. Since the element may be inside an entering
  49931. // transition at this very moment, we make a clone of it and remove
  49932. // all other transition classes applied to ensure only the move class
  49933. // is applied.
  49934. var clone = el.cloneNode();
  49935. if (el._transitionClasses) {
  49936. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49937. }
  49938. addClass(clone, moveClass);
  49939. clone.style.display = 'none';
  49940. this.$el.appendChild(clone);
  49941. var info = getTransitionInfo(clone);
  49942. this.$el.removeChild(clone);
  49943. return (this._hasMove = info.hasTransform)
  49944. }
  49945. }
  49946. };
  49947. function callPendingCbs (c) {
  49948. /* istanbul ignore if */
  49949. if (c.elm._moveCb) {
  49950. c.elm._moveCb();
  49951. }
  49952. /* istanbul ignore if */
  49953. if (c.elm._enterCb) {
  49954. c.elm._enterCb();
  49955. }
  49956. }
  49957. function recordPosition (c) {
  49958. c.data.newPos = c.elm.getBoundingClientRect();
  49959. }
  49960. function applyTranslation (c) {
  49961. var oldPos = c.data.pos;
  49962. var newPos = c.data.newPos;
  49963. var dx = oldPos.left - newPos.left;
  49964. var dy = oldPos.top - newPos.top;
  49965. if (dx || dy) {
  49966. c.data.moved = true;
  49967. var s = c.elm.style;
  49968. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49969. s.transitionDuration = '0s';
  49970. }
  49971. }
  49972. var platformComponents = {
  49973. Transition: Transition,
  49974. TransitionGroup: TransitionGroup
  49975. };
  49976. /* */
  49977. // install platform specific utils
  49978. Vue.config.mustUseProp = mustUseProp;
  49979. Vue.config.isReservedTag = isReservedTag;
  49980. Vue.config.isReservedAttr = isReservedAttr;
  49981. Vue.config.getTagNamespace = getTagNamespace;
  49982. Vue.config.isUnknownElement = isUnknownElement;
  49983. // install platform runtime directives & components
  49984. extend(Vue.options.directives, platformDirectives);
  49985. extend(Vue.options.components, platformComponents);
  49986. // install platform patch function
  49987. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49988. // public mount method
  49989. Vue.prototype.$mount = function (
  49990. el,
  49991. hydrating
  49992. ) {
  49993. el = el && inBrowser ? query(el) : undefined;
  49994. return mountComponent(this, el, hydrating)
  49995. };
  49996. // devtools global hook
  49997. /* istanbul ignore next */
  49998. if (inBrowser) {
  49999. setTimeout(function () {
  50000. if (config.devtools) {
  50001. if (devtools) {
  50002. devtools.emit('init', Vue);
  50003. } else {
  50004. console[console.info ? 'info' : 'log'](
  50005. 'Download the Vue Devtools extension for a better development experience:\n' +
  50006. 'https://github.com/vuejs/vue-devtools'
  50007. );
  50008. }
  50009. }
  50010. if (config.productionTip !== false &&
  50011. typeof console !== 'undefined'
  50012. ) {
  50013. console[console.info ? 'info' : 'log'](
  50014. "You are running Vue in development mode.\n" +
  50015. "Make sure to turn on production mode when deploying for production.\n" +
  50016. "See more tips at https://vuejs.org/guide/deployment.html"
  50017. );
  50018. }
  50019. }, 0);
  50020. }
  50021. /* */
  50022. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  50023. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  50024. var buildRegex = cached(function (delimiters) {
  50025. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  50026. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  50027. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  50028. });
  50029. function parseText (
  50030. text,
  50031. delimiters
  50032. ) {
  50033. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  50034. if (!tagRE.test(text)) {
  50035. return
  50036. }
  50037. var tokens = [];
  50038. var rawTokens = [];
  50039. var lastIndex = tagRE.lastIndex = 0;
  50040. var match, index, tokenValue;
  50041. while ((match = tagRE.exec(text))) {
  50042. index = match.index;
  50043. // push text token
  50044. if (index > lastIndex) {
  50045. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  50046. tokens.push(JSON.stringify(tokenValue));
  50047. }
  50048. // tag token
  50049. var exp = parseFilters(match[1].trim());
  50050. tokens.push(("_s(" + exp + ")"));
  50051. rawTokens.push({ '@binding': exp });
  50052. lastIndex = index + match[0].length;
  50053. }
  50054. if (lastIndex < text.length) {
  50055. rawTokens.push(tokenValue = text.slice(lastIndex));
  50056. tokens.push(JSON.stringify(tokenValue));
  50057. }
  50058. return {
  50059. expression: tokens.join('+'),
  50060. tokens: rawTokens
  50061. }
  50062. }
  50063. /* */
  50064. function transformNode (el, options) {
  50065. var warn = options.warn || baseWarn;
  50066. var staticClass = getAndRemoveAttr(el, 'class');
  50067. if (staticClass) {
  50068. var res = parseText(staticClass, options.delimiters);
  50069. if (res) {
  50070. warn(
  50071. "class=\"" + staticClass + "\": " +
  50072. 'Interpolation inside attributes has been removed. ' +
  50073. 'Use v-bind or the colon shorthand instead. For example, ' +
  50074. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  50075. el.rawAttrsMap['class']
  50076. );
  50077. }
  50078. }
  50079. if (staticClass) {
  50080. el.staticClass = JSON.stringify(staticClass);
  50081. }
  50082. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  50083. if (classBinding) {
  50084. el.classBinding = classBinding;
  50085. }
  50086. }
  50087. function genData (el) {
  50088. var data = '';
  50089. if (el.staticClass) {
  50090. data += "staticClass:" + (el.staticClass) + ",";
  50091. }
  50092. if (el.classBinding) {
  50093. data += "class:" + (el.classBinding) + ",";
  50094. }
  50095. return data
  50096. }
  50097. var klass$1 = {
  50098. staticKeys: ['staticClass'],
  50099. transformNode: transformNode,
  50100. genData: genData
  50101. };
  50102. /* */
  50103. function transformNode$1 (el, options) {
  50104. var warn = options.warn || baseWarn;
  50105. var staticStyle = getAndRemoveAttr(el, 'style');
  50106. if (staticStyle) {
  50107. /* istanbul ignore if */
  50108. {
  50109. var res = parseText(staticStyle, options.delimiters);
  50110. if (res) {
  50111. warn(
  50112. "style=\"" + staticStyle + "\": " +
  50113. 'Interpolation inside attributes has been removed. ' +
  50114. 'Use v-bind or the colon shorthand instead. For example, ' +
  50115. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  50116. el.rawAttrsMap['style']
  50117. );
  50118. }
  50119. }
  50120. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  50121. }
  50122. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  50123. if (styleBinding) {
  50124. el.styleBinding = styleBinding;
  50125. }
  50126. }
  50127. function genData$1 (el) {
  50128. var data = '';
  50129. if (el.staticStyle) {
  50130. data += "staticStyle:" + (el.staticStyle) + ",";
  50131. }
  50132. if (el.styleBinding) {
  50133. data += "style:(" + (el.styleBinding) + "),";
  50134. }
  50135. return data
  50136. }
  50137. var style$1 = {
  50138. staticKeys: ['staticStyle'],
  50139. transformNode: transformNode$1,
  50140. genData: genData$1
  50141. };
  50142. /* */
  50143. var decoder;
  50144. var he = {
  50145. decode: function decode (html) {
  50146. decoder = decoder || document.createElement('div');
  50147. decoder.innerHTML = html;
  50148. return decoder.textContent
  50149. }
  50150. };
  50151. /* */
  50152. var isUnaryTag = makeMap(
  50153. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50154. 'link,meta,param,source,track,wbr'
  50155. );
  50156. // Elements that you can, intentionally, leave open
  50157. // (and which close themselves)
  50158. var canBeLeftOpenTag = makeMap(
  50159. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50160. );
  50161. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50162. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50163. var isNonPhrasingTag = makeMap(
  50164. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50165. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50166. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50167. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50168. 'title,tr,track'
  50169. );
  50170. /**
  50171. * Not type-checking this file because it's mostly vendor code.
  50172. */
  50173. // Regular Expressions for parsing tags and attributes
  50174. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50175. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50176. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50177. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50178. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50179. var startTagClose = /^\s*(\/?)>/;
  50180. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50181. var doctype = /^<!DOCTYPE [^>]+>/i;
  50182. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50183. var comment = /^<!\--/;
  50184. var conditionalComment = /^<!\[/;
  50185. // Special Elements (can contain anything)
  50186. var isPlainTextElement = makeMap('script,style,textarea', true);
  50187. var reCache = {};
  50188. var decodingMap = {
  50189. '&lt;': '<',
  50190. '&gt;': '>',
  50191. '&quot;': '"',
  50192. '&amp;': '&',
  50193. '&#10;': '\n',
  50194. '&#9;': '\t',
  50195. '&#39;': "'"
  50196. };
  50197. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50198. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50199. // #5992
  50200. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50201. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50202. function decodeAttr (value, shouldDecodeNewlines) {
  50203. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50204. return value.replace(re, function (match) { return decodingMap[match]; })
  50205. }
  50206. function parseHTML (html, options) {
  50207. var stack = [];
  50208. var expectHTML = options.expectHTML;
  50209. var isUnaryTag$$1 = options.isUnaryTag || no;
  50210. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50211. var index = 0;
  50212. var last, lastTag;
  50213. while (html) {
  50214. last = html;
  50215. // Make sure we're not in a plaintext content element like script/style
  50216. if (!lastTag || !isPlainTextElement(lastTag)) {
  50217. var textEnd = html.indexOf('<');
  50218. if (textEnd === 0) {
  50219. // Comment:
  50220. if (comment.test(html)) {
  50221. var commentEnd = html.indexOf('-->');
  50222. if (commentEnd >= 0) {
  50223. if (options.shouldKeepComment) {
  50224. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50225. }
  50226. advance(commentEnd + 3);
  50227. continue
  50228. }
  50229. }
  50230. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50231. if (conditionalComment.test(html)) {
  50232. var conditionalEnd = html.indexOf(']>');
  50233. if (conditionalEnd >= 0) {
  50234. advance(conditionalEnd + 2);
  50235. continue
  50236. }
  50237. }
  50238. // Doctype:
  50239. var doctypeMatch = html.match(doctype);
  50240. if (doctypeMatch) {
  50241. advance(doctypeMatch[0].length);
  50242. continue
  50243. }
  50244. // End tag:
  50245. var endTagMatch = html.match(endTag);
  50246. if (endTagMatch) {
  50247. var curIndex = index;
  50248. advance(endTagMatch[0].length);
  50249. parseEndTag(endTagMatch[1], curIndex, index);
  50250. continue
  50251. }
  50252. // Start tag:
  50253. var startTagMatch = parseStartTag();
  50254. if (startTagMatch) {
  50255. handleStartTag(startTagMatch);
  50256. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50257. advance(1);
  50258. }
  50259. continue
  50260. }
  50261. }
  50262. var text = (void 0), rest = (void 0), next = (void 0);
  50263. if (textEnd >= 0) {
  50264. rest = html.slice(textEnd);
  50265. while (
  50266. !endTag.test(rest) &&
  50267. !startTagOpen.test(rest) &&
  50268. !comment.test(rest) &&
  50269. !conditionalComment.test(rest)
  50270. ) {
  50271. // < in plain text, be forgiving and treat it as text
  50272. next = rest.indexOf('<', 1);
  50273. if (next < 0) { break }
  50274. textEnd += next;
  50275. rest = html.slice(textEnd);
  50276. }
  50277. text = html.substring(0, textEnd);
  50278. }
  50279. if (textEnd < 0) {
  50280. text = html;
  50281. }
  50282. if (text) {
  50283. advance(text.length);
  50284. }
  50285. if (options.chars && text) {
  50286. options.chars(text, index - text.length, index);
  50287. }
  50288. } else {
  50289. var endTagLength = 0;
  50290. var stackedTag = lastTag.toLowerCase();
  50291. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50292. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50293. endTagLength = endTag.length;
  50294. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50295. text = text
  50296. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50297. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50298. }
  50299. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50300. text = text.slice(1);
  50301. }
  50302. if (options.chars) {
  50303. options.chars(text);
  50304. }
  50305. return ''
  50306. });
  50307. index += html.length - rest$1.length;
  50308. html = rest$1;
  50309. parseEndTag(stackedTag, index - endTagLength, index);
  50310. }
  50311. if (html === last) {
  50312. options.chars && options.chars(html);
  50313. if (!stack.length && options.warn) {
  50314. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50315. }
  50316. break
  50317. }
  50318. }
  50319. // Clean up any remaining tags
  50320. parseEndTag();
  50321. function advance (n) {
  50322. index += n;
  50323. html = html.substring(n);
  50324. }
  50325. function parseStartTag () {
  50326. var start = html.match(startTagOpen);
  50327. if (start) {
  50328. var match = {
  50329. tagName: start[1],
  50330. attrs: [],
  50331. start: index
  50332. };
  50333. advance(start[0].length);
  50334. var end, attr;
  50335. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50336. attr.start = index;
  50337. advance(attr[0].length);
  50338. attr.end = index;
  50339. match.attrs.push(attr);
  50340. }
  50341. if (end) {
  50342. match.unarySlash = end[1];
  50343. advance(end[0].length);
  50344. match.end = index;
  50345. return match
  50346. }
  50347. }
  50348. }
  50349. function handleStartTag (match) {
  50350. var tagName = match.tagName;
  50351. var unarySlash = match.unarySlash;
  50352. if (expectHTML) {
  50353. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50354. parseEndTag(lastTag);
  50355. }
  50356. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50357. parseEndTag(tagName);
  50358. }
  50359. }
  50360. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50361. var l = match.attrs.length;
  50362. var attrs = new Array(l);
  50363. for (var i = 0; i < l; i++) {
  50364. var args = match.attrs[i];
  50365. var value = args[3] || args[4] || args[5] || '';
  50366. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50367. ? options.shouldDecodeNewlinesForHref
  50368. : options.shouldDecodeNewlines;
  50369. attrs[i] = {
  50370. name: args[1],
  50371. value: decodeAttr(value, shouldDecodeNewlines)
  50372. };
  50373. if (options.outputSourceRange) {
  50374. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50375. attrs[i].end = args.end;
  50376. }
  50377. }
  50378. if (!unary) {
  50379. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50380. lastTag = tagName;
  50381. }
  50382. if (options.start) {
  50383. options.start(tagName, attrs, unary, match.start, match.end);
  50384. }
  50385. }
  50386. function parseEndTag (tagName, start, end) {
  50387. var pos, lowerCasedTagName;
  50388. if (start == null) { start = index; }
  50389. if (end == null) { end = index; }
  50390. // Find the closest opened tag of the same type
  50391. if (tagName) {
  50392. lowerCasedTagName = tagName.toLowerCase();
  50393. for (pos = stack.length - 1; pos >= 0; pos--) {
  50394. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50395. break
  50396. }
  50397. }
  50398. } else {
  50399. // If no tag name is provided, clean shop
  50400. pos = 0;
  50401. }
  50402. if (pos >= 0) {
  50403. // Close all the open elements, up the stack
  50404. for (var i = stack.length - 1; i >= pos; i--) {
  50405. if (i > pos || !tagName &&
  50406. options.warn
  50407. ) {
  50408. options.warn(
  50409. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50410. { start: stack[i].start, end: stack[i].end }
  50411. );
  50412. }
  50413. if (options.end) {
  50414. options.end(stack[i].tag, start, end);
  50415. }
  50416. }
  50417. // Remove the open elements from the stack
  50418. stack.length = pos;
  50419. lastTag = pos && stack[pos - 1].tag;
  50420. } else if (lowerCasedTagName === 'br') {
  50421. if (options.start) {
  50422. options.start(tagName, [], true, start, end);
  50423. }
  50424. } else if (lowerCasedTagName === 'p') {
  50425. if (options.start) {
  50426. options.start(tagName, [], false, start, end);
  50427. }
  50428. if (options.end) {
  50429. options.end(tagName, start, end);
  50430. }
  50431. }
  50432. }
  50433. }
  50434. /* */
  50435. var onRE = /^@|^v-on:/;
  50436. var dirRE = /^v-|^@|^:|^#/;
  50437. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50438. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50439. var stripParensRE = /^\(|\)$/g;
  50440. var dynamicArgRE = /^\[.*\]$/;
  50441. var argRE = /:(.*)$/;
  50442. var bindRE = /^:|^\.|^v-bind:/;
  50443. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50444. var slotRE = /^v-slot(:|$)|^#/;
  50445. var lineBreakRE = /[\r\n]/;
  50446. var whitespaceRE$1 = /\s+/g;
  50447. var invalidAttributeRE = /[\s"'<>\/=]/;
  50448. var decodeHTMLCached = cached(he.decode);
  50449. var emptySlotScopeToken = "_empty_";
  50450. // configurable state
  50451. var warn$2;
  50452. var delimiters;
  50453. var transforms;
  50454. var preTransforms;
  50455. var postTransforms;
  50456. var platformIsPreTag;
  50457. var platformMustUseProp;
  50458. var platformGetTagNamespace;
  50459. var maybeComponent;
  50460. function createASTElement (
  50461. tag,
  50462. attrs,
  50463. parent
  50464. ) {
  50465. return {
  50466. type: 1,
  50467. tag: tag,
  50468. attrsList: attrs,
  50469. attrsMap: makeAttrsMap(attrs),
  50470. rawAttrsMap: {},
  50471. parent: parent,
  50472. children: []
  50473. }
  50474. }
  50475. /**
  50476. * Convert HTML string to AST.
  50477. */
  50478. function parse (
  50479. template,
  50480. options
  50481. ) {
  50482. warn$2 = options.warn || baseWarn;
  50483. platformIsPreTag = options.isPreTag || no;
  50484. platformMustUseProp = options.mustUseProp || no;
  50485. platformGetTagNamespace = options.getTagNamespace || no;
  50486. var isReservedTag = options.isReservedTag || no;
  50487. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50488. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50489. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50490. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50491. delimiters = options.delimiters;
  50492. var stack = [];
  50493. var preserveWhitespace = options.preserveWhitespace !== false;
  50494. var whitespaceOption = options.whitespace;
  50495. var root;
  50496. var currentParent;
  50497. var inVPre = false;
  50498. var inPre = false;
  50499. var warned = false;
  50500. function warnOnce (msg, range) {
  50501. if (!warned) {
  50502. warned = true;
  50503. warn$2(msg, range);
  50504. }
  50505. }
  50506. function closeElement (element) {
  50507. trimEndingWhitespace(element);
  50508. if (!inVPre && !element.processed) {
  50509. element = processElement(element, options);
  50510. }
  50511. // tree management
  50512. if (!stack.length && element !== root) {
  50513. // allow root elements with v-if, v-else-if and v-else
  50514. if (root.if && (element.elseif || element.else)) {
  50515. {
  50516. checkRootConstraints(element);
  50517. }
  50518. addIfCondition(root, {
  50519. exp: element.elseif,
  50520. block: element
  50521. });
  50522. } else {
  50523. warnOnce(
  50524. "Component template should contain exactly one root element. " +
  50525. "If you are using v-if on multiple elements, " +
  50526. "use v-else-if to chain them instead.",
  50527. { start: element.start }
  50528. );
  50529. }
  50530. }
  50531. if (currentParent && !element.forbidden) {
  50532. if (element.elseif || element.else) {
  50533. processIfConditions(element, currentParent);
  50534. } else {
  50535. if (element.slotScope) {
  50536. // scoped slot
  50537. // keep it in the children list so that v-else(-if) conditions can
  50538. // find it as the prev node.
  50539. var name = element.slotTarget || '"default"'
  50540. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50541. }
  50542. currentParent.children.push(element);
  50543. element.parent = currentParent;
  50544. }
  50545. }
  50546. // final children cleanup
  50547. // filter out scoped slots
  50548. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50549. // remove trailing whitespace node again
  50550. trimEndingWhitespace(element);
  50551. // check pre state
  50552. if (element.pre) {
  50553. inVPre = false;
  50554. }
  50555. if (platformIsPreTag(element.tag)) {
  50556. inPre = false;
  50557. }
  50558. // apply post-transforms
  50559. for (var i = 0; i < postTransforms.length; i++) {
  50560. postTransforms[i](element, options);
  50561. }
  50562. }
  50563. function trimEndingWhitespace (el) {
  50564. // remove trailing whitespace node
  50565. if (!inPre) {
  50566. var lastNode;
  50567. while (
  50568. (lastNode = el.children[el.children.length - 1]) &&
  50569. lastNode.type === 3 &&
  50570. lastNode.text === ' '
  50571. ) {
  50572. el.children.pop();
  50573. }
  50574. }
  50575. }
  50576. function checkRootConstraints (el) {
  50577. if (el.tag === 'slot' || el.tag === 'template') {
  50578. warnOnce(
  50579. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50580. 'contain multiple nodes.',
  50581. { start: el.start }
  50582. );
  50583. }
  50584. if (el.attrsMap.hasOwnProperty('v-for')) {
  50585. warnOnce(
  50586. 'Cannot use v-for on stateful component root element because ' +
  50587. 'it renders multiple elements.',
  50588. el.rawAttrsMap['v-for']
  50589. );
  50590. }
  50591. }
  50592. parseHTML(template, {
  50593. warn: warn$2,
  50594. expectHTML: options.expectHTML,
  50595. isUnaryTag: options.isUnaryTag,
  50596. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50597. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50598. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50599. shouldKeepComment: options.comments,
  50600. outputSourceRange: options.outputSourceRange,
  50601. start: function start (tag, attrs, unary, start$1, end) {
  50602. // check namespace.
  50603. // inherit parent ns if there is one
  50604. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50605. // handle IE svg bug
  50606. /* istanbul ignore if */
  50607. if (isIE && ns === 'svg') {
  50608. attrs = guardIESVGBug(attrs);
  50609. }
  50610. var element = createASTElement(tag, attrs, currentParent);
  50611. if (ns) {
  50612. element.ns = ns;
  50613. }
  50614. {
  50615. if (options.outputSourceRange) {
  50616. element.start = start$1;
  50617. element.end = end;
  50618. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50619. cumulated[attr.name] = attr;
  50620. return cumulated
  50621. }, {});
  50622. }
  50623. attrs.forEach(function (attr) {
  50624. if (invalidAttributeRE.test(attr.name)) {
  50625. warn$2(
  50626. "Invalid dynamic argument expression: attribute names cannot contain " +
  50627. "spaces, quotes, <, >, / or =.",
  50628. {
  50629. start: attr.start + attr.name.indexOf("["),
  50630. end: attr.start + attr.name.length
  50631. }
  50632. );
  50633. }
  50634. });
  50635. }
  50636. if (isForbiddenTag(element) && !isServerRendering()) {
  50637. element.forbidden = true;
  50638. warn$2(
  50639. 'Templates should only be responsible for mapping the state to the ' +
  50640. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50641. "<" + tag + ">" + ', as they will not be parsed.',
  50642. { start: element.start }
  50643. );
  50644. }
  50645. // apply pre-transforms
  50646. for (var i = 0; i < preTransforms.length; i++) {
  50647. element = preTransforms[i](element, options) || element;
  50648. }
  50649. if (!inVPre) {
  50650. processPre(element);
  50651. if (element.pre) {
  50652. inVPre = true;
  50653. }
  50654. }
  50655. if (platformIsPreTag(element.tag)) {
  50656. inPre = true;
  50657. }
  50658. if (inVPre) {
  50659. processRawAttrs(element);
  50660. } else if (!element.processed) {
  50661. // structural directives
  50662. processFor(element);
  50663. processIf(element);
  50664. processOnce(element);
  50665. }
  50666. if (!root) {
  50667. root = element;
  50668. {
  50669. checkRootConstraints(root);
  50670. }
  50671. }
  50672. if (!unary) {
  50673. currentParent = element;
  50674. stack.push(element);
  50675. } else {
  50676. closeElement(element);
  50677. }
  50678. },
  50679. end: function end (tag, start, end$1) {
  50680. var element = stack[stack.length - 1];
  50681. // pop stack
  50682. stack.length -= 1;
  50683. currentParent = stack[stack.length - 1];
  50684. if (options.outputSourceRange) {
  50685. element.end = end$1;
  50686. }
  50687. closeElement(element);
  50688. },
  50689. chars: function chars (text, start, end) {
  50690. if (!currentParent) {
  50691. {
  50692. if (text === template) {
  50693. warnOnce(
  50694. 'Component template requires a root element, rather than just text.',
  50695. { start: start }
  50696. );
  50697. } else if ((text = text.trim())) {
  50698. warnOnce(
  50699. ("text \"" + text + "\" outside root element will be ignored."),
  50700. { start: start }
  50701. );
  50702. }
  50703. }
  50704. return
  50705. }
  50706. // IE textarea placeholder bug
  50707. /* istanbul ignore if */
  50708. if (isIE &&
  50709. currentParent.tag === 'textarea' &&
  50710. currentParent.attrsMap.placeholder === text
  50711. ) {
  50712. return
  50713. }
  50714. var children = currentParent.children;
  50715. if (inPre || text.trim()) {
  50716. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50717. } else if (!children.length) {
  50718. // remove the whitespace-only node right after an opening tag
  50719. text = '';
  50720. } else if (whitespaceOption) {
  50721. if (whitespaceOption === 'condense') {
  50722. // in condense mode, remove the whitespace node if it contains
  50723. // line break, otherwise condense to a single space
  50724. text = lineBreakRE.test(text) ? '' : ' ';
  50725. } else {
  50726. text = ' ';
  50727. }
  50728. } else {
  50729. text = preserveWhitespace ? ' ' : '';
  50730. }
  50731. if (text) {
  50732. if (!inPre && whitespaceOption === 'condense') {
  50733. // condense consecutive whitespaces into single space
  50734. text = text.replace(whitespaceRE$1, ' ');
  50735. }
  50736. var res;
  50737. var child;
  50738. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50739. child = {
  50740. type: 2,
  50741. expression: res.expression,
  50742. tokens: res.tokens,
  50743. text: text
  50744. };
  50745. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50746. child = {
  50747. type: 3,
  50748. text: text
  50749. };
  50750. }
  50751. if (child) {
  50752. if (options.outputSourceRange) {
  50753. child.start = start;
  50754. child.end = end;
  50755. }
  50756. children.push(child);
  50757. }
  50758. }
  50759. },
  50760. comment: function comment (text, start, end) {
  50761. // adding anyting as a sibling to the root node is forbidden
  50762. // comments should still be allowed, but ignored
  50763. if (currentParent) {
  50764. var child = {
  50765. type: 3,
  50766. text: text,
  50767. isComment: true
  50768. };
  50769. if (options.outputSourceRange) {
  50770. child.start = start;
  50771. child.end = end;
  50772. }
  50773. currentParent.children.push(child);
  50774. }
  50775. }
  50776. });
  50777. return root
  50778. }
  50779. function processPre (el) {
  50780. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50781. el.pre = true;
  50782. }
  50783. }
  50784. function processRawAttrs (el) {
  50785. var list = el.attrsList;
  50786. var len = list.length;
  50787. if (len) {
  50788. var attrs = el.attrs = new Array(len);
  50789. for (var i = 0; i < len; i++) {
  50790. attrs[i] = {
  50791. name: list[i].name,
  50792. value: JSON.stringify(list[i].value)
  50793. };
  50794. if (list[i].start != null) {
  50795. attrs[i].start = list[i].start;
  50796. attrs[i].end = list[i].end;
  50797. }
  50798. }
  50799. } else if (!el.pre) {
  50800. // non root node in pre blocks with no attributes
  50801. el.plain = true;
  50802. }
  50803. }
  50804. function processElement (
  50805. element,
  50806. options
  50807. ) {
  50808. processKey(element);
  50809. // determine whether this is a plain element after
  50810. // removing structural attributes
  50811. element.plain = (
  50812. !element.key &&
  50813. !element.scopedSlots &&
  50814. !element.attrsList.length
  50815. );
  50816. processRef(element);
  50817. processSlotContent(element);
  50818. processSlotOutlet(element);
  50819. processComponent(element);
  50820. for (var i = 0; i < transforms.length; i++) {
  50821. element = transforms[i](element, options) || element;
  50822. }
  50823. processAttrs(element);
  50824. return element
  50825. }
  50826. function processKey (el) {
  50827. var exp = getBindingAttr(el, 'key');
  50828. if (exp) {
  50829. {
  50830. if (el.tag === 'template') {
  50831. warn$2(
  50832. "<template> cannot be keyed. Place the key on real elements instead.",
  50833. getRawBindingAttr(el, 'key')
  50834. );
  50835. }
  50836. if (el.for) {
  50837. var iterator = el.iterator2 || el.iterator1;
  50838. var parent = el.parent;
  50839. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50840. warn$2(
  50841. "Do not use v-for index as key on <transition-group> children, " +
  50842. "this is the same as not using keys.",
  50843. getRawBindingAttr(el, 'key'),
  50844. true /* tip */
  50845. );
  50846. }
  50847. }
  50848. }
  50849. el.key = exp;
  50850. }
  50851. }
  50852. function processRef (el) {
  50853. var ref = getBindingAttr(el, 'ref');
  50854. if (ref) {
  50855. el.ref = ref;
  50856. el.refInFor = checkInFor(el);
  50857. }
  50858. }
  50859. function processFor (el) {
  50860. var exp;
  50861. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50862. var res = parseFor(exp);
  50863. if (res) {
  50864. extend(el, res);
  50865. } else {
  50866. warn$2(
  50867. ("Invalid v-for expression: " + exp),
  50868. el.rawAttrsMap['v-for']
  50869. );
  50870. }
  50871. }
  50872. }
  50873. function parseFor (exp) {
  50874. var inMatch = exp.match(forAliasRE);
  50875. if (!inMatch) { return }
  50876. var res = {};
  50877. res.for = inMatch[2].trim();
  50878. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50879. var iteratorMatch = alias.match(forIteratorRE);
  50880. if (iteratorMatch) {
  50881. res.alias = alias.replace(forIteratorRE, '').trim();
  50882. res.iterator1 = iteratorMatch[1].trim();
  50883. if (iteratorMatch[2]) {
  50884. res.iterator2 = iteratorMatch[2].trim();
  50885. }
  50886. } else {
  50887. res.alias = alias;
  50888. }
  50889. return res
  50890. }
  50891. function processIf (el) {
  50892. var exp = getAndRemoveAttr(el, 'v-if');
  50893. if (exp) {
  50894. el.if = exp;
  50895. addIfCondition(el, {
  50896. exp: exp,
  50897. block: el
  50898. });
  50899. } else {
  50900. if (getAndRemoveAttr(el, 'v-else') != null) {
  50901. el.else = true;
  50902. }
  50903. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50904. if (elseif) {
  50905. el.elseif = elseif;
  50906. }
  50907. }
  50908. }
  50909. function processIfConditions (el, parent) {
  50910. var prev = findPrevElement(parent.children);
  50911. if (prev && prev.if) {
  50912. addIfCondition(prev, {
  50913. exp: el.elseif,
  50914. block: el
  50915. });
  50916. } else {
  50917. warn$2(
  50918. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50919. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50920. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50921. );
  50922. }
  50923. }
  50924. function findPrevElement (children) {
  50925. var i = children.length;
  50926. while (i--) {
  50927. if (children[i].type === 1) {
  50928. return children[i]
  50929. } else {
  50930. if (children[i].text !== ' ') {
  50931. warn$2(
  50932. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50933. "will be ignored.",
  50934. children[i]
  50935. );
  50936. }
  50937. children.pop();
  50938. }
  50939. }
  50940. }
  50941. function addIfCondition (el, condition) {
  50942. if (!el.ifConditions) {
  50943. el.ifConditions = [];
  50944. }
  50945. el.ifConditions.push(condition);
  50946. }
  50947. function processOnce (el) {
  50948. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50949. if (once$$1 != null) {
  50950. el.once = true;
  50951. }
  50952. }
  50953. // handle content being passed to a component as slot,
  50954. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50955. function processSlotContent (el) {
  50956. var slotScope;
  50957. if (el.tag === 'template') {
  50958. slotScope = getAndRemoveAttr(el, 'scope');
  50959. /* istanbul ignore if */
  50960. if (slotScope) {
  50961. warn$2(
  50962. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50963. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50964. "can also be used on plain elements in addition to <template> to " +
  50965. "denote scoped slots.",
  50966. el.rawAttrsMap['scope'],
  50967. true
  50968. );
  50969. }
  50970. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50971. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50972. /* istanbul ignore if */
  50973. if (el.attrsMap['v-for']) {
  50974. warn$2(
  50975. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50976. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50977. "scoped slot to make it clearer.",
  50978. el.rawAttrsMap['slot-scope'],
  50979. true
  50980. );
  50981. }
  50982. el.slotScope = slotScope;
  50983. }
  50984. // slot="xxx"
  50985. var slotTarget = getBindingAttr(el, 'slot');
  50986. if (slotTarget) {
  50987. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50988. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50989. // preserve slot as an attribute for native shadow DOM compat
  50990. // only for non-scoped slots.
  50991. if (el.tag !== 'template' && !el.slotScope) {
  50992. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50993. }
  50994. }
  50995. // 2.6 v-slot syntax
  50996. {
  50997. if (el.tag === 'template') {
  50998. // v-slot on <template>
  50999. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  51000. if (slotBinding) {
  51001. {
  51002. if (el.slotTarget || el.slotScope) {
  51003. warn$2(
  51004. "Unexpected mixed usage of different slot syntaxes.",
  51005. el
  51006. );
  51007. }
  51008. if (el.parent && !maybeComponent(el.parent)) {
  51009. warn$2(
  51010. "<template v-slot> can only appear at the root level inside " +
  51011. "the receiving component",
  51012. el
  51013. );
  51014. }
  51015. }
  51016. var ref = getSlotName(slotBinding);
  51017. var name = ref.name;
  51018. var dynamic = ref.dynamic;
  51019. el.slotTarget = name;
  51020. el.slotTargetDynamic = dynamic;
  51021. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  51022. }
  51023. } else {
  51024. // v-slot on component, denotes default slot
  51025. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  51026. if (slotBinding$1) {
  51027. {
  51028. if (!maybeComponent(el)) {
  51029. warn$2(
  51030. "v-slot can only be used on components or <template>.",
  51031. slotBinding$1
  51032. );
  51033. }
  51034. if (el.slotScope || el.slotTarget) {
  51035. warn$2(
  51036. "Unexpected mixed usage of different slot syntaxes.",
  51037. el
  51038. );
  51039. }
  51040. if (el.scopedSlots) {
  51041. warn$2(
  51042. "To avoid scope ambiguity, the default slot should also use " +
  51043. "<template> syntax when there are other named slots.",
  51044. slotBinding$1
  51045. );
  51046. }
  51047. }
  51048. // add the component's children to its default slot
  51049. var slots = el.scopedSlots || (el.scopedSlots = {});
  51050. var ref$1 = getSlotName(slotBinding$1);
  51051. var name$1 = ref$1.name;
  51052. var dynamic$1 = ref$1.dynamic;
  51053. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  51054. slotContainer.slotTarget = name$1;
  51055. slotContainer.slotTargetDynamic = dynamic$1;
  51056. slotContainer.children = el.children.filter(function (c) {
  51057. if (!c.slotScope) {
  51058. c.parent = slotContainer;
  51059. return true
  51060. }
  51061. });
  51062. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  51063. // remove children as they are returned from scopedSlots now
  51064. el.children = [];
  51065. // mark el non-plain so data gets generated
  51066. el.plain = false;
  51067. }
  51068. }
  51069. }
  51070. }
  51071. function getSlotName (binding) {
  51072. var name = binding.name.replace(slotRE, '');
  51073. if (!name) {
  51074. if (binding.name[0] !== '#') {
  51075. name = 'default';
  51076. } else {
  51077. warn$2(
  51078. "v-slot shorthand syntax requires a slot name.",
  51079. binding
  51080. );
  51081. }
  51082. }
  51083. return dynamicArgRE.test(name)
  51084. // dynamic [name]
  51085. ? { name: name.slice(1, -1), dynamic: true }
  51086. // static name
  51087. : { name: ("\"" + name + "\""), dynamic: false }
  51088. }
  51089. // handle <slot/> outlets
  51090. function processSlotOutlet (el) {
  51091. if (el.tag === 'slot') {
  51092. el.slotName = getBindingAttr(el, 'name');
  51093. if (el.key) {
  51094. warn$2(
  51095. "`key` does not work on <slot> because slots are abstract outlets " +
  51096. "and can possibly expand into multiple elements. " +
  51097. "Use the key on a wrapping element instead.",
  51098. getRawBindingAttr(el, 'key')
  51099. );
  51100. }
  51101. }
  51102. }
  51103. function processComponent (el) {
  51104. var binding;
  51105. if ((binding = getBindingAttr(el, 'is'))) {
  51106. el.component = binding;
  51107. }
  51108. if (getAndRemoveAttr(el, 'inline-template') != null) {
  51109. el.inlineTemplate = true;
  51110. }
  51111. }
  51112. function processAttrs (el) {
  51113. var list = el.attrsList;
  51114. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  51115. for (i = 0, l = list.length; i < l; i++) {
  51116. name = rawName = list[i].name;
  51117. value = list[i].value;
  51118. if (dirRE.test(name)) {
  51119. // mark element as dynamic
  51120. el.hasBindings = true;
  51121. // modifiers
  51122. modifiers = parseModifiers(name.replace(dirRE, ''));
  51123. // support .foo shorthand syntax for the .prop modifier
  51124. if (modifiers) {
  51125. name = name.replace(modifierRE, '');
  51126. }
  51127. if (bindRE.test(name)) { // v-bind
  51128. name = name.replace(bindRE, '');
  51129. value = parseFilters(value);
  51130. isDynamic = dynamicArgRE.test(name);
  51131. if (isDynamic) {
  51132. name = name.slice(1, -1);
  51133. }
  51134. if (
  51135. value.trim().length === 0
  51136. ) {
  51137. warn$2(
  51138. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  51139. );
  51140. }
  51141. if (modifiers) {
  51142. if (modifiers.prop && !isDynamic) {
  51143. name = camelize(name);
  51144. if (name === 'innerHtml') { name = 'innerHTML'; }
  51145. }
  51146. if (modifiers.camel && !isDynamic) {
  51147. name = camelize(name);
  51148. }
  51149. if (modifiers.sync) {
  51150. syncGen = genAssignmentCode(value, "$event");
  51151. if (!isDynamic) {
  51152. addHandler(
  51153. el,
  51154. ("update:" + (camelize(name))),
  51155. syncGen,
  51156. null,
  51157. false,
  51158. warn$2,
  51159. list[i]
  51160. );
  51161. if (hyphenate(name) !== camelize(name)) {
  51162. addHandler(
  51163. el,
  51164. ("update:" + (hyphenate(name))),
  51165. syncGen,
  51166. null,
  51167. false,
  51168. warn$2,
  51169. list[i]
  51170. );
  51171. }
  51172. } else {
  51173. // handler w/ dynamic event name
  51174. addHandler(
  51175. el,
  51176. ("\"update:\"+(" + name + ")"),
  51177. syncGen,
  51178. null,
  51179. false,
  51180. warn$2,
  51181. list[i],
  51182. true // dynamic
  51183. );
  51184. }
  51185. }
  51186. }
  51187. if ((modifiers && modifiers.prop) || (
  51188. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51189. )) {
  51190. addProp(el, name, value, list[i], isDynamic);
  51191. } else {
  51192. addAttr(el, name, value, list[i], isDynamic);
  51193. }
  51194. } else if (onRE.test(name)) { // v-on
  51195. name = name.replace(onRE, '');
  51196. isDynamic = dynamicArgRE.test(name);
  51197. if (isDynamic) {
  51198. name = name.slice(1, -1);
  51199. }
  51200. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51201. } else { // normal directives
  51202. name = name.replace(dirRE, '');
  51203. // parse arg
  51204. var argMatch = name.match(argRE);
  51205. var arg = argMatch && argMatch[1];
  51206. isDynamic = false;
  51207. if (arg) {
  51208. name = name.slice(0, -(arg.length + 1));
  51209. if (dynamicArgRE.test(arg)) {
  51210. arg = arg.slice(1, -1);
  51211. isDynamic = true;
  51212. }
  51213. }
  51214. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51215. if (name === 'model') {
  51216. checkForAliasModel(el, value);
  51217. }
  51218. }
  51219. } else {
  51220. // literal attribute
  51221. {
  51222. var res = parseText(value, delimiters);
  51223. if (res) {
  51224. warn$2(
  51225. name + "=\"" + value + "\": " +
  51226. 'Interpolation inside attributes has been removed. ' +
  51227. 'Use v-bind or the colon shorthand instead. For example, ' +
  51228. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51229. list[i]
  51230. );
  51231. }
  51232. }
  51233. addAttr(el, name, JSON.stringify(value), list[i]);
  51234. // #6887 firefox doesn't update muted state if set via attribute
  51235. // even immediately after element creation
  51236. if (!el.component &&
  51237. name === 'muted' &&
  51238. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51239. addProp(el, name, 'true', list[i]);
  51240. }
  51241. }
  51242. }
  51243. }
  51244. function checkInFor (el) {
  51245. var parent = el;
  51246. while (parent) {
  51247. if (parent.for !== undefined) {
  51248. return true
  51249. }
  51250. parent = parent.parent;
  51251. }
  51252. return false
  51253. }
  51254. function parseModifiers (name) {
  51255. var match = name.match(modifierRE);
  51256. if (match) {
  51257. var ret = {};
  51258. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51259. return ret
  51260. }
  51261. }
  51262. function makeAttrsMap (attrs) {
  51263. var map = {};
  51264. for (var i = 0, l = attrs.length; i < l; i++) {
  51265. if (
  51266. map[attrs[i].name] && !isIE && !isEdge
  51267. ) {
  51268. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51269. }
  51270. map[attrs[i].name] = attrs[i].value;
  51271. }
  51272. return map
  51273. }
  51274. // for script (e.g. type="x/template") or style, do not decode content
  51275. function isTextTag (el) {
  51276. return el.tag === 'script' || el.tag === 'style'
  51277. }
  51278. function isForbiddenTag (el) {
  51279. return (
  51280. el.tag === 'style' ||
  51281. (el.tag === 'script' && (
  51282. !el.attrsMap.type ||
  51283. el.attrsMap.type === 'text/javascript'
  51284. ))
  51285. )
  51286. }
  51287. var ieNSBug = /^xmlns:NS\d+/;
  51288. var ieNSPrefix = /^NS\d+:/;
  51289. /* istanbul ignore next */
  51290. function guardIESVGBug (attrs) {
  51291. var res = [];
  51292. for (var i = 0; i < attrs.length; i++) {
  51293. var attr = attrs[i];
  51294. if (!ieNSBug.test(attr.name)) {
  51295. attr.name = attr.name.replace(ieNSPrefix, '');
  51296. res.push(attr);
  51297. }
  51298. }
  51299. return res
  51300. }
  51301. function checkForAliasModel (el, value) {
  51302. var _el = el;
  51303. while (_el) {
  51304. if (_el.for && _el.alias === value) {
  51305. warn$2(
  51306. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51307. "You are binding v-model directly to a v-for iteration alias. " +
  51308. "This will not be able to modify the v-for source array because " +
  51309. "writing to the alias is like modifying a function local variable. " +
  51310. "Consider using an array of objects and use v-model on an object property instead.",
  51311. el.rawAttrsMap['v-model']
  51312. );
  51313. }
  51314. _el = _el.parent;
  51315. }
  51316. }
  51317. /* */
  51318. function preTransformNode (el, options) {
  51319. if (el.tag === 'input') {
  51320. var map = el.attrsMap;
  51321. if (!map['v-model']) {
  51322. return
  51323. }
  51324. var typeBinding;
  51325. if (map[':type'] || map['v-bind:type']) {
  51326. typeBinding = getBindingAttr(el, 'type');
  51327. }
  51328. if (!map.type && !typeBinding && map['v-bind']) {
  51329. typeBinding = "(" + (map['v-bind']) + ").type";
  51330. }
  51331. if (typeBinding) {
  51332. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51333. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51334. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51335. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51336. // 1. checkbox
  51337. var branch0 = cloneASTElement(el);
  51338. // process for on the main node
  51339. processFor(branch0);
  51340. addRawAttr(branch0, 'type', 'checkbox');
  51341. processElement(branch0, options);
  51342. branch0.processed = true; // prevent it from double-processed
  51343. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51344. addIfCondition(branch0, {
  51345. exp: branch0.if,
  51346. block: branch0
  51347. });
  51348. // 2. add radio else-if condition
  51349. var branch1 = cloneASTElement(el);
  51350. getAndRemoveAttr(branch1, 'v-for', true);
  51351. addRawAttr(branch1, 'type', 'radio');
  51352. processElement(branch1, options);
  51353. addIfCondition(branch0, {
  51354. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51355. block: branch1
  51356. });
  51357. // 3. other
  51358. var branch2 = cloneASTElement(el);
  51359. getAndRemoveAttr(branch2, 'v-for', true);
  51360. addRawAttr(branch2, ':type', typeBinding);
  51361. processElement(branch2, options);
  51362. addIfCondition(branch0, {
  51363. exp: ifCondition,
  51364. block: branch2
  51365. });
  51366. if (hasElse) {
  51367. branch0.else = true;
  51368. } else if (elseIfCondition) {
  51369. branch0.elseif = elseIfCondition;
  51370. }
  51371. return branch0
  51372. }
  51373. }
  51374. }
  51375. function cloneASTElement (el) {
  51376. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51377. }
  51378. var model$1 = {
  51379. preTransformNode: preTransformNode
  51380. };
  51381. var modules$1 = [
  51382. klass$1,
  51383. style$1,
  51384. model$1
  51385. ];
  51386. /* */
  51387. function text (el, dir) {
  51388. if (dir.value) {
  51389. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51390. }
  51391. }
  51392. /* */
  51393. function html (el, dir) {
  51394. if (dir.value) {
  51395. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51396. }
  51397. }
  51398. var directives$1 = {
  51399. model: model,
  51400. text: text,
  51401. html: html
  51402. };
  51403. /* */
  51404. var baseOptions = {
  51405. expectHTML: true,
  51406. modules: modules$1,
  51407. directives: directives$1,
  51408. isPreTag: isPreTag,
  51409. isUnaryTag: isUnaryTag,
  51410. mustUseProp: mustUseProp,
  51411. canBeLeftOpenTag: canBeLeftOpenTag,
  51412. isReservedTag: isReservedTag,
  51413. getTagNamespace: getTagNamespace,
  51414. staticKeys: genStaticKeys(modules$1)
  51415. };
  51416. /* */
  51417. var isStaticKey;
  51418. var isPlatformReservedTag;
  51419. var genStaticKeysCached = cached(genStaticKeys$1);
  51420. /**
  51421. * Goal of the optimizer: walk the generated template AST tree
  51422. * and detect sub-trees that are purely static, i.e. parts of
  51423. * the DOM that never needs to change.
  51424. *
  51425. * Once we detect these sub-trees, we can:
  51426. *
  51427. * 1. Hoist them into constants, so that we no longer need to
  51428. * create fresh nodes for them on each re-render;
  51429. * 2. Completely skip them in the patching process.
  51430. */
  51431. function optimize (root, options) {
  51432. if (!root) { return }
  51433. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51434. isPlatformReservedTag = options.isReservedTag || no;
  51435. // first pass: mark all non-static nodes.
  51436. markStatic$1(root);
  51437. // second pass: mark static roots.
  51438. markStaticRoots(root, false);
  51439. }
  51440. function genStaticKeys$1 (keys) {
  51441. return makeMap(
  51442. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51443. (keys ? ',' + keys : '')
  51444. )
  51445. }
  51446. function markStatic$1 (node) {
  51447. node.static = isStatic(node);
  51448. if (node.type === 1) {
  51449. // do not make component slot content static. this avoids
  51450. // 1. components not able to mutate slot nodes
  51451. // 2. static slot content fails for hot-reloading
  51452. if (
  51453. !isPlatformReservedTag(node.tag) &&
  51454. node.tag !== 'slot' &&
  51455. node.attrsMap['inline-template'] == null
  51456. ) {
  51457. return
  51458. }
  51459. for (var i = 0, l = node.children.length; i < l; i++) {
  51460. var child = node.children[i];
  51461. markStatic$1(child);
  51462. if (!child.static) {
  51463. node.static = false;
  51464. }
  51465. }
  51466. if (node.ifConditions) {
  51467. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51468. var block = node.ifConditions[i$1].block;
  51469. markStatic$1(block);
  51470. if (!block.static) {
  51471. node.static = false;
  51472. }
  51473. }
  51474. }
  51475. }
  51476. }
  51477. function markStaticRoots (node, isInFor) {
  51478. if (node.type === 1) {
  51479. if (node.static || node.once) {
  51480. node.staticInFor = isInFor;
  51481. }
  51482. // For a node to qualify as a static root, it should have children that
  51483. // are not just static text. Otherwise the cost of hoisting out will
  51484. // outweigh the benefits and it's better off to just always render it fresh.
  51485. if (node.static && node.children.length && !(
  51486. node.children.length === 1 &&
  51487. node.children[0].type === 3
  51488. )) {
  51489. node.staticRoot = true;
  51490. return
  51491. } else {
  51492. node.staticRoot = false;
  51493. }
  51494. if (node.children) {
  51495. for (var i = 0, l = node.children.length; i < l; i++) {
  51496. markStaticRoots(node.children[i], isInFor || !!node.for);
  51497. }
  51498. }
  51499. if (node.ifConditions) {
  51500. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51501. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51502. }
  51503. }
  51504. }
  51505. }
  51506. function isStatic (node) {
  51507. if (node.type === 2) { // expression
  51508. return false
  51509. }
  51510. if (node.type === 3) { // text
  51511. return true
  51512. }
  51513. return !!(node.pre || (
  51514. !node.hasBindings && // no dynamic bindings
  51515. !node.if && !node.for && // not v-if or v-for or v-else
  51516. !isBuiltInTag(node.tag) && // not a built-in
  51517. isPlatformReservedTag(node.tag) && // not a component
  51518. !isDirectChildOfTemplateFor(node) &&
  51519. Object.keys(node).every(isStaticKey)
  51520. ))
  51521. }
  51522. function isDirectChildOfTemplateFor (node) {
  51523. while (node.parent) {
  51524. node = node.parent;
  51525. if (node.tag !== 'template') {
  51526. return false
  51527. }
  51528. if (node.for) {
  51529. return true
  51530. }
  51531. }
  51532. return false
  51533. }
  51534. /* */
  51535. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51536. var fnInvokeRE = /\([^)]*?\);*$/;
  51537. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51538. // KeyboardEvent.keyCode aliases
  51539. var keyCodes = {
  51540. esc: 27,
  51541. tab: 9,
  51542. enter: 13,
  51543. space: 32,
  51544. up: 38,
  51545. left: 37,
  51546. right: 39,
  51547. down: 40,
  51548. 'delete': [8, 46]
  51549. };
  51550. // KeyboardEvent.key aliases
  51551. var keyNames = {
  51552. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51553. esc: ['Esc', 'Escape'],
  51554. tab: 'Tab',
  51555. enter: 'Enter',
  51556. // #9112: IE11 uses `Spacebar` for Space key name.
  51557. space: [' ', 'Spacebar'],
  51558. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51559. up: ['Up', 'ArrowUp'],
  51560. left: ['Left', 'ArrowLeft'],
  51561. right: ['Right', 'ArrowRight'],
  51562. down: ['Down', 'ArrowDown'],
  51563. // #9112: IE11 uses `Del` for Delete key name.
  51564. 'delete': ['Backspace', 'Delete', 'Del']
  51565. };
  51566. // #4868: modifiers that prevent the execution of the listener
  51567. // need to explicitly return null so that we can determine whether to remove
  51568. // the listener for .once
  51569. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51570. var modifierCode = {
  51571. stop: '$event.stopPropagation();',
  51572. prevent: '$event.preventDefault();',
  51573. self: genGuard("$event.target !== $event.currentTarget"),
  51574. ctrl: genGuard("!$event.ctrlKey"),
  51575. shift: genGuard("!$event.shiftKey"),
  51576. alt: genGuard("!$event.altKey"),
  51577. meta: genGuard("!$event.metaKey"),
  51578. left: genGuard("'button' in $event && $event.button !== 0"),
  51579. middle: genGuard("'button' in $event && $event.button !== 1"),
  51580. right: genGuard("'button' in $event && $event.button !== 2")
  51581. };
  51582. function genHandlers (
  51583. events,
  51584. isNative
  51585. ) {
  51586. var prefix = isNative ? 'nativeOn:' : 'on:';
  51587. var staticHandlers = "";
  51588. var dynamicHandlers = "";
  51589. for (var name in events) {
  51590. var handlerCode = genHandler(events[name]);
  51591. if (events[name] && events[name].dynamic) {
  51592. dynamicHandlers += name + "," + handlerCode + ",";
  51593. } else {
  51594. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51595. }
  51596. }
  51597. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51598. if (dynamicHandlers) {
  51599. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51600. } else {
  51601. return prefix + staticHandlers
  51602. }
  51603. }
  51604. function genHandler (handler) {
  51605. if (!handler) {
  51606. return 'function(){}'
  51607. }
  51608. if (Array.isArray(handler)) {
  51609. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51610. }
  51611. var isMethodPath = simplePathRE.test(handler.value);
  51612. var isFunctionExpression = fnExpRE.test(handler.value);
  51613. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51614. if (!handler.modifiers) {
  51615. if (isMethodPath || isFunctionExpression) {
  51616. return handler.value
  51617. }
  51618. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51619. } else {
  51620. var code = '';
  51621. var genModifierCode = '';
  51622. var keys = [];
  51623. for (var key in handler.modifiers) {
  51624. if (modifierCode[key]) {
  51625. genModifierCode += modifierCode[key];
  51626. // left/right
  51627. if (keyCodes[key]) {
  51628. keys.push(key);
  51629. }
  51630. } else if (key === 'exact') {
  51631. var modifiers = (handler.modifiers);
  51632. genModifierCode += genGuard(
  51633. ['ctrl', 'shift', 'alt', 'meta']
  51634. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51635. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51636. .join('||')
  51637. );
  51638. } else {
  51639. keys.push(key);
  51640. }
  51641. }
  51642. if (keys.length) {
  51643. code += genKeyFilter(keys);
  51644. }
  51645. // Make sure modifiers like prevent and stop get executed after key filtering
  51646. if (genModifierCode) {
  51647. code += genModifierCode;
  51648. }
  51649. var handlerCode = isMethodPath
  51650. ? ("return " + (handler.value) + "($event)")
  51651. : isFunctionExpression
  51652. ? ("return (" + (handler.value) + ")($event)")
  51653. : isFunctionInvocation
  51654. ? ("return " + (handler.value))
  51655. : handler.value;
  51656. return ("function($event){" + code + handlerCode + "}")
  51657. }
  51658. }
  51659. function genKeyFilter (keys) {
  51660. return (
  51661. // make sure the key filters only apply to KeyboardEvents
  51662. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51663. // key events that do not have keyCode property...
  51664. "if(!$event.type.indexOf('key')&&" +
  51665. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51666. )
  51667. }
  51668. function genFilterCode (key) {
  51669. var keyVal = parseInt(key, 10);
  51670. if (keyVal) {
  51671. return ("$event.keyCode!==" + keyVal)
  51672. }
  51673. var keyCode = keyCodes[key];
  51674. var keyName = keyNames[key];
  51675. return (
  51676. "_k($event.keyCode," +
  51677. (JSON.stringify(key)) + "," +
  51678. (JSON.stringify(keyCode)) + "," +
  51679. "$event.key," +
  51680. "" + (JSON.stringify(keyName)) +
  51681. ")"
  51682. )
  51683. }
  51684. /* */
  51685. function on (el, dir) {
  51686. if (dir.modifiers) {
  51687. warn("v-on without argument does not support modifiers.");
  51688. }
  51689. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51690. }
  51691. /* */
  51692. function bind$1 (el, dir) {
  51693. el.wrapData = function (code) {
  51694. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51695. };
  51696. }
  51697. /* */
  51698. var baseDirectives = {
  51699. on: on,
  51700. bind: bind$1,
  51701. cloak: noop
  51702. };
  51703. /* */
  51704. var CodegenState = function CodegenState (options) {
  51705. this.options = options;
  51706. this.warn = options.warn || baseWarn;
  51707. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51708. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51709. this.directives = extend(extend({}, baseDirectives), options.directives);
  51710. var isReservedTag = options.isReservedTag || no;
  51711. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51712. this.onceId = 0;
  51713. this.staticRenderFns = [];
  51714. this.pre = false;
  51715. };
  51716. function generate (
  51717. ast,
  51718. options
  51719. ) {
  51720. var state = new CodegenState(options);
  51721. var code = ast ? genElement(ast, state) : '_c("div")';
  51722. return {
  51723. render: ("with(this){return " + code + "}"),
  51724. staticRenderFns: state.staticRenderFns
  51725. }
  51726. }
  51727. function genElement (el, state) {
  51728. if (el.parent) {
  51729. el.pre = el.pre || el.parent.pre;
  51730. }
  51731. if (el.staticRoot && !el.staticProcessed) {
  51732. return genStatic(el, state)
  51733. } else if (el.once && !el.onceProcessed) {
  51734. return genOnce(el, state)
  51735. } else if (el.for && !el.forProcessed) {
  51736. return genFor(el, state)
  51737. } else if (el.if && !el.ifProcessed) {
  51738. return genIf(el, state)
  51739. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51740. return genChildren(el, state) || 'void 0'
  51741. } else if (el.tag === 'slot') {
  51742. return genSlot(el, state)
  51743. } else {
  51744. // component or element
  51745. var code;
  51746. if (el.component) {
  51747. code = genComponent(el.component, el, state);
  51748. } else {
  51749. var data;
  51750. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51751. data = genData$2(el, state);
  51752. }
  51753. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51754. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51755. }
  51756. // module transforms
  51757. for (var i = 0; i < state.transforms.length; i++) {
  51758. code = state.transforms[i](el, code);
  51759. }
  51760. return code
  51761. }
  51762. }
  51763. // hoist static sub-trees out
  51764. function genStatic (el, state) {
  51765. el.staticProcessed = true;
  51766. // Some elements (templates) need to behave differently inside of a v-pre
  51767. // node. All pre nodes are static roots, so we can use this as a location to
  51768. // wrap a state change and reset it upon exiting the pre node.
  51769. var originalPreState = state.pre;
  51770. if (el.pre) {
  51771. state.pre = el.pre;
  51772. }
  51773. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51774. state.pre = originalPreState;
  51775. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51776. }
  51777. // v-once
  51778. function genOnce (el, state) {
  51779. el.onceProcessed = true;
  51780. if (el.if && !el.ifProcessed) {
  51781. return genIf(el, state)
  51782. } else if (el.staticInFor) {
  51783. var key = '';
  51784. var parent = el.parent;
  51785. while (parent) {
  51786. if (parent.for) {
  51787. key = parent.key;
  51788. break
  51789. }
  51790. parent = parent.parent;
  51791. }
  51792. if (!key) {
  51793. state.warn(
  51794. "v-once can only be used inside v-for that is keyed. ",
  51795. el.rawAttrsMap['v-once']
  51796. );
  51797. return genElement(el, state)
  51798. }
  51799. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51800. } else {
  51801. return genStatic(el, state)
  51802. }
  51803. }
  51804. function genIf (
  51805. el,
  51806. state,
  51807. altGen,
  51808. altEmpty
  51809. ) {
  51810. el.ifProcessed = true; // avoid recursion
  51811. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51812. }
  51813. function genIfConditions (
  51814. conditions,
  51815. state,
  51816. altGen,
  51817. altEmpty
  51818. ) {
  51819. if (!conditions.length) {
  51820. return altEmpty || '_e()'
  51821. }
  51822. var condition = conditions.shift();
  51823. if (condition.exp) {
  51824. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51825. } else {
  51826. return ("" + (genTernaryExp(condition.block)))
  51827. }
  51828. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51829. function genTernaryExp (el) {
  51830. return altGen
  51831. ? altGen(el, state)
  51832. : el.once
  51833. ? genOnce(el, state)
  51834. : genElement(el, state)
  51835. }
  51836. }
  51837. function genFor (
  51838. el,
  51839. state,
  51840. altGen,
  51841. altHelper
  51842. ) {
  51843. var exp = el.for;
  51844. var alias = el.alias;
  51845. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51846. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51847. if (state.maybeComponent(el) &&
  51848. el.tag !== 'slot' &&
  51849. el.tag !== 'template' &&
  51850. !el.key
  51851. ) {
  51852. state.warn(
  51853. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51854. "v-for should have explicit keys. " +
  51855. "See https://vuejs.org/guide/list.html#key for more info.",
  51856. el.rawAttrsMap['v-for'],
  51857. true /* tip */
  51858. );
  51859. }
  51860. el.forProcessed = true; // avoid recursion
  51861. return (altHelper || '_l') + "((" + exp + ")," +
  51862. "function(" + alias + iterator1 + iterator2 + "){" +
  51863. "return " + ((altGen || genElement)(el, state)) +
  51864. '})'
  51865. }
  51866. function genData$2 (el, state) {
  51867. var data = '{';
  51868. // directives first.
  51869. // directives may mutate the el's other properties before they are generated.
  51870. var dirs = genDirectives(el, state);
  51871. if (dirs) { data += dirs + ','; }
  51872. // key
  51873. if (el.key) {
  51874. data += "key:" + (el.key) + ",";
  51875. }
  51876. // ref
  51877. if (el.ref) {
  51878. data += "ref:" + (el.ref) + ",";
  51879. }
  51880. if (el.refInFor) {
  51881. data += "refInFor:true,";
  51882. }
  51883. // pre
  51884. if (el.pre) {
  51885. data += "pre:true,";
  51886. }
  51887. // record original tag name for components using "is" attribute
  51888. if (el.component) {
  51889. data += "tag:\"" + (el.tag) + "\",";
  51890. }
  51891. // module data generation functions
  51892. for (var i = 0; i < state.dataGenFns.length; i++) {
  51893. data += state.dataGenFns[i](el);
  51894. }
  51895. // attributes
  51896. if (el.attrs) {
  51897. data += "attrs:" + (genProps(el.attrs)) + ",";
  51898. }
  51899. // DOM props
  51900. if (el.props) {
  51901. data += "domProps:" + (genProps(el.props)) + ",";
  51902. }
  51903. // event handlers
  51904. if (el.events) {
  51905. data += (genHandlers(el.events, false)) + ",";
  51906. }
  51907. if (el.nativeEvents) {
  51908. data += (genHandlers(el.nativeEvents, true)) + ",";
  51909. }
  51910. // slot target
  51911. // only for non-scoped slots
  51912. if (el.slotTarget && !el.slotScope) {
  51913. data += "slot:" + (el.slotTarget) + ",";
  51914. }
  51915. // scoped slots
  51916. if (el.scopedSlots) {
  51917. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51918. }
  51919. // component v-model
  51920. if (el.model) {
  51921. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51922. }
  51923. // inline-template
  51924. if (el.inlineTemplate) {
  51925. var inlineTemplate = genInlineTemplate(el, state);
  51926. if (inlineTemplate) {
  51927. data += inlineTemplate + ",";
  51928. }
  51929. }
  51930. data = data.replace(/,$/, '') + '}';
  51931. // v-bind dynamic argument wrap
  51932. // v-bind with dynamic arguments must be applied using the same v-bind object
  51933. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51934. if (el.dynamicAttrs) {
  51935. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51936. }
  51937. // v-bind data wrap
  51938. if (el.wrapData) {
  51939. data = el.wrapData(data);
  51940. }
  51941. // v-on data wrap
  51942. if (el.wrapListeners) {
  51943. data = el.wrapListeners(data);
  51944. }
  51945. return data
  51946. }
  51947. function genDirectives (el, state) {
  51948. var dirs = el.directives;
  51949. if (!dirs) { return }
  51950. var res = 'directives:[';
  51951. var hasRuntime = false;
  51952. var i, l, dir, needRuntime;
  51953. for (i = 0, l = dirs.length; i < l; i++) {
  51954. dir = dirs[i];
  51955. needRuntime = true;
  51956. var gen = state.directives[dir.name];
  51957. if (gen) {
  51958. // compile-time directive that manipulates AST.
  51959. // returns true if it also needs a runtime counterpart.
  51960. needRuntime = !!gen(el, dir, state.warn);
  51961. }
  51962. if (needRuntime) {
  51963. hasRuntime = true;
  51964. 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))) : '') + "},";
  51965. }
  51966. }
  51967. if (hasRuntime) {
  51968. return res.slice(0, -1) + ']'
  51969. }
  51970. }
  51971. function genInlineTemplate (el, state) {
  51972. var ast = el.children[0];
  51973. if (el.children.length !== 1 || ast.type !== 1) {
  51974. state.warn(
  51975. 'Inline-template components must have exactly one child element.',
  51976. { start: el.start }
  51977. );
  51978. }
  51979. if (ast && ast.type === 1) {
  51980. var inlineRenderFns = generate(ast, state.options);
  51981. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51982. }
  51983. }
  51984. function genScopedSlots (
  51985. el,
  51986. slots,
  51987. state
  51988. ) {
  51989. // by default scoped slots are considered "stable", this allows child
  51990. // components with only scoped slots to skip forced updates from parent.
  51991. // but in some cases we have to bail-out of this optimization
  51992. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51993. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51994. var slot = slots[key];
  51995. return (
  51996. slot.slotTargetDynamic ||
  51997. slot.if ||
  51998. slot.for ||
  51999. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  52000. )
  52001. });
  52002. // #9534: if a component with scoped slots is inside a conditional branch,
  52003. // it's possible for the same component to be reused but with different
  52004. // compiled slot content. To avoid that, we generate a unique key based on
  52005. // the generated code of all the slot contents.
  52006. var needsKey = !!el.if;
  52007. // OR when it is inside another scoped slot or v-for (the reactivity may be
  52008. // disconnected due to the intermediate scope variable)
  52009. // #9438, #9506
  52010. // TODO: this can be further optimized by properly analyzing in-scope bindings
  52011. // and skip force updating ones that do not actually use scope variables.
  52012. if (!needsForceUpdate) {
  52013. var parent = el.parent;
  52014. while (parent) {
  52015. if (
  52016. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  52017. parent.for
  52018. ) {
  52019. needsForceUpdate = true;
  52020. break
  52021. }
  52022. if (parent.if) {
  52023. needsKey = true;
  52024. }
  52025. parent = parent.parent;
  52026. }
  52027. }
  52028. var generatedSlots = Object.keys(slots)
  52029. .map(function (key) { return genScopedSlot(slots[key], state); })
  52030. .join(',');
  52031. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  52032. }
  52033. function hash(str) {
  52034. var hash = 5381;
  52035. var i = str.length;
  52036. while(i) {
  52037. hash = (hash * 33) ^ str.charCodeAt(--i);
  52038. }
  52039. return hash >>> 0
  52040. }
  52041. function containsSlotChild (el) {
  52042. if (el.type === 1) {
  52043. if (el.tag === 'slot') {
  52044. return true
  52045. }
  52046. return el.children.some(containsSlotChild)
  52047. }
  52048. return false
  52049. }
  52050. function genScopedSlot (
  52051. el,
  52052. state
  52053. ) {
  52054. var isLegacySyntax = el.attrsMap['slot-scope'];
  52055. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  52056. return genIf(el, state, genScopedSlot, "null")
  52057. }
  52058. if (el.for && !el.forProcessed) {
  52059. return genFor(el, state, genScopedSlot)
  52060. }
  52061. var slotScope = el.slotScope === emptySlotScopeToken
  52062. ? ""
  52063. : String(el.slotScope);
  52064. var fn = "function(" + slotScope + "){" +
  52065. "return " + (el.tag === 'template'
  52066. ? el.if && isLegacySyntax
  52067. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  52068. : genChildren(el, state) || 'undefined'
  52069. : genElement(el, state)) + "}";
  52070. // reverse proxy v-slot without scope on this.$slots
  52071. var reverseProxy = slotScope ? "" : ",proxy:true";
  52072. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  52073. }
  52074. function genChildren (
  52075. el,
  52076. state,
  52077. checkSkip,
  52078. altGenElement,
  52079. altGenNode
  52080. ) {
  52081. var children = el.children;
  52082. if (children.length) {
  52083. var el$1 = children[0];
  52084. // optimize single v-for
  52085. if (children.length === 1 &&
  52086. el$1.for &&
  52087. el$1.tag !== 'template' &&
  52088. el$1.tag !== 'slot'
  52089. ) {
  52090. var normalizationType = checkSkip
  52091. ? state.maybeComponent(el$1) ? ",1" : ",0"
  52092. : "";
  52093. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  52094. }
  52095. var normalizationType$1 = checkSkip
  52096. ? getNormalizationType(children, state.maybeComponent)
  52097. : 0;
  52098. var gen = altGenNode || genNode;
  52099. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  52100. }
  52101. }
  52102. // determine the normalization needed for the children array.
  52103. // 0: no normalization needed
  52104. // 1: simple normalization needed (possible 1-level deep nested array)
  52105. // 2: full normalization needed
  52106. function getNormalizationType (
  52107. children,
  52108. maybeComponent
  52109. ) {
  52110. var res = 0;
  52111. for (var i = 0; i < children.length; i++) {
  52112. var el = children[i];
  52113. if (el.type !== 1) {
  52114. continue
  52115. }
  52116. if (needsNormalization(el) ||
  52117. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  52118. res = 2;
  52119. break
  52120. }
  52121. if (maybeComponent(el) ||
  52122. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  52123. res = 1;
  52124. }
  52125. }
  52126. return res
  52127. }
  52128. function needsNormalization (el) {
  52129. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  52130. }
  52131. function genNode (node, state) {
  52132. if (node.type === 1) {
  52133. return genElement(node, state)
  52134. } else if (node.type === 3 && node.isComment) {
  52135. return genComment(node)
  52136. } else {
  52137. return genText(node)
  52138. }
  52139. }
  52140. function genText (text) {
  52141. return ("_v(" + (text.type === 2
  52142. ? text.expression // no need for () because already wrapped in _s()
  52143. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52144. }
  52145. function genComment (comment) {
  52146. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52147. }
  52148. function genSlot (el, state) {
  52149. var slotName = el.slotName || '"default"';
  52150. var children = genChildren(el, state);
  52151. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52152. var attrs = el.attrs || el.dynamicAttrs
  52153. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52154. // slot props are camelized
  52155. name: camelize(attr.name),
  52156. value: attr.value,
  52157. dynamic: attr.dynamic
  52158. }); }))
  52159. : null;
  52160. var bind$$1 = el.attrsMap['v-bind'];
  52161. if ((attrs || bind$$1) && !children) {
  52162. res += ",null";
  52163. }
  52164. if (attrs) {
  52165. res += "," + attrs;
  52166. }
  52167. if (bind$$1) {
  52168. res += (attrs ? '' : ',null') + "," + bind$$1;
  52169. }
  52170. return res + ')'
  52171. }
  52172. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52173. function genComponent (
  52174. componentName,
  52175. el,
  52176. state
  52177. ) {
  52178. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52179. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52180. }
  52181. function genProps (props) {
  52182. var staticProps = "";
  52183. var dynamicProps = "";
  52184. for (var i = 0; i < props.length; i++) {
  52185. var prop = props[i];
  52186. var value = transformSpecialNewlines(prop.value);
  52187. if (prop.dynamic) {
  52188. dynamicProps += (prop.name) + "," + value + ",";
  52189. } else {
  52190. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52191. }
  52192. }
  52193. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52194. if (dynamicProps) {
  52195. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52196. } else {
  52197. return staticProps
  52198. }
  52199. }
  52200. // #3895, #4268
  52201. function transformSpecialNewlines (text) {
  52202. return text
  52203. .replace(/\u2028/g, '\\u2028')
  52204. .replace(/\u2029/g, '\\u2029')
  52205. }
  52206. /* */
  52207. // these keywords should not appear inside expressions, but operators like
  52208. // typeof, instanceof and in are allowed
  52209. var prohibitedKeywordRE = new RegExp('\\b' + (
  52210. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52211. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52212. 'extends,finally,continue,debugger,function,arguments'
  52213. ).split(',').join('\\b|\\b') + '\\b');
  52214. // these unary operators should not be used as property/method names
  52215. var unaryOperatorsRE = new RegExp('\\b' + (
  52216. 'delete,typeof,void'
  52217. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52218. // strip strings in expressions
  52219. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52220. // detect problematic expressions in a template
  52221. function detectErrors (ast, warn) {
  52222. if (ast) {
  52223. checkNode(ast, warn);
  52224. }
  52225. }
  52226. function checkNode (node, warn) {
  52227. if (node.type === 1) {
  52228. for (var name in node.attrsMap) {
  52229. if (dirRE.test(name)) {
  52230. var value = node.attrsMap[name];
  52231. if (value) {
  52232. var range = node.rawAttrsMap[name];
  52233. if (name === 'v-for') {
  52234. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52235. } else if (name === 'v-slot' || name[0] === '#') {
  52236. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52237. } else if (onRE.test(name)) {
  52238. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52239. } else {
  52240. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52241. }
  52242. }
  52243. }
  52244. }
  52245. if (node.children) {
  52246. for (var i = 0; i < node.children.length; i++) {
  52247. checkNode(node.children[i], warn);
  52248. }
  52249. }
  52250. } else if (node.type === 2) {
  52251. checkExpression(node.expression, node.text, warn, node);
  52252. }
  52253. }
  52254. function checkEvent (exp, text, warn, range) {
  52255. var stripped = exp.replace(stripStringRE, '');
  52256. var keywordMatch = stripped.match(unaryOperatorsRE);
  52257. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52258. warn(
  52259. "avoid using JavaScript unary operator as property name: " +
  52260. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52261. range
  52262. );
  52263. }
  52264. checkExpression(exp, text, warn, range);
  52265. }
  52266. function checkFor (node, text, warn, range) {
  52267. checkExpression(node.for || '', text, warn, range);
  52268. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52269. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52270. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52271. }
  52272. function checkIdentifier (
  52273. ident,
  52274. type,
  52275. text,
  52276. warn,
  52277. range
  52278. ) {
  52279. if (typeof ident === 'string') {
  52280. try {
  52281. new Function(("var " + ident + "=_"));
  52282. } catch (e) {
  52283. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52284. }
  52285. }
  52286. }
  52287. function checkExpression (exp, text, warn, range) {
  52288. try {
  52289. new Function(("return " + exp));
  52290. } catch (e) {
  52291. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52292. if (keywordMatch) {
  52293. warn(
  52294. "avoid using JavaScript keyword as property name: " +
  52295. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52296. range
  52297. );
  52298. } else {
  52299. warn(
  52300. "invalid expression: " + (e.message) + " in\n\n" +
  52301. " " + exp + "\n\n" +
  52302. " Raw expression: " + (text.trim()) + "\n",
  52303. range
  52304. );
  52305. }
  52306. }
  52307. }
  52308. function checkFunctionParameterExpression (exp, text, warn, range) {
  52309. try {
  52310. new Function(exp, '');
  52311. } catch (e) {
  52312. warn(
  52313. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52314. " " + exp + "\n\n" +
  52315. " Raw expression: " + (text.trim()) + "\n",
  52316. range
  52317. );
  52318. }
  52319. }
  52320. /* */
  52321. var range = 2;
  52322. function generateCodeFrame (
  52323. source,
  52324. start,
  52325. end
  52326. ) {
  52327. if ( start === void 0 ) start = 0;
  52328. if ( end === void 0 ) end = source.length;
  52329. var lines = source.split(/\r?\n/);
  52330. var count = 0;
  52331. var res = [];
  52332. for (var i = 0; i < lines.length; i++) {
  52333. count += lines[i].length + 1;
  52334. if (count >= start) {
  52335. for (var j = i - range; j <= i + range || end > count; j++) {
  52336. if (j < 0 || j >= lines.length) { continue }
  52337. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52338. var lineLength = lines[j].length;
  52339. if (j === i) {
  52340. // push underline
  52341. var pad = start - (count - lineLength) + 1;
  52342. var length = end > count ? lineLength - pad : end - start;
  52343. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52344. } else if (j > i) {
  52345. if (end > count) {
  52346. var length$1 = Math.min(end - count, lineLength);
  52347. res.push(" | " + repeat$1("^", length$1));
  52348. }
  52349. count += lineLength + 1;
  52350. }
  52351. }
  52352. break
  52353. }
  52354. }
  52355. return res.join('\n')
  52356. }
  52357. function repeat$1 (str, n) {
  52358. var result = '';
  52359. if (n > 0) {
  52360. while (true) { // eslint-disable-line
  52361. if (n & 1) { result += str; }
  52362. n >>>= 1;
  52363. if (n <= 0) { break }
  52364. str += str;
  52365. }
  52366. }
  52367. return result
  52368. }
  52369. /* */
  52370. function createFunction (code, errors) {
  52371. try {
  52372. return new Function(code)
  52373. } catch (err) {
  52374. errors.push({ err: err, code: code });
  52375. return noop
  52376. }
  52377. }
  52378. function createCompileToFunctionFn (compile) {
  52379. var cache = Object.create(null);
  52380. return function compileToFunctions (
  52381. template,
  52382. options,
  52383. vm
  52384. ) {
  52385. options = extend({}, options);
  52386. var warn$$1 = options.warn || warn;
  52387. delete options.warn;
  52388. /* istanbul ignore if */
  52389. {
  52390. // detect possible CSP restriction
  52391. try {
  52392. new Function('return 1');
  52393. } catch (e) {
  52394. if (e.toString().match(/unsafe-eval|CSP/)) {
  52395. warn$$1(
  52396. 'It seems you are using the standalone build of Vue.js in an ' +
  52397. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52398. 'The template compiler cannot work in this environment. Consider ' +
  52399. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52400. 'templates into render functions.'
  52401. );
  52402. }
  52403. }
  52404. }
  52405. // check cache
  52406. var key = options.delimiters
  52407. ? String(options.delimiters) + template
  52408. : template;
  52409. if (cache[key]) {
  52410. return cache[key]
  52411. }
  52412. // compile
  52413. var compiled = compile(template, options);
  52414. // check compilation errors/tips
  52415. {
  52416. if (compiled.errors && compiled.errors.length) {
  52417. if (options.outputSourceRange) {
  52418. compiled.errors.forEach(function (e) {
  52419. warn$$1(
  52420. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52421. generateCodeFrame(template, e.start, e.end),
  52422. vm
  52423. );
  52424. });
  52425. } else {
  52426. warn$$1(
  52427. "Error compiling template:\n\n" + template + "\n\n" +
  52428. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52429. vm
  52430. );
  52431. }
  52432. }
  52433. if (compiled.tips && compiled.tips.length) {
  52434. if (options.outputSourceRange) {
  52435. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52436. } else {
  52437. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52438. }
  52439. }
  52440. }
  52441. // turn code into functions
  52442. var res = {};
  52443. var fnGenErrors = [];
  52444. res.render = createFunction(compiled.render, fnGenErrors);
  52445. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52446. return createFunction(code, fnGenErrors)
  52447. });
  52448. // check function generation errors.
  52449. // this should only happen if there is a bug in the compiler itself.
  52450. // mostly for codegen development use
  52451. /* istanbul ignore if */
  52452. {
  52453. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52454. warn$$1(
  52455. "Failed to generate render function:\n\n" +
  52456. fnGenErrors.map(function (ref) {
  52457. var err = ref.err;
  52458. var code = ref.code;
  52459. return ((err.toString()) + " in\n\n" + code + "\n");
  52460. }).join('\n'),
  52461. vm
  52462. );
  52463. }
  52464. }
  52465. return (cache[key] = res)
  52466. }
  52467. }
  52468. /* */
  52469. function createCompilerCreator (baseCompile) {
  52470. return function createCompiler (baseOptions) {
  52471. function compile (
  52472. template,
  52473. options
  52474. ) {
  52475. var finalOptions = Object.create(baseOptions);
  52476. var errors = [];
  52477. var tips = [];
  52478. var warn = function (msg, range, tip) {
  52479. (tip ? tips : errors).push(msg);
  52480. };
  52481. if (options) {
  52482. if (options.outputSourceRange) {
  52483. // $flow-disable-line
  52484. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52485. warn = function (msg, range, tip) {
  52486. var data = { msg: msg };
  52487. if (range) {
  52488. if (range.start != null) {
  52489. data.start = range.start + leadingSpaceLength;
  52490. }
  52491. if (range.end != null) {
  52492. data.end = range.end + leadingSpaceLength;
  52493. }
  52494. }
  52495. (tip ? tips : errors).push(data);
  52496. };
  52497. }
  52498. // merge custom modules
  52499. if (options.modules) {
  52500. finalOptions.modules =
  52501. (baseOptions.modules || []).concat(options.modules);
  52502. }
  52503. // merge custom directives
  52504. if (options.directives) {
  52505. finalOptions.directives = extend(
  52506. Object.create(baseOptions.directives || null),
  52507. options.directives
  52508. );
  52509. }
  52510. // copy other options
  52511. for (var key in options) {
  52512. if (key !== 'modules' && key !== 'directives') {
  52513. finalOptions[key] = options[key];
  52514. }
  52515. }
  52516. }
  52517. finalOptions.warn = warn;
  52518. var compiled = baseCompile(template.trim(), finalOptions);
  52519. {
  52520. detectErrors(compiled.ast, warn);
  52521. }
  52522. compiled.errors = errors;
  52523. compiled.tips = tips;
  52524. return compiled
  52525. }
  52526. return {
  52527. compile: compile,
  52528. compileToFunctions: createCompileToFunctionFn(compile)
  52529. }
  52530. }
  52531. }
  52532. /* */
  52533. // `createCompilerCreator` allows creating compilers that use alternative
  52534. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52535. // Here we just export a default compiler using the default parts.
  52536. var createCompiler = createCompilerCreator(function baseCompile (
  52537. template,
  52538. options
  52539. ) {
  52540. var ast = parse(template.trim(), options);
  52541. if (options.optimize !== false) {
  52542. optimize(ast, options);
  52543. }
  52544. var code = generate(ast, options);
  52545. return {
  52546. ast: ast,
  52547. render: code.render,
  52548. staticRenderFns: code.staticRenderFns
  52549. }
  52550. });
  52551. /* */
  52552. var ref$1 = createCompiler(baseOptions);
  52553. var compile = ref$1.compile;
  52554. var compileToFunctions = ref$1.compileToFunctions;
  52555. /* */
  52556. // check whether current browser encodes a char inside attribute values
  52557. var div;
  52558. function getShouldDecode (href) {
  52559. div = div || document.createElement('div');
  52560. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52561. return div.innerHTML.indexOf('&#10;') > 0
  52562. }
  52563. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52564. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52565. // #6828: chrome encodes content in a[href]
  52566. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52567. /* */
  52568. var idToTemplate = cached(function (id) {
  52569. var el = query(id);
  52570. return el && el.innerHTML
  52571. });
  52572. var mount = Vue.prototype.$mount;
  52573. Vue.prototype.$mount = function (
  52574. el,
  52575. hydrating
  52576. ) {
  52577. el = el && query(el);
  52578. /* istanbul ignore if */
  52579. if (el === document.body || el === document.documentElement) {
  52580. warn(
  52581. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52582. );
  52583. return this
  52584. }
  52585. var options = this.$options;
  52586. // resolve template/el and convert to render function
  52587. if (!options.render) {
  52588. var template = options.template;
  52589. if (template) {
  52590. if (typeof template === 'string') {
  52591. if (template.charAt(0) === '#') {
  52592. template = idToTemplate(template);
  52593. /* istanbul ignore if */
  52594. if (!template) {
  52595. warn(
  52596. ("Template element not found or is empty: " + (options.template)),
  52597. this
  52598. );
  52599. }
  52600. }
  52601. } else if (template.nodeType) {
  52602. template = template.innerHTML;
  52603. } else {
  52604. {
  52605. warn('invalid template option:' + template, this);
  52606. }
  52607. return this
  52608. }
  52609. } else if (el) {
  52610. template = getOuterHTML(el);
  52611. }
  52612. if (template) {
  52613. /* istanbul ignore if */
  52614. if (config.performance && mark) {
  52615. mark('compile');
  52616. }
  52617. var ref = compileToFunctions(template, {
  52618. outputSourceRange: "development" !== 'production',
  52619. shouldDecodeNewlines: shouldDecodeNewlines,
  52620. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52621. delimiters: options.delimiters,
  52622. comments: options.comments
  52623. }, this);
  52624. var render = ref.render;
  52625. var staticRenderFns = ref.staticRenderFns;
  52626. options.render = render;
  52627. options.staticRenderFns = staticRenderFns;
  52628. /* istanbul ignore if */
  52629. if (config.performance && mark) {
  52630. mark('compile end');
  52631. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52632. }
  52633. }
  52634. }
  52635. return mount.call(this, el, hydrating)
  52636. };
  52637. /**
  52638. * Get outerHTML of elements, taking care
  52639. * of SVG elements in IE as well.
  52640. */
  52641. function getOuterHTML (el) {
  52642. if (el.outerHTML) {
  52643. return el.outerHTML
  52644. } else {
  52645. var container = document.createElement('div');
  52646. container.appendChild(el.cloneNode(true));
  52647. return container.innerHTML
  52648. }
  52649. }
  52650. Vue.compile = compileToFunctions;
  52651. module.exports = Vue;
  52652. /* 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))
  52653. /***/ }),
  52654. /***/ "./node_modules/vue/dist/vue.common.js":
  52655. /*!*********************************************!*\
  52656. !*** ./node_modules/vue/dist/vue.common.js ***!
  52657. \*********************************************/
  52658. /*! no static exports found */
  52659. /***/ (function(module, exports, __webpack_require__) {
  52660. if (false) {} else {
  52661. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52662. }
  52663. /***/ }),
  52664. /***/ "./node_modules/webpack/buildin/global.js":
  52665. /*!***********************************!*\
  52666. !*** (webpack)/buildin/global.js ***!
  52667. \***********************************/
  52668. /*! no static exports found */
  52669. /***/ (function(module, exports) {
  52670. var g;
  52671. // This works in non-strict mode
  52672. g = (function() {
  52673. return this;
  52674. })();
  52675. try {
  52676. // This works if eval is allowed (see CSP)
  52677. g = g || new Function("return this")();
  52678. } catch (e) {
  52679. // This works if the window reference is available
  52680. if (typeof window === "object") g = window;
  52681. }
  52682. // g can still be undefined, but nothing to do about it...
  52683. // We return undefined, instead of nothing here, so it's
  52684. // easier to handle this case. if(!global) { ...}
  52685. module.exports = g;
  52686. /***/ }),
  52687. /***/ "./node_modules/webpack/buildin/module.js":
  52688. /*!***********************************!*\
  52689. !*** (webpack)/buildin/module.js ***!
  52690. \***********************************/
  52691. /*! no static exports found */
  52692. /***/ (function(module, exports) {
  52693. module.exports = function(module) {
  52694. if (!module.webpackPolyfill) {
  52695. module.deprecate = function() {};
  52696. module.paths = [];
  52697. // module.parent = undefined by default
  52698. if (!module.children) module.children = [];
  52699. Object.defineProperty(module, "loaded", {
  52700. enumerable: true,
  52701. get: function() {
  52702. return module.l;
  52703. }
  52704. });
  52705. Object.defineProperty(module, "id", {
  52706. enumerable: true,
  52707. get: function() {
  52708. return module.i;
  52709. }
  52710. });
  52711. module.webpackPolyfill = 1;
  52712. }
  52713. return module;
  52714. };
  52715. /***/ }),
  52716. /***/ "./resources/js/app.js":
  52717. /*!*****************************!*\
  52718. !*** ./resources/js/app.js ***!
  52719. \*****************************/
  52720. /*! no static exports found */
  52721. /***/ (function(module, exports, __webpack_require__) {
  52722. /**
  52723. * First we will load all of this project's JavaScript dependencies which
  52724. * includes Vue and other libraries. It is a great starting point when
  52725. * building robust, powerful web applications using Vue and Laravel.
  52726. */
  52727. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52728. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52729. /**
  52730. * The following block of code may be used to automatically register your
  52731. * Vue components. It will recursively scan this directory for the Vue
  52732. * components and automatically register them with their "basename".
  52733. *
  52734. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52735. */
  52736. // const files = require.context('./', true, /\.vue$/i)
  52737. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52738. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52739. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  52740. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  52741. /**
  52742. * Next, we will create a fresh Vue application instance and attach it to
  52743. * the page. Then, you may begin adding components to this application
  52744. * or customize the JavaScript scaffolding to fit your unique needs.
  52745. */
  52746. var app = new Vue({
  52747. el: '#app'
  52748. });
  52749. $(function () {
  52750. $('[data-toggle="tooltip"]').tooltip();
  52751. });
  52752. /***/ }),
  52753. /***/ "./resources/js/bootstrap.js":
  52754. /*!***********************************!*\
  52755. !*** ./resources/js/bootstrap.js ***!
  52756. \***********************************/
  52757. /*! no exports provided */
  52758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52759. "use strict";
  52760. __webpack_require__.r(__webpack_exports__);
  52761. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52762. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52763. /**
  52764. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52765. * for JavaScript based Bootstrap features such as modals and tabs. This
  52766. * code may be modified to fit the specific needs of your application.
  52767. */
  52768. try {
  52769. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52770. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52771. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52772. } catch (e) {}
  52773. /**
  52774. * We'll load the axios HTTP library which allows us to easily issue requests
  52775. * to our Laravel back-end. This library automatically handles sending the
  52776. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52777. */
  52778. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52779. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52780. /**
  52781. * Echo exposes an expressive API for subscribing to channels and listening
  52782. * for events that are broadcast by Laravel. Echo and event broadcasting
  52783. * allows your team to easily build robust real-time web applications.
  52784. */
  52785. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52786. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52787. broadcaster: 'pusher',
  52788. key: "upccrt",
  52789. wsHost: window.location.hostname,
  52790. wsPort: 6001,
  52791. disableStats: true
  52792. });
  52793. /***/ }),
  52794. /***/ "./resources/js/components/ExampleComponent.vue":
  52795. /*!******************************************************!*\
  52796. !*** ./resources/js/components/ExampleComponent.vue ***!
  52797. \******************************************************/
  52798. /*! exports provided: default */
  52799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52800. "use strict";
  52801. __webpack_require__.r(__webpack_exports__);
  52802. /* 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&");
  52803. /* 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&");
  52804. /* 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");
  52805. /* normalize component */
  52806. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52807. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52808. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52809. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52810. false,
  52811. null,
  52812. null,
  52813. null
  52814. )
  52815. /* hot reload */
  52816. if (false) { var api; }
  52817. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52818. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52819. /***/ }),
  52820. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52821. /*!*******************************************************************************!*\
  52822. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52823. \*******************************************************************************/
  52824. /*! exports provided: default */
  52825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52826. "use strict";
  52827. __webpack_require__.r(__webpack_exports__);
  52828. /* 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&");
  52829. /* 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"]);
  52830. /***/ }),
  52831. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52832. /*!*************************************************************************************!*\
  52833. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52834. \*************************************************************************************/
  52835. /*! exports provided: render, staticRenderFns */
  52836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52837. "use strict";
  52838. __webpack_require__.r(__webpack_exports__);
  52839. /* 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&");
  52840. /* 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"]; });
  52841. /* 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"]; });
  52842. /***/ }),
  52843. /***/ "./resources/js/components/assetinfo.vue":
  52844. /*!***********************************************!*\
  52845. !*** ./resources/js/components/assetinfo.vue ***!
  52846. \***********************************************/
  52847. /*! exports provided: default */
  52848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52849. "use strict";
  52850. __webpack_require__.r(__webpack_exports__);
  52851. /* harmony import */ var _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52852. /* harmony import */ var _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52853. /* 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");
  52854. /* normalize component */
  52855. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52856. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52857. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  52858. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52859. false,
  52860. null,
  52861. null,
  52862. null
  52863. )
  52864. /* hot reload */
  52865. if (false) { var api; }
  52866. component.options.__file = "resources/js/components/assetinfo.vue"
  52867. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52868. /***/ }),
  52869. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  52870. /*!************************************************************************!*\
  52871. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  52872. \************************************************************************/
  52873. /*! exports provided: default */
  52874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52875. "use strict";
  52876. __webpack_require__.r(__webpack_exports__);
  52877. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_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!./assetinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52878. /* 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_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52879. /***/ }),
  52880. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  52881. /*!******************************************************************************!*\
  52882. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  52883. \******************************************************************************/
  52884. /*! exports provided: render, staticRenderFns */
  52885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52886. "use strict";
  52887. __webpack_require__.r(__webpack_exports__);
  52888. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___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!./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52889. /* 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_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52890. /* 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_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52891. /***/ }),
  52892. /***/ "./resources/js/components/woinfo.vue":
  52893. /*!********************************************!*\
  52894. !*** ./resources/js/components/woinfo.vue ***!
  52895. \********************************************/
  52896. /*! exports provided: default */
  52897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52898. "use strict";
  52899. __webpack_require__.r(__webpack_exports__);
  52900. /* harmony import */ var _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./woinfo.vue?vue&type=template&id=33ce32de& */ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  52901. /* harmony import */ var _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./woinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  52902. /* 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");
  52903. /* normalize component */
  52904. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52905. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52906. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  52907. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52908. false,
  52909. null,
  52910. null,
  52911. null
  52912. )
  52913. /* hot reload */
  52914. if (false) { var api; }
  52915. component.options.__file = "resources/js/components/woinfo.vue"
  52916. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52917. /***/ }),
  52918. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  52919. /*!*********************************************************************!*\
  52920. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  52921. \*********************************************************************/
  52922. /*! exports provided: default */
  52923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52924. "use strict";
  52925. __webpack_require__.r(__webpack_exports__);
  52926. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_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!./woinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  52927. /* 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_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52928. /***/ }),
  52929. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  52930. /*!***************************************************************************!*\
  52931. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  52932. \***************************************************************************/
  52933. /*! exports provided: render, staticRenderFns */
  52934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52935. "use strict";
  52936. __webpack_require__.r(__webpack_exports__);
  52937. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___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!./woinfo.vue?vue&type=template&id=33ce32de& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  52938. /* 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_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52939. /* 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_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52940. /***/ }),
  52941. /***/ "./resources/js/mixins/dateMixin.js":
  52942. /*!******************************************!*\
  52943. !*** ./resources/js/mixins/dateMixin.js ***!
  52944. \******************************************/
  52945. /*! exports provided: default */
  52946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52947. "use strict";
  52948. __webpack_require__.r(__webpack_exports__);
  52949. /* harmony default export */ __webpack_exports__["default"] = ({
  52950. methods: {
  52951. treatAsUTC: function treatAsUTC(date) {
  52952. var result = new Date(date);
  52953. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  52954. return result;
  52955. },
  52956. daysSinceToday: function daysSinceToday(date) {
  52957. var currentDate = new Date();
  52958. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  52959. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  52960. },
  52961. getHRDate: function getHRDate(dateString) {
  52962. var date = new Date(dateString);
  52963. var year = date.getFullYear();
  52964. var month = date.toLocaleString('default', {
  52965. month: 'short'
  52966. });
  52967. var day = date.getDate();
  52968. var hour = date.getHours() % 12;
  52969. var minute = date.getMinutes();
  52970. var period = date.getHours() < 24 ? 'AM' : 'PM';
  52971. return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
  52972. },
  52973. isZero: function isZero(dateString) {
  52974. return dateString === '0000-00-00 00:00:00';
  52975. }
  52976. }
  52977. });
  52978. /***/ }),
  52979. /***/ "./resources/sass/app.scss":
  52980. /*!*********************************!*\
  52981. !*** ./resources/sass/app.scss ***!
  52982. \*********************************/
  52983. /*! no static exports found */
  52984. /***/ (function(module, exports) {
  52985. // removed by extract-text-webpack-plugin
  52986. /***/ }),
  52987. /***/ 0:
  52988. /*!*************************************************************!*\
  52989. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52990. \*************************************************************/
  52991. /*! no static exports found */
  52992. /***/ (function(module, exports, __webpack_require__) {
  52993. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52994. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52995. /***/ })
  52996. /******/ });