app.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114
  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/views/App.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/views/App.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. //
  1598. //
  1599. //
  1600. //
  1601. //
  1602. //
  1603. //
  1604. //
  1605. //
  1606. //
  1607. //
  1608. //
  1609. //
  1610. //
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. //
  1618. //
  1619. //
  1620. //
  1621. //
  1622. //
  1623. //
  1624. //
  1625. //
  1626. //
  1627. //
  1628. //
  1629. //
  1630. //
  1631. //
  1632. //
  1633. //
  1634. //
  1635. //
  1636. //
  1637. //
  1638. //
  1639. //
  1640. //
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. /* harmony default export */ __webpack_exports__["default"] = ({
  1653. data: function data() {
  1654. return {
  1655. isLoggedIn: null,
  1656. username: null
  1657. };
  1658. },
  1659. mounted: function mounted() {
  1660. this.isLoggedIn = localStorage.getItem('jwt');
  1661. this.username = localStorage.getItem('user');
  1662. }
  1663. });
  1664. /***/ }),
  1665. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Login.vue?vue&type=script&lang=js&":
  1666. /*!***********************************************************************************************************************************************************!*\
  1667. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Login.vue?vue&type=script&lang=js& ***!
  1668. \***********************************************************************************************************************************************************/
  1669. /*! exports provided: default */
  1670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1671. "use strict";
  1672. __webpack_require__.r(__webpack_exports__);
  1673. //
  1674. //
  1675. //
  1676. //
  1677. //
  1678. //
  1679. //
  1680. //
  1681. //
  1682. //
  1683. //
  1684. //
  1685. //
  1686. //
  1687. //
  1688. //
  1689. //
  1690. //
  1691. //
  1692. //
  1693. //
  1694. //
  1695. //
  1696. //
  1697. //
  1698. //
  1699. //
  1700. //
  1701. //
  1702. //
  1703. //
  1704. //
  1705. //
  1706. //
  1707. //
  1708. //
  1709. //
  1710. //
  1711. //
  1712. /* harmony default export */ __webpack_exports__["default"] = ({
  1713. data: function data() {
  1714. return {
  1715. username: "",
  1716. password: ""
  1717. };
  1718. },
  1719. methods: {
  1720. handleSubmit: function handleSubmit(e) {
  1721. var _this = this;
  1722. e.preventDefault();
  1723. if (this.password.length > 0) {
  1724. axios.post('api/login', {
  1725. username: this.username,
  1726. password: this.password
  1727. }).then(function (response) {
  1728. localStorage.setItem('user', response.data.success.username);
  1729. localStorage.setItem('jwt', response.data.success.token);
  1730. if (localStorage.getItem('jwt') != null) {
  1731. _this.$router.go('/');
  1732. }
  1733. })["catch"](function (error) {
  1734. console.error(error);
  1735. });
  1736. }
  1737. }
  1738. },
  1739. beforeRouteEnter: function beforeRouteEnter(to, from, next) {
  1740. if (localStorage.getItem('jwt')) {
  1741. return next('board');
  1742. }
  1743. next();
  1744. }
  1745. });
  1746. /***/ }),
  1747. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=script&lang=js&":
  1748. /*!*************************************************************************************************************************************************************!*\
  1749. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=script&lang=js& ***!
  1750. \*************************************************************************************************************************************************************/
  1751. /*! exports provided: default */
  1752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1753. "use strict";
  1754. __webpack_require__.r(__webpack_exports__);
  1755. //
  1756. //
  1757. //
  1758. //
  1759. //
  1760. //
  1761. //
  1762. //
  1763. //
  1764. //
  1765. //
  1766. //
  1767. //
  1768. //
  1769. //
  1770. //
  1771. //
  1772. //
  1773. //
  1774. //
  1775. //
  1776. //
  1777. //
  1778. //
  1779. //
  1780. //
  1781. //
  1782. //
  1783. //
  1784. //
  1785. //
  1786. //
  1787. //
  1788. //
  1789. //
  1790. //
  1791. //
  1792. //
  1793. //
  1794. //
  1795. //
  1796. //
  1797. //
  1798. //
  1799. //
  1800. //
  1801. //
  1802. //
  1803. //
  1804. //
  1805. //
  1806. /* harmony default export */ __webpack_exports__["default"] = ({});
  1807. /***/ }),
  1808. /***/ "./node_modules/base64-js/index.js":
  1809. /*!*****************************************!*\
  1810. !*** ./node_modules/base64-js/index.js ***!
  1811. \*****************************************/
  1812. /*! no static exports found */
  1813. /***/ (function(module, exports, __webpack_require__) {
  1814. "use strict";
  1815. exports.byteLength = byteLength
  1816. exports.toByteArray = toByteArray
  1817. exports.fromByteArray = fromByteArray
  1818. var lookup = []
  1819. var revLookup = []
  1820. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1821. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1822. for (var i = 0, len = code.length; i < len; ++i) {
  1823. lookup[i] = code[i]
  1824. revLookup[code.charCodeAt(i)] = i
  1825. }
  1826. // Support decoding URL-safe base64 strings, as Node.js does.
  1827. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1828. revLookup['-'.charCodeAt(0)] = 62
  1829. revLookup['_'.charCodeAt(0)] = 63
  1830. function getLens (b64) {
  1831. var len = b64.length
  1832. if (len % 4 > 0) {
  1833. throw new Error('Invalid string. Length must be a multiple of 4')
  1834. }
  1835. // Trim off extra bytes after placeholder bytes are found
  1836. // See: https://github.com/beatgammit/base64-js/issues/42
  1837. var validLen = b64.indexOf('=')
  1838. if (validLen === -1) validLen = len
  1839. var placeHoldersLen = validLen === len
  1840. ? 0
  1841. : 4 - (validLen % 4)
  1842. return [validLen, placeHoldersLen]
  1843. }
  1844. // base64 is 4/3 + up to two characters of the original data
  1845. function byteLength (b64) {
  1846. var lens = getLens(b64)
  1847. var validLen = lens[0]
  1848. var placeHoldersLen = lens[1]
  1849. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1850. }
  1851. function _byteLength (b64, validLen, placeHoldersLen) {
  1852. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1853. }
  1854. function toByteArray (b64) {
  1855. var tmp
  1856. var lens = getLens(b64)
  1857. var validLen = lens[0]
  1858. var placeHoldersLen = lens[1]
  1859. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1860. var curByte = 0
  1861. // if there are placeholders, only get up to the last complete 4 chars
  1862. var len = placeHoldersLen > 0
  1863. ? validLen - 4
  1864. : validLen
  1865. var i
  1866. for (i = 0; i < len; i += 4) {
  1867. tmp =
  1868. (revLookup[b64.charCodeAt(i)] << 18) |
  1869. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1870. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1871. revLookup[b64.charCodeAt(i + 3)]
  1872. arr[curByte++] = (tmp >> 16) & 0xFF
  1873. arr[curByte++] = (tmp >> 8) & 0xFF
  1874. arr[curByte++] = tmp & 0xFF
  1875. }
  1876. if (placeHoldersLen === 2) {
  1877. tmp =
  1878. (revLookup[b64.charCodeAt(i)] << 2) |
  1879. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1880. arr[curByte++] = tmp & 0xFF
  1881. }
  1882. if (placeHoldersLen === 1) {
  1883. tmp =
  1884. (revLookup[b64.charCodeAt(i)] << 10) |
  1885. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1886. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1887. arr[curByte++] = (tmp >> 8) & 0xFF
  1888. arr[curByte++] = tmp & 0xFF
  1889. }
  1890. return arr
  1891. }
  1892. function tripletToBase64 (num) {
  1893. return lookup[num >> 18 & 0x3F] +
  1894. lookup[num >> 12 & 0x3F] +
  1895. lookup[num >> 6 & 0x3F] +
  1896. lookup[num & 0x3F]
  1897. }
  1898. function encodeChunk (uint8, start, end) {
  1899. var tmp
  1900. var output = []
  1901. for (var i = start; i < end; i += 3) {
  1902. tmp =
  1903. ((uint8[i] << 16) & 0xFF0000) +
  1904. ((uint8[i + 1] << 8) & 0xFF00) +
  1905. (uint8[i + 2] & 0xFF)
  1906. output.push(tripletToBase64(tmp))
  1907. }
  1908. return output.join('')
  1909. }
  1910. function fromByteArray (uint8) {
  1911. var tmp
  1912. var len = uint8.length
  1913. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1914. var parts = []
  1915. var maxChunkLength = 16383 // must be multiple of 3
  1916. // go through the array every three bytes, we'll deal with trailing stuff later
  1917. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1918. parts.push(encodeChunk(
  1919. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1920. ))
  1921. }
  1922. // pad the end with zeros, but make sure to not forget the extra bytes
  1923. if (extraBytes === 1) {
  1924. tmp = uint8[len - 1]
  1925. parts.push(
  1926. lookup[tmp >> 2] +
  1927. lookup[(tmp << 4) & 0x3F] +
  1928. '=='
  1929. )
  1930. } else if (extraBytes === 2) {
  1931. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1932. parts.push(
  1933. lookup[tmp >> 10] +
  1934. lookup[(tmp >> 4) & 0x3F] +
  1935. lookup[(tmp << 2) & 0x3F] +
  1936. '='
  1937. )
  1938. }
  1939. return parts.join('')
  1940. }
  1941. /***/ }),
  1942. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1943. /*!*****************************************************!*\
  1944. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1945. \*****************************************************/
  1946. /*! no static exports found */
  1947. /***/ (function(module, exports, __webpack_require__) {
  1948. /*!
  1949. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1950. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1951. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1952. */
  1953. (function (global, factory) {
  1954. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1955. undefined;
  1956. }(this, (function (exports, $, Popper) { 'use strict';
  1957. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1958. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1959. function _defineProperties(target, props) {
  1960. for (var i = 0; i < props.length; i++) {
  1961. var descriptor = props[i];
  1962. descriptor.enumerable = descriptor.enumerable || false;
  1963. descriptor.configurable = true;
  1964. if ("value" in descriptor) descriptor.writable = true;
  1965. Object.defineProperty(target, descriptor.key, descriptor);
  1966. }
  1967. }
  1968. function _createClass(Constructor, protoProps, staticProps) {
  1969. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1970. if (staticProps) _defineProperties(Constructor, staticProps);
  1971. return Constructor;
  1972. }
  1973. function _defineProperty(obj, key, value) {
  1974. if (key in obj) {
  1975. Object.defineProperty(obj, key, {
  1976. value: value,
  1977. enumerable: true,
  1978. configurable: true,
  1979. writable: true
  1980. });
  1981. } else {
  1982. obj[key] = value;
  1983. }
  1984. return obj;
  1985. }
  1986. function ownKeys(object, enumerableOnly) {
  1987. var keys = Object.keys(object);
  1988. if (Object.getOwnPropertySymbols) {
  1989. var symbols = Object.getOwnPropertySymbols(object);
  1990. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1991. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1992. });
  1993. keys.push.apply(keys, symbols);
  1994. }
  1995. return keys;
  1996. }
  1997. function _objectSpread2(target) {
  1998. for (var i = 1; i < arguments.length; i++) {
  1999. var source = arguments[i] != null ? arguments[i] : {};
  2000. if (i % 2) {
  2001. ownKeys(Object(source), true).forEach(function (key) {
  2002. _defineProperty(target, key, source[key]);
  2003. });
  2004. } else if (Object.getOwnPropertyDescriptors) {
  2005. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  2006. } else {
  2007. ownKeys(Object(source)).forEach(function (key) {
  2008. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2009. });
  2010. }
  2011. }
  2012. return target;
  2013. }
  2014. function _inheritsLoose(subClass, superClass) {
  2015. subClass.prototype = Object.create(superClass.prototype);
  2016. subClass.prototype.constructor = subClass;
  2017. subClass.__proto__ = superClass;
  2018. }
  2019. /**
  2020. * --------------------------------------------------------------------------
  2021. * Bootstrap (v4.4.1): util.js
  2022. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2023. * --------------------------------------------------------------------------
  2024. */
  2025. /**
  2026. * ------------------------------------------------------------------------
  2027. * Private TransitionEnd Helpers
  2028. * ------------------------------------------------------------------------
  2029. */
  2030. var TRANSITION_END = 'transitionend';
  2031. var MAX_UID = 1000000;
  2032. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  2033. function toType(obj) {
  2034. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  2035. }
  2036. function getSpecialTransitionEndEvent() {
  2037. return {
  2038. bindType: TRANSITION_END,
  2039. delegateType: TRANSITION_END,
  2040. handle: function handle(event) {
  2041. if ($(event.target).is(this)) {
  2042. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2043. }
  2044. return undefined; // eslint-disable-line no-undefined
  2045. }
  2046. };
  2047. }
  2048. function transitionEndEmulator(duration) {
  2049. var _this = this;
  2050. var called = false;
  2051. $(this).one(Util.TRANSITION_END, function () {
  2052. called = true;
  2053. });
  2054. setTimeout(function () {
  2055. if (!called) {
  2056. Util.triggerTransitionEnd(_this);
  2057. }
  2058. }, duration);
  2059. return this;
  2060. }
  2061. function setTransitionEndSupport() {
  2062. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2063. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2064. }
  2065. /**
  2066. * --------------------------------------------------------------------------
  2067. * Public Util Api
  2068. * --------------------------------------------------------------------------
  2069. */
  2070. var Util = {
  2071. TRANSITION_END: 'bsTransitionEnd',
  2072. getUID: function getUID(prefix) {
  2073. do {
  2074. // eslint-disable-next-line no-bitwise
  2075. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2076. } while (document.getElementById(prefix));
  2077. return prefix;
  2078. },
  2079. getSelectorFromElement: function getSelectorFromElement(element) {
  2080. var selector = element.getAttribute('data-target');
  2081. if (!selector || selector === '#') {
  2082. var hrefAttr = element.getAttribute('href');
  2083. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2084. }
  2085. try {
  2086. return document.querySelector(selector) ? selector : null;
  2087. } catch (err) {
  2088. return null;
  2089. }
  2090. },
  2091. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2092. if (!element) {
  2093. return 0;
  2094. } // Get transition-duration of the element
  2095. var transitionDuration = $(element).css('transition-duration');
  2096. var transitionDelay = $(element).css('transition-delay');
  2097. var floatTransitionDuration = parseFloat(transitionDuration);
  2098. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2099. if (!floatTransitionDuration && !floatTransitionDelay) {
  2100. return 0;
  2101. } // If multiple durations are defined, take the first
  2102. transitionDuration = transitionDuration.split(',')[0];
  2103. transitionDelay = transitionDelay.split(',')[0];
  2104. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2105. },
  2106. reflow: function reflow(element) {
  2107. return element.offsetHeight;
  2108. },
  2109. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2110. $(element).trigger(TRANSITION_END);
  2111. },
  2112. // TODO: Remove in v5
  2113. supportsTransitionEnd: function supportsTransitionEnd() {
  2114. return Boolean(TRANSITION_END);
  2115. },
  2116. isElement: function isElement(obj) {
  2117. return (obj[0] || obj).nodeType;
  2118. },
  2119. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2120. for (var property in configTypes) {
  2121. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2122. var expectedTypes = configTypes[property];
  2123. var value = config[property];
  2124. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2125. if (!new RegExp(expectedTypes).test(valueType)) {
  2126. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2127. }
  2128. }
  2129. }
  2130. },
  2131. findShadowRoot: function findShadowRoot(element) {
  2132. if (!document.documentElement.attachShadow) {
  2133. return null;
  2134. } // Can find the shadow root otherwise it'll return the document
  2135. if (typeof element.getRootNode === 'function') {
  2136. var root = element.getRootNode();
  2137. return root instanceof ShadowRoot ? root : null;
  2138. }
  2139. if (element instanceof ShadowRoot) {
  2140. return element;
  2141. } // when we don't find a shadow root
  2142. if (!element.parentNode) {
  2143. return null;
  2144. }
  2145. return Util.findShadowRoot(element.parentNode);
  2146. },
  2147. jQueryDetection: function jQueryDetection() {
  2148. if (typeof $ === 'undefined') {
  2149. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2150. }
  2151. var version = $.fn.jquery.split(' ')[0].split('.');
  2152. var minMajor = 1;
  2153. var ltMajor = 2;
  2154. var minMinor = 9;
  2155. var minPatch = 1;
  2156. var maxMajor = 4;
  2157. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2158. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2159. }
  2160. }
  2161. };
  2162. Util.jQueryDetection();
  2163. setTransitionEndSupport();
  2164. /**
  2165. * ------------------------------------------------------------------------
  2166. * Constants
  2167. * ------------------------------------------------------------------------
  2168. */
  2169. var NAME = 'alert';
  2170. var VERSION = '4.4.1';
  2171. var DATA_KEY = 'bs.alert';
  2172. var EVENT_KEY = "." + DATA_KEY;
  2173. var DATA_API_KEY = '.data-api';
  2174. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2175. var Selector = {
  2176. DISMISS: '[data-dismiss="alert"]'
  2177. };
  2178. var Event = {
  2179. CLOSE: "close" + EVENT_KEY,
  2180. CLOSED: "closed" + EVENT_KEY,
  2181. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2182. };
  2183. var ClassName = {
  2184. ALERT: 'alert',
  2185. FADE: 'fade',
  2186. SHOW: 'show'
  2187. };
  2188. /**
  2189. * ------------------------------------------------------------------------
  2190. * Class Definition
  2191. * ------------------------------------------------------------------------
  2192. */
  2193. var Alert =
  2194. /*#__PURE__*/
  2195. function () {
  2196. function Alert(element) {
  2197. this._element = element;
  2198. } // Getters
  2199. var _proto = Alert.prototype;
  2200. // Public
  2201. _proto.close = function close(element) {
  2202. var rootElement = this._element;
  2203. if (element) {
  2204. rootElement = this._getRootElement(element);
  2205. }
  2206. var customEvent = this._triggerCloseEvent(rootElement);
  2207. if (customEvent.isDefaultPrevented()) {
  2208. return;
  2209. }
  2210. this._removeElement(rootElement);
  2211. };
  2212. _proto.dispose = function dispose() {
  2213. $.removeData(this._element, DATA_KEY);
  2214. this._element = null;
  2215. } // Private
  2216. ;
  2217. _proto._getRootElement = function _getRootElement(element) {
  2218. var selector = Util.getSelectorFromElement(element);
  2219. var parent = false;
  2220. if (selector) {
  2221. parent = document.querySelector(selector);
  2222. }
  2223. if (!parent) {
  2224. parent = $(element).closest("." + ClassName.ALERT)[0];
  2225. }
  2226. return parent;
  2227. };
  2228. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2229. var closeEvent = $.Event(Event.CLOSE);
  2230. $(element).trigger(closeEvent);
  2231. return closeEvent;
  2232. };
  2233. _proto._removeElement = function _removeElement(element) {
  2234. var _this = this;
  2235. $(element).removeClass(ClassName.SHOW);
  2236. if (!$(element).hasClass(ClassName.FADE)) {
  2237. this._destroyElement(element);
  2238. return;
  2239. }
  2240. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2241. $(element).one(Util.TRANSITION_END, function (event) {
  2242. return _this._destroyElement(element, event);
  2243. }).emulateTransitionEnd(transitionDuration);
  2244. };
  2245. _proto._destroyElement = function _destroyElement(element) {
  2246. $(element).detach().trigger(Event.CLOSED).remove();
  2247. } // Static
  2248. ;
  2249. Alert._jQueryInterface = function _jQueryInterface(config) {
  2250. return this.each(function () {
  2251. var $element = $(this);
  2252. var data = $element.data(DATA_KEY);
  2253. if (!data) {
  2254. data = new Alert(this);
  2255. $element.data(DATA_KEY, data);
  2256. }
  2257. if (config === 'close') {
  2258. data[config](this);
  2259. }
  2260. });
  2261. };
  2262. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2263. return function (event) {
  2264. if (event) {
  2265. event.preventDefault();
  2266. }
  2267. alertInstance.close(this);
  2268. };
  2269. };
  2270. _createClass(Alert, null, [{
  2271. key: "VERSION",
  2272. get: function get() {
  2273. return VERSION;
  2274. }
  2275. }]);
  2276. return Alert;
  2277. }();
  2278. /**
  2279. * ------------------------------------------------------------------------
  2280. * Data Api implementation
  2281. * ------------------------------------------------------------------------
  2282. */
  2283. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2284. /**
  2285. * ------------------------------------------------------------------------
  2286. * jQuery
  2287. * ------------------------------------------------------------------------
  2288. */
  2289. $.fn[NAME] = Alert._jQueryInterface;
  2290. $.fn[NAME].Constructor = Alert;
  2291. $.fn[NAME].noConflict = function () {
  2292. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2293. return Alert._jQueryInterface;
  2294. };
  2295. /**
  2296. * ------------------------------------------------------------------------
  2297. * Constants
  2298. * ------------------------------------------------------------------------
  2299. */
  2300. var NAME$1 = 'button';
  2301. var VERSION$1 = '4.4.1';
  2302. var DATA_KEY$1 = 'bs.button';
  2303. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2304. var DATA_API_KEY$1 = '.data-api';
  2305. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2306. var ClassName$1 = {
  2307. ACTIVE: 'active',
  2308. BUTTON: 'btn',
  2309. FOCUS: 'focus'
  2310. };
  2311. var Selector$1 = {
  2312. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2313. DATA_TOGGLES: '[data-toggle="buttons"]',
  2314. DATA_TOGGLE: '[data-toggle="button"]',
  2315. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2316. INPUT: 'input:not([type="hidden"])',
  2317. ACTIVE: '.active',
  2318. BUTTON: '.btn'
  2319. };
  2320. var Event$1 = {
  2321. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2322. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2323. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2324. };
  2325. /**
  2326. * ------------------------------------------------------------------------
  2327. * Class Definition
  2328. * ------------------------------------------------------------------------
  2329. */
  2330. var Button =
  2331. /*#__PURE__*/
  2332. function () {
  2333. function Button(element) {
  2334. this._element = element;
  2335. } // Getters
  2336. var _proto = Button.prototype;
  2337. // Public
  2338. _proto.toggle = function toggle() {
  2339. var triggerChangeEvent = true;
  2340. var addAriaPressed = true;
  2341. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2342. if (rootElement) {
  2343. var input = this._element.querySelector(Selector$1.INPUT);
  2344. if (input) {
  2345. if (input.type === 'radio') {
  2346. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2347. triggerChangeEvent = false;
  2348. } else {
  2349. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2350. if (activeElement) {
  2351. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2352. }
  2353. }
  2354. } else if (input.type === 'checkbox') {
  2355. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2356. triggerChangeEvent = false;
  2357. }
  2358. } else {
  2359. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2360. triggerChangeEvent = false;
  2361. }
  2362. if (triggerChangeEvent) {
  2363. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2364. $(input).trigger('change');
  2365. }
  2366. input.focus();
  2367. addAriaPressed = false;
  2368. }
  2369. }
  2370. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2371. if (addAriaPressed) {
  2372. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2373. }
  2374. if (triggerChangeEvent) {
  2375. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2376. }
  2377. }
  2378. };
  2379. _proto.dispose = function dispose() {
  2380. $.removeData(this._element, DATA_KEY$1);
  2381. this._element = null;
  2382. } // Static
  2383. ;
  2384. Button._jQueryInterface = function _jQueryInterface(config) {
  2385. return this.each(function () {
  2386. var data = $(this).data(DATA_KEY$1);
  2387. if (!data) {
  2388. data = new Button(this);
  2389. $(this).data(DATA_KEY$1, data);
  2390. }
  2391. if (config === 'toggle') {
  2392. data[config]();
  2393. }
  2394. });
  2395. };
  2396. _createClass(Button, null, [{
  2397. key: "VERSION",
  2398. get: function get() {
  2399. return VERSION$1;
  2400. }
  2401. }]);
  2402. return Button;
  2403. }();
  2404. /**
  2405. * ------------------------------------------------------------------------
  2406. * Data Api implementation
  2407. * ------------------------------------------------------------------------
  2408. */
  2409. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2410. var button = event.target;
  2411. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2412. button = $(button).closest(Selector$1.BUTTON)[0];
  2413. }
  2414. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2415. event.preventDefault(); // work around Firefox bug #1540995
  2416. } else {
  2417. var inputBtn = button.querySelector(Selector$1.INPUT);
  2418. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2419. event.preventDefault(); // work around Firefox bug #1540995
  2420. return;
  2421. }
  2422. Button._jQueryInterface.call($(button), 'toggle');
  2423. }
  2424. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2425. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2426. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2427. });
  2428. $(window).on(Event$1.LOAD_DATA_API, function () {
  2429. // ensure correct active class is set to match the controls' actual values/states
  2430. // find all checkboxes/readio buttons inside data-toggle groups
  2431. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2432. for (var i = 0, len = buttons.length; i < len; i++) {
  2433. var button = buttons[i];
  2434. var input = button.querySelector(Selector$1.INPUT);
  2435. if (input.checked || input.hasAttribute('checked')) {
  2436. button.classList.add(ClassName$1.ACTIVE);
  2437. } else {
  2438. button.classList.remove(ClassName$1.ACTIVE);
  2439. }
  2440. } // find all button toggles
  2441. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2442. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2443. var _button = buttons[_i];
  2444. if (_button.getAttribute('aria-pressed') === 'true') {
  2445. _button.classList.add(ClassName$1.ACTIVE);
  2446. } else {
  2447. _button.classList.remove(ClassName$1.ACTIVE);
  2448. }
  2449. }
  2450. });
  2451. /**
  2452. * ------------------------------------------------------------------------
  2453. * jQuery
  2454. * ------------------------------------------------------------------------
  2455. */
  2456. $.fn[NAME$1] = Button._jQueryInterface;
  2457. $.fn[NAME$1].Constructor = Button;
  2458. $.fn[NAME$1].noConflict = function () {
  2459. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2460. return Button._jQueryInterface;
  2461. };
  2462. /**
  2463. * ------------------------------------------------------------------------
  2464. * Constants
  2465. * ------------------------------------------------------------------------
  2466. */
  2467. var NAME$2 = 'carousel';
  2468. var VERSION$2 = '4.4.1';
  2469. var DATA_KEY$2 = 'bs.carousel';
  2470. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2471. var DATA_API_KEY$2 = '.data-api';
  2472. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2473. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2474. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2475. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2476. var SWIPE_THRESHOLD = 40;
  2477. var Default = {
  2478. interval: 5000,
  2479. keyboard: true,
  2480. slide: false,
  2481. pause: 'hover',
  2482. wrap: true,
  2483. touch: true
  2484. };
  2485. var DefaultType = {
  2486. interval: '(number|boolean)',
  2487. keyboard: 'boolean',
  2488. slide: '(boolean|string)',
  2489. pause: '(string|boolean)',
  2490. wrap: 'boolean',
  2491. touch: 'boolean'
  2492. };
  2493. var Direction = {
  2494. NEXT: 'next',
  2495. PREV: 'prev',
  2496. LEFT: 'left',
  2497. RIGHT: 'right'
  2498. };
  2499. var Event$2 = {
  2500. SLIDE: "slide" + EVENT_KEY$2,
  2501. SLID: "slid" + EVENT_KEY$2,
  2502. KEYDOWN: "keydown" + EVENT_KEY$2,
  2503. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2504. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2505. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2506. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2507. TOUCHEND: "touchend" + EVENT_KEY$2,
  2508. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2509. POINTERUP: "pointerup" + EVENT_KEY$2,
  2510. DRAG_START: "dragstart" + EVENT_KEY$2,
  2511. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2512. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2513. };
  2514. var ClassName$2 = {
  2515. CAROUSEL: 'carousel',
  2516. ACTIVE: 'active',
  2517. SLIDE: 'slide',
  2518. RIGHT: 'carousel-item-right',
  2519. LEFT: 'carousel-item-left',
  2520. NEXT: 'carousel-item-next',
  2521. PREV: 'carousel-item-prev',
  2522. ITEM: 'carousel-item',
  2523. POINTER_EVENT: 'pointer-event'
  2524. };
  2525. var Selector$2 = {
  2526. ACTIVE: '.active',
  2527. ACTIVE_ITEM: '.active.carousel-item',
  2528. ITEM: '.carousel-item',
  2529. ITEM_IMG: '.carousel-item img',
  2530. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2531. INDICATORS: '.carousel-indicators',
  2532. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2533. DATA_RIDE: '[data-ride="carousel"]'
  2534. };
  2535. var PointerType = {
  2536. TOUCH: 'touch',
  2537. PEN: 'pen'
  2538. };
  2539. /**
  2540. * ------------------------------------------------------------------------
  2541. * Class Definition
  2542. * ------------------------------------------------------------------------
  2543. */
  2544. var Carousel =
  2545. /*#__PURE__*/
  2546. function () {
  2547. function Carousel(element, config) {
  2548. this._items = null;
  2549. this._interval = null;
  2550. this._activeElement = null;
  2551. this._isPaused = false;
  2552. this._isSliding = false;
  2553. this.touchTimeout = null;
  2554. this.touchStartX = 0;
  2555. this.touchDeltaX = 0;
  2556. this._config = this._getConfig(config);
  2557. this._element = element;
  2558. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2559. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2560. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2561. this._addEventListeners();
  2562. } // Getters
  2563. var _proto = Carousel.prototype;
  2564. // Public
  2565. _proto.next = function next() {
  2566. if (!this._isSliding) {
  2567. this._slide(Direction.NEXT);
  2568. }
  2569. };
  2570. _proto.nextWhenVisible = function nextWhenVisible() {
  2571. // Don't call next when the page isn't visible
  2572. // or the carousel or its parent isn't visible
  2573. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2574. this.next();
  2575. }
  2576. };
  2577. _proto.prev = function prev() {
  2578. if (!this._isSliding) {
  2579. this._slide(Direction.PREV);
  2580. }
  2581. };
  2582. _proto.pause = function pause(event) {
  2583. if (!event) {
  2584. this._isPaused = true;
  2585. }
  2586. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2587. Util.triggerTransitionEnd(this._element);
  2588. this.cycle(true);
  2589. }
  2590. clearInterval(this._interval);
  2591. this._interval = null;
  2592. };
  2593. _proto.cycle = function cycle(event) {
  2594. if (!event) {
  2595. this._isPaused = false;
  2596. }
  2597. if (this._interval) {
  2598. clearInterval(this._interval);
  2599. this._interval = null;
  2600. }
  2601. if (this._config.interval && !this._isPaused) {
  2602. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2603. }
  2604. };
  2605. _proto.to = function to(index) {
  2606. var _this = this;
  2607. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2608. var activeIndex = this._getItemIndex(this._activeElement);
  2609. if (index > this._items.length - 1 || index < 0) {
  2610. return;
  2611. }
  2612. if (this._isSliding) {
  2613. $(this._element).one(Event$2.SLID, function () {
  2614. return _this.to(index);
  2615. });
  2616. return;
  2617. }
  2618. if (activeIndex === index) {
  2619. this.pause();
  2620. this.cycle();
  2621. return;
  2622. }
  2623. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2624. this._slide(direction, this._items[index]);
  2625. };
  2626. _proto.dispose = function dispose() {
  2627. $(this._element).off(EVENT_KEY$2);
  2628. $.removeData(this._element, DATA_KEY$2);
  2629. this._items = null;
  2630. this._config = null;
  2631. this._element = null;
  2632. this._interval = null;
  2633. this._isPaused = null;
  2634. this._isSliding = null;
  2635. this._activeElement = null;
  2636. this._indicatorsElement = null;
  2637. } // Private
  2638. ;
  2639. _proto._getConfig = function _getConfig(config) {
  2640. config = _objectSpread2({}, Default, {}, config);
  2641. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2642. return config;
  2643. };
  2644. _proto._handleSwipe = function _handleSwipe() {
  2645. var absDeltax = Math.abs(this.touchDeltaX);
  2646. if (absDeltax <= SWIPE_THRESHOLD) {
  2647. return;
  2648. }
  2649. var direction = absDeltax / this.touchDeltaX;
  2650. this.touchDeltaX = 0; // swipe left
  2651. if (direction > 0) {
  2652. this.prev();
  2653. } // swipe right
  2654. if (direction < 0) {
  2655. this.next();
  2656. }
  2657. };
  2658. _proto._addEventListeners = function _addEventListeners() {
  2659. var _this2 = this;
  2660. if (this._config.keyboard) {
  2661. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2662. return _this2._keydown(event);
  2663. });
  2664. }
  2665. if (this._config.pause === 'hover') {
  2666. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2667. return _this2.pause(event);
  2668. }).on(Event$2.MOUSELEAVE, function (event) {
  2669. return _this2.cycle(event);
  2670. });
  2671. }
  2672. if (this._config.touch) {
  2673. this._addTouchEventListeners();
  2674. }
  2675. };
  2676. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2677. var _this3 = this;
  2678. if (!this._touchSupported) {
  2679. return;
  2680. }
  2681. var start = function start(event) {
  2682. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2683. _this3.touchStartX = event.originalEvent.clientX;
  2684. } else if (!_this3._pointerEvent) {
  2685. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2686. }
  2687. };
  2688. var move = function move(event) {
  2689. // ensure swiping with one touch and not pinching
  2690. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2691. _this3.touchDeltaX = 0;
  2692. } else {
  2693. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2694. }
  2695. };
  2696. var end = function end(event) {
  2697. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2698. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2699. }
  2700. _this3._handleSwipe();
  2701. if (_this3._config.pause === 'hover') {
  2702. // If it's a touch-enabled device, mouseenter/leave are fired as
  2703. // part of the mouse compatibility events on first tap - the carousel
  2704. // would stop cycling until user tapped out of it;
  2705. // here, we listen for touchend, explicitly pause the carousel
  2706. // (as if it's the second time we tap on it, mouseenter compat event
  2707. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2708. // events to fire) we explicitly restart cycling
  2709. _this3.pause();
  2710. if (_this3.touchTimeout) {
  2711. clearTimeout(_this3.touchTimeout);
  2712. }
  2713. _this3.touchTimeout = setTimeout(function (event) {
  2714. return _this3.cycle(event);
  2715. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2716. }
  2717. };
  2718. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2719. return e.preventDefault();
  2720. });
  2721. if (this._pointerEvent) {
  2722. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2723. return start(event);
  2724. });
  2725. $(this._element).on(Event$2.POINTERUP, function (event) {
  2726. return end(event);
  2727. });
  2728. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2729. } else {
  2730. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2731. return start(event);
  2732. });
  2733. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2734. return move(event);
  2735. });
  2736. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2737. return end(event);
  2738. });
  2739. }
  2740. };
  2741. _proto._keydown = function _keydown(event) {
  2742. if (/input|textarea/i.test(event.target.tagName)) {
  2743. return;
  2744. }
  2745. switch (event.which) {
  2746. case ARROW_LEFT_KEYCODE:
  2747. event.preventDefault();
  2748. this.prev();
  2749. break;
  2750. case ARROW_RIGHT_KEYCODE:
  2751. event.preventDefault();
  2752. this.next();
  2753. break;
  2754. }
  2755. };
  2756. _proto._getItemIndex = function _getItemIndex(element) {
  2757. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2758. return this._items.indexOf(element);
  2759. };
  2760. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2761. var isNextDirection = direction === Direction.NEXT;
  2762. var isPrevDirection = direction === Direction.PREV;
  2763. var activeIndex = this._getItemIndex(activeElement);
  2764. var lastItemIndex = this._items.length - 1;
  2765. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2766. if (isGoingToWrap && !this._config.wrap) {
  2767. return activeElement;
  2768. }
  2769. var delta = direction === Direction.PREV ? -1 : 1;
  2770. var itemIndex = (activeIndex + delta) % this._items.length;
  2771. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2772. };
  2773. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2774. var targetIndex = this._getItemIndex(relatedTarget);
  2775. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2776. var slideEvent = $.Event(Event$2.SLIDE, {
  2777. relatedTarget: relatedTarget,
  2778. direction: eventDirectionName,
  2779. from: fromIndex,
  2780. to: targetIndex
  2781. });
  2782. $(this._element).trigger(slideEvent);
  2783. return slideEvent;
  2784. };
  2785. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2786. if (this._indicatorsElement) {
  2787. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2788. $(indicators).removeClass(ClassName$2.ACTIVE);
  2789. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2790. if (nextIndicator) {
  2791. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2792. }
  2793. }
  2794. };
  2795. _proto._slide = function _slide(direction, element) {
  2796. var _this4 = this;
  2797. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2798. var activeElementIndex = this._getItemIndex(activeElement);
  2799. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2800. var nextElementIndex = this._getItemIndex(nextElement);
  2801. var isCycling = Boolean(this._interval);
  2802. var directionalClassName;
  2803. var orderClassName;
  2804. var eventDirectionName;
  2805. if (direction === Direction.NEXT) {
  2806. directionalClassName = ClassName$2.LEFT;
  2807. orderClassName = ClassName$2.NEXT;
  2808. eventDirectionName = Direction.LEFT;
  2809. } else {
  2810. directionalClassName = ClassName$2.RIGHT;
  2811. orderClassName = ClassName$2.PREV;
  2812. eventDirectionName = Direction.RIGHT;
  2813. }
  2814. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2815. this._isSliding = false;
  2816. return;
  2817. }
  2818. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2819. if (slideEvent.isDefaultPrevented()) {
  2820. return;
  2821. }
  2822. if (!activeElement || !nextElement) {
  2823. // Some weirdness is happening, so we bail
  2824. return;
  2825. }
  2826. this._isSliding = true;
  2827. if (isCycling) {
  2828. this.pause();
  2829. }
  2830. this._setActiveIndicatorElement(nextElement);
  2831. var slidEvent = $.Event(Event$2.SLID, {
  2832. relatedTarget: nextElement,
  2833. direction: eventDirectionName,
  2834. from: activeElementIndex,
  2835. to: nextElementIndex
  2836. });
  2837. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2838. $(nextElement).addClass(orderClassName);
  2839. Util.reflow(nextElement);
  2840. $(activeElement).addClass(directionalClassName);
  2841. $(nextElement).addClass(directionalClassName);
  2842. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2843. if (nextElementInterval) {
  2844. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2845. this._config.interval = nextElementInterval;
  2846. } else {
  2847. this._config.interval = this._config.defaultInterval || this._config.interval;
  2848. }
  2849. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2850. $(activeElement).one(Util.TRANSITION_END, function () {
  2851. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2852. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2853. _this4._isSliding = false;
  2854. setTimeout(function () {
  2855. return $(_this4._element).trigger(slidEvent);
  2856. }, 0);
  2857. }).emulateTransitionEnd(transitionDuration);
  2858. } else {
  2859. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2860. $(nextElement).addClass(ClassName$2.ACTIVE);
  2861. this._isSliding = false;
  2862. $(this._element).trigger(slidEvent);
  2863. }
  2864. if (isCycling) {
  2865. this.cycle();
  2866. }
  2867. } // Static
  2868. ;
  2869. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2870. return this.each(function () {
  2871. var data = $(this).data(DATA_KEY$2);
  2872. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2873. if (typeof config === 'object') {
  2874. _config = _objectSpread2({}, _config, {}, config);
  2875. }
  2876. var action = typeof config === 'string' ? config : _config.slide;
  2877. if (!data) {
  2878. data = new Carousel(this, _config);
  2879. $(this).data(DATA_KEY$2, data);
  2880. }
  2881. if (typeof config === 'number') {
  2882. data.to(config);
  2883. } else if (typeof action === 'string') {
  2884. if (typeof data[action] === 'undefined') {
  2885. throw new TypeError("No method named \"" + action + "\"");
  2886. }
  2887. data[action]();
  2888. } else if (_config.interval && _config.ride) {
  2889. data.pause();
  2890. data.cycle();
  2891. }
  2892. });
  2893. };
  2894. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2895. var selector = Util.getSelectorFromElement(this);
  2896. if (!selector) {
  2897. return;
  2898. }
  2899. var target = $(selector)[0];
  2900. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2901. return;
  2902. }
  2903. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2904. var slideIndex = this.getAttribute('data-slide-to');
  2905. if (slideIndex) {
  2906. config.interval = false;
  2907. }
  2908. Carousel._jQueryInterface.call($(target), config);
  2909. if (slideIndex) {
  2910. $(target).data(DATA_KEY$2).to(slideIndex);
  2911. }
  2912. event.preventDefault();
  2913. };
  2914. _createClass(Carousel, null, [{
  2915. key: "VERSION",
  2916. get: function get() {
  2917. return VERSION$2;
  2918. }
  2919. }, {
  2920. key: "Default",
  2921. get: function get() {
  2922. return Default;
  2923. }
  2924. }]);
  2925. return Carousel;
  2926. }();
  2927. /**
  2928. * ------------------------------------------------------------------------
  2929. * Data Api implementation
  2930. * ------------------------------------------------------------------------
  2931. */
  2932. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2933. $(window).on(Event$2.LOAD_DATA_API, function () {
  2934. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2935. for (var i = 0, len = carousels.length; i < len; i++) {
  2936. var $carousel = $(carousels[i]);
  2937. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2938. }
  2939. });
  2940. /**
  2941. * ------------------------------------------------------------------------
  2942. * jQuery
  2943. * ------------------------------------------------------------------------
  2944. */
  2945. $.fn[NAME$2] = Carousel._jQueryInterface;
  2946. $.fn[NAME$2].Constructor = Carousel;
  2947. $.fn[NAME$2].noConflict = function () {
  2948. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2949. return Carousel._jQueryInterface;
  2950. };
  2951. /**
  2952. * ------------------------------------------------------------------------
  2953. * Constants
  2954. * ------------------------------------------------------------------------
  2955. */
  2956. var NAME$3 = 'collapse';
  2957. var VERSION$3 = '4.4.1';
  2958. var DATA_KEY$3 = 'bs.collapse';
  2959. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2960. var DATA_API_KEY$3 = '.data-api';
  2961. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2962. var Default$1 = {
  2963. toggle: true,
  2964. parent: ''
  2965. };
  2966. var DefaultType$1 = {
  2967. toggle: 'boolean',
  2968. parent: '(string|element)'
  2969. };
  2970. var Event$3 = {
  2971. SHOW: "show" + EVENT_KEY$3,
  2972. SHOWN: "shown" + EVENT_KEY$3,
  2973. HIDE: "hide" + EVENT_KEY$3,
  2974. HIDDEN: "hidden" + EVENT_KEY$3,
  2975. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2976. };
  2977. var ClassName$3 = {
  2978. SHOW: 'show',
  2979. COLLAPSE: 'collapse',
  2980. COLLAPSING: 'collapsing',
  2981. COLLAPSED: 'collapsed'
  2982. };
  2983. var Dimension = {
  2984. WIDTH: 'width',
  2985. HEIGHT: 'height'
  2986. };
  2987. var Selector$3 = {
  2988. ACTIVES: '.show, .collapsing',
  2989. DATA_TOGGLE: '[data-toggle="collapse"]'
  2990. };
  2991. /**
  2992. * ------------------------------------------------------------------------
  2993. * Class Definition
  2994. * ------------------------------------------------------------------------
  2995. */
  2996. var Collapse =
  2997. /*#__PURE__*/
  2998. function () {
  2999. function Collapse(element, config) {
  3000. this._isTransitioning = false;
  3001. this._element = element;
  3002. this._config = this._getConfig(config);
  3003. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  3004. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  3005. for (var i = 0, len = toggleList.length; i < len; i++) {
  3006. var elem = toggleList[i];
  3007. var selector = Util.getSelectorFromElement(elem);
  3008. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  3009. return foundElem === element;
  3010. });
  3011. if (selector !== null && filterElement.length > 0) {
  3012. this._selector = selector;
  3013. this._triggerArray.push(elem);
  3014. }
  3015. }
  3016. this._parent = this._config.parent ? this._getParent() : null;
  3017. if (!this._config.parent) {
  3018. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  3019. }
  3020. if (this._config.toggle) {
  3021. this.toggle();
  3022. }
  3023. } // Getters
  3024. var _proto = Collapse.prototype;
  3025. // Public
  3026. _proto.toggle = function toggle() {
  3027. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  3028. this.hide();
  3029. } else {
  3030. this.show();
  3031. }
  3032. };
  3033. _proto.show = function show() {
  3034. var _this = this;
  3035. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  3036. return;
  3037. }
  3038. var actives;
  3039. var activesData;
  3040. if (this._parent) {
  3041. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  3042. if (typeof _this._config.parent === 'string') {
  3043. return elem.getAttribute('data-parent') === _this._config.parent;
  3044. }
  3045. return elem.classList.contains(ClassName$3.COLLAPSE);
  3046. });
  3047. if (actives.length === 0) {
  3048. actives = null;
  3049. }
  3050. }
  3051. if (actives) {
  3052. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3053. if (activesData && activesData._isTransitioning) {
  3054. return;
  3055. }
  3056. }
  3057. var startEvent = $.Event(Event$3.SHOW);
  3058. $(this._element).trigger(startEvent);
  3059. if (startEvent.isDefaultPrevented()) {
  3060. return;
  3061. }
  3062. if (actives) {
  3063. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3064. if (!activesData) {
  3065. $(actives).data(DATA_KEY$3, null);
  3066. }
  3067. }
  3068. var dimension = this._getDimension();
  3069. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  3070. this._element.style[dimension] = 0;
  3071. if (this._triggerArray.length) {
  3072. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  3073. }
  3074. this.setTransitioning(true);
  3075. var complete = function complete() {
  3076. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  3077. _this._element.style[dimension] = '';
  3078. _this.setTransitioning(false);
  3079. $(_this._element).trigger(Event$3.SHOWN);
  3080. };
  3081. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3082. var scrollSize = "scroll" + capitalizedDimension;
  3083. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3084. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3085. this._element.style[dimension] = this._element[scrollSize] + "px";
  3086. };
  3087. _proto.hide = function hide() {
  3088. var _this2 = this;
  3089. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  3090. return;
  3091. }
  3092. var startEvent = $.Event(Event$3.HIDE);
  3093. $(this._element).trigger(startEvent);
  3094. if (startEvent.isDefaultPrevented()) {
  3095. return;
  3096. }
  3097. var dimension = this._getDimension();
  3098. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3099. Util.reflow(this._element);
  3100. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3101. var triggerArrayLength = this._triggerArray.length;
  3102. if (triggerArrayLength > 0) {
  3103. for (var i = 0; i < triggerArrayLength; i++) {
  3104. var trigger = this._triggerArray[i];
  3105. var selector = Util.getSelectorFromElement(trigger);
  3106. if (selector !== null) {
  3107. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3108. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3109. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3110. }
  3111. }
  3112. }
  3113. }
  3114. this.setTransitioning(true);
  3115. var complete = function complete() {
  3116. _this2.setTransitioning(false);
  3117. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3118. };
  3119. this._element.style[dimension] = '';
  3120. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3121. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3122. };
  3123. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3124. this._isTransitioning = isTransitioning;
  3125. };
  3126. _proto.dispose = function dispose() {
  3127. $.removeData(this._element, DATA_KEY$3);
  3128. this._config = null;
  3129. this._parent = null;
  3130. this._element = null;
  3131. this._triggerArray = null;
  3132. this._isTransitioning = null;
  3133. } // Private
  3134. ;
  3135. _proto._getConfig = function _getConfig(config) {
  3136. config = _objectSpread2({}, Default$1, {}, config);
  3137. config.toggle = Boolean(config.toggle); // Coerce string values
  3138. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3139. return config;
  3140. };
  3141. _proto._getDimension = function _getDimension() {
  3142. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3143. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3144. };
  3145. _proto._getParent = function _getParent() {
  3146. var _this3 = this;
  3147. var parent;
  3148. if (Util.isElement(this._config.parent)) {
  3149. parent = this._config.parent; // It's a jQuery object
  3150. if (typeof this._config.parent.jquery !== 'undefined') {
  3151. parent = this._config.parent[0];
  3152. }
  3153. } else {
  3154. parent = document.querySelector(this._config.parent);
  3155. }
  3156. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3157. var children = [].slice.call(parent.querySelectorAll(selector));
  3158. $(children).each(function (i, element) {
  3159. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3160. });
  3161. return parent;
  3162. };
  3163. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3164. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3165. if (triggerArray.length) {
  3166. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3167. }
  3168. } // Static
  3169. ;
  3170. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3171. var selector = Util.getSelectorFromElement(element);
  3172. return selector ? document.querySelector(selector) : null;
  3173. };
  3174. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3175. return this.each(function () {
  3176. var $this = $(this);
  3177. var data = $this.data(DATA_KEY$3);
  3178. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3179. if (!data && _config.toggle && /show|hide/.test(config)) {
  3180. _config.toggle = false;
  3181. }
  3182. if (!data) {
  3183. data = new Collapse(this, _config);
  3184. $this.data(DATA_KEY$3, data);
  3185. }
  3186. if (typeof config === 'string') {
  3187. if (typeof data[config] === 'undefined') {
  3188. throw new TypeError("No method named \"" + config + "\"");
  3189. }
  3190. data[config]();
  3191. }
  3192. });
  3193. };
  3194. _createClass(Collapse, null, [{
  3195. key: "VERSION",
  3196. get: function get() {
  3197. return VERSION$3;
  3198. }
  3199. }, {
  3200. key: "Default",
  3201. get: function get() {
  3202. return Default$1;
  3203. }
  3204. }]);
  3205. return Collapse;
  3206. }();
  3207. /**
  3208. * ------------------------------------------------------------------------
  3209. * Data Api implementation
  3210. * ------------------------------------------------------------------------
  3211. */
  3212. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3213. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3214. if (event.currentTarget.tagName === 'A') {
  3215. event.preventDefault();
  3216. }
  3217. var $trigger = $(this);
  3218. var selector = Util.getSelectorFromElement(this);
  3219. var selectors = [].slice.call(document.querySelectorAll(selector));
  3220. $(selectors).each(function () {
  3221. var $target = $(this);
  3222. var data = $target.data(DATA_KEY$3);
  3223. var config = data ? 'toggle' : $trigger.data();
  3224. Collapse._jQueryInterface.call($target, config);
  3225. });
  3226. });
  3227. /**
  3228. * ------------------------------------------------------------------------
  3229. * jQuery
  3230. * ------------------------------------------------------------------------
  3231. */
  3232. $.fn[NAME$3] = Collapse._jQueryInterface;
  3233. $.fn[NAME$3].Constructor = Collapse;
  3234. $.fn[NAME$3].noConflict = function () {
  3235. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3236. return Collapse._jQueryInterface;
  3237. };
  3238. /**
  3239. * ------------------------------------------------------------------------
  3240. * Constants
  3241. * ------------------------------------------------------------------------
  3242. */
  3243. var NAME$4 = 'dropdown';
  3244. var VERSION$4 = '4.4.1';
  3245. var DATA_KEY$4 = 'bs.dropdown';
  3246. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3247. var DATA_API_KEY$4 = '.data-api';
  3248. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3249. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3250. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3251. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3252. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3253. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3254. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3255. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3256. var Event$4 = {
  3257. HIDE: "hide" + EVENT_KEY$4,
  3258. HIDDEN: "hidden" + EVENT_KEY$4,
  3259. SHOW: "show" + EVENT_KEY$4,
  3260. SHOWN: "shown" + EVENT_KEY$4,
  3261. CLICK: "click" + EVENT_KEY$4,
  3262. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3263. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3264. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3265. };
  3266. var ClassName$4 = {
  3267. DISABLED: 'disabled',
  3268. SHOW: 'show',
  3269. DROPUP: 'dropup',
  3270. DROPRIGHT: 'dropright',
  3271. DROPLEFT: 'dropleft',
  3272. MENURIGHT: 'dropdown-menu-right',
  3273. MENULEFT: 'dropdown-menu-left',
  3274. POSITION_STATIC: 'position-static'
  3275. };
  3276. var Selector$4 = {
  3277. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3278. FORM_CHILD: '.dropdown form',
  3279. MENU: '.dropdown-menu',
  3280. NAVBAR_NAV: '.navbar-nav',
  3281. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3282. };
  3283. var AttachmentMap = {
  3284. TOP: 'top-start',
  3285. TOPEND: 'top-end',
  3286. BOTTOM: 'bottom-start',
  3287. BOTTOMEND: 'bottom-end',
  3288. RIGHT: 'right-start',
  3289. RIGHTEND: 'right-end',
  3290. LEFT: 'left-start',
  3291. LEFTEND: 'left-end'
  3292. };
  3293. var Default$2 = {
  3294. offset: 0,
  3295. flip: true,
  3296. boundary: 'scrollParent',
  3297. reference: 'toggle',
  3298. display: 'dynamic',
  3299. popperConfig: null
  3300. };
  3301. var DefaultType$2 = {
  3302. offset: '(number|string|function)',
  3303. flip: 'boolean',
  3304. boundary: '(string|element)',
  3305. reference: '(string|element)',
  3306. display: 'string',
  3307. popperConfig: '(null|object)'
  3308. };
  3309. /**
  3310. * ------------------------------------------------------------------------
  3311. * Class Definition
  3312. * ------------------------------------------------------------------------
  3313. */
  3314. var Dropdown =
  3315. /*#__PURE__*/
  3316. function () {
  3317. function Dropdown(element, config) {
  3318. this._element = element;
  3319. this._popper = null;
  3320. this._config = this._getConfig(config);
  3321. this._menu = this._getMenuElement();
  3322. this._inNavbar = this._detectNavbar();
  3323. this._addEventListeners();
  3324. } // Getters
  3325. var _proto = Dropdown.prototype;
  3326. // Public
  3327. _proto.toggle = function toggle() {
  3328. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3329. return;
  3330. }
  3331. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3332. Dropdown._clearMenus();
  3333. if (isActive) {
  3334. return;
  3335. }
  3336. this.show(true);
  3337. };
  3338. _proto.show = function show(usePopper) {
  3339. if (usePopper === void 0) {
  3340. usePopper = false;
  3341. }
  3342. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3343. return;
  3344. }
  3345. var relatedTarget = {
  3346. relatedTarget: this._element
  3347. };
  3348. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3349. var parent = Dropdown._getParentFromElement(this._element);
  3350. $(parent).trigger(showEvent);
  3351. if (showEvent.isDefaultPrevented()) {
  3352. return;
  3353. } // Disable totally Popper.js for Dropdown in Navbar
  3354. if (!this._inNavbar && usePopper) {
  3355. /**
  3356. * Check for Popper dependency
  3357. * Popper - https://popper.js.org
  3358. */
  3359. if (typeof Popper === 'undefined') {
  3360. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3361. }
  3362. var referenceElement = this._element;
  3363. if (this._config.reference === 'parent') {
  3364. referenceElement = parent;
  3365. } else if (Util.isElement(this._config.reference)) {
  3366. referenceElement = this._config.reference; // Check if it's jQuery element
  3367. if (typeof this._config.reference.jquery !== 'undefined') {
  3368. referenceElement = this._config.reference[0];
  3369. }
  3370. } // If boundary is not `scrollParent`, then set position to `static`
  3371. // to allow the menu to "escape" the scroll parent's boundaries
  3372. // https://github.com/twbs/bootstrap/issues/24251
  3373. if (this._config.boundary !== 'scrollParent') {
  3374. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3375. }
  3376. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3377. } // If this is a touch-enabled device we add extra
  3378. // empty mouseover listeners to the body's immediate children;
  3379. // only needed because of broken event delegation on iOS
  3380. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3381. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3382. $(document.body).children().on('mouseover', null, $.noop);
  3383. }
  3384. this._element.focus();
  3385. this._element.setAttribute('aria-expanded', true);
  3386. $(this._menu).toggleClass(ClassName$4.SHOW);
  3387. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3388. };
  3389. _proto.hide = function hide() {
  3390. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3391. return;
  3392. }
  3393. var relatedTarget = {
  3394. relatedTarget: this._element
  3395. };
  3396. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3397. var parent = Dropdown._getParentFromElement(this._element);
  3398. $(parent).trigger(hideEvent);
  3399. if (hideEvent.isDefaultPrevented()) {
  3400. return;
  3401. }
  3402. if (this._popper) {
  3403. this._popper.destroy();
  3404. }
  3405. $(this._menu).toggleClass(ClassName$4.SHOW);
  3406. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3407. };
  3408. _proto.dispose = function dispose() {
  3409. $.removeData(this._element, DATA_KEY$4);
  3410. $(this._element).off(EVENT_KEY$4);
  3411. this._element = null;
  3412. this._menu = null;
  3413. if (this._popper !== null) {
  3414. this._popper.destroy();
  3415. this._popper = null;
  3416. }
  3417. };
  3418. _proto.update = function update() {
  3419. this._inNavbar = this._detectNavbar();
  3420. if (this._popper !== null) {
  3421. this._popper.scheduleUpdate();
  3422. }
  3423. } // Private
  3424. ;
  3425. _proto._addEventListeners = function _addEventListeners() {
  3426. var _this = this;
  3427. $(this._element).on(Event$4.CLICK, function (event) {
  3428. event.preventDefault();
  3429. event.stopPropagation();
  3430. _this.toggle();
  3431. });
  3432. };
  3433. _proto._getConfig = function _getConfig(config) {
  3434. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3435. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3436. return config;
  3437. };
  3438. _proto._getMenuElement = function _getMenuElement() {
  3439. if (!this._menu) {
  3440. var parent = Dropdown._getParentFromElement(this._element);
  3441. if (parent) {
  3442. this._menu = parent.querySelector(Selector$4.MENU);
  3443. }
  3444. }
  3445. return this._menu;
  3446. };
  3447. _proto._getPlacement = function _getPlacement() {
  3448. var $parentDropdown = $(this._element.parentNode);
  3449. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3450. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3451. placement = AttachmentMap.TOP;
  3452. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3453. placement = AttachmentMap.TOPEND;
  3454. }
  3455. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3456. placement = AttachmentMap.RIGHT;
  3457. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3458. placement = AttachmentMap.LEFT;
  3459. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3460. placement = AttachmentMap.BOTTOMEND;
  3461. }
  3462. return placement;
  3463. };
  3464. _proto._detectNavbar = function _detectNavbar() {
  3465. return $(this._element).closest('.navbar').length > 0;
  3466. };
  3467. _proto._getOffset = function _getOffset() {
  3468. var _this2 = this;
  3469. var offset = {};
  3470. if (typeof this._config.offset === 'function') {
  3471. offset.fn = function (data) {
  3472. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3473. return data;
  3474. };
  3475. } else {
  3476. offset.offset = this._config.offset;
  3477. }
  3478. return offset;
  3479. };
  3480. _proto._getPopperConfig = function _getPopperConfig() {
  3481. var popperConfig = {
  3482. placement: this._getPlacement(),
  3483. modifiers: {
  3484. offset: this._getOffset(),
  3485. flip: {
  3486. enabled: this._config.flip
  3487. },
  3488. preventOverflow: {
  3489. boundariesElement: this._config.boundary
  3490. }
  3491. }
  3492. }; // Disable Popper.js if we have a static display
  3493. if (this._config.display === 'static') {
  3494. popperConfig.modifiers.applyStyle = {
  3495. enabled: false
  3496. };
  3497. }
  3498. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3499. } // Static
  3500. ;
  3501. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3502. return this.each(function () {
  3503. var data = $(this).data(DATA_KEY$4);
  3504. var _config = typeof config === 'object' ? config : null;
  3505. if (!data) {
  3506. data = new Dropdown(this, _config);
  3507. $(this).data(DATA_KEY$4, data);
  3508. }
  3509. if (typeof config === 'string') {
  3510. if (typeof data[config] === 'undefined') {
  3511. throw new TypeError("No method named \"" + config + "\"");
  3512. }
  3513. data[config]();
  3514. }
  3515. });
  3516. };
  3517. Dropdown._clearMenus = function _clearMenus(event) {
  3518. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3519. return;
  3520. }
  3521. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3522. for (var i = 0, len = toggles.length; i < len; i++) {
  3523. var parent = Dropdown._getParentFromElement(toggles[i]);
  3524. var context = $(toggles[i]).data(DATA_KEY$4);
  3525. var relatedTarget = {
  3526. relatedTarget: toggles[i]
  3527. };
  3528. if (event && event.type === 'click') {
  3529. relatedTarget.clickEvent = event;
  3530. }
  3531. if (!context) {
  3532. continue;
  3533. }
  3534. var dropdownMenu = context._menu;
  3535. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3536. continue;
  3537. }
  3538. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3539. continue;
  3540. }
  3541. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3542. $(parent).trigger(hideEvent);
  3543. if (hideEvent.isDefaultPrevented()) {
  3544. continue;
  3545. } // If this is a touch-enabled device we remove the extra
  3546. // empty mouseover listeners we added for iOS support
  3547. if ('ontouchstart' in document.documentElement) {
  3548. $(document.body).children().off('mouseover', null, $.noop);
  3549. }
  3550. toggles[i].setAttribute('aria-expanded', 'false');
  3551. if (context._popper) {
  3552. context._popper.destroy();
  3553. }
  3554. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3555. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3556. }
  3557. };
  3558. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3559. var parent;
  3560. var selector = Util.getSelectorFromElement(element);
  3561. if (selector) {
  3562. parent = document.querySelector(selector);
  3563. }
  3564. return parent || element.parentNode;
  3565. } // eslint-disable-next-line complexity
  3566. ;
  3567. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3568. // If not input/textarea:
  3569. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3570. // If input/textarea:
  3571. // - If space key => not a dropdown command
  3572. // - If key is other than escape
  3573. // - If key is not up or down => not a dropdown command
  3574. // - If trigger inside the menu => not a dropdown command
  3575. 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)) {
  3576. return;
  3577. }
  3578. event.preventDefault();
  3579. event.stopPropagation();
  3580. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3581. return;
  3582. }
  3583. var parent = Dropdown._getParentFromElement(this);
  3584. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3585. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3586. return;
  3587. }
  3588. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3589. if (event.which === ESCAPE_KEYCODE) {
  3590. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3591. $(toggle).trigger('focus');
  3592. }
  3593. $(this).trigger('click');
  3594. return;
  3595. }
  3596. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3597. return $(item).is(':visible');
  3598. });
  3599. if (items.length === 0) {
  3600. return;
  3601. }
  3602. var index = items.indexOf(event.target);
  3603. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3604. // Up
  3605. index--;
  3606. }
  3607. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3608. // Down
  3609. index++;
  3610. }
  3611. if (index < 0) {
  3612. index = 0;
  3613. }
  3614. items[index].focus();
  3615. };
  3616. _createClass(Dropdown, null, [{
  3617. key: "VERSION",
  3618. get: function get() {
  3619. return VERSION$4;
  3620. }
  3621. }, {
  3622. key: "Default",
  3623. get: function get() {
  3624. return Default$2;
  3625. }
  3626. }, {
  3627. key: "DefaultType",
  3628. get: function get() {
  3629. return DefaultType$2;
  3630. }
  3631. }]);
  3632. return Dropdown;
  3633. }();
  3634. /**
  3635. * ------------------------------------------------------------------------
  3636. * Data Api implementation
  3637. * ------------------------------------------------------------------------
  3638. */
  3639. $(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) {
  3640. event.preventDefault();
  3641. event.stopPropagation();
  3642. Dropdown._jQueryInterface.call($(this), 'toggle');
  3643. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3644. e.stopPropagation();
  3645. });
  3646. /**
  3647. * ------------------------------------------------------------------------
  3648. * jQuery
  3649. * ------------------------------------------------------------------------
  3650. */
  3651. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3652. $.fn[NAME$4].Constructor = Dropdown;
  3653. $.fn[NAME$4].noConflict = function () {
  3654. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3655. return Dropdown._jQueryInterface;
  3656. };
  3657. /**
  3658. * ------------------------------------------------------------------------
  3659. * Constants
  3660. * ------------------------------------------------------------------------
  3661. */
  3662. var NAME$5 = 'modal';
  3663. var VERSION$5 = '4.4.1';
  3664. var DATA_KEY$5 = 'bs.modal';
  3665. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3666. var DATA_API_KEY$5 = '.data-api';
  3667. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3668. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3669. var Default$3 = {
  3670. backdrop: true,
  3671. keyboard: true,
  3672. focus: true,
  3673. show: true
  3674. };
  3675. var DefaultType$3 = {
  3676. backdrop: '(boolean|string)',
  3677. keyboard: 'boolean',
  3678. focus: 'boolean',
  3679. show: 'boolean'
  3680. };
  3681. var Event$5 = {
  3682. HIDE: "hide" + EVENT_KEY$5,
  3683. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3684. HIDDEN: "hidden" + EVENT_KEY$5,
  3685. SHOW: "show" + EVENT_KEY$5,
  3686. SHOWN: "shown" + EVENT_KEY$5,
  3687. FOCUSIN: "focusin" + EVENT_KEY$5,
  3688. RESIZE: "resize" + EVENT_KEY$5,
  3689. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3690. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3691. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3692. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3693. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3694. };
  3695. var ClassName$5 = {
  3696. SCROLLABLE: 'modal-dialog-scrollable',
  3697. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3698. BACKDROP: 'modal-backdrop',
  3699. OPEN: 'modal-open',
  3700. FADE: 'fade',
  3701. SHOW: 'show',
  3702. STATIC: 'modal-static'
  3703. };
  3704. var Selector$5 = {
  3705. DIALOG: '.modal-dialog',
  3706. MODAL_BODY: '.modal-body',
  3707. DATA_TOGGLE: '[data-toggle="modal"]',
  3708. DATA_DISMISS: '[data-dismiss="modal"]',
  3709. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3710. STICKY_CONTENT: '.sticky-top'
  3711. };
  3712. /**
  3713. * ------------------------------------------------------------------------
  3714. * Class Definition
  3715. * ------------------------------------------------------------------------
  3716. */
  3717. var Modal =
  3718. /*#__PURE__*/
  3719. function () {
  3720. function Modal(element, config) {
  3721. this._config = this._getConfig(config);
  3722. this._element = element;
  3723. this._dialog = element.querySelector(Selector$5.DIALOG);
  3724. this._backdrop = null;
  3725. this._isShown = false;
  3726. this._isBodyOverflowing = false;
  3727. this._ignoreBackdropClick = false;
  3728. this._isTransitioning = false;
  3729. this._scrollbarWidth = 0;
  3730. } // Getters
  3731. var _proto = Modal.prototype;
  3732. // Public
  3733. _proto.toggle = function toggle(relatedTarget) {
  3734. return this._isShown ? this.hide() : this.show(relatedTarget);
  3735. };
  3736. _proto.show = function show(relatedTarget) {
  3737. var _this = this;
  3738. if (this._isShown || this._isTransitioning) {
  3739. return;
  3740. }
  3741. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3742. this._isTransitioning = true;
  3743. }
  3744. var showEvent = $.Event(Event$5.SHOW, {
  3745. relatedTarget: relatedTarget
  3746. });
  3747. $(this._element).trigger(showEvent);
  3748. if (this._isShown || showEvent.isDefaultPrevented()) {
  3749. return;
  3750. }
  3751. this._isShown = true;
  3752. this._checkScrollbar();
  3753. this._setScrollbar();
  3754. this._adjustDialog();
  3755. this._setEscapeEvent();
  3756. this._setResizeEvent();
  3757. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3758. return _this.hide(event);
  3759. });
  3760. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3761. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3762. if ($(event.target).is(_this._element)) {
  3763. _this._ignoreBackdropClick = true;
  3764. }
  3765. });
  3766. });
  3767. this._showBackdrop(function () {
  3768. return _this._showElement(relatedTarget);
  3769. });
  3770. };
  3771. _proto.hide = function hide(event) {
  3772. var _this2 = this;
  3773. if (event) {
  3774. event.preventDefault();
  3775. }
  3776. if (!this._isShown || this._isTransitioning) {
  3777. return;
  3778. }
  3779. var hideEvent = $.Event(Event$5.HIDE);
  3780. $(this._element).trigger(hideEvent);
  3781. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3782. return;
  3783. }
  3784. this._isShown = false;
  3785. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3786. if (transition) {
  3787. this._isTransitioning = true;
  3788. }
  3789. this._setEscapeEvent();
  3790. this._setResizeEvent();
  3791. $(document).off(Event$5.FOCUSIN);
  3792. $(this._element).removeClass(ClassName$5.SHOW);
  3793. $(this._element).off(Event$5.CLICK_DISMISS);
  3794. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3795. if (transition) {
  3796. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3797. $(this._element).one(Util.TRANSITION_END, function (event) {
  3798. return _this2._hideModal(event);
  3799. }).emulateTransitionEnd(transitionDuration);
  3800. } else {
  3801. this._hideModal();
  3802. }
  3803. };
  3804. _proto.dispose = function dispose() {
  3805. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3806. return $(htmlElement).off(EVENT_KEY$5);
  3807. });
  3808. /**
  3809. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3810. * Do not move `document` in `htmlElements` array
  3811. * It will remove `Event.CLICK_DATA_API` event that should remain
  3812. */
  3813. $(document).off(Event$5.FOCUSIN);
  3814. $.removeData(this._element, DATA_KEY$5);
  3815. this._config = null;
  3816. this._element = null;
  3817. this._dialog = null;
  3818. this._backdrop = null;
  3819. this._isShown = null;
  3820. this._isBodyOverflowing = null;
  3821. this._ignoreBackdropClick = null;
  3822. this._isTransitioning = null;
  3823. this._scrollbarWidth = null;
  3824. };
  3825. _proto.handleUpdate = function handleUpdate() {
  3826. this._adjustDialog();
  3827. } // Private
  3828. ;
  3829. _proto._getConfig = function _getConfig(config) {
  3830. config = _objectSpread2({}, Default$3, {}, config);
  3831. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3832. return config;
  3833. };
  3834. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3835. var _this3 = this;
  3836. if (this._config.backdrop === 'static') {
  3837. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3838. $(this._element).trigger(hideEventPrevented);
  3839. if (hideEventPrevented.defaultPrevented) {
  3840. return;
  3841. }
  3842. this._element.classList.add(ClassName$5.STATIC);
  3843. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3844. $(this._element).one(Util.TRANSITION_END, function () {
  3845. _this3._element.classList.remove(ClassName$5.STATIC);
  3846. }).emulateTransitionEnd(modalTransitionDuration);
  3847. this._element.focus();
  3848. } else {
  3849. this.hide();
  3850. }
  3851. };
  3852. _proto._showElement = function _showElement(relatedTarget) {
  3853. var _this4 = this;
  3854. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3855. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3856. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3857. // Don't move modal's DOM position
  3858. document.body.appendChild(this._element);
  3859. }
  3860. this._element.style.display = 'block';
  3861. this._element.removeAttribute('aria-hidden');
  3862. this._element.setAttribute('aria-modal', true);
  3863. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3864. modalBody.scrollTop = 0;
  3865. } else {
  3866. this._element.scrollTop = 0;
  3867. }
  3868. if (transition) {
  3869. Util.reflow(this._element);
  3870. }
  3871. $(this._element).addClass(ClassName$5.SHOW);
  3872. if (this._config.focus) {
  3873. this._enforceFocus();
  3874. }
  3875. var shownEvent = $.Event(Event$5.SHOWN, {
  3876. relatedTarget: relatedTarget
  3877. });
  3878. var transitionComplete = function transitionComplete() {
  3879. if (_this4._config.focus) {
  3880. _this4._element.focus();
  3881. }
  3882. _this4._isTransitioning = false;
  3883. $(_this4._element).trigger(shownEvent);
  3884. };
  3885. if (transition) {
  3886. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3887. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3888. } else {
  3889. transitionComplete();
  3890. }
  3891. };
  3892. _proto._enforceFocus = function _enforceFocus() {
  3893. var _this5 = this;
  3894. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3895. .on(Event$5.FOCUSIN, function (event) {
  3896. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3897. _this5._element.focus();
  3898. }
  3899. });
  3900. };
  3901. _proto._setEscapeEvent = function _setEscapeEvent() {
  3902. var _this6 = this;
  3903. if (this._isShown && this._config.keyboard) {
  3904. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3905. if (event.which === ESCAPE_KEYCODE$1) {
  3906. _this6._triggerBackdropTransition();
  3907. }
  3908. });
  3909. } else if (!this._isShown) {
  3910. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3911. }
  3912. };
  3913. _proto._setResizeEvent = function _setResizeEvent() {
  3914. var _this7 = this;
  3915. if (this._isShown) {
  3916. $(window).on(Event$5.RESIZE, function (event) {
  3917. return _this7.handleUpdate(event);
  3918. });
  3919. } else {
  3920. $(window).off(Event$5.RESIZE);
  3921. }
  3922. };
  3923. _proto._hideModal = function _hideModal() {
  3924. var _this8 = this;
  3925. this._element.style.display = 'none';
  3926. this._element.setAttribute('aria-hidden', true);
  3927. this._element.removeAttribute('aria-modal');
  3928. this._isTransitioning = false;
  3929. this._showBackdrop(function () {
  3930. $(document.body).removeClass(ClassName$5.OPEN);
  3931. _this8._resetAdjustments();
  3932. _this8._resetScrollbar();
  3933. $(_this8._element).trigger(Event$5.HIDDEN);
  3934. });
  3935. };
  3936. _proto._removeBackdrop = function _removeBackdrop() {
  3937. if (this._backdrop) {
  3938. $(this._backdrop).remove();
  3939. this._backdrop = null;
  3940. }
  3941. };
  3942. _proto._showBackdrop = function _showBackdrop(callback) {
  3943. var _this9 = this;
  3944. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3945. if (this._isShown && this._config.backdrop) {
  3946. this._backdrop = document.createElement('div');
  3947. this._backdrop.className = ClassName$5.BACKDROP;
  3948. if (animate) {
  3949. this._backdrop.classList.add(animate);
  3950. }
  3951. $(this._backdrop).appendTo(document.body);
  3952. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3953. if (_this9._ignoreBackdropClick) {
  3954. _this9._ignoreBackdropClick = false;
  3955. return;
  3956. }
  3957. if (event.target !== event.currentTarget) {
  3958. return;
  3959. }
  3960. _this9._triggerBackdropTransition();
  3961. });
  3962. if (animate) {
  3963. Util.reflow(this._backdrop);
  3964. }
  3965. $(this._backdrop).addClass(ClassName$5.SHOW);
  3966. if (!callback) {
  3967. return;
  3968. }
  3969. if (!animate) {
  3970. callback();
  3971. return;
  3972. }
  3973. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3974. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3975. } else if (!this._isShown && this._backdrop) {
  3976. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3977. var callbackRemove = function callbackRemove() {
  3978. _this9._removeBackdrop();
  3979. if (callback) {
  3980. callback();
  3981. }
  3982. };
  3983. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3984. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3985. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3986. } else {
  3987. callbackRemove();
  3988. }
  3989. } else if (callback) {
  3990. callback();
  3991. }
  3992. } // ----------------------------------------------------------------------
  3993. // the following methods are used to handle overflowing modals
  3994. // todo (fat): these should probably be refactored out of modal.js
  3995. // ----------------------------------------------------------------------
  3996. ;
  3997. _proto._adjustDialog = function _adjustDialog() {
  3998. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3999. if (!this._isBodyOverflowing && isModalOverflowing) {
  4000. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  4001. }
  4002. if (this._isBodyOverflowing && !isModalOverflowing) {
  4003. this._element.style.paddingRight = this._scrollbarWidth + "px";
  4004. }
  4005. };
  4006. _proto._resetAdjustments = function _resetAdjustments() {
  4007. this._element.style.paddingLeft = '';
  4008. this._element.style.paddingRight = '';
  4009. };
  4010. _proto._checkScrollbar = function _checkScrollbar() {
  4011. var rect = document.body.getBoundingClientRect();
  4012. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  4013. this._scrollbarWidth = this._getScrollbarWidth();
  4014. };
  4015. _proto._setScrollbar = function _setScrollbar() {
  4016. var _this10 = this;
  4017. if (this._isBodyOverflowing) {
  4018. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  4019. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  4020. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4021. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  4022. $(fixedContent).each(function (index, element) {
  4023. var actualPadding = element.style.paddingRight;
  4024. var calculatedPadding = $(element).css('padding-right');
  4025. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  4026. }); // Adjust sticky content margin
  4027. $(stickyContent).each(function (index, element) {
  4028. var actualMargin = element.style.marginRight;
  4029. var calculatedMargin = $(element).css('margin-right');
  4030. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  4031. }); // Adjust body padding
  4032. var actualPadding = document.body.style.paddingRight;
  4033. var calculatedPadding = $(document.body).css('padding-right');
  4034. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  4035. }
  4036. $(document.body).addClass(ClassName$5.OPEN);
  4037. };
  4038. _proto._resetScrollbar = function _resetScrollbar() {
  4039. // Restore fixed content padding
  4040. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4041. $(fixedContent).each(function (index, element) {
  4042. var padding = $(element).data('padding-right');
  4043. $(element).removeData('padding-right');
  4044. element.style.paddingRight = padding ? padding : '';
  4045. }); // Restore sticky content
  4046. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  4047. $(elements).each(function (index, element) {
  4048. var margin = $(element).data('margin-right');
  4049. if (typeof margin !== 'undefined') {
  4050. $(element).css('margin-right', margin).removeData('margin-right');
  4051. }
  4052. }); // Restore body padding
  4053. var padding = $(document.body).data('padding-right');
  4054. $(document.body).removeData('padding-right');
  4055. document.body.style.paddingRight = padding ? padding : '';
  4056. };
  4057. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4058. // thx d.walsh
  4059. var scrollDiv = document.createElement('div');
  4060. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  4061. document.body.appendChild(scrollDiv);
  4062. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4063. document.body.removeChild(scrollDiv);
  4064. return scrollbarWidth;
  4065. } // Static
  4066. ;
  4067. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4068. return this.each(function () {
  4069. var data = $(this).data(DATA_KEY$5);
  4070. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  4071. if (!data) {
  4072. data = new Modal(this, _config);
  4073. $(this).data(DATA_KEY$5, data);
  4074. }
  4075. if (typeof config === 'string') {
  4076. if (typeof data[config] === 'undefined') {
  4077. throw new TypeError("No method named \"" + config + "\"");
  4078. }
  4079. data[config](relatedTarget);
  4080. } else if (_config.show) {
  4081. data.show(relatedTarget);
  4082. }
  4083. });
  4084. };
  4085. _createClass(Modal, null, [{
  4086. key: "VERSION",
  4087. get: function get() {
  4088. return VERSION$5;
  4089. }
  4090. }, {
  4091. key: "Default",
  4092. get: function get() {
  4093. return Default$3;
  4094. }
  4095. }]);
  4096. return Modal;
  4097. }();
  4098. /**
  4099. * ------------------------------------------------------------------------
  4100. * Data Api implementation
  4101. * ------------------------------------------------------------------------
  4102. */
  4103. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4104. var _this11 = this;
  4105. var target;
  4106. var selector = Util.getSelectorFromElement(this);
  4107. if (selector) {
  4108. target = document.querySelector(selector);
  4109. }
  4110. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4111. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4112. event.preventDefault();
  4113. }
  4114. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4115. if (showEvent.isDefaultPrevented()) {
  4116. // Only register focus restorer if modal will actually get shown
  4117. return;
  4118. }
  4119. $target.one(Event$5.HIDDEN, function () {
  4120. if ($(_this11).is(':visible')) {
  4121. _this11.focus();
  4122. }
  4123. });
  4124. });
  4125. Modal._jQueryInterface.call($(target), config, this);
  4126. });
  4127. /**
  4128. * ------------------------------------------------------------------------
  4129. * jQuery
  4130. * ------------------------------------------------------------------------
  4131. */
  4132. $.fn[NAME$5] = Modal._jQueryInterface;
  4133. $.fn[NAME$5].Constructor = Modal;
  4134. $.fn[NAME$5].noConflict = function () {
  4135. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4136. return Modal._jQueryInterface;
  4137. };
  4138. /**
  4139. * --------------------------------------------------------------------------
  4140. * Bootstrap (v4.4.1): tools/sanitizer.js
  4141. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4142. * --------------------------------------------------------------------------
  4143. */
  4144. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4145. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4146. var DefaultWhitelist = {
  4147. // Global attributes allowed on any supplied element below.
  4148. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4149. a: ['target', 'href', 'title', 'rel'],
  4150. area: [],
  4151. b: [],
  4152. br: [],
  4153. col: [],
  4154. code: [],
  4155. div: [],
  4156. em: [],
  4157. hr: [],
  4158. h1: [],
  4159. h2: [],
  4160. h3: [],
  4161. h4: [],
  4162. h5: [],
  4163. h6: [],
  4164. i: [],
  4165. img: ['src', 'alt', 'title', 'width', 'height'],
  4166. li: [],
  4167. ol: [],
  4168. p: [],
  4169. pre: [],
  4170. s: [],
  4171. small: [],
  4172. span: [],
  4173. sub: [],
  4174. sup: [],
  4175. strong: [],
  4176. u: [],
  4177. ul: []
  4178. };
  4179. /**
  4180. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4181. *
  4182. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4183. */
  4184. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4185. /**
  4186. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4187. *
  4188. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4189. */
  4190. 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;
  4191. function allowedAttribute(attr, allowedAttributeList) {
  4192. var attrName = attr.nodeName.toLowerCase();
  4193. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4194. if (uriAttrs.indexOf(attrName) !== -1) {
  4195. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4196. }
  4197. return true;
  4198. }
  4199. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4200. return attrRegex instanceof RegExp;
  4201. }); // Check if a regular expression validates the attribute.
  4202. for (var i = 0, l = regExp.length; i < l; i++) {
  4203. if (attrName.match(regExp[i])) {
  4204. return true;
  4205. }
  4206. }
  4207. return false;
  4208. }
  4209. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4210. if (unsafeHtml.length === 0) {
  4211. return unsafeHtml;
  4212. }
  4213. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4214. return sanitizeFn(unsafeHtml);
  4215. }
  4216. var domParser = new window.DOMParser();
  4217. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4218. var whitelistKeys = Object.keys(whiteList);
  4219. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4220. var _loop = function _loop(i, len) {
  4221. var el = elements[i];
  4222. var elName = el.nodeName.toLowerCase();
  4223. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4224. el.parentNode.removeChild(el);
  4225. return "continue";
  4226. }
  4227. var attributeList = [].slice.call(el.attributes);
  4228. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4229. attributeList.forEach(function (attr) {
  4230. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4231. el.removeAttribute(attr.nodeName);
  4232. }
  4233. });
  4234. };
  4235. for (var i = 0, len = elements.length; i < len; i++) {
  4236. var _ret = _loop(i);
  4237. if (_ret === "continue") continue;
  4238. }
  4239. return createdDocument.body.innerHTML;
  4240. }
  4241. /**
  4242. * ------------------------------------------------------------------------
  4243. * Constants
  4244. * ------------------------------------------------------------------------
  4245. */
  4246. var NAME$6 = 'tooltip';
  4247. var VERSION$6 = '4.4.1';
  4248. var DATA_KEY$6 = 'bs.tooltip';
  4249. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4250. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4251. var CLASS_PREFIX = 'bs-tooltip';
  4252. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4253. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4254. var DefaultType$4 = {
  4255. animation: 'boolean',
  4256. template: 'string',
  4257. title: '(string|element|function)',
  4258. trigger: 'string',
  4259. delay: '(number|object)',
  4260. html: 'boolean',
  4261. selector: '(string|boolean)',
  4262. placement: '(string|function)',
  4263. offset: '(number|string|function)',
  4264. container: '(string|element|boolean)',
  4265. fallbackPlacement: '(string|array)',
  4266. boundary: '(string|element)',
  4267. sanitize: 'boolean',
  4268. sanitizeFn: '(null|function)',
  4269. whiteList: 'object',
  4270. popperConfig: '(null|object)'
  4271. };
  4272. var AttachmentMap$1 = {
  4273. AUTO: 'auto',
  4274. TOP: 'top',
  4275. RIGHT: 'right',
  4276. BOTTOM: 'bottom',
  4277. LEFT: 'left'
  4278. };
  4279. var Default$4 = {
  4280. animation: true,
  4281. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4282. trigger: 'hover focus',
  4283. title: '',
  4284. delay: 0,
  4285. html: false,
  4286. selector: false,
  4287. placement: 'top',
  4288. offset: 0,
  4289. container: false,
  4290. fallbackPlacement: 'flip',
  4291. boundary: 'scrollParent',
  4292. sanitize: true,
  4293. sanitizeFn: null,
  4294. whiteList: DefaultWhitelist,
  4295. popperConfig: null
  4296. };
  4297. var HoverState = {
  4298. SHOW: 'show',
  4299. OUT: 'out'
  4300. };
  4301. var Event$6 = {
  4302. HIDE: "hide" + EVENT_KEY$6,
  4303. HIDDEN: "hidden" + EVENT_KEY$6,
  4304. SHOW: "show" + EVENT_KEY$6,
  4305. SHOWN: "shown" + EVENT_KEY$6,
  4306. INSERTED: "inserted" + EVENT_KEY$6,
  4307. CLICK: "click" + EVENT_KEY$6,
  4308. FOCUSIN: "focusin" + EVENT_KEY$6,
  4309. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4310. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4311. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4312. };
  4313. var ClassName$6 = {
  4314. FADE: 'fade',
  4315. SHOW: 'show'
  4316. };
  4317. var Selector$6 = {
  4318. TOOLTIP: '.tooltip',
  4319. TOOLTIP_INNER: '.tooltip-inner',
  4320. ARROW: '.arrow'
  4321. };
  4322. var Trigger = {
  4323. HOVER: 'hover',
  4324. FOCUS: 'focus',
  4325. CLICK: 'click',
  4326. MANUAL: 'manual'
  4327. };
  4328. /**
  4329. * ------------------------------------------------------------------------
  4330. * Class Definition
  4331. * ------------------------------------------------------------------------
  4332. */
  4333. var Tooltip =
  4334. /*#__PURE__*/
  4335. function () {
  4336. function Tooltip(element, config) {
  4337. if (typeof Popper === 'undefined') {
  4338. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4339. } // private
  4340. this._isEnabled = true;
  4341. this._timeout = 0;
  4342. this._hoverState = '';
  4343. this._activeTrigger = {};
  4344. this._popper = null; // Protected
  4345. this.element = element;
  4346. this.config = this._getConfig(config);
  4347. this.tip = null;
  4348. this._setListeners();
  4349. } // Getters
  4350. var _proto = Tooltip.prototype;
  4351. // Public
  4352. _proto.enable = function enable() {
  4353. this._isEnabled = true;
  4354. };
  4355. _proto.disable = function disable() {
  4356. this._isEnabled = false;
  4357. };
  4358. _proto.toggleEnabled = function toggleEnabled() {
  4359. this._isEnabled = !this._isEnabled;
  4360. };
  4361. _proto.toggle = function toggle(event) {
  4362. if (!this._isEnabled) {
  4363. return;
  4364. }
  4365. if (event) {
  4366. var dataKey = this.constructor.DATA_KEY;
  4367. var context = $(event.currentTarget).data(dataKey);
  4368. if (!context) {
  4369. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4370. $(event.currentTarget).data(dataKey, context);
  4371. }
  4372. context._activeTrigger.click = !context._activeTrigger.click;
  4373. if (context._isWithActiveTrigger()) {
  4374. context._enter(null, context);
  4375. } else {
  4376. context._leave(null, context);
  4377. }
  4378. } else {
  4379. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4380. this._leave(null, this);
  4381. return;
  4382. }
  4383. this._enter(null, this);
  4384. }
  4385. };
  4386. _proto.dispose = function dispose() {
  4387. clearTimeout(this._timeout);
  4388. $.removeData(this.element, this.constructor.DATA_KEY);
  4389. $(this.element).off(this.constructor.EVENT_KEY);
  4390. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4391. if (this.tip) {
  4392. $(this.tip).remove();
  4393. }
  4394. this._isEnabled = null;
  4395. this._timeout = null;
  4396. this._hoverState = null;
  4397. this._activeTrigger = null;
  4398. if (this._popper) {
  4399. this._popper.destroy();
  4400. }
  4401. this._popper = null;
  4402. this.element = null;
  4403. this.config = null;
  4404. this.tip = null;
  4405. };
  4406. _proto.show = function show() {
  4407. var _this = this;
  4408. if ($(this.element).css('display') === 'none') {
  4409. throw new Error('Please use show on visible elements');
  4410. }
  4411. var showEvent = $.Event(this.constructor.Event.SHOW);
  4412. if (this.isWithContent() && this._isEnabled) {
  4413. $(this.element).trigger(showEvent);
  4414. var shadowRoot = Util.findShadowRoot(this.element);
  4415. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4416. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4417. return;
  4418. }
  4419. var tip = this.getTipElement();
  4420. var tipId = Util.getUID(this.constructor.NAME);
  4421. tip.setAttribute('id', tipId);
  4422. this.element.setAttribute('aria-describedby', tipId);
  4423. this.setContent();
  4424. if (this.config.animation) {
  4425. $(tip).addClass(ClassName$6.FADE);
  4426. }
  4427. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4428. var attachment = this._getAttachment(placement);
  4429. this.addAttachmentClass(attachment);
  4430. var container = this._getContainer();
  4431. $(tip).data(this.constructor.DATA_KEY, this);
  4432. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4433. $(tip).appendTo(container);
  4434. }
  4435. $(this.element).trigger(this.constructor.Event.INSERTED);
  4436. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4437. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4438. // empty mouseover listeners to the body's immediate children;
  4439. // only needed because of broken event delegation on iOS
  4440. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4441. if ('ontouchstart' in document.documentElement) {
  4442. $(document.body).children().on('mouseover', null, $.noop);
  4443. }
  4444. var complete = function complete() {
  4445. if (_this.config.animation) {
  4446. _this._fixTransition();
  4447. }
  4448. var prevHoverState = _this._hoverState;
  4449. _this._hoverState = null;
  4450. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4451. if (prevHoverState === HoverState.OUT) {
  4452. _this._leave(null, _this);
  4453. }
  4454. };
  4455. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4456. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4457. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4458. } else {
  4459. complete();
  4460. }
  4461. }
  4462. };
  4463. _proto.hide = function hide(callback) {
  4464. var _this2 = this;
  4465. var tip = this.getTipElement();
  4466. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4467. var complete = function complete() {
  4468. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4469. tip.parentNode.removeChild(tip);
  4470. }
  4471. _this2._cleanTipClass();
  4472. _this2.element.removeAttribute('aria-describedby');
  4473. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4474. if (_this2._popper !== null) {
  4475. _this2._popper.destroy();
  4476. }
  4477. if (callback) {
  4478. callback();
  4479. }
  4480. };
  4481. $(this.element).trigger(hideEvent);
  4482. if (hideEvent.isDefaultPrevented()) {
  4483. return;
  4484. }
  4485. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4486. // empty mouseover listeners we added for iOS support
  4487. if ('ontouchstart' in document.documentElement) {
  4488. $(document.body).children().off('mouseover', null, $.noop);
  4489. }
  4490. this._activeTrigger[Trigger.CLICK] = false;
  4491. this._activeTrigger[Trigger.FOCUS] = false;
  4492. this._activeTrigger[Trigger.HOVER] = false;
  4493. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4494. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4495. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4496. } else {
  4497. complete();
  4498. }
  4499. this._hoverState = '';
  4500. };
  4501. _proto.update = function update() {
  4502. if (this._popper !== null) {
  4503. this._popper.scheduleUpdate();
  4504. }
  4505. } // Protected
  4506. ;
  4507. _proto.isWithContent = function isWithContent() {
  4508. return Boolean(this.getTitle());
  4509. };
  4510. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4511. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4512. };
  4513. _proto.getTipElement = function getTipElement() {
  4514. this.tip = this.tip || $(this.config.template)[0];
  4515. return this.tip;
  4516. };
  4517. _proto.setContent = function setContent() {
  4518. var tip = this.getTipElement();
  4519. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4520. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4521. };
  4522. _proto.setElementContent = function setElementContent($element, content) {
  4523. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4524. // Content is a DOM node or a jQuery
  4525. if (this.config.html) {
  4526. if (!$(content).parent().is($element)) {
  4527. $element.empty().append(content);
  4528. }
  4529. } else {
  4530. $element.text($(content).text());
  4531. }
  4532. return;
  4533. }
  4534. if (this.config.html) {
  4535. if (this.config.sanitize) {
  4536. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4537. }
  4538. $element.html(content);
  4539. } else {
  4540. $element.text(content);
  4541. }
  4542. };
  4543. _proto.getTitle = function getTitle() {
  4544. var title = this.element.getAttribute('data-original-title');
  4545. if (!title) {
  4546. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4547. }
  4548. return title;
  4549. } // Private
  4550. ;
  4551. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4552. var _this3 = this;
  4553. var defaultBsConfig = {
  4554. placement: attachment,
  4555. modifiers: {
  4556. offset: this._getOffset(),
  4557. flip: {
  4558. behavior: this.config.fallbackPlacement
  4559. },
  4560. arrow: {
  4561. element: Selector$6.ARROW
  4562. },
  4563. preventOverflow: {
  4564. boundariesElement: this.config.boundary
  4565. }
  4566. },
  4567. onCreate: function onCreate(data) {
  4568. if (data.originalPlacement !== data.placement) {
  4569. _this3._handlePopperPlacementChange(data);
  4570. }
  4571. },
  4572. onUpdate: function onUpdate(data) {
  4573. return _this3._handlePopperPlacementChange(data);
  4574. }
  4575. };
  4576. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4577. };
  4578. _proto._getOffset = function _getOffset() {
  4579. var _this4 = this;
  4580. var offset = {};
  4581. if (typeof this.config.offset === 'function') {
  4582. offset.fn = function (data) {
  4583. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4584. return data;
  4585. };
  4586. } else {
  4587. offset.offset = this.config.offset;
  4588. }
  4589. return offset;
  4590. };
  4591. _proto._getContainer = function _getContainer() {
  4592. if (this.config.container === false) {
  4593. return document.body;
  4594. }
  4595. if (Util.isElement(this.config.container)) {
  4596. return $(this.config.container);
  4597. }
  4598. return $(document).find(this.config.container);
  4599. };
  4600. _proto._getAttachment = function _getAttachment(placement) {
  4601. return AttachmentMap$1[placement.toUpperCase()];
  4602. };
  4603. _proto._setListeners = function _setListeners() {
  4604. var _this5 = this;
  4605. var triggers = this.config.trigger.split(' ');
  4606. triggers.forEach(function (trigger) {
  4607. if (trigger === 'click') {
  4608. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4609. return _this5.toggle(event);
  4610. });
  4611. } else if (trigger !== Trigger.MANUAL) {
  4612. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4613. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4614. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4615. return _this5._enter(event);
  4616. }).on(eventOut, _this5.config.selector, function (event) {
  4617. return _this5._leave(event);
  4618. });
  4619. }
  4620. });
  4621. this._hideModalHandler = function () {
  4622. if (_this5.element) {
  4623. _this5.hide();
  4624. }
  4625. };
  4626. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4627. if (this.config.selector) {
  4628. this.config = _objectSpread2({}, this.config, {
  4629. trigger: 'manual',
  4630. selector: ''
  4631. });
  4632. } else {
  4633. this._fixTitle();
  4634. }
  4635. };
  4636. _proto._fixTitle = function _fixTitle() {
  4637. var titleType = typeof this.element.getAttribute('data-original-title');
  4638. if (this.element.getAttribute('title') || titleType !== 'string') {
  4639. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4640. this.element.setAttribute('title', '');
  4641. }
  4642. };
  4643. _proto._enter = function _enter(event, context) {
  4644. var dataKey = this.constructor.DATA_KEY;
  4645. context = context || $(event.currentTarget).data(dataKey);
  4646. if (!context) {
  4647. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4648. $(event.currentTarget).data(dataKey, context);
  4649. }
  4650. if (event) {
  4651. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4652. }
  4653. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4654. context._hoverState = HoverState.SHOW;
  4655. return;
  4656. }
  4657. clearTimeout(context._timeout);
  4658. context._hoverState = HoverState.SHOW;
  4659. if (!context.config.delay || !context.config.delay.show) {
  4660. context.show();
  4661. return;
  4662. }
  4663. context._timeout = setTimeout(function () {
  4664. if (context._hoverState === HoverState.SHOW) {
  4665. context.show();
  4666. }
  4667. }, context.config.delay.show);
  4668. };
  4669. _proto._leave = function _leave(event, context) {
  4670. var dataKey = this.constructor.DATA_KEY;
  4671. context = context || $(event.currentTarget).data(dataKey);
  4672. if (!context) {
  4673. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4674. $(event.currentTarget).data(dataKey, context);
  4675. }
  4676. if (event) {
  4677. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4678. }
  4679. if (context._isWithActiveTrigger()) {
  4680. return;
  4681. }
  4682. clearTimeout(context._timeout);
  4683. context._hoverState = HoverState.OUT;
  4684. if (!context.config.delay || !context.config.delay.hide) {
  4685. context.hide();
  4686. return;
  4687. }
  4688. context._timeout = setTimeout(function () {
  4689. if (context._hoverState === HoverState.OUT) {
  4690. context.hide();
  4691. }
  4692. }, context.config.delay.hide);
  4693. };
  4694. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4695. for (var trigger in this._activeTrigger) {
  4696. if (this._activeTrigger[trigger]) {
  4697. return true;
  4698. }
  4699. }
  4700. return false;
  4701. };
  4702. _proto._getConfig = function _getConfig(config) {
  4703. var dataAttributes = $(this.element).data();
  4704. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4705. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4706. delete dataAttributes[dataAttr];
  4707. }
  4708. });
  4709. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4710. if (typeof config.delay === 'number') {
  4711. config.delay = {
  4712. show: config.delay,
  4713. hide: config.delay
  4714. };
  4715. }
  4716. if (typeof config.title === 'number') {
  4717. config.title = config.title.toString();
  4718. }
  4719. if (typeof config.content === 'number') {
  4720. config.content = config.content.toString();
  4721. }
  4722. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4723. if (config.sanitize) {
  4724. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4725. }
  4726. return config;
  4727. };
  4728. _proto._getDelegateConfig = function _getDelegateConfig() {
  4729. var config = {};
  4730. if (this.config) {
  4731. for (var key in this.config) {
  4732. if (this.constructor.Default[key] !== this.config[key]) {
  4733. config[key] = this.config[key];
  4734. }
  4735. }
  4736. }
  4737. return config;
  4738. };
  4739. _proto._cleanTipClass = function _cleanTipClass() {
  4740. var $tip = $(this.getTipElement());
  4741. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4742. if (tabClass !== null && tabClass.length) {
  4743. $tip.removeClass(tabClass.join(''));
  4744. }
  4745. };
  4746. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4747. var popperInstance = popperData.instance;
  4748. this.tip = popperInstance.popper;
  4749. this._cleanTipClass();
  4750. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4751. };
  4752. _proto._fixTransition = function _fixTransition() {
  4753. var tip = this.getTipElement();
  4754. var initConfigAnimation = this.config.animation;
  4755. if (tip.getAttribute('x-placement') !== null) {
  4756. return;
  4757. }
  4758. $(tip).removeClass(ClassName$6.FADE);
  4759. this.config.animation = false;
  4760. this.hide();
  4761. this.show();
  4762. this.config.animation = initConfigAnimation;
  4763. } // Static
  4764. ;
  4765. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4766. return this.each(function () {
  4767. var data = $(this).data(DATA_KEY$6);
  4768. var _config = typeof config === 'object' && config;
  4769. if (!data && /dispose|hide/.test(config)) {
  4770. return;
  4771. }
  4772. if (!data) {
  4773. data = new Tooltip(this, _config);
  4774. $(this).data(DATA_KEY$6, data);
  4775. }
  4776. if (typeof config === 'string') {
  4777. if (typeof data[config] === 'undefined') {
  4778. throw new TypeError("No method named \"" + config + "\"");
  4779. }
  4780. data[config]();
  4781. }
  4782. });
  4783. };
  4784. _createClass(Tooltip, null, [{
  4785. key: "VERSION",
  4786. get: function get() {
  4787. return VERSION$6;
  4788. }
  4789. }, {
  4790. key: "Default",
  4791. get: function get() {
  4792. return Default$4;
  4793. }
  4794. }, {
  4795. key: "NAME",
  4796. get: function get() {
  4797. return NAME$6;
  4798. }
  4799. }, {
  4800. key: "DATA_KEY",
  4801. get: function get() {
  4802. return DATA_KEY$6;
  4803. }
  4804. }, {
  4805. key: "Event",
  4806. get: function get() {
  4807. return Event$6;
  4808. }
  4809. }, {
  4810. key: "EVENT_KEY",
  4811. get: function get() {
  4812. return EVENT_KEY$6;
  4813. }
  4814. }, {
  4815. key: "DefaultType",
  4816. get: function get() {
  4817. return DefaultType$4;
  4818. }
  4819. }]);
  4820. return Tooltip;
  4821. }();
  4822. /**
  4823. * ------------------------------------------------------------------------
  4824. * jQuery
  4825. * ------------------------------------------------------------------------
  4826. */
  4827. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4828. $.fn[NAME$6].Constructor = Tooltip;
  4829. $.fn[NAME$6].noConflict = function () {
  4830. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4831. return Tooltip._jQueryInterface;
  4832. };
  4833. /**
  4834. * ------------------------------------------------------------------------
  4835. * Constants
  4836. * ------------------------------------------------------------------------
  4837. */
  4838. var NAME$7 = 'popover';
  4839. var VERSION$7 = '4.4.1';
  4840. var DATA_KEY$7 = 'bs.popover';
  4841. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4842. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4843. var CLASS_PREFIX$1 = 'bs-popover';
  4844. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4845. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4846. placement: 'right',
  4847. trigger: 'click',
  4848. content: '',
  4849. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4850. });
  4851. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4852. content: '(string|element|function)'
  4853. });
  4854. var ClassName$7 = {
  4855. FADE: 'fade',
  4856. SHOW: 'show'
  4857. };
  4858. var Selector$7 = {
  4859. TITLE: '.popover-header',
  4860. CONTENT: '.popover-body'
  4861. };
  4862. var Event$7 = {
  4863. HIDE: "hide" + EVENT_KEY$7,
  4864. HIDDEN: "hidden" + EVENT_KEY$7,
  4865. SHOW: "show" + EVENT_KEY$7,
  4866. SHOWN: "shown" + EVENT_KEY$7,
  4867. INSERTED: "inserted" + EVENT_KEY$7,
  4868. CLICK: "click" + EVENT_KEY$7,
  4869. FOCUSIN: "focusin" + EVENT_KEY$7,
  4870. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4871. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4872. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4873. };
  4874. /**
  4875. * ------------------------------------------------------------------------
  4876. * Class Definition
  4877. * ------------------------------------------------------------------------
  4878. */
  4879. var Popover =
  4880. /*#__PURE__*/
  4881. function (_Tooltip) {
  4882. _inheritsLoose(Popover, _Tooltip);
  4883. function Popover() {
  4884. return _Tooltip.apply(this, arguments) || this;
  4885. }
  4886. var _proto = Popover.prototype;
  4887. // Overrides
  4888. _proto.isWithContent = function isWithContent() {
  4889. return this.getTitle() || this._getContent();
  4890. };
  4891. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4892. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4893. };
  4894. _proto.getTipElement = function getTipElement() {
  4895. this.tip = this.tip || $(this.config.template)[0];
  4896. return this.tip;
  4897. };
  4898. _proto.setContent = function setContent() {
  4899. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4900. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4901. var content = this._getContent();
  4902. if (typeof content === 'function') {
  4903. content = content.call(this.element);
  4904. }
  4905. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4906. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4907. } // Private
  4908. ;
  4909. _proto._getContent = function _getContent() {
  4910. return this.element.getAttribute('data-content') || this.config.content;
  4911. };
  4912. _proto._cleanTipClass = function _cleanTipClass() {
  4913. var $tip = $(this.getTipElement());
  4914. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4915. if (tabClass !== null && tabClass.length > 0) {
  4916. $tip.removeClass(tabClass.join(''));
  4917. }
  4918. } // Static
  4919. ;
  4920. Popover._jQueryInterface = function _jQueryInterface(config) {
  4921. return this.each(function () {
  4922. var data = $(this).data(DATA_KEY$7);
  4923. var _config = typeof config === 'object' ? config : null;
  4924. if (!data && /dispose|hide/.test(config)) {
  4925. return;
  4926. }
  4927. if (!data) {
  4928. data = new Popover(this, _config);
  4929. $(this).data(DATA_KEY$7, data);
  4930. }
  4931. if (typeof config === 'string') {
  4932. if (typeof data[config] === 'undefined') {
  4933. throw new TypeError("No method named \"" + config + "\"");
  4934. }
  4935. data[config]();
  4936. }
  4937. });
  4938. };
  4939. _createClass(Popover, null, [{
  4940. key: "VERSION",
  4941. // Getters
  4942. get: function get() {
  4943. return VERSION$7;
  4944. }
  4945. }, {
  4946. key: "Default",
  4947. get: function get() {
  4948. return Default$5;
  4949. }
  4950. }, {
  4951. key: "NAME",
  4952. get: function get() {
  4953. return NAME$7;
  4954. }
  4955. }, {
  4956. key: "DATA_KEY",
  4957. get: function get() {
  4958. return DATA_KEY$7;
  4959. }
  4960. }, {
  4961. key: "Event",
  4962. get: function get() {
  4963. return Event$7;
  4964. }
  4965. }, {
  4966. key: "EVENT_KEY",
  4967. get: function get() {
  4968. return EVENT_KEY$7;
  4969. }
  4970. }, {
  4971. key: "DefaultType",
  4972. get: function get() {
  4973. return DefaultType$5;
  4974. }
  4975. }]);
  4976. return Popover;
  4977. }(Tooltip);
  4978. /**
  4979. * ------------------------------------------------------------------------
  4980. * jQuery
  4981. * ------------------------------------------------------------------------
  4982. */
  4983. $.fn[NAME$7] = Popover._jQueryInterface;
  4984. $.fn[NAME$7].Constructor = Popover;
  4985. $.fn[NAME$7].noConflict = function () {
  4986. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4987. return Popover._jQueryInterface;
  4988. };
  4989. /**
  4990. * ------------------------------------------------------------------------
  4991. * Constants
  4992. * ------------------------------------------------------------------------
  4993. */
  4994. var NAME$8 = 'scrollspy';
  4995. var VERSION$8 = '4.4.1';
  4996. var DATA_KEY$8 = 'bs.scrollspy';
  4997. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4998. var DATA_API_KEY$6 = '.data-api';
  4999. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  5000. var Default$6 = {
  5001. offset: 10,
  5002. method: 'auto',
  5003. target: ''
  5004. };
  5005. var DefaultType$6 = {
  5006. offset: 'number',
  5007. method: 'string',
  5008. target: '(string|element)'
  5009. };
  5010. var Event$8 = {
  5011. ACTIVATE: "activate" + EVENT_KEY$8,
  5012. SCROLL: "scroll" + EVENT_KEY$8,
  5013. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  5014. };
  5015. var ClassName$8 = {
  5016. DROPDOWN_ITEM: 'dropdown-item',
  5017. DROPDOWN_MENU: 'dropdown-menu',
  5018. ACTIVE: 'active'
  5019. };
  5020. var Selector$8 = {
  5021. DATA_SPY: '[data-spy="scroll"]',
  5022. ACTIVE: '.active',
  5023. NAV_LIST_GROUP: '.nav, .list-group',
  5024. NAV_LINKS: '.nav-link',
  5025. NAV_ITEMS: '.nav-item',
  5026. LIST_ITEMS: '.list-group-item',
  5027. DROPDOWN: '.dropdown',
  5028. DROPDOWN_ITEMS: '.dropdown-item',
  5029. DROPDOWN_TOGGLE: '.dropdown-toggle'
  5030. };
  5031. var OffsetMethod = {
  5032. OFFSET: 'offset',
  5033. POSITION: 'position'
  5034. };
  5035. /**
  5036. * ------------------------------------------------------------------------
  5037. * Class Definition
  5038. * ------------------------------------------------------------------------
  5039. */
  5040. var ScrollSpy =
  5041. /*#__PURE__*/
  5042. function () {
  5043. function ScrollSpy(element, config) {
  5044. var _this = this;
  5045. this._element = element;
  5046. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5047. this._config = this._getConfig(config);
  5048. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  5049. this._offsets = [];
  5050. this._targets = [];
  5051. this._activeTarget = null;
  5052. this._scrollHeight = 0;
  5053. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  5054. return _this._process(event);
  5055. });
  5056. this.refresh();
  5057. this._process();
  5058. } // Getters
  5059. var _proto = ScrollSpy.prototype;
  5060. // Public
  5061. _proto.refresh = function refresh() {
  5062. var _this2 = this;
  5063. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  5064. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5065. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  5066. this._offsets = [];
  5067. this._targets = [];
  5068. this._scrollHeight = this._getScrollHeight();
  5069. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5070. targets.map(function (element) {
  5071. var target;
  5072. var targetSelector = Util.getSelectorFromElement(element);
  5073. if (targetSelector) {
  5074. target = document.querySelector(targetSelector);
  5075. }
  5076. if (target) {
  5077. var targetBCR = target.getBoundingClientRect();
  5078. if (targetBCR.width || targetBCR.height) {
  5079. // TODO (fat): remove sketch reliance on jQuery position/offset
  5080. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5081. }
  5082. }
  5083. return null;
  5084. }).filter(function (item) {
  5085. return item;
  5086. }).sort(function (a, b) {
  5087. return a[0] - b[0];
  5088. }).forEach(function (item) {
  5089. _this2._offsets.push(item[0]);
  5090. _this2._targets.push(item[1]);
  5091. });
  5092. };
  5093. _proto.dispose = function dispose() {
  5094. $.removeData(this._element, DATA_KEY$8);
  5095. $(this._scrollElement).off(EVENT_KEY$8);
  5096. this._element = null;
  5097. this._scrollElement = null;
  5098. this._config = null;
  5099. this._selector = null;
  5100. this._offsets = null;
  5101. this._targets = null;
  5102. this._activeTarget = null;
  5103. this._scrollHeight = null;
  5104. } // Private
  5105. ;
  5106. _proto._getConfig = function _getConfig(config) {
  5107. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5108. if (typeof config.target !== 'string') {
  5109. var id = $(config.target).attr('id');
  5110. if (!id) {
  5111. id = Util.getUID(NAME$8);
  5112. $(config.target).attr('id', id);
  5113. }
  5114. config.target = "#" + id;
  5115. }
  5116. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5117. return config;
  5118. };
  5119. _proto._getScrollTop = function _getScrollTop() {
  5120. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5121. };
  5122. _proto._getScrollHeight = function _getScrollHeight() {
  5123. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5124. };
  5125. _proto._getOffsetHeight = function _getOffsetHeight() {
  5126. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5127. };
  5128. _proto._process = function _process() {
  5129. var scrollTop = this._getScrollTop() + this._config.offset;
  5130. var scrollHeight = this._getScrollHeight();
  5131. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5132. if (this._scrollHeight !== scrollHeight) {
  5133. this.refresh();
  5134. }
  5135. if (scrollTop >= maxScroll) {
  5136. var target = this._targets[this._targets.length - 1];
  5137. if (this._activeTarget !== target) {
  5138. this._activate(target);
  5139. }
  5140. return;
  5141. }
  5142. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5143. this._activeTarget = null;
  5144. this._clear();
  5145. return;
  5146. }
  5147. var offsetLength = this._offsets.length;
  5148. for (var i = offsetLength; i--;) {
  5149. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5150. if (isActiveTarget) {
  5151. this._activate(this._targets[i]);
  5152. }
  5153. }
  5154. };
  5155. _proto._activate = function _activate(target) {
  5156. this._activeTarget = target;
  5157. this._clear();
  5158. var queries = this._selector.split(',').map(function (selector) {
  5159. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5160. });
  5161. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5162. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5163. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5164. $link.addClass(ClassName$8.ACTIVE);
  5165. } else {
  5166. // Set triggered link as active
  5167. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5168. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5169. $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
  5170. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5171. }
  5172. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5173. relatedTarget: target
  5174. });
  5175. };
  5176. _proto._clear = function _clear() {
  5177. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5178. return node.classList.contains(ClassName$8.ACTIVE);
  5179. }).forEach(function (node) {
  5180. return node.classList.remove(ClassName$8.ACTIVE);
  5181. });
  5182. } // Static
  5183. ;
  5184. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5185. return this.each(function () {
  5186. var data = $(this).data(DATA_KEY$8);
  5187. var _config = typeof config === 'object' && config;
  5188. if (!data) {
  5189. data = new ScrollSpy(this, _config);
  5190. $(this).data(DATA_KEY$8, data);
  5191. }
  5192. if (typeof config === 'string') {
  5193. if (typeof data[config] === 'undefined') {
  5194. throw new TypeError("No method named \"" + config + "\"");
  5195. }
  5196. data[config]();
  5197. }
  5198. });
  5199. };
  5200. _createClass(ScrollSpy, null, [{
  5201. key: "VERSION",
  5202. get: function get() {
  5203. return VERSION$8;
  5204. }
  5205. }, {
  5206. key: "Default",
  5207. get: function get() {
  5208. return Default$6;
  5209. }
  5210. }]);
  5211. return ScrollSpy;
  5212. }();
  5213. /**
  5214. * ------------------------------------------------------------------------
  5215. * Data Api implementation
  5216. * ------------------------------------------------------------------------
  5217. */
  5218. $(window).on(Event$8.LOAD_DATA_API, function () {
  5219. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5220. var scrollSpysLength = scrollSpys.length;
  5221. for (var i = scrollSpysLength; i--;) {
  5222. var $spy = $(scrollSpys[i]);
  5223. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5224. }
  5225. });
  5226. /**
  5227. * ------------------------------------------------------------------------
  5228. * jQuery
  5229. * ------------------------------------------------------------------------
  5230. */
  5231. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5232. $.fn[NAME$8].Constructor = ScrollSpy;
  5233. $.fn[NAME$8].noConflict = function () {
  5234. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5235. return ScrollSpy._jQueryInterface;
  5236. };
  5237. /**
  5238. * ------------------------------------------------------------------------
  5239. * Constants
  5240. * ------------------------------------------------------------------------
  5241. */
  5242. var NAME$9 = 'tab';
  5243. var VERSION$9 = '4.4.1';
  5244. var DATA_KEY$9 = 'bs.tab';
  5245. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5246. var DATA_API_KEY$7 = '.data-api';
  5247. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5248. var Event$9 = {
  5249. HIDE: "hide" + EVENT_KEY$9,
  5250. HIDDEN: "hidden" + EVENT_KEY$9,
  5251. SHOW: "show" + EVENT_KEY$9,
  5252. SHOWN: "shown" + EVENT_KEY$9,
  5253. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5254. };
  5255. var ClassName$9 = {
  5256. DROPDOWN_MENU: 'dropdown-menu',
  5257. ACTIVE: 'active',
  5258. DISABLED: 'disabled',
  5259. FADE: 'fade',
  5260. SHOW: 'show'
  5261. };
  5262. var Selector$9 = {
  5263. DROPDOWN: '.dropdown',
  5264. NAV_LIST_GROUP: '.nav, .list-group',
  5265. ACTIVE: '.active',
  5266. ACTIVE_UL: '> li > .active',
  5267. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5268. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5269. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5270. };
  5271. /**
  5272. * ------------------------------------------------------------------------
  5273. * Class Definition
  5274. * ------------------------------------------------------------------------
  5275. */
  5276. var Tab =
  5277. /*#__PURE__*/
  5278. function () {
  5279. function Tab(element) {
  5280. this._element = element;
  5281. } // Getters
  5282. var _proto = Tab.prototype;
  5283. // Public
  5284. _proto.show = function show() {
  5285. var _this = this;
  5286. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5287. return;
  5288. }
  5289. var target;
  5290. var previous;
  5291. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5292. var selector = Util.getSelectorFromElement(this._element);
  5293. if (listElement) {
  5294. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5295. previous = $.makeArray($(listElement).find(itemSelector));
  5296. previous = previous[previous.length - 1];
  5297. }
  5298. var hideEvent = $.Event(Event$9.HIDE, {
  5299. relatedTarget: this._element
  5300. });
  5301. var showEvent = $.Event(Event$9.SHOW, {
  5302. relatedTarget: previous
  5303. });
  5304. if (previous) {
  5305. $(previous).trigger(hideEvent);
  5306. }
  5307. $(this._element).trigger(showEvent);
  5308. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5309. return;
  5310. }
  5311. if (selector) {
  5312. target = document.querySelector(selector);
  5313. }
  5314. this._activate(this._element, listElement);
  5315. var complete = function complete() {
  5316. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5317. relatedTarget: _this._element
  5318. });
  5319. var shownEvent = $.Event(Event$9.SHOWN, {
  5320. relatedTarget: previous
  5321. });
  5322. $(previous).trigger(hiddenEvent);
  5323. $(_this._element).trigger(shownEvent);
  5324. };
  5325. if (target) {
  5326. this._activate(target, target.parentNode, complete);
  5327. } else {
  5328. complete();
  5329. }
  5330. };
  5331. _proto.dispose = function dispose() {
  5332. $.removeData(this._element, DATA_KEY$9);
  5333. this._element = null;
  5334. } // Private
  5335. ;
  5336. _proto._activate = function _activate(element, container, callback) {
  5337. var _this2 = this;
  5338. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5339. var active = activeElements[0];
  5340. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5341. var complete = function complete() {
  5342. return _this2._transitionComplete(element, active, callback);
  5343. };
  5344. if (active && isTransitioning) {
  5345. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5346. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5347. } else {
  5348. complete();
  5349. }
  5350. };
  5351. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5352. if (active) {
  5353. $(active).removeClass(ClassName$9.ACTIVE);
  5354. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5355. if (dropdownChild) {
  5356. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5357. }
  5358. if (active.getAttribute('role') === 'tab') {
  5359. active.setAttribute('aria-selected', false);
  5360. }
  5361. }
  5362. $(element).addClass(ClassName$9.ACTIVE);
  5363. if (element.getAttribute('role') === 'tab') {
  5364. element.setAttribute('aria-selected', true);
  5365. }
  5366. Util.reflow(element);
  5367. if (element.classList.contains(ClassName$9.FADE)) {
  5368. element.classList.add(ClassName$9.SHOW);
  5369. }
  5370. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5371. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5372. if (dropdownElement) {
  5373. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5374. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5375. }
  5376. element.setAttribute('aria-expanded', true);
  5377. }
  5378. if (callback) {
  5379. callback();
  5380. }
  5381. } // Static
  5382. ;
  5383. Tab._jQueryInterface = function _jQueryInterface(config) {
  5384. return this.each(function () {
  5385. var $this = $(this);
  5386. var data = $this.data(DATA_KEY$9);
  5387. if (!data) {
  5388. data = new Tab(this);
  5389. $this.data(DATA_KEY$9, data);
  5390. }
  5391. if (typeof config === 'string') {
  5392. if (typeof data[config] === 'undefined') {
  5393. throw new TypeError("No method named \"" + config + "\"");
  5394. }
  5395. data[config]();
  5396. }
  5397. });
  5398. };
  5399. _createClass(Tab, null, [{
  5400. key: "VERSION",
  5401. get: function get() {
  5402. return VERSION$9;
  5403. }
  5404. }]);
  5405. return Tab;
  5406. }();
  5407. /**
  5408. * ------------------------------------------------------------------------
  5409. * Data Api implementation
  5410. * ------------------------------------------------------------------------
  5411. */
  5412. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5413. event.preventDefault();
  5414. Tab._jQueryInterface.call($(this), 'show');
  5415. });
  5416. /**
  5417. * ------------------------------------------------------------------------
  5418. * jQuery
  5419. * ------------------------------------------------------------------------
  5420. */
  5421. $.fn[NAME$9] = Tab._jQueryInterface;
  5422. $.fn[NAME$9].Constructor = Tab;
  5423. $.fn[NAME$9].noConflict = function () {
  5424. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5425. return Tab._jQueryInterface;
  5426. };
  5427. /**
  5428. * ------------------------------------------------------------------------
  5429. * Constants
  5430. * ------------------------------------------------------------------------
  5431. */
  5432. var NAME$a = 'toast';
  5433. var VERSION$a = '4.4.1';
  5434. var DATA_KEY$a = 'bs.toast';
  5435. var EVENT_KEY$a = "." + DATA_KEY$a;
  5436. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5437. var Event$a = {
  5438. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5439. HIDE: "hide" + EVENT_KEY$a,
  5440. HIDDEN: "hidden" + EVENT_KEY$a,
  5441. SHOW: "show" + EVENT_KEY$a,
  5442. SHOWN: "shown" + EVENT_KEY$a
  5443. };
  5444. var ClassName$a = {
  5445. FADE: 'fade',
  5446. HIDE: 'hide',
  5447. SHOW: 'show',
  5448. SHOWING: 'showing'
  5449. };
  5450. var DefaultType$7 = {
  5451. animation: 'boolean',
  5452. autohide: 'boolean',
  5453. delay: 'number'
  5454. };
  5455. var Default$7 = {
  5456. animation: true,
  5457. autohide: true,
  5458. delay: 500
  5459. };
  5460. var Selector$a = {
  5461. DATA_DISMISS: '[data-dismiss="toast"]'
  5462. };
  5463. /**
  5464. * ------------------------------------------------------------------------
  5465. * Class Definition
  5466. * ------------------------------------------------------------------------
  5467. */
  5468. var Toast =
  5469. /*#__PURE__*/
  5470. function () {
  5471. function Toast(element, config) {
  5472. this._element = element;
  5473. this._config = this._getConfig(config);
  5474. this._timeout = null;
  5475. this._setListeners();
  5476. } // Getters
  5477. var _proto = Toast.prototype;
  5478. // Public
  5479. _proto.show = function show() {
  5480. var _this = this;
  5481. var showEvent = $.Event(Event$a.SHOW);
  5482. $(this._element).trigger(showEvent);
  5483. if (showEvent.isDefaultPrevented()) {
  5484. return;
  5485. }
  5486. if (this._config.animation) {
  5487. this._element.classList.add(ClassName$a.FADE);
  5488. }
  5489. var complete = function complete() {
  5490. _this._element.classList.remove(ClassName$a.SHOWING);
  5491. _this._element.classList.add(ClassName$a.SHOW);
  5492. $(_this._element).trigger(Event$a.SHOWN);
  5493. if (_this._config.autohide) {
  5494. _this._timeout = setTimeout(function () {
  5495. _this.hide();
  5496. }, _this._config.delay);
  5497. }
  5498. };
  5499. this._element.classList.remove(ClassName$a.HIDE);
  5500. Util.reflow(this._element);
  5501. this._element.classList.add(ClassName$a.SHOWING);
  5502. if (this._config.animation) {
  5503. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5504. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5505. } else {
  5506. complete();
  5507. }
  5508. };
  5509. _proto.hide = function hide() {
  5510. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5511. return;
  5512. }
  5513. var hideEvent = $.Event(Event$a.HIDE);
  5514. $(this._element).trigger(hideEvent);
  5515. if (hideEvent.isDefaultPrevented()) {
  5516. return;
  5517. }
  5518. this._close();
  5519. };
  5520. _proto.dispose = function dispose() {
  5521. clearTimeout(this._timeout);
  5522. this._timeout = null;
  5523. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5524. this._element.classList.remove(ClassName$a.SHOW);
  5525. }
  5526. $(this._element).off(Event$a.CLICK_DISMISS);
  5527. $.removeData(this._element, DATA_KEY$a);
  5528. this._element = null;
  5529. this._config = null;
  5530. } // Private
  5531. ;
  5532. _proto._getConfig = function _getConfig(config) {
  5533. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5534. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5535. return config;
  5536. };
  5537. _proto._setListeners = function _setListeners() {
  5538. var _this2 = this;
  5539. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5540. return _this2.hide();
  5541. });
  5542. };
  5543. _proto._close = function _close() {
  5544. var _this3 = this;
  5545. var complete = function complete() {
  5546. _this3._element.classList.add(ClassName$a.HIDE);
  5547. $(_this3._element).trigger(Event$a.HIDDEN);
  5548. };
  5549. this._element.classList.remove(ClassName$a.SHOW);
  5550. if (this._config.animation) {
  5551. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5552. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5553. } else {
  5554. complete();
  5555. }
  5556. } // Static
  5557. ;
  5558. Toast._jQueryInterface = function _jQueryInterface(config) {
  5559. return this.each(function () {
  5560. var $element = $(this);
  5561. var data = $element.data(DATA_KEY$a);
  5562. var _config = typeof config === 'object' && config;
  5563. if (!data) {
  5564. data = new Toast(this, _config);
  5565. $element.data(DATA_KEY$a, data);
  5566. }
  5567. if (typeof config === 'string') {
  5568. if (typeof data[config] === 'undefined') {
  5569. throw new TypeError("No method named \"" + config + "\"");
  5570. }
  5571. data[config](this);
  5572. }
  5573. });
  5574. };
  5575. _createClass(Toast, null, [{
  5576. key: "VERSION",
  5577. get: function get() {
  5578. return VERSION$a;
  5579. }
  5580. }, {
  5581. key: "DefaultType",
  5582. get: function get() {
  5583. return DefaultType$7;
  5584. }
  5585. }, {
  5586. key: "Default",
  5587. get: function get() {
  5588. return Default$7;
  5589. }
  5590. }]);
  5591. return Toast;
  5592. }();
  5593. /**
  5594. * ------------------------------------------------------------------------
  5595. * jQuery
  5596. * ------------------------------------------------------------------------
  5597. */
  5598. $.fn[NAME$a] = Toast._jQueryInterface;
  5599. $.fn[NAME$a].Constructor = Toast;
  5600. $.fn[NAME$a].noConflict = function () {
  5601. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5602. return Toast._jQueryInterface;
  5603. };
  5604. exports.Alert = Alert;
  5605. exports.Button = Button;
  5606. exports.Carousel = Carousel;
  5607. exports.Collapse = Collapse;
  5608. exports.Dropdown = Dropdown;
  5609. exports.Modal = Modal;
  5610. exports.Popover = Popover;
  5611. exports.Scrollspy = ScrollSpy;
  5612. exports.Tab = Tab;
  5613. exports.Toast = Toast;
  5614. exports.Tooltip = Tooltip;
  5615. exports.Util = Util;
  5616. Object.defineProperty(exports, '__esModule', { value: true });
  5617. })));
  5618. //# sourceMappingURL=bootstrap.js.map
  5619. /***/ }),
  5620. /***/ "./node_modules/buffer/index.js":
  5621. /*!**************************************!*\
  5622. !*** ./node_modules/buffer/index.js ***!
  5623. \**************************************/
  5624. /*! no static exports found */
  5625. /***/ (function(module, exports, __webpack_require__) {
  5626. "use strict";
  5627. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5628. * The buffer module from node.js, for the browser.
  5629. *
  5630. * @author Feross Aboukhadijeh <http://feross.org>
  5631. * @license MIT
  5632. */
  5633. /* eslint-disable no-proto */
  5634. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5635. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5636. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5637. exports.Buffer = Buffer
  5638. exports.SlowBuffer = SlowBuffer
  5639. exports.INSPECT_MAX_BYTES = 50
  5640. /**
  5641. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5642. * === true Use Uint8Array implementation (fastest)
  5643. * === false Use Object implementation (most compatible, even IE6)
  5644. *
  5645. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5646. * Opera 11.6+, iOS 4.2+.
  5647. *
  5648. * Due to various browser bugs, sometimes the Object implementation will be used even
  5649. * when the browser supports typed arrays.
  5650. *
  5651. * Note:
  5652. *
  5653. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5654. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5655. *
  5656. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5657. *
  5658. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5659. * incorrect length in some situations.
  5660. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5661. * get the Object implementation, which is slower but behaves correctly.
  5662. */
  5663. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5664. ? global.TYPED_ARRAY_SUPPORT
  5665. : typedArraySupport()
  5666. /*
  5667. * Export kMaxLength after typed array support is determined.
  5668. */
  5669. exports.kMaxLength = kMaxLength()
  5670. function typedArraySupport () {
  5671. try {
  5672. var arr = new Uint8Array(1)
  5673. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5674. return arr.foo() === 42 && // typed array instances can be augmented
  5675. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5676. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5677. } catch (e) {
  5678. return false
  5679. }
  5680. }
  5681. function kMaxLength () {
  5682. return Buffer.TYPED_ARRAY_SUPPORT
  5683. ? 0x7fffffff
  5684. : 0x3fffffff
  5685. }
  5686. function createBuffer (that, length) {
  5687. if (kMaxLength() < length) {
  5688. throw new RangeError('Invalid typed array length')
  5689. }
  5690. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5691. // Return an augmented `Uint8Array` instance, for best performance
  5692. that = new Uint8Array(length)
  5693. that.__proto__ = Buffer.prototype
  5694. } else {
  5695. // Fallback: Return an object instance of the Buffer class
  5696. if (that === null) {
  5697. that = new Buffer(length)
  5698. }
  5699. that.length = length
  5700. }
  5701. return that
  5702. }
  5703. /**
  5704. * The Buffer constructor returns instances of `Uint8Array` that have their
  5705. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5706. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5707. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5708. * returns a single octet.
  5709. *
  5710. * The `Uint8Array` prototype remains unmodified.
  5711. */
  5712. function Buffer (arg, encodingOrOffset, length) {
  5713. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5714. return new Buffer(arg, encodingOrOffset, length)
  5715. }
  5716. // Common case.
  5717. if (typeof arg === 'number') {
  5718. if (typeof encodingOrOffset === 'string') {
  5719. throw new Error(
  5720. 'If encoding is specified then the first argument must be a string'
  5721. )
  5722. }
  5723. return allocUnsafe(this, arg)
  5724. }
  5725. return from(this, arg, encodingOrOffset, length)
  5726. }
  5727. Buffer.poolSize = 8192 // not used by this implementation
  5728. // TODO: Legacy, not needed anymore. Remove in next major version.
  5729. Buffer._augment = function (arr) {
  5730. arr.__proto__ = Buffer.prototype
  5731. return arr
  5732. }
  5733. function from (that, value, encodingOrOffset, length) {
  5734. if (typeof value === 'number') {
  5735. throw new TypeError('"value" argument must not be a number')
  5736. }
  5737. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5738. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5739. }
  5740. if (typeof value === 'string') {
  5741. return fromString(that, value, encodingOrOffset)
  5742. }
  5743. return fromObject(that, value)
  5744. }
  5745. /**
  5746. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5747. * if value is a number.
  5748. * Buffer.from(str[, encoding])
  5749. * Buffer.from(array)
  5750. * Buffer.from(buffer)
  5751. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5752. **/
  5753. Buffer.from = function (value, encodingOrOffset, length) {
  5754. return from(null, value, encodingOrOffset, length)
  5755. }
  5756. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5757. Buffer.prototype.__proto__ = Uint8Array.prototype
  5758. Buffer.__proto__ = Uint8Array
  5759. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5760. Buffer[Symbol.species] === Buffer) {
  5761. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5762. Object.defineProperty(Buffer, Symbol.species, {
  5763. value: null,
  5764. configurable: true
  5765. })
  5766. }
  5767. }
  5768. function assertSize (size) {
  5769. if (typeof size !== 'number') {
  5770. throw new TypeError('"size" argument must be a number')
  5771. } else if (size < 0) {
  5772. throw new RangeError('"size" argument must not be negative')
  5773. }
  5774. }
  5775. function alloc (that, size, fill, encoding) {
  5776. assertSize(size)
  5777. if (size <= 0) {
  5778. return createBuffer(that, size)
  5779. }
  5780. if (fill !== undefined) {
  5781. // Only pay attention to encoding if it's a string. This
  5782. // prevents accidentally sending in a number that would
  5783. // be interpretted as a start offset.
  5784. return typeof encoding === 'string'
  5785. ? createBuffer(that, size).fill(fill, encoding)
  5786. : createBuffer(that, size).fill(fill)
  5787. }
  5788. return createBuffer(that, size)
  5789. }
  5790. /**
  5791. * Creates a new filled Buffer instance.
  5792. * alloc(size[, fill[, encoding]])
  5793. **/
  5794. Buffer.alloc = function (size, fill, encoding) {
  5795. return alloc(null, size, fill, encoding)
  5796. }
  5797. function allocUnsafe (that, size) {
  5798. assertSize(size)
  5799. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5800. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5801. for (var i = 0; i < size; ++i) {
  5802. that[i] = 0
  5803. }
  5804. }
  5805. return that
  5806. }
  5807. /**
  5808. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5809. * */
  5810. Buffer.allocUnsafe = function (size) {
  5811. return allocUnsafe(null, size)
  5812. }
  5813. /**
  5814. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5815. */
  5816. Buffer.allocUnsafeSlow = function (size) {
  5817. return allocUnsafe(null, size)
  5818. }
  5819. function fromString (that, string, encoding) {
  5820. if (typeof encoding !== 'string' || encoding === '') {
  5821. encoding = 'utf8'
  5822. }
  5823. if (!Buffer.isEncoding(encoding)) {
  5824. throw new TypeError('"encoding" must be a valid string encoding')
  5825. }
  5826. var length = byteLength(string, encoding) | 0
  5827. that = createBuffer(that, length)
  5828. var actual = that.write(string, encoding)
  5829. if (actual !== length) {
  5830. // Writing a hex string, for example, that contains invalid characters will
  5831. // cause everything after the first invalid character to be ignored. (e.g.
  5832. // 'abxxcd' will be treated as 'ab')
  5833. that = that.slice(0, actual)
  5834. }
  5835. return that
  5836. }
  5837. function fromArrayLike (that, array) {
  5838. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5839. that = createBuffer(that, length)
  5840. for (var i = 0; i < length; i += 1) {
  5841. that[i] = array[i] & 255
  5842. }
  5843. return that
  5844. }
  5845. function fromArrayBuffer (that, array, byteOffset, length) {
  5846. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5847. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5848. throw new RangeError('\'offset\' is out of bounds')
  5849. }
  5850. if (array.byteLength < byteOffset + (length || 0)) {
  5851. throw new RangeError('\'length\' is out of bounds')
  5852. }
  5853. if (byteOffset === undefined && length === undefined) {
  5854. array = new Uint8Array(array)
  5855. } else if (length === undefined) {
  5856. array = new Uint8Array(array, byteOffset)
  5857. } else {
  5858. array = new Uint8Array(array, byteOffset, length)
  5859. }
  5860. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5861. // Return an augmented `Uint8Array` instance, for best performance
  5862. that = array
  5863. that.__proto__ = Buffer.prototype
  5864. } else {
  5865. // Fallback: Return an object instance of the Buffer class
  5866. that = fromArrayLike(that, array)
  5867. }
  5868. return that
  5869. }
  5870. function fromObject (that, obj) {
  5871. if (Buffer.isBuffer(obj)) {
  5872. var len = checked(obj.length) | 0
  5873. that = createBuffer(that, len)
  5874. if (that.length === 0) {
  5875. return that
  5876. }
  5877. obj.copy(that, 0, 0, len)
  5878. return that
  5879. }
  5880. if (obj) {
  5881. if ((typeof ArrayBuffer !== 'undefined' &&
  5882. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5883. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5884. return createBuffer(that, 0)
  5885. }
  5886. return fromArrayLike(that, obj)
  5887. }
  5888. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5889. return fromArrayLike(that, obj.data)
  5890. }
  5891. }
  5892. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5893. }
  5894. function checked (length) {
  5895. // Note: cannot use `length < kMaxLength()` here because that fails when
  5896. // length is NaN (which is otherwise coerced to zero.)
  5897. if (length >= kMaxLength()) {
  5898. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5899. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5900. }
  5901. return length | 0
  5902. }
  5903. function SlowBuffer (length) {
  5904. if (+length != length) { // eslint-disable-line eqeqeq
  5905. length = 0
  5906. }
  5907. return Buffer.alloc(+length)
  5908. }
  5909. Buffer.isBuffer = function isBuffer (b) {
  5910. return !!(b != null && b._isBuffer)
  5911. }
  5912. Buffer.compare = function compare (a, b) {
  5913. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5914. throw new TypeError('Arguments must be Buffers')
  5915. }
  5916. if (a === b) return 0
  5917. var x = a.length
  5918. var y = b.length
  5919. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5920. if (a[i] !== b[i]) {
  5921. x = a[i]
  5922. y = b[i]
  5923. break
  5924. }
  5925. }
  5926. if (x < y) return -1
  5927. if (y < x) return 1
  5928. return 0
  5929. }
  5930. Buffer.isEncoding = function isEncoding (encoding) {
  5931. switch (String(encoding).toLowerCase()) {
  5932. case 'hex':
  5933. case 'utf8':
  5934. case 'utf-8':
  5935. case 'ascii':
  5936. case 'latin1':
  5937. case 'binary':
  5938. case 'base64':
  5939. case 'ucs2':
  5940. case 'ucs-2':
  5941. case 'utf16le':
  5942. case 'utf-16le':
  5943. return true
  5944. default:
  5945. return false
  5946. }
  5947. }
  5948. Buffer.concat = function concat (list, length) {
  5949. if (!isArray(list)) {
  5950. throw new TypeError('"list" argument must be an Array of Buffers')
  5951. }
  5952. if (list.length === 0) {
  5953. return Buffer.alloc(0)
  5954. }
  5955. var i
  5956. if (length === undefined) {
  5957. length = 0
  5958. for (i = 0; i < list.length; ++i) {
  5959. length += list[i].length
  5960. }
  5961. }
  5962. var buffer = Buffer.allocUnsafe(length)
  5963. var pos = 0
  5964. for (i = 0; i < list.length; ++i) {
  5965. var buf = list[i]
  5966. if (!Buffer.isBuffer(buf)) {
  5967. throw new TypeError('"list" argument must be an Array of Buffers')
  5968. }
  5969. buf.copy(buffer, pos)
  5970. pos += buf.length
  5971. }
  5972. return buffer
  5973. }
  5974. function byteLength (string, encoding) {
  5975. if (Buffer.isBuffer(string)) {
  5976. return string.length
  5977. }
  5978. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5979. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5980. return string.byteLength
  5981. }
  5982. if (typeof string !== 'string') {
  5983. string = '' + string
  5984. }
  5985. var len = string.length
  5986. if (len === 0) return 0
  5987. // Use a for loop to avoid recursion
  5988. var loweredCase = false
  5989. for (;;) {
  5990. switch (encoding) {
  5991. case 'ascii':
  5992. case 'latin1':
  5993. case 'binary':
  5994. return len
  5995. case 'utf8':
  5996. case 'utf-8':
  5997. case undefined:
  5998. return utf8ToBytes(string).length
  5999. case 'ucs2':
  6000. case 'ucs-2':
  6001. case 'utf16le':
  6002. case 'utf-16le':
  6003. return len * 2
  6004. case 'hex':
  6005. return len >>> 1
  6006. case 'base64':
  6007. return base64ToBytes(string).length
  6008. default:
  6009. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  6010. encoding = ('' + encoding).toLowerCase()
  6011. loweredCase = true
  6012. }
  6013. }
  6014. }
  6015. Buffer.byteLength = byteLength
  6016. function slowToString (encoding, start, end) {
  6017. var loweredCase = false
  6018. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6019. // property of a typed array.
  6020. // This behaves neither like String nor Uint8Array in that we set start/end
  6021. // to their upper/lower bounds if the value passed is out of range.
  6022. // undefined is handled specially as per ECMA-262 6th Edition,
  6023. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6024. if (start === undefined || start < 0) {
  6025. start = 0
  6026. }
  6027. // Return early if start > this.length. Done here to prevent potential uint32
  6028. // coercion fail below.
  6029. if (start > this.length) {
  6030. return ''
  6031. }
  6032. if (end === undefined || end > this.length) {
  6033. end = this.length
  6034. }
  6035. if (end <= 0) {
  6036. return ''
  6037. }
  6038. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6039. end >>>= 0
  6040. start >>>= 0
  6041. if (end <= start) {
  6042. return ''
  6043. }
  6044. if (!encoding) encoding = 'utf8'
  6045. while (true) {
  6046. switch (encoding) {
  6047. case 'hex':
  6048. return hexSlice(this, start, end)
  6049. case 'utf8':
  6050. case 'utf-8':
  6051. return utf8Slice(this, start, end)
  6052. case 'ascii':
  6053. return asciiSlice(this, start, end)
  6054. case 'latin1':
  6055. case 'binary':
  6056. return latin1Slice(this, start, end)
  6057. case 'base64':
  6058. return base64Slice(this, start, end)
  6059. case 'ucs2':
  6060. case 'ucs-2':
  6061. case 'utf16le':
  6062. case 'utf-16le':
  6063. return utf16leSlice(this, start, end)
  6064. default:
  6065. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6066. encoding = (encoding + '').toLowerCase()
  6067. loweredCase = true
  6068. }
  6069. }
  6070. }
  6071. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6072. // Buffer instances.
  6073. Buffer.prototype._isBuffer = true
  6074. function swap (b, n, m) {
  6075. var i = b[n]
  6076. b[n] = b[m]
  6077. b[m] = i
  6078. }
  6079. Buffer.prototype.swap16 = function swap16 () {
  6080. var len = this.length
  6081. if (len % 2 !== 0) {
  6082. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6083. }
  6084. for (var i = 0; i < len; i += 2) {
  6085. swap(this, i, i + 1)
  6086. }
  6087. return this
  6088. }
  6089. Buffer.prototype.swap32 = function swap32 () {
  6090. var len = this.length
  6091. if (len % 4 !== 0) {
  6092. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6093. }
  6094. for (var i = 0; i < len; i += 4) {
  6095. swap(this, i, i + 3)
  6096. swap(this, i + 1, i + 2)
  6097. }
  6098. return this
  6099. }
  6100. Buffer.prototype.swap64 = function swap64 () {
  6101. var len = this.length
  6102. if (len % 8 !== 0) {
  6103. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6104. }
  6105. for (var i = 0; i < len; i += 8) {
  6106. swap(this, i, i + 7)
  6107. swap(this, i + 1, i + 6)
  6108. swap(this, i + 2, i + 5)
  6109. swap(this, i + 3, i + 4)
  6110. }
  6111. return this
  6112. }
  6113. Buffer.prototype.toString = function toString () {
  6114. var length = this.length | 0
  6115. if (length === 0) return ''
  6116. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6117. return slowToString.apply(this, arguments)
  6118. }
  6119. Buffer.prototype.equals = function equals (b) {
  6120. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6121. if (this === b) return true
  6122. return Buffer.compare(this, b) === 0
  6123. }
  6124. Buffer.prototype.inspect = function inspect () {
  6125. var str = ''
  6126. var max = exports.INSPECT_MAX_BYTES
  6127. if (this.length > 0) {
  6128. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6129. if (this.length > max) str += ' ... '
  6130. }
  6131. return '<Buffer ' + str + '>'
  6132. }
  6133. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6134. if (!Buffer.isBuffer(target)) {
  6135. throw new TypeError('Argument must be a Buffer')
  6136. }
  6137. if (start === undefined) {
  6138. start = 0
  6139. }
  6140. if (end === undefined) {
  6141. end = target ? target.length : 0
  6142. }
  6143. if (thisStart === undefined) {
  6144. thisStart = 0
  6145. }
  6146. if (thisEnd === undefined) {
  6147. thisEnd = this.length
  6148. }
  6149. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6150. throw new RangeError('out of range index')
  6151. }
  6152. if (thisStart >= thisEnd && start >= end) {
  6153. return 0
  6154. }
  6155. if (thisStart >= thisEnd) {
  6156. return -1
  6157. }
  6158. if (start >= end) {
  6159. return 1
  6160. }
  6161. start >>>= 0
  6162. end >>>= 0
  6163. thisStart >>>= 0
  6164. thisEnd >>>= 0
  6165. if (this === target) return 0
  6166. var x = thisEnd - thisStart
  6167. var y = end - start
  6168. var len = Math.min(x, y)
  6169. var thisCopy = this.slice(thisStart, thisEnd)
  6170. var targetCopy = target.slice(start, end)
  6171. for (var i = 0; i < len; ++i) {
  6172. if (thisCopy[i] !== targetCopy[i]) {
  6173. x = thisCopy[i]
  6174. y = targetCopy[i]
  6175. break
  6176. }
  6177. }
  6178. if (x < y) return -1
  6179. if (y < x) return 1
  6180. return 0
  6181. }
  6182. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6183. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6184. //
  6185. // Arguments:
  6186. // - buffer - a Buffer to search
  6187. // - val - a string, Buffer, or number
  6188. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6189. // - encoding - an optional encoding, relevant is val is a string
  6190. // - dir - true for indexOf, false for lastIndexOf
  6191. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6192. // Empty buffer means no match
  6193. if (buffer.length === 0) return -1
  6194. // Normalize byteOffset
  6195. if (typeof byteOffset === 'string') {
  6196. encoding = byteOffset
  6197. byteOffset = 0
  6198. } else if (byteOffset > 0x7fffffff) {
  6199. byteOffset = 0x7fffffff
  6200. } else if (byteOffset < -0x80000000) {
  6201. byteOffset = -0x80000000
  6202. }
  6203. byteOffset = +byteOffset // Coerce to Number.
  6204. if (isNaN(byteOffset)) {
  6205. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6206. byteOffset = dir ? 0 : (buffer.length - 1)
  6207. }
  6208. // Normalize byteOffset: negative offsets start from the end of the buffer
  6209. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6210. if (byteOffset >= buffer.length) {
  6211. if (dir) return -1
  6212. else byteOffset = buffer.length - 1
  6213. } else if (byteOffset < 0) {
  6214. if (dir) byteOffset = 0
  6215. else return -1
  6216. }
  6217. // Normalize val
  6218. if (typeof val === 'string') {
  6219. val = Buffer.from(val, encoding)
  6220. }
  6221. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6222. if (Buffer.isBuffer(val)) {
  6223. // Special case: looking for empty string/buffer always fails
  6224. if (val.length === 0) {
  6225. return -1
  6226. }
  6227. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6228. } else if (typeof val === 'number') {
  6229. val = val & 0xFF // Search for a byte value [0-255]
  6230. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6231. typeof Uint8Array.prototype.indexOf === 'function') {
  6232. if (dir) {
  6233. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6234. } else {
  6235. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6236. }
  6237. }
  6238. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6239. }
  6240. throw new TypeError('val must be string, number or Buffer')
  6241. }
  6242. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6243. var indexSize = 1
  6244. var arrLength = arr.length
  6245. var valLength = val.length
  6246. if (encoding !== undefined) {
  6247. encoding = String(encoding).toLowerCase()
  6248. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6249. encoding === 'utf16le' || encoding === 'utf-16le') {
  6250. if (arr.length < 2 || val.length < 2) {
  6251. return -1
  6252. }
  6253. indexSize = 2
  6254. arrLength /= 2
  6255. valLength /= 2
  6256. byteOffset /= 2
  6257. }
  6258. }
  6259. function read (buf, i) {
  6260. if (indexSize === 1) {
  6261. return buf[i]
  6262. } else {
  6263. return buf.readUInt16BE(i * indexSize)
  6264. }
  6265. }
  6266. var i
  6267. if (dir) {
  6268. var foundIndex = -1
  6269. for (i = byteOffset; i < arrLength; i++) {
  6270. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6271. if (foundIndex === -1) foundIndex = i
  6272. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6273. } else {
  6274. if (foundIndex !== -1) i -= i - foundIndex
  6275. foundIndex = -1
  6276. }
  6277. }
  6278. } else {
  6279. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6280. for (i = byteOffset; i >= 0; i--) {
  6281. var found = true
  6282. for (var j = 0; j < valLength; j++) {
  6283. if (read(arr, i + j) !== read(val, j)) {
  6284. found = false
  6285. break
  6286. }
  6287. }
  6288. if (found) return i
  6289. }
  6290. }
  6291. return -1
  6292. }
  6293. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6294. return this.indexOf(val, byteOffset, encoding) !== -1
  6295. }
  6296. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6297. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6298. }
  6299. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6300. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6301. }
  6302. function hexWrite (buf, string, offset, length) {
  6303. offset = Number(offset) || 0
  6304. var remaining = buf.length - offset
  6305. if (!length) {
  6306. length = remaining
  6307. } else {
  6308. length = Number(length)
  6309. if (length > remaining) {
  6310. length = remaining
  6311. }
  6312. }
  6313. // must be an even number of digits
  6314. var strLen = string.length
  6315. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6316. if (length > strLen / 2) {
  6317. length = strLen / 2
  6318. }
  6319. for (var i = 0; i < length; ++i) {
  6320. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6321. if (isNaN(parsed)) return i
  6322. buf[offset + i] = parsed
  6323. }
  6324. return i
  6325. }
  6326. function utf8Write (buf, string, offset, length) {
  6327. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6328. }
  6329. function asciiWrite (buf, string, offset, length) {
  6330. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6331. }
  6332. function latin1Write (buf, string, offset, length) {
  6333. return asciiWrite(buf, string, offset, length)
  6334. }
  6335. function base64Write (buf, string, offset, length) {
  6336. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6337. }
  6338. function ucs2Write (buf, string, offset, length) {
  6339. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6340. }
  6341. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6342. // Buffer#write(string)
  6343. if (offset === undefined) {
  6344. encoding = 'utf8'
  6345. length = this.length
  6346. offset = 0
  6347. // Buffer#write(string, encoding)
  6348. } else if (length === undefined && typeof offset === 'string') {
  6349. encoding = offset
  6350. length = this.length
  6351. offset = 0
  6352. // Buffer#write(string, offset[, length][, encoding])
  6353. } else if (isFinite(offset)) {
  6354. offset = offset | 0
  6355. if (isFinite(length)) {
  6356. length = length | 0
  6357. if (encoding === undefined) encoding = 'utf8'
  6358. } else {
  6359. encoding = length
  6360. length = undefined
  6361. }
  6362. // legacy write(string, encoding, offset, length) - remove in v0.13
  6363. } else {
  6364. throw new Error(
  6365. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6366. )
  6367. }
  6368. var remaining = this.length - offset
  6369. if (length === undefined || length > remaining) length = remaining
  6370. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6371. throw new RangeError('Attempt to write outside buffer bounds')
  6372. }
  6373. if (!encoding) encoding = 'utf8'
  6374. var loweredCase = false
  6375. for (;;) {
  6376. switch (encoding) {
  6377. case 'hex':
  6378. return hexWrite(this, string, offset, length)
  6379. case 'utf8':
  6380. case 'utf-8':
  6381. return utf8Write(this, string, offset, length)
  6382. case 'ascii':
  6383. return asciiWrite(this, string, offset, length)
  6384. case 'latin1':
  6385. case 'binary':
  6386. return latin1Write(this, string, offset, length)
  6387. case 'base64':
  6388. // Warning: maxLength not taken into account in base64Write
  6389. return base64Write(this, string, offset, length)
  6390. case 'ucs2':
  6391. case 'ucs-2':
  6392. case 'utf16le':
  6393. case 'utf-16le':
  6394. return ucs2Write(this, string, offset, length)
  6395. default:
  6396. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6397. encoding = ('' + encoding).toLowerCase()
  6398. loweredCase = true
  6399. }
  6400. }
  6401. }
  6402. Buffer.prototype.toJSON = function toJSON () {
  6403. return {
  6404. type: 'Buffer',
  6405. data: Array.prototype.slice.call(this._arr || this, 0)
  6406. }
  6407. }
  6408. function base64Slice (buf, start, end) {
  6409. if (start === 0 && end === buf.length) {
  6410. return base64.fromByteArray(buf)
  6411. } else {
  6412. return base64.fromByteArray(buf.slice(start, end))
  6413. }
  6414. }
  6415. function utf8Slice (buf, start, end) {
  6416. end = Math.min(buf.length, end)
  6417. var res = []
  6418. var i = start
  6419. while (i < end) {
  6420. var firstByte = buf[i]
  6421. var codePoint = null
  6422. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6423. : (firstByte > 0xDF) ? 3
  6424. : (firstByte > 0xBF) ? 2
  6425. : 1
  6426. if (i + bytesPerSequence <= end) {
  6427. var secondByte, thirdByte, fourthByte, tempCodePoint
  6428. switch (bytesPerSequence) {
  6429. case 1:
  6430. if (firstByte < 0x80) {
  6431. codePoint = firstByte
  6432. }
  6433. break
  6434. case 2:
  6435. secondByte = buf[i + 1]
  6436. if ((secondByte & 0xC0) === 0x80) {
  6437. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6438. if (tempCodePoint > 0x7F) {
  6439. codePoint = tempCodePoint
  6440. }
  6441. }
  6442. break
  6443. case 3:
  6444. secondByte = buf[i + 1]
  6445. thirdByte = buf[i + 2]
  6446. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6447. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6448. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6449. codePoint = tempCodePoint
  6450. }
  6451. }
  6452. break
  6453. case 4:
  6454. secondByte = buf[i + 1]
  6455. thirdByte = buf[i + 2]
  6456. fourthByte = buf[i + 3]
  6457. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6458. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6459. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6460. codePoint = tempCodePoint
  6461. }
  6462. }
  6463. }
  6464. }
  6465. if (codePoint === null) {
  6466. // we did not generate a valid codePoint so insert a
  6467. // replacement char (U+FFFD) and advance only 1 byte
  6468. codePoint = 0xFFFD
  6469. bytesPerSequence = 1
  6470. } else if (codePoint > 0xFFFF) {
  6471. // encode to utf16 (surrogate pair dance)
  6472. codePoint -= 0x10000
  6473. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6474. codePoint = 0xDC00 | codePoint & 0x3FF
  6475. }
  6476. res.push(codePoint)
  6477. i += bytesPerSequence
  6478. }
  6479. return decodeCodePointsArray(res)
  6480. }
  6481. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6482. // the lowest limit is Chrome, with 0x10000 args.
  6483. // We go 1 magnitude less, for safety
  6484. var MAX_ARGUMENTS_LENGTH = 0x1000
  6485. function decodeCodePointsArray (codePoints) {
  6486. var len = codePoints.length
  6487. if (len <= MAX_ARGUMENTS_LENGTH) {
  6488. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6489. }
  6490. // Decode in chunks to avoid "call stack size exceeded".
  6491. var res = ''
  6492. var i = 0
  6493. while (i < len) {
  6494. res += String.fromCharCode.apply(
  6495. String,
  6496. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6497. )
  6498. }
  6499. return res
  6500. }
  6501. function asciiSlice (buf, start, end) {
  6502. var ret = ''
  6503. end = Math.min(buf.length, end)
  6504. for (var i = start; i < end; ++i) {
  6505. ret += String.fromCharCode(buf[i] & 0x7F)
  6506. }
  6507. return ret
  6508. }
  6509. function latin1Slice (buf, start, end) {
  6510. var ret = ''
  6511. end = Math.min(buf.length, end)
  6512. for (var i = start; i < end; ++i) {
  6513. ret += String.fromCharCode(buf[i])
  6514. }
  6515. return ret
  6516. }
  6517. function hexSlice (buf, start, end) {
  6518. var len = buf.length
  6519. if (!start || start < 0) start = 0
  6520. if (!end || end < 0 || end > len) end = len
  6521. var out = ''
  6522. for (var i = start; i < end; ++i) {
  6523. out += toHex(buf[i])
  6524. }
  6525. return out
  6526. }
  6527. function utf16leSlice (buf, start, end) {
  6528. var bytes = buf.slice(start, end)
  6529. var res = ''
  6530. for (var i = 0; i < bytes.length; i += 2) {
  6531. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6532. }
  6533. return res
  6534. }
  6535. Buffer.prototype.slice = function slice (start, end) {
  6536. var len = this.length
  6537. start = ~~start
  6538. end = end === undefined ? len : ~~end
  6539. if (start < 0) {
  6540. start += len
  6541. if (start < 0) start = 0
  6542. } else if (start > len) {
  6543. start = len
  6544. }
  6545. if (end < 0) {
  6546. end += len
  6547. if (end < 0) end = 0
  6548. } else if (end > len) {
  6549. end = len
  6550. }
  6551. if (end < start) end = start
  6552. var newBuf
  6553. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6554. newBuf = this.subarray(start, end)
  6555. newBuf.__proto__ = Buffer.prototype
  6556. } else {
  6557. var sliceLen = end - start
  6558. newBuf = new Buffer(sliceLen, undefined)
  6559. for (var i = 0; i < sliceLen; ++i) {
  6560. newBuf[i] = this[i + start]
  6561. }
  6562. }
  6563. return newBuf
  6564. }
  6565. /*
  6566. * Need to make sure that buffer isn't trying to write out of bounds.
  6567. */
  6568. function checkOffset (offset, ext, length) {
  6569. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6570. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6571. }
  6572. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6573. offset = offset | 0
  6574. byteLength = byteLength | 0
  6575. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6576. var val = this[offset]
  6577. var mul = 1
  6578. var i = 0
  6579. while (++i < byteLength && (mul *= 0x100)) {
  6580. val += this[offset + i] * mul
  6581. }
  6582. return val
  6583. }
  6584. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6585. offset = offset | 0
  6586. byteLength = byteLength | 0
  6587. if (!noAssert) {
  6588. checkOffset(offset, byteLength, this.length)
  6589. }
  6590. var val = this[offset + --byteLength]
  6591. var mul = 1
  6592. while (byteLength > 0 && (mul *= 0x100)) {
  6593. val += this[offset + --byteLength] * mul
  6594. }
  6595. return val
  6596. }
  6597. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6598. if (!noAssert) checkOffset(offset, 1, this.length)
  6599. return this[offset]
  6600. }
  6601. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6602. if (!noAssert) checkOffset(offset, 2, this.length)
  6603. return this[offset] | (this[offset + 1] << 8)
  6604. }
  6605. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6606. if (!noAssert) checkOffset(offset, 2, this.length)
  6607. return (this[offset] << 8) | this[offset + 1]
  6608. }
  6609. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6610. if (!noAssert) checkOffset(offset, 4, this.length)
  6611. return ((this[offset]) |
  6612. (this[offset + 1] << 8) |
  6613. (this[offset + 2] << 16)) +
  6614. (this[offset + 3] * 0x1000000)
  6615. }
  6616. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6617. if (!noAssert) checkOffset(offset, 4, this.length)
  6618. return (this[offset] * 0x1000000) +
  6619. ((this[offset + 1] << 16) |
  6620. (this[offset + 2] << 8) |
  6621. this[offset + 3])
  6622. }
  6623. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6624. offset = offset | 0
  6625. byteLength = byteLength | 0
  6626. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6627. var val = this[offset]
  6628. var mul = 1
  6629. var i = 0
  6630. while (++i < byteLength && (mul *= 0x100)) {
  6631. val += this[offset + i] * mul
  6632. }
  6633. mul *= 0x80
  6634. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6635. return val
  6636. }
  6637. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6638. offset = offset | 0
  6639. byteLength = byteLength | 0
  6640. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6641. var i = byteLength
  6642. var mul = 1
  6643. var val = this[offset + --i]
  6644. while (i > 0 && (mul *= 0x100)) {
  6645. val += this[offset + --i] * mul
  6646. }
  6647. mul *= 0x80
  6648. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6649. return val
  6650. }
  6651. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6652. if (!noAssert) checkOffset(offset, 1, this.length)
  6653. if (!(this[offset] & 0x80)) return (this[offset])
  6654. return ((0xff - this[offset] + 1) * -1)
  6655. }
  6656. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6657. if (!noAssert) checkOffset(offset, 2, this.length)
  6658. var val = this[offset] | (this[offset + 1] << 8)
  6659. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6660. }
  6661. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6662. if (!noAssert) checkOffset(offset, 2, this.length)
  6663. var val = this[offset + 1] | (this[offset] << 8)
  6664. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6665. }
  6666. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6667. if (!noAssert) checkOffset(offset, 4, this.length)
  6668. return (this[offset]) |
  6669. (this[offset + 1] << 8) |
  6670. (this[offset + 2] << 16) |
  6671. (this[offset + 3] << 24)
  6672. }
  6673. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6674. if (!noAssert) checkOffset(offset, 4, this.length)
  6675. return (this[offset] << 24) |
  6676. (this[offset + 1] << 16) |
  6677. (this[offset + 2] << 8) |
  6678. (this[offset + 3])
  6679. }
  6680. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6681. if (!noAssert) checkOffset(offset, 4, this.length)
  6682. return ieee754.read(this, offset, true, 23, 4)
  6683. }
  6684. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6685. if (!noAssert) checkOffset(offset, 4, this.length)
  6686. return ieee754.read(this, offset, false, 23, 4)
  6687. }
  6688. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6689. if (!noAssert) checkOffset(offset, 8, this.length)
  6690. return ieee754.read(this, offset, true, 52, 8)
  6691. }
  6692. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6693. if (!noAssert) checkOffset(offset, 8, this.length)
  6694. return ieee754.read(this, offset, false, 52, 8)
  6695. }
  6696. function checkInt (buf, value, offset, ext, max, min) {
  6697. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6698. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6699. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6700. }
  6701. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6702. value = +value
  6703. offset = offset | 0
  6704. byteLength = byteLength | 0
  6705. if (!noAssert) {
  6706. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6707. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6708. }
  6709. var mul = 1
  6710. var i = 0
  6711. this[offset] = value & 0xFF
  6712. while (++i < byteLength && (mul *= 0x100)) {
  6713. this[offset + i] = (value / mul) & 0xFF
  6714. }
  6715. return offset + byteLength
  6716. }
  6717. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6718. value = +value
  6719. offset = offset | 0
  6720. byteLength = byteLength | 0
  6721. if (!noAssert) {
  6722. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6723. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6724. }
  6725. var i = byteLength - 1
  6726. var mul = 1
  6727. this[offset + i] = value & 0xFF
  6728. while (--i >= 0 && (mul *= 0x100)) {
  6729. this[offset + i] = (value / mul) & 0xFF
  6730. }
  6731. return offset + byteLength
  6732. }
  6733. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6734. value = +value
  6735. offset = offset | 0
  6736. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6737. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6738. this[offset] = (value & 0xff)
  6739. return offset + 1
  6740. }
  6741. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6742. if (value < 0) value = 0xffff + value + 1
  6743. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6744. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6745. (littleEndian ? i : 1 - i) * 8
  6746. }
  6747. }
  6748. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6749. value = +value
  6750. offset = offset | 0
  6751. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6752. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6753. this[offset] = (value & 0xff)
  6754. this[offset + 1] = (value >>> 8)
  6755. } else {
  6756. objectWriteUInt16(this, value, offset, true)
  6757. }
  6758. return offset + 2
  6759. }
  6760. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6761. value = +value
  6762. offset = offset | 0
  6763. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6764. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6765. this[offset] = (value >>> 8)
  6766. this[offset + 1] = (value & 0xff)
  6767. } else {
  6768. objectWriteUInt16(this, value, offset, false)
  6769. }
  6770. return offset + 2
  6771. }
  6772. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6773. if (value < 0) value = 0xffffffff + value + 1
  6774. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6775. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6776. }
  6777. }
  6778. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6779. value = +value
  6780. offset = offset | 0
  6781. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6782. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6783. this[offset + 3] = (value >>> 24)
  6784. this[offset + 2] = (value >>> 16)
  6785. this[offset + 1] = (value >>> 8)
  6786. this[offset] = (value & 0xff)
  6787. } else {
  6788. objectWriteUInt32(this, value, offset, true)
  6789. }
  6790. return offset + 4
  6791. }
  6792. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6793. value = +value
  6794. offset = offset | 0
  6795. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6796. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6797. this[offset] = (value >>> 24)
  6798. this[offset + 1] = (value >>> 16)
  6799. this[offset + 2] = (value >>> 8)
  6800. this[offset + 3] = (value & 0xff)
  6801. } else {
  6802. objectWriteUInt32(this, value, offset, false)
  6803. }
  6804. return offset + 4
  6805. }
  6806. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6807. value = +value
  6808. offset = offset | 0
  6809. if (!noAssert) {
  6810. var limit = Math.pow(2, 8 * byteLength - 1)
  6811. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6812. }
  6813. var i = 0
  6814. var mul = 1
  6815. var sub = 0
  6816. this[offset] = value & 0xFF
  6817. while (++i < byteLength && (mul *= 0x100)) {
  6818. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6819. sub = 1
  6820. }
  6821. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6822. }
  6823. return offset + byteLength
  6824. }
  6825. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6826. value = +value
  6827. offset = offset | 0
  6828. if (!noAssert) {
  6829. var limit = Math.pow(2, 8 * byteLength - 1)
  6830. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6831. }
  6832. var i = byteLength - 1
  6833. var mul = 1
  6834. var sub = 0
  6835. this[offset + i] = value & 0xFF
  6836. while (--i >= 0 && (mul *= 0x100)) {
  6837. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6838. sub = 1
  6839. }
  6840. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6841. }
  6842. return offset + byteLength
  6843. }
  6844. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6845. value = +value
  6846. offset = offset | 0
  6847. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6848. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6849. if (value < 0) value = 0xff + value + 1
  6850. this[offset] = (value & 0xff)
  6851. return offset + 1
  6852. }
  6853. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6854. value = +value
  6855. offset = offset | 0
  6856. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6857. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6858. this[offset] = (value & 0xff)
  6859. this[offset + 1] = (value >>> 8)
  6860. } else {
  6861. objectWriteUInt16(this, value, offset, true)
  6862. }
  6863. return offset + 2
  6864. }
  6865. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6866. value = +value
  6867. offset = offset | 0
  6868. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6869. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6870. this[offset] = (value >>> 8)
  6871. this[offset + 1] = (value & 0xff)
  6872. } else {
  6873. objectWriteUInt16(this, value, offset, false)
  6874. }
  6875. return offset + 2
  6876. }
  6877. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6878. value = +value
  6879. offset = offset | 0
  6880. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6881. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6882. this[offset] = (value & 0xff)
  6883. this[offset + 1] = (value >>> 8)
  6884. this[offset + 2] = (value >>> 16)
  6885. this[offset + 3] = (value >>> 24)
  6886. } else {
  6887. objectWriteUInt32(this, value, offset, true)
  6888. }
  6889. return offset + 4
  6890. }
  6891. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6892. value = +value
  6893. offset = offset | 0
  6894. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6895. if (value < 0) value = 0xffffffff + value + 1
  6896. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6897. this[offset] = (value >>> 24)
  6898. this[offset + 1] = (value >>> 16)
  6899. this[offset + 2] = (value >>> 8)
  6900. this[offset + 3] = (value & 0xff)
  6901. } else {
  6902. objectWriteUInt32(this, value, offset, false)
  6903. }
  6904. return offset + 4
  6905. }
  6906. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6907. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6908. if (offset < 0) throw new RangeError('Index out of range')
  6909. }
  6910. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6911. if (!noAssert) {
  6912. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6913. }
  6914. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6915. return offset + 4
  6916. }
  6917. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6918. return writeFloat(this, value, offset, true, noAssert)
  6919. }
  6920. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6921. return writeFloat(this, value, offset, false, noAssert)
  6922. }
  6923. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6924. if (!noAssert) {
  6925. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6926. }
  6927. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6928. return offset + 8
  6929. }
  6930. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6931. return writeDouble(this, value, offset, true, noAssert)
  6932. }
  6933. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6934. return writeDouble(this, value, offset, false, noAssert)
  6935. }
  6936. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6937. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6938. if (!start) start = 0
  6939. if (!end && end !== 0) end = this.length
  6940. if (targetStart >= target.length) targetStart = target.length
  6941. if (!targetStart) targetStart = 0
  6942. if (end > 0 && end < start) end = start
  6943. // Copy 0 bytes; we're done
  6944. if (end === start) return 0
  6945. if (target.length === 0 || this.length === 0) return 0
  6946. // Fatal error conditions
  6947. if (targetStart < 0) {
  6948. throw new RangeError('targetStart out of bounds')
  6949. }
  6950. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6951. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6952. // Are we oob?
  6953. if (end > this.length) end = this.length
  6954. if (target.length - targetStart < end - start) {
  6955. end = target.length - targetStart + start
  6956. }
  6957. var len = end - start
  6958. var i
  6959. if (this === target && start < targetStart && targetStart < end) {
  6960. // descending copy from end
  6961. for (i = len - 1; i >= 0; --i) {
  6962. target[i + targetStart] = this[i + start]
  6963. }
  6964. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6965. // ascending copy from start
  6966. for (i = 0; i < len; ++i) {
  6967. target[i + targetStart] = this[i + start]
  6968. }
  6969. } else {
  6970. Uint8Array.prototype.set.call(
  6971. target,
  6972. this.subarray(start, start + len),
  6973. targetStart
  6974. )
  6975. }
  6976. return len
  6977. }
  6978. // Usage:
  6979. // buffer.fill(number[, offset[, end]])
  6980. // buffer.fill(buffer[, offset[, end]])
  6981. // buffer.fill(string[, offset[, end]][, encoding])
  6982. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6983. // Handle string cases:
  6984. if (typeof val === 'string') {
  6985. if (typeof start === 'string') {
  6986. encoding = start
  6987. start = 0
  6988. end = this.length
  6989. } else if (typeof end === 'string') {
  6990. encoding = end
  6991. end = this.length
  6992. }
  6993. if (val.length === 1) {
  6994. var code = val.charCodeAt(0)
  6995. if (code < 256) {
  6996. val = code
  6997. }
  6998. }
  6999. if (encoding !== undefined && typeof encoding !== 'string') {
  7000. throw new TypeError('encoding must be a string')
  7001. }
  7002. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7003. throw new TypeError('Unknown encoding: ' + encoding)
  7004. }
  7005. } else if (typeof val === 'number') {
  7006. val = val & 255
  7007. }
  7008. // Invalid ranges are not set to a default, so can range check early.
  7009. if (start < 0 || this.length < start || this.length < end) {
  7010. throw new RangeError('Out of range index')
  7011. }
  7012. if (end <= start) {
  7013. return this
  7014. }
  7015. start = start >>> 0
  7016. end = end === undefined ? this.length : end >>> 0
  7017. if (!val) val = 0
  7018. var i
  7019. if (typeof val === 'number') {
  7020. for (i = start; i < end; ++i) {
  7021. this[i] = val
  7022. }
  7023. } else {
  7024. var bytes = Buffer.isBuffer(val)
  7025. ? val
  7026. : utf8ToBytes(new Buffer(val, encoding).toString())
  7027. var len = bytes.length
  7028. for (i = 0; i < end - start; ++i) {
  7029. this[i + start] = bytes[i % len]
  7030. }
  7031. }
  7032. return this
  7033. }
  7034. // HELPER FUNCTIONS
  7035. // ================
  7036. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  7037. function base64clean (str) {
  7038. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7039. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  7040. // Node converts strings with length < 2 to ''
  7041. if (str.length < 2) return ''
  7042. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7043. while (str.length % 4 !== 0) {
  7044. str = str + '='
  7045. }
  7046. return str
  7047. }
  7048. function stringtrim (str) {
  7049. if (str.trim) return str.trim()
  7050. return str.replace(/^\s+|\s+$/g, '')
  7051. }
  7052. function toHex (n) {
  7053. if (n < 16) return '0' + n.toString(16)
  7054. return n.toString(16)
  7055. }
  7056. function utf8ToBytes (string, units) {
  7057. units = units || Infinity
  7058. var codePoint
  7059. var length = string.length
  7060. var leadSurrogate = null
  7061. var bytes = []
  7062. for (var i = 0; i < length; ++i) {
  7063. codePoint = string.charCodeAt(i)
  7064. // is surrogate component
  7065. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7066. // last char was a lead
  7067. if (!leadSurrogate) {
  7068. // no lead yet
  7069. if (codePoint > 0xDBFF) {
  7070. // unexpected trail
  7071. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7072. continue
  7073. } else if (i + 1 === length) {
  7074. // unpaired lead
  7075. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7076. continue
  7077. }
  7078. // valid lead
  7079. leadSurrogate = codePoint
  7080. continue
  7081. }
  7082. // 2 leads in a row
  7083. if (codePoint < 0xDC00) {
  7084. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7085. leadSurrogate = codePoint
  7086. continue
  7087. }
  7088. // valid surrogate pair
  7089. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7090. } else if (leadSurrogate) {
  7091. // valid bmp char, but last char was a lead
  7092. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7093. }
  7094. leadSurrogate = null
  7095. // encode utf8
  7096. if (codePoint < 0x80) {
  7097. if ((units -= 1) < 0) break
  7098. bytes.push(codePoint)
  7099. } else if (codePoint < 0x800) {
  7100. if ((units -= 2) < 0) break
  7101. bytes.push(
  7102. codePoint >> 0x6 | 0xC0,
  7103. codePoint & 0x3F | 0x80
  7104. )
  7105. } else if (codePoint < 0x10000) {
  7106. if ((units -= 3) < 0) break
  7107. bytes.push(
  7108. codePoint >> 0xC | 0xE0,
  7109. codePoint >> 0x6 & 0x3F | 0x80,
  7110. codePoint & 0x3F | 0x80
  7111. )
  7112. } else if (codePoint < 0x110000) {
  7113. if ((units -= 4) < 0) break
  7114. bytes.push(
  7115. codePoint >> 0x12 | 0xF0,
  7116. codePoint >> 0xC & 0x3F | 0x80,
  7117. codePoint >> 0x6 & 0x3F | 0x80,
  7118. codePoint & 0x3F | 0x80
  7119. )
  7120. } else {
  7121. throw new Error('Invalid code point')
  7122. }
  7123. }
  7124. return bytes
  7125. }
  7126. function asciiToBytes (str) {
  7127. var byteArray = []
  7128. for (var i = 0; i < str.length; ++i) {
  7129. // Node's code seems to be doing this and not & 0x7F..
  7130. byteArray.push(str.charCodeAt(i) & 0xFF)
  7131. }
  7132. return byteArray
  7133. }
  7134. function utf16leToBytes (str, units) {
  7135. var c, hi, lo
  7136. var byteArray = []
  7137. for (var i = 0; i < str.length; ++i) {
  7138. if ((units -= 2) < 0) break
  7139. c = str.charCodeAt(i)
  7140. hi = c >> 8
  7141. lo = c % 256
  7142. byteArray.push(lo)
  7143. byteArray.push(hi)
  7144. }
  7145. return byteArray
  7146. }
  7147. function base64ToBytes (str) {
  7148. return base64.toByteArray(base64clean(str))
  7149. }
  7150. function blitBuffer (src, dst, offset, length) {
  7151. for (var i = 0; i < length; ++i) {
  7152. if ((i + offset >= dst.length) || (i >= src.length)) break
  7153. dst[i + offset] = src[i]
  7154. }
  7155. return i
  7156. }
  7157. function isnan (val) {
  7158. return val !== val // eslint-disable-line no-self-compare
  7159. }
  7160. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7161. /***/ }),
  7162. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7163. /*!**************************************************!*\
  7164. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7165. \**************************************************/
  7166. /*! no static exports found */
  7167. /***/ (function(module, exports, __webpack_require__) {
  7168. /*!
  7169. * clipboard.js v2.0.4
  7170. * https://zenorocha.github.io/clipboard.js
  7171. *
  7172. * Licensed MIT © Zeno Rocha
  7173. */
  7174. (function webpackUniversalModuleDefinition(root, factory) {
  7175. if(true)
  7176. module.exports = factory();
  7177. else {}
  7178. })(this, function() {
  7179. return /******/ (function(modules) { // webpackBootstrap
  7180. /******/ // The module cache
  7181. /******/ var installedModules = {};
  7182. /******/
  7183. /******/ // The require function
  7184. /******/ function __webpack_require__(moduleId) {
  7185. /******/
  7186. /******/ // Check if module is in cache
  7187. /******/ if(installedModules[moduleId]) {
  7188. /******/ return installedModules[moduleId].exports;
  7189. /******/ }
  7190. /******/ // Create a new module (and put it into the cache)
  7191. /******/ var module = installedModules[moduleId] = {
  7192. /******/ i: moduleId,
  7193. /******/ l: false,
  7194. /******/ exports: {}
  7195. /******/ };
  7196. /******/
  7197. /******/ // Execute the module function
  7198. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7199. /******/
  7200. /******/ // Flag the module as loaded
  7201. /******/ module.l = true;
  7202. /******/
  7203. /******/ // Return the exports of the module
  7204. /******/ return module.exports;
  7205. /******/ }
  7206. /******/
  7207. /******/
  7208. /******/ // expose the modules object (__webpack_modules__)
  7209. /******/ __webpack_require__.m = modules;
  7210. /******/
  7211. /******/ // expose the module cache
  7212. /******/ __webpack_require__.c = installedModules;
  7213. /******/
  7214. /******/ // define getter function for harmony exports
  7215. /******/ __webpack_require__.d = function(exports, name, getter) {
  7216. /******/ if(!__webpack_require__.o(exports, name)) {
  7217. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7218. /******/ }
  7219. /******/ };
  7220. /******/
  7221. /******/ // define __esModule on exports
  7222. /******/ __webpack_require__.r = function(exports) {
  7223. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7224. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7225. /******/ }
  7226. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7227. /******/ };
  7228. /******/
  7229. /******/ // create a fake namespace object
  7230. /******/ // mode & 1: value is a module id, require it
  7231. /******/ // mode & 2: merge all properties of value into the ns
  7232. /******/ // mode & 4: return value when already ns object
  7233. /******/ // mode & 8|1: behave like require
  7234. /******/ __webpack_require__.t = function(value, mode) {
  7235. /******/ if(mode & 1) value = __webpack_require__(value);
  7236. /******/ if(mode & 8) return value;
  7237. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7238. /******/ var ns = Object.create(null);
  7239. /******/ __webpack_require__.r(ns);
  7240. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7241. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7242. /******/ return ns;
  7243. /******/ };
  7244. /******/
  7245. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7246. /******/ __webpack_require__.n = function(module) {
  7247. /******/ var getter = module && module.__esModule ?
  7248. /******/ function getDefault() { return module['default']; } :
  7249. /******/ function getModuleExports() { return module; };
  7250. /******/ __webpack_require__.d(getter, 'a', getter);
  7251. /******/ return getter;
  7252. /******/ };
  7253. /******/
  7254. /******/ // Object.prototype.hasOwnProperty.call
  7255. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7256. /******/
  7257. /******/ // __webpack_public_path__
  7258. /******/ __webpack_require__.p = "";
  7259. /******/
  7260. /******/
  7261. /******/ // Load entry module and return exports
  7262. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7263. /******/ })
  7264. /************************************************************************/
  7265. /******/ ([
  7266. /* 0 */
  7267. /***/ (function(module, exports, __webpack_require__) {
  7268. "use strict";
  7269. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7270. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7271. var _clipboardAction = __webpack_require__(1);
  7272. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7273. var _tinyEmitter = __webpack_require__(3);
  7274. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7275. var _goodListener = __webpack_require__(4);
  7276. var _goodListener2 = _interopRequireDefault(_goodListener);
  7277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7278. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7279. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  7280. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7281. /**
  7282. * Base class which takes one or more elements, adds event listeners to them,
  7283. * and instantiates a new `ClipboardAction` on each click.
  7284. */
  7285. var Clipboard = function (_Emitter) {
  7286. _inherits(Clipboard, _Emitter);
  7287. /**
  7288. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7289. * @param {Object} options
  7290. */
  7291. function Clipboard(trigger, options) {
  7292. _classCallCheck(this, Clipboard);
  7293. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7294. _this.resolveOptions(options);
  7295. _this.listenClick(trigger);
  7296. return _this;
  7297. }
  7298. /**
  7299. * Defines if attributes would be resolved using internal setter functions
  7300. * or custom functions that were passed in the constructor.
  7301. * @param {Object} options
  7302. */
  7303. _createClass(Clipboard, [{
  7304. key: 'resolveOptions',
  7305. value: function resolveOptions() {
  7306. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7307. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7308. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7309. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7310. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7311. }
  7312. /**
  7313. * Adds a click event listener to the passed trigger.
  7314. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7315. */
  7316. }, {
  7317. key: 'listenClick',
  7318. value: function listenClick(trigger) {
  7319. var _this2 = this;
  7320. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7321. return _this2.onClick(e);
  7322. });
  7323. }
  7324. /**
  7325. * Defines a new `ClipboardAction` on each click event.
  7326. * @param {Event} e
  7327. */
  7328. }, {
  7329. key: 'onClick',
  7330. value: function onClick(e) {
  7331. var trigger = e.delegateTarget || e.currentTarget;
  7332. if (this.clipboardAction) {
  7333. this.clipboardAction = null;
  7334. }
  7335. this.clipboardAction = new _clipboardAction2.default({
  7336. action: this.action(trigger),
  7337. target: this.target(trigger),
  7338. text: this.text(trigger),
  7339. container: this.container,
  7340. trigger: trigger,
  7341. emitter: this
  7342. });
  7343. }
  7344. /**
  7345. * Default `action` lookup function.
  7346. * @param {Element} trigger
  7347. */
  7348. }, {
  7349. key: 'defaultAction',
  7350. value: function defaultAction(trigger) {
  7351. return getAttributeValue('action', trigger);
  7352. }
  7353. /**
  7354. * Default `target` lookup function.
  7355. * @param {Element} trigger
  7356. */
  7357. }, {
  7358. key: 'defaultTarget',
  7359. value: function defaultTarget(trigger) {
  7360. var selector = getAttributeValue('target', trigger);
  7361. if (selector) {
  7362. return document.querySelector(selector);
  7363. }
  7364. }
  7365. /**
  7366. * Returns the support of the given action, or all actions if no action is
  7367. * given.
  7368. * @param {String} [action]
  7369. */
  7370. }, {
  7371. key: 'defaultText',
  7372. /**
  7373. * Default `text` lookup function.
  7374. * @param {Element} trigger
  7375. */
  7376. value: function defaultText(trigger) {
  7377. return getAttributeValue('text', trigger);
  7378. }
  7379. /**
  7380. * Destroy lifecycle.
  7381. */
  7382. }, {
  7383. key: 'destroy',
  7384. value: function destroy() {
  7385. this.listener.destroy();
  7386. if (this.clipboardAction) {
  7387. this.clipboardAction.destroy();
  7388. this.clipboardAction = null;
  7389. }
  7390. }
  7391. }], [{
  7392. key: 'isSupported',
  7393. value: function isSupported() {
  7394. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7395. var actions = typeof action === 'string' ? [action] : action;
  7396. var support = !!document.queryCommandSupported;
  7397. actions.forEach(function (action) {
  7398. support = support && !!document.queryCommandSupported(action);
  7399. });
  7400. return support;
  7401. }
  7402. }]);
  7403. return Clipboard;
  7404. }(_tinyEmitter2.default);
  7405. /**
  7406. * Helper function to retrieve attribute value.
  7407. * @param {String} suffix
  7408. * @param {Element} element
  7409. */
  7410. function getAttributeValue(suffix, element) {
  7411. var attribute = 'data-clipboard-' + suffix;
  7412. if (!element.hasAttribute(attribute)) {
  7413. return;
  7414. }
  7415. return element.getAttribute(attribute);
  7416. }
  7417. module.exports = Clipboard;
  7418. /***/ }),
  7419. /* 1 */
  7420. /***/ (function(module, exports, __webpack_require__) {
  7421. "use strict";
  7422. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7423. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7424. var _select = __webpack_require__(2);
  7425. var _select2 = _interopRequireDefault(_select);
  7426. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7428. /**
  7429. * Inner class which performs selection from either `text` or `target`
  7430. * properties and then executes copy or cut operations.
  7431. */
  7432. var ClipboardAction = function () {
  7433. /**
  7434. * @param {Object} options
  7435. */
  7436. function ClipboardAction(options) {
  7437. _classCallCheck(this, ClipboardAction);
  7438. this.resolveOptions(options);
  7439. this.initSelection();
  7440. }
  7441. /**
  7442. * Defines base properties passed from constructor.
  7443. * @param {Object} options
  7444. */
  7445. _createClass(ClipboardAction, [{
  7446. key: 'resolveOptions',
  7447. value: function resolveOptions() {
  7448. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7449. this.action = options.action;
  7450. this.container = options.container;
  7451. this.emitter = options.emitter;
  7452. this.target = options.target;
  7453. this.text = options.text;
  7454. this.trigger = options.trigger;
  7455. this.selectedText = '';
  7456. }
  7457. /**
  7458. * Decides which selection strategy is going to be applied based
  7459. * on the existence of `text` and `target` properties.
  7460. */
  7461. }, {
  7462. key: 'initSelection',
  7463. value: function initSelection() {
  7464. if (this.text) {
  7465. this.selectFake();
  7466. } else if (this.target) {
  7467. this.selectTarget();
  7468. }
  7469. }
  7470. /**
  7471. * Creates a fake textarea element, sets its value from `text` property,
  7472. * and makes a selection on it.
  7473. */
  7474. }, {
  7475. key: 'selectFake',
  7476. value: function selectFake() {
  7477. var _this = this;
  7478. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7479. this.removeFake();
  7480. this.fakeHandlerCallback = function () {
  7481. return _this.removeFake();
  7482. };
  7483. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7484. this.fakeElem = document.createElement('textarea');
  7485. // Prevent zooming on iOS
  7486. this.fakeElem.style.fontSize = '12pt';
  7487. // Reset box model
  7488. this.fakeElem.style.border = '0';
  7489. this.fakeElem.style.padding = '0';
  7490. this.fakeElem.style.margin = '0';
  7491. // Move element out of screen horizontally
  7492. this.fakeElem.style.position = 'absolute';
  7493. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7494. // Move element to the same position vertically
  7495. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7496. this.fakeElem.style.top = yPosition + 'px';
  7497. this.fakeElem.setAttribute('readonly', '');
  7498. this.fakeElem.value = this.text;
  7499. this.container.appendChild(this.fakeElem);
  7500. this.selectedText = (0, _select2.default)(this.fakeElem);
  7501. this.copyText();
  7502. }
  7503. /**
  7504. * Only removes the fake element after another click event, that way
  7505. * a user can hit `Ctrl+C` to copy because selection still exists.
  7506. */
  7507. }, {
  7508. key: 'removeFake',
  7509. value: function removeFake() {
  7510. if (this.fakeHandler) {
  7511. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7512. this.fakeHandler = null;
  7513. this.fakeHandlerCallback = null;
  7514. }
  7515. if (this.fakeElem) {
  7516. this.container.removeChild(this.fakeElem);
  7517. this.fakeElem = null;
  7518. }
  7519. }
  7520. /**
  7521. * Selects the content from element passed on `target` property.
  7522. */
  7523. }, {
  7524. key: 'selectTarget',
  7525. value: function selectTarget() {
  7526. this.selectedText = (0, _select2.default)(this.target);
  7527. this.copyText();
  7528. }
  7529. /**
  7530. * Executes the copy operation based on the current selection.
  7531. */
  7532. }, {
  7533. key: 'copyText',
  7534. value: function copyText() {
  7535. var succeeded = void 0;
  7536. try {
  7537. succeeded = document.execCommand(this.action);
  7538. } catch (err) {
  7539. succeeded = false;
  7540. }
  7541. this.handleResult(succeeded);
  7542. }
  7543. /**
  7544. * Fires an event based on the copy operation result.
  7545. * @param {Boolean} succeeded
  7546. */
  7547. }, {
  7548. key: 'handleResult',
  7549. value: function handleResult(succeeded) {
  7550. this.emitter.emit(succeeded ? 'success' : 'error', {
  7551. action: this.action,
  7552. text: this.selectedText,
  7553. trigger: this.trigger,
  7554. clearSelection: this.clearSelection.bind(this)
  7555. });
  7556. }
  7557. /**
  7558. * Moves focus away from `target` and back to the trigger, removes current selection.
  7559. */
  7560. }, {
  7561. key: 'clearSelection',
  7562. value: function clearSelection() {
  7563. if (this.trigger) {
  7564. this.trigger.focus();
  7565. }
  7566. window.getSelection().removeAllRanges();
  7567. }
  7568. /**
  7569. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7570. * @param {String} action
  7571. */
  7572. }, {
  7573. key: 'destroy',
  7574. /**
  7575. * Destroy lifecycle.
  7576. */
  7577. value: function destroy() {
  7578. this.removeFake();
  7579. }
  7580. }, {
  7581. key: 'action',
  7582. set: function set() {
  7583. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7584. this._action = action;
  7585. if (this._action !== 'copy' && this._action !== 'cut') {
  7586. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7587. }
  7588. }
  7589. /**
  7590. * Gets the `action` property.
  7591. * @return {String}
  7592. */
  7593. ,
  7594. get: function get() {
  7595. return this._action;
  7596. }
  7597. /**
  7598. * Sets the `target` property using an element
  7599. * that will be have its content copied.
  7600. * @param {Element} target
  7601. */
  7602. }, {
  7603. key: 'target',
  7604. set: function set(target) {
  7605. if (target !== undefined) {
  7606. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7607. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7608. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7609. }
  7610. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7611. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7612. }
  7613. this._target = target;
  7614. } else {
  7615. throw new Error('Invalid "target" value, use a valid Element');
  7616. }
  7617. }
  7618. }
  7619. /**
  7620. * Gets the `target` property.
  7621. * @return {String|HTMLElement}
  7622. */
  7623. ,
  7624. get: function get() {
  7625. return this._target;
  7626. }
  7627. }]);
  7628. return ClipboardAction;
  7629. }();
  7630. module.exports = ClipboardAction;
  7631. /***/ }),
  7632. /* 2 */
  7633. /***/ (function(module, exports) {
  7634. function select(element) {
  7635. var selectedText;
  7636. if (element.nodeName === 'SELECT') {
  7637. element.focus();
  7638. selectedText = element.value;
  7639. }
  7640. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7641. var isReadOnly = element.hasAttribute('readonly');
  7642. if (!isReadOnly) {
  7643. element.setAttribute('readonly', '');
  7644. }
  7645. element.select();
  7646. element.setSelectionRange(0, element.value.length);
  7647. if (!isReadOnly) {
  7648. element.removeAttribute('readonly');
  7649. }
  7650. selectedText = element.value;
  7651. }
  7652. else {
  7653. if (element.hasAttribute('contenteditable')) {
  7654. element.focus();
  7655. }
  7656. var selection = window.getSelection();
  7657. var range = document.createRange();
  7658. range.selectNodeContents(element);
  7659. selection.removeAllRanges();
  7660. selection.addRange(range);
  7661. selectedText = selection.toString();
  7662. }
  7663. return selectedText;
  7664. }
  7665. module.exports = select;
  7666. /***/ }),
  7667. /* 3 */
  7668. /***/ (function(module, exports) {
  7669. function E () {
  7670. // Keep this empty so it's easier to inherit from
  7671. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7672. }
  7673. E.prototype = {
  7674. on: function (name, callback, ctx) {
  7675. var e = this.e || (this.e = {});
  7676. (e[name] || (e[name] = [])).push({
  7677. fn: callback,
  7678. ctx: ctx
  7679. });
  7680. return this;
  7681. },
  7682. once: function (name, callback, ctx) {
  7683. var self = this;
  7684. function listener () {
  7685. self.off(name, listener);
  7686. callback.apply(ctx, arguments);
  7687. };
  7688. listener._ = callback
  7689. return this.on(name, listener, ctx);
  7690. },
  7691. emit: function (name) {
  7692. var data = [].slice.call(arguments, 1);
  7693. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7694. var i = 0;
  7695. var len = evtArr.length;
  7696. for (i; i < len; i++) {
  7697. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7698. }
  7699. return this;
  7700. },
  7701. off: function (name, callback) {
  7702. var e = this.e || (this.e = {});
  7703. var evts = e[name];
  7704. var liveEvents = [];
  7705. if (evts && callback) {
  7706. for (var i = 0, len = evts.length; i < len; i++) {
  7707. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7708. liveEvents.push(evts[i]);
  7709. }
  7710. }
  7711. // Remove event from queue to prevent memory leak
  7712. // Suggested by https://github.com/lazd
  7713. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7714. (liveEvents.length)
  7715. ? e[name] = liveEvents
  7716. : delete e[name];
  7717. return this;
  7718. }
  7719. };
  7720. module.exports = E;
  7721. /***/ }),
  7722. /* 4 */
  7723. /***/ (function(module, exports, __webpack_require__) {
  7724. var is = __webpack_require__(5);
  7725. var delegate = __webpack_require__(6);
  7726. /**
  7727. * Validates all params and calls the right
  7728. * listener function based on its target type.
  7729. *
  7730. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7731. * @param {String} type
  7732. * @param {Function} callback
  7733. * @return {Object}
  7734. */
  7735. function listen(target, type, callback) {
  7736. if (!target && !type && !callback) {
  7737. throw new Error('Missing required arguments');
  7738. }
  7739. if (!is.string(type)) {
  7740. throw new TypeError('Second argument must be a String');
  7741. }
  7742. if (!is.fn(callback)) {
  7743. throw new TypeError('Third argument must be a Function');
  7744. }
  7745. if (is.node(target)) {
  7746. return listenNode(target, type, callback);
  7747. }
  7748. else if (is.nodeList(target)) {
  7749. return listenNodeList(target, type, callback);
  7750. }
  7751. else if (is.string(target)) {
  7752. return listenSelector(target, type, callback);
  7753. }
  7754. else {
  7755. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7756. }
  7757. }
  7758. /**
  7759. * Adds an event listener to a HTML element
  7760. * and returns a remove listener function.
  7761. *
  7762. * @param {HTMLElement} node
  7763. * @param {String} type
  7764. * @param {Function} callback
  7765. * @return {Object}
  7766. */
  7767. function listenNode(node, type, callback) {
  7768. node.addEventListener(type, callback);
  7769. return {
  7770. destroy: function() {
  7771. node.removeEventListener(type, callback);
  7772. }
  7773. }
  7774. }
  7775. /**
  7776. * Add an event listener to a list of HTML elements
  7777. * and returns a remove listener function.
  7778. *
  7779. * @param {NodeList|HTMLCollection} nodeList
  7780. * @param {String} type
  7781. * @param {Function} callback
  7782. * @return {Object}
  7783. */
  7784. function listenNodeList(nodeList, type, callback) {
  7785. Array.prototype.forEach.call(nodeList, function(node) {
  7786. node.addEventListener(type, callback);
  7787. });
  7788. return {
  7789. destroy: function() {
  7790. Array.prototype.forEach.call(nodeList, function(node) {
  7791. node.removeEventListener(type, callback);
  7792. });
  7793. }
  7794. }
  7795. }
  7796. /**
  7797. * Add an event listener to a selector
  7798. * and returns a remove listener function.
  7799. *
  7800. * @param {String} selector
  7801. * @param {String} type
  7802. * @param {Function} callback
  7803. * @return {Object}
  7804. */
  7805. function listenSelector(selector, type, callback) {
  7806. return delegate(document.body, selector, type, callback);
  7807. }
  7808. module.exports = listen;
  7809. /***/ }),
  7810. /* 5 */
  7811. /***/ (function(module, exports) {
  7812. /**
  7813. * Check if argument is a HTML element.
  7814. *
  7815. * @param {Object} value
  7816. * @return {Boolean}
  7817. */
  7818. exports.node = function(value) {
  7819. return value !== undefined
  7820. && value instanceof HTMLElement
  7821. && value.nodeType === 1;
  7822. };
  7823. /**
  7824. * Check if argument is a list of HTML elements.
  7825. *
  7826. * @param {Object} value
  7827. * @return {Boolean}
  7828. */
  7829. exports.nodeList = function(value) {
  7830. var type = Object.prototype.toString.call(value);
  7831. return value !== undefined
  7832. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7833. && ('length' in value)
  7834. && (value.length === 0 || exports.node(value[0]));
  7835. };
  7836. /**
  7837. * Check if argument is a string.
  7838. *
  7839. * @param {Object} value
  7840. * @return {Boolean}
  7841. */
  7842. exports.string = function(value) {
  7843. return typeof value === 'string'
  7844. || value instanceof String;
  7845. };
  7846. /**
  7847. * Check if argument is a function.
  7848. *
  7849. * @param {Object} value
  7850. * @return {Boolean}
  7851. */
  7852. exports.fn = function(value) {
  7853. var type = Object.prototype.toString.call(value);
  7854. return type === '[object Function]';
  7855. };
  7856. /***/ }),
  7857. /* 6 */
  7858. /***/ (function(module, exports, __webpack_require__) {
  7859. var closest = __webpack_require__(7);
  7860. /**
  7861. * Delegates event to a selector.
  7862. *
  7863. * @param {Element} element
  7864. * @param {String} selector
  7865. * @param {String} type
  7866. * @param {Function} callback
  7867. * @param {Boolean} useCapture
  7868. * @return {Object}
  7869. */
  7870. function _delegate(element, selector, type, callback, useCapture) {
  7871. var listenerFn = listener.apply(this, arguments);
  7872. element.addEventListener(type, listenerFn, useCapture);
  7873. return {
  7874. destroy: function() {
  7875. element.removeEventListener(type, listenerFn, useCapture);
  7876. }
  7877. }
  7878. }
  7879. /**
  7880. * Delegates event to a selector.
  7881. *
  7882. * @param {Element|String|Array} [elements]
  7883. * @param {String} selector
  7884. * @param {String} type
  7885. * @param {Function} callback
  7886. * @param {Boolean} useCapture
  7887. * @return {Object}
  7888. */
  7889. function delegate(elements, selector, type, callback, useCapture) {
  7890. // Handle the regular Element usage
  7891. if (typeof elements.addEventListener === 'function') {
  7892. return _delegate.apply(null, arguments);
  7893. }
  7894. // Handle Element-less usage, it defaults to global delegation
  7895. if (typeof type === 'function') {
  7896. // Use `document` as the first parameter, then apply arguments
  7897. // This is a short way to .unshift `arguments` without running into deoptimizations
  7898. return _delegate.bind(null, document).apply(null, arguments);
  7899. }
  7900. // Handle Selector-based usage
  7901. if (typeof elements === 'string') {
  7902. elements = document.querySelectorAll(elements);
  7903. }
  7904. // Handle Array-like based usage
  7905. return Array.prototype.map.call(elements, function (element) {
  7906. return _delegate(element, selector, type, callback, useCapture);
  7907. });
  7908. }
  7909. /**
  7910. * Finds closest match and invokes callback.
  7911. *
  7912. * @param {Element} element
  7913. * @param {String} selector
  7914. * @param {String} type
  7915. * @param {Function} callback
  7916. * @return {Function}
  7917. */
  7918. function listener(element, selector, type, callback) {
  7919. return function(e) {
  7920. e.delegateTarget = closest(e.target, selector);
  7921. if (e.delegateTarget) {
  7922. callback.call(element, e);
  7923. }
  7924. }
  7925. }
  7926. module.exports = delegate;
  7927. /***/ }),
  7928. /* 7 */
  7929. /***/ (function(module, exports) {
  7930. var DOCUMENT_NODE_TYPE = 9;
  7931. /**
  7932. * A polyfill for Element.matches()
  7933. */
  7934. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  7935. var proto = Element.prototype;
  7936. proto.matches = proto.matchesSelector ||
  7937. proto.mozMatchesSelector ||
  7938. proto.msMatchesSelector ||
  7939. proto.oMatchesSelector ||
  7940. proto.webkitMatchesSelector;
  7941. }
  7942. /**
  7943. * Finds the closest parent that matches a selector.
  7944. *
  7945. * @param {Element} element
  7946. * @param {String} selector
  7947. * @return {Function}
  7948. */
  7949. function closest (element, selector) {
  7950. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  7951. if (typeof element.matches === 'function' &&
  7952. element.matches(selector)) {
  7953. return element;
  7954. }
  7955. element = element.parentNode;
  7956. }
  7957. }
  7958. module.exports = closest;
  7959. /***/ })
  7960. /******/ ]);
  7961. });
  7962. /***/ }),
  7963. /***/ "./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  7964. /*!********************************************************************************************************************************************************************************************************************************************************************************************!*\
  7965. !*** ./node_modules/css-loader??ref--6-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  7966. \********************************************************************************************************************************************************************************************************************************************************************************************/
  7967. /*! no static exports found */
  7968. /***/ (function(module, exports, __webpack_require__) {
  7969. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
  7970. // imports
  7971. // module
  7972. exports.push([module.i, "\n.full-height[data-v-1ae8ae93] {\n height: 100vh;\n}\n.flex-center[data-v-1ae8ae93] {\n align-items: center;\n display: flex;\n justify-content: center;\n}\n.position-ref[data-v-1ae8ae93] {\n position: relative;\n}\n.top-right[data-v-1ae8ae93] {\n position: absolute;\n right: 10px;\n top: 18px;\n}\n.content[data-v-1ae8ae93] {\n text-align: center;\n}\n.title[data-v-1ae8ae93] {\n font-size: 60px;\n}\n.links > a[data-v-1ae8ae93] {\n color: #636b6f;\n padding: 0 25px;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: .1rem;\n text-decoration: none;\n text-transform: uppercase;\n}\n.m-b-md[data-v-1ae8ae93] {\n margin-bottom: 30px;\n color: #000000;\n}\n", ""]);
  7973. // exports
  7974. /***/ }),
  7975. /***/ "./node_modules/css-loader/lib/css-base.js":
  7976. /*!*************************************************!*\
  7977. !*** ./node_modules/css-loader/lib/css-base.js ***!
  7978. \*************************************************/
  7979. /*! no static exports found */
  7980. /***/ (function(module, exports) {
  7981. /*
  7982. MIT License http://www.opensource.org/licenses/mit-license.php
  7983. Author Tobias Koppers @sokra
  7984. */
  7985. // css base code, injected by the css-loader
  7986. module.exports = function(useSourceMap) {
  7987. var list = [];
  7988. // return the list of modules as css string
  7989. list.toString = function toString() {
  7990. return this.map(function (item) {
  7991. var content = cssWithMappingToString(item, useSourceMap);
  7992. if(item[2]) {
  7993. return "@media " + item[2] + "{" + content + "}";
  7994. } else {
  7995. return content;
  7996. }
  7997. }).join("");
  7998. };
  7999. // import a list of modules into the list
  8000. list.i = function(modules, mediaQuery) {
  8001. if(typeof modules === "string")
  8002. modules = [[null, modules, ""]];
  8003. var alreadyImportedModules = {};
  8004. for(var i = 0; i < this.length; i++) {
  8005. var id = this[i][0];
  8006. if(typeof id === "number")
  8007. alreadyImportedModules[id] = true;
  8008. }
  8009. for(i = 0; i < modules.length; i++) {
  8010. var item = modules[i];
  8011. // skip already imported module
  8012. // this implementation is not 100% perfect for weird media query combinations
  8013. // when a module is imported multiple times with different media queries.
  8014. // I hope this will never occur (Hey this way we have smaller bundles)
  8015. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  8016. if(mediaQuery && !item[2]) {
  8017. item[2] = mediaQuery;
  8018. } else if(mediaQuery) {
  8019. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  8020. }
  8021. list.push(item);
  8022. }
  8023. }
  8024. };
  8025. return list;
  8026. };
  8027. function cssWithMappingToString(item, useSourceMap) {
  8028. var content = item[1] || '';
  8029. var cssMapping = item[3];
  8030. if (!cssMapping) {
  8031. return content;
  8032. }
  8033. if (useSourceMap && typeof btoa === 'function') {
  8034. var sourceMapping = toComment(cssMapping);
  8035. var sourceURLs = cssMapping.sources.map(function (source) {
  8036. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  8037. });
  8038. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  8039. }
  8040. return [content].join('\n');
  8041. }
  8042. // Adapted from convert-source-map (MIT)
  8043. function toComment(sourceMap) {
  8044. // eslint-disable-next-line no-undef
  8045. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  8046. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  8047. return '/*# ' + data + ' */';
  8048. }
  8049. /***/ }),
  8050. /***/ "./node_modules/ieee754/index.js":
  8051. /*!***************************************!*\
  8052. !*** ./node_modules/ieee754/index.js ***!
  8053. \***************************************/
  8054. /*! no static exports found */
  8055. /***/ (function(module, exports) {
  8056. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  8057. var e, m
  8058. var eLen = (nBytes * 8) - mLen - 1
  8059. var eMax = (1 << eLen) - 1
  8060. var eBias = eMax >> 1
  8061. var nBits = -7
  8062. var i = isLE ? (nBytes - 1) : 0
  8063. var d = isLE ? -1 : 1
  8064. var s = buffer[offset + i]
  8065. i += d
  8066. e = s & ((1 << (-nBits)) - 1)
  8067. s >>= (-nBits)
  8068. nBits += eLen
  8069. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8070. m = e & ((1 << (-nBits)) - 1)
  8071. e >>= (-nBits)
  8072. nBits += mLen
  8073. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8074. if (e === 0) {
  8075. e = 1 - eBias
  8076. } else if (e === eMax) {
  8077. return m ? NaN : ((s ? -1 : 1) * Infinity)
  8078. } else {
  8079. m = m + Math.pow(2, mLen)
  8080. e = e - eBias
  8081. }
  8082. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  8083. }
  8084. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  8085. var e, m, c
  8086. var eLen = (nBytes * 8) - mLen - 1
  8087. var eMax = (1 << eLen) - 1
  8088. var eBias = eMax >> 1
  8089. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  8090. var i = isLE ? 0 : (nBytes - 1)
  8091. var d = isLE ? 1 : -1
  8092. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  8093. value = Math.abs(value)
  8094. if (isNaN(value) || value === Infinity) {
  8095. m = isNaN(value) ? 1 : 0
  8096. e = eMax
  8097. } else {
  8098. e = Math.floor(Math.log(value) / Math.LN2)
  8099. if (value * (c = Math.pow(2, -e)) < 1) {
  8100. e--
  8101. c *= 2
  8102. }
  8103. if (e + eBias >= 1) {
  8104. value += rt / c
  8105. } else {
  8106. value += rt * Math.pow(2, 1 - eBias)
  8107. }
  8108. if (value * c >= 2) {
  8109. e++
  8110. c /= 2
  8111. }
  8112. if (e + eBias >= eMax) {
  8113. m = 0
  8114. e = eMax
  8115. } else if (e + eBias >= 1) {
  8116. m = ((value * c) - 1) * Math.pow(2, mLen)
  8117. e = e + eBias
  8118. } else {
  8119. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  8120. e = 0
  8121. }
  8122. }
  8123. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  8124. e = (e << mLen) | m
  8125. eLen += mLen
  8126. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  8127. buffer[offset + i - d] |= s * 128
  8128. }
  8129. /***/ }),
  8130. /***/ "./node_modules/isarray/index.js":
  8131. /*!***************************************!*\
  8132. !*** ./node_modules/isarray/index.js ***!
  8133. \***************************************/
  8134. /*! no static exports found */
  8135. /***/ (function(module, exports) {
  8136. var toString = {}.toString;
  8137. module.exports = Array.isArray || function (arr) {
  8138. return toString.call(arr) == '[object Array]';
  8139. };
  8140. /***/ }),
  8141. /***/ "./node_modules/jquery/dist/jquery.js":
  8142. /*!********************************************!*\
  8143. !*** ./node_modules/jquery/dist/jquery.js ***!
  8144. \********************************************/
  8145. /*! no static exports found */
  8146. /***/ (function(module, exports, __webpack_require__) {
  8147. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8148. * jQuery JavaScript Library v3.4.1
  8149. * https://jquery.com/
  8150. *
  8151. * Includes Sizzle.js
  8152. * https://sizzlejs.com/
  8153. *
  8154. * Copyright JS Foundation and other contributors
  8155. * Released under the MIT license
  8156. * https://jquery.org/license
  8157. *
  8158. * Date: 2019-05-01T21:04Z
  8159. */
  8160. ( function( global, factory ) {
  8161. "use strict";
  8162. if ( true && typeof module.exports === "object" ) {
  8163. // For CommonJS and CommonJS-like environments where a proper `window`
  8164. // is present, execute the factory and get jQuery.
  8165. // For environments that do not have a `window` with a `document`
  8166. // (such as Node.js), expose a factory as module.exports.
  8167. // This accentuates the need for the creation of a real `window`.
  8168. // e.g. var jQuery = require("jquery")(window);
  8169. // See ticket #14549 for more info.
  8170. module.exports = global.document ?
  8171. factory( global, true ) :
  8172. function( w ) {
  8173. if ( !w.document ) {
  8174. throw new Error( "jQuery requires a window with a document" );
  8175. }
  8176. return factory( w );
  8177. };
  8178. } else {
  8179. factory( global );
  8180. }
  8181. // Pass this if window is not defined yet
  8182. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8183. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8184. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8185. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8186. // enough that all such attempts are guarded in a try block.
  8187. "use strict";
  8188. var arr = [];
  8189. var document = window.document;
  8190. var getProto = Object.getPrototypeOf;
  8191. var slice = arr.slice;
  8192. var concat = arr.concat;
  8193. var push = arr.push;
  8194. var indexOf = arr.indexOf;
  8195. var class2type = {};
  8196. var toString = class2type.toString;
  8197. var hasOwn = class2type.hasOwnProperty;
  8198. var fnToString = hasOwn.toString;
  8199. var ObjectFunctionString = fnToString.call( Object );
  8200. var support = {};
  8201. var isFunction = function isFunction( obj ) {
  8202. // Support: Chrome <=57, Firefox <=52
  8203. // In some browsers, typeof returns "function" for HTML <object> elements
  8204. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8205. // We don't want to classify *any* DOM node as a function.
  8206. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8207. };
  8208. var isWindow = function isWindow( obj ) {
  8209. return obj != null && obj === obj.window;
  8210. };
  8211. var preservedScriptAttributes = {
  8212. type: true,
  8213. src: true,
  8214. nonce: true,
  8215. noModule: true
  8216. };
  8217. function DOMEval( code, node, doc ) {
  8218. doc = doc || document;
  8219. var i, val,
  8220. script = doc.createElement( "script" );
  8221. script.text = code;
  8222. if ( node ) {
  8223. for ( i in preservedScriptAttributes ) {
  8224. // Support: Firefox 64+, Edge 18+
  8225. // Some browsers don't support the "nonce" property on scripts.
  8226. // On the other hand, just using `getAttribute` is not enough as
  8227. // the `nonce` attribute is reset to an empty string whenever it
  8228. // becomes browsing-context connected.
  8229. // See https://github.com/whatwg/html/issues/2369
  8230. // See https://html.spec.whatwg.org/#nonce-attributes
  8231. // The `node.getAttribute` check was added for the sake of
  8232. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8233. // via an object.
  8234. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8235. if ( val ) {
  8236. script.setAttribute( i, val );
  8237. }
  8238. }
  8239. }
  8240. doc.head.appendChild( script ).parentNode.removeChild( script );
  8241. }
  8242. function toType( obj ) {
  8243. if ( obj == null ) {
  8244. return obj + "";
  8245. }
  8246. // Support: Android <=2.3 only (functionish RegExp)
  8247. return typeof obj === "object" || typeof obj === "function" ?
  8248. class2type[ toString.call( obj ) ] || "object" :
  8249. typeof obj;
  8250. }
  8251. /* global Symbol */
  8252. // Defining this global in .eslintrc.json would create a danger of using the global
  8253. // unguarded in another place, it seems safer to define global only for this module
  8254. var
  8255. version = "3.4.1",
  8256. // Define a local copy of jQuery
  8257. jQuery = function( selector, context ) {
  8258. // The jQuery object is actually just the init constructor 'enhanced'
  8259. // Need init if jQuery is called (just allow error to be thrown if not included)
  8260. return new jQuery.fn.init( selector, context );
  8261. },
  8262. // Support: Android <=4.0 only
  8263. // Make sure we trim BOM and NBSP
  8264. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8265. jQuery.fn = jQuery.prototype = {
  8266. // The current version of jQuery being used
  8267. jquery: version,
  8268. constructor: jQuery,
  8269. // The default length of a jQuery object is 0
  8270. length: 0,
  8271. toArray: function() {
  8272. return slice.call( this );
  8273. },
  8274. // Get the Nth element in the matched element set OR
  8275. // Get the whole matched element set as a clean array
  8276. get: function( num ) {
  8277. // Return all the elements in a clean array
  8278. if ( num == null ) {
  8279. return slice.call( this );
  8280. }
  8281. // Return just the one element from the set
  8282. return num < 0 ? this[ num + this.length ] : this[ num ];
  8283. },
  8284. // Take an array of elements and push it onto the stack
  8285. // (returning the new matched element set)
  8286. pushStack: function( elems ) {
  8287. // Build a new jQuery matched element set
  8288. var ret = jQuery.merge( this.constructor(), elems );
  8289. // Add the old object onto the stack (as a reference)
  8290. ret.prevObject = this;
  8291. // Return the newly-formed element set
  8292. return ret;
  8293. },
  8294. // Execute a callback for every element in the matched set.
  8295. each: function( callback ) {
  8296. return jQuery.each( this, callback );
  8297. },
  8298. map: function( callback ) {
  8299. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8300. return callback.call( elem, i, elem );
  8301. } ) );
  8302. },
  8303. slice: function() {
  8304. return this.pushStack( slice.apply( this, arguments ) );
  8305. },
  8306. first: function() {
  8307. return this.eq( 0 );
  8308. },
  8309. last: function() {
  8310. return this.eq( -1 );
  8311. },
  8312. eq: function( i ) {
  8313. var len = this.length,
  8314. j = +i + ( i < 0 ? len : 0 );
  8315. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8316. },
  8317. end: function() {
  8318. return this.prevObject || this.constructor();
  8319. },
  8320. // For internal use only.
  8321. // Behaves like an Array's method, not like a jQuery method.
  8322. push: push,
  8323. sort: arr.sort,
  8324. splice: arr.splice
  8325. };
  8326. jQuery.extend = jQuery.fn.extend = function() {
  8327. var options, name, src, copy, copyIsArray, clone,
  8328. target = arguments[ 0 ] || {},
  8329. i = 1,
  8330. length = arguments.length,
  8331. deep = false;
  8332. // Handle a deep copy situation
  8333. if ( typeof target === "boolean" ) {
  8334. deep = target;
  8335. // Skip the boolean and the target
  8336. target = arguments[ i ] || {};
  8337. i++;
  8338. }
  8339. // Handle case when target is a string or something (possible in deep copy)
  8340. if ( typeof target !== "object" && !isFunction( target ) ) {
  8341. target = {};
  8342. }
  8343. // Extend jQuery itself if only one argument is passed
  8344. if ( i === length ) {
  8345. target = this;
  8346. i--;
  8347. }
  8348. for ( ; i < length; i++ ) {
  8349. // Only deal with non-null/undefined values
  8350. if ( ( options = arguments[ i ] ) != null ) {
  8351. // Extend the base object
  8352. for ( name in options ) {
  8353. copy = options[ name ];
  8354. // Prevent Object.prototype pollution
  8355. // Prevent never-ending loop
  8356. if ( name === "__proto__" || target === copy ) {
  8357. continue;
  8358. }
  8359. // Recurse if we're merging plain objects or arrays
  8360. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8361. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8362. src = target[ name ];
  8363. // Ensure proper type for the source value
  8364. if ( copyIsArray && !Array.isArray( src ) ) {
  8365. clone = [];
  8366. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8367. clone = {};
  8368. } else {
  8369. clone = src;
  8370. }
  8371. copyIsArray = false;
  8372. // Never move original objects, clone them
  8373. target[ name ] = jQuery.extend( deep, clone, copy );
  8374. // Don't bring in undefined values
  8375. } else if ( copy !== undefined ) {
  8376. target[ name ] = copy;
  8377. }
  8378. }
  8379. }
  8380. }
  8381. // Return the modified object
  8382. return target;
  8383. };
  8384. jQuery.extend( {
  8385. // Unique for each copy of jQuery on the page
  8386. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8387. // Assume jQuery is ready without the ready module
  8388. isReady: true,
  8389. error: function( msg ) {
  8390. throw new Error( msg );
  8391. },
  8392. noop: function() {},
  8393. isPlainObject: function( obj ) {
  8394. var proto, Ctor;
  8395. // Detect obvious negatives
  8396. // Use toString instead of jQuery.type to catch host objects
  8397. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8398. return false;
  8399. }
  8400. proto = getProto( obj );
  8401. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8402. if ( !proto ) {
  8403. return true;
  8404. }
  8405. // Objects with prototype are plain iff they were constructed by a global Object function
  8406. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8407. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8408. },
  8409. isEmptyObject: function( obj ) {
  8410. var name;
  8411. for ( name in obj ) {
  8412. return false;
  8413. }
  8414. return true;
  8415. },
  8416. // Evaluates a script in a global context
  8417. globalEval: function( code, options ) {
  8418. DOMEval( code, { nonce: options && options.nonce } );
  8419. },
  8420. each: function( obj, callback ) {
  8421. var length, i = 0;
  8422. if ( isArrayLike( obj ) ) {
  8423. length = obj.length;
  8424. for ( ; i < length; i++ ) {
  8425. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8426. break;
  8427. }
  8428. }
  8429. } else {
  8430. for ( i in obj ) {
  8431. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8432. break;
  8433. }
  8434. }
  8435. }
  8436. return obj;
  8437. },
  8438. // Support: Android <=4.0 only
  8439. trim: function( text ) {
  8440. return text == null ?
  8441. "" :
  8442. ( text + "" ).replace( rtrim, "" );
  8443. },
  8444. // results is for internal usage only
  8445. makeArray: function( arr, results ) {
  8446. var ret = results || [];
  8447. if ( arr != null ) {
  8448. if ( isArrayLike( Object( arr ) ) ) {
  8449. jQuery.merge( ret,
  8450. typeof arr === "string" ?
  8451. [ arr ] : arr
  8452. );
  8453. } else {
  8454. push.call( ret, arr );
  8455. }
  8456. }
  8457. return ret;
  8458. },
  8459. inArray: function( elem, arr, i ) {
  8460. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8461. },
  8462. // Support: Android <=4.0 only, PhantomJS 1 only
  8463. // push.apply(_, arraylike) throws on ancient WebKit
  8464. merge: function( first, second ) {
  8465. var len = +second.length,
  8466. j = 0,
  8467. i = first.length;
  8468. for ( ; j < len; j++ ) {
  8469. first[ i++ ] = second[ j ];
  8470. }
  8471. first.length = i;
  8472. return first;
  8473. },
  8474. grep: function( elems, callback, invert ) {
  8475. var callbackInverse,
  8476. matches = [],
  8477. i = 0,
  8478. length = elems.length,
  8479. callbackExpect = !invert;
  8480. // Go through the array, only saving the items
  8481. // that pass the validator function
  8482. for ( ; i < length; i++ ) {
  8483. callbackInverse = !callback( elems[ i ], i );
  8484. if ( callbackInverse !== callbackExpect ) {
  8485. matches.push( elems[ i ] );
  8486. }
  8487. }
  8488. return matches;
  8489. },
  8490. // arg is for internal usage only
  8491. map: function( elems, callback, arg ) {
  8492. var length, value,
  8493. i = 0,
  8494. ret = [];
  8495. // Go through the array, translating each of the items to their new values
  8496. if ( isArrayLike( elems ) ) {
  8497. length = elems.length;
  8498. for ( ; i < length; i++ ) {
  8499. value = callback( elems[ i ], i, arg );
  8500. if ( value != null ) {
  8501. ret.push( value );
  8502. }
  8503. }
  8504. // Go through every key on the object,
  8505. } else {
  8506. for ( i in elems ) {
  8507. value = callback( elems[ i ], i, arg );
  8508. if ( value != null ) {
  8509. ret.push( value );
  8510. }
  8511. }
  8512. }
  8513. // Flatten any nested arrays
  8514. return concat.apply( [], ret );
  8515. },
  8516. // A global GUID counter for objects
  8517. guid: 1,
  8518. // jQuery.support is not used in Core but other projects attach their
  8519. // properties to it so it needs to exist.
  8520. support: support
  8521. } );
  8522. if ( typeof Symbol === "function" ) {
  8523. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8524. }
  8525. // Populate the class2type map
  8526. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8527. function( i, name ) {
  8528. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8529. } );
  8530. function isArrayLike( obj ) {
  8531. // Support: real iOS 8.2 only (not reproducible in simulator)
  8532. // `in` check used to prevent JIT error (gh-2145)
  8533. // hasOwn isn't used here due to false negatives
  8534. // regarding Nodelist length in IE
  8535. var length = !!obj && "length" in obj && obj.length,
  8536. type = toType( obj );
  8537. if ( isFunction( obj ) || isWindow( obj ) ) {
  8538. return false;
  8539. }
  8540. return type === "array" || length === 0 ||
  8541. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8542. }
  8543. var Sizzle =
  8544. /*!
  8545. * Sizzle CSS Selector Engine v2.3.4
  8546. * https://sizzlejs.com/
  8547. *
  8548. * Copyright JS Foundation and other contributors
  8549. * Released under the MIT license
  8550. * https://js.foundation/
  8551. *
  8552. * Date: 2019-04-08
  8553. */
  8554. (function( window ) {
  8555. var i,
  8556. support,
  8557. Expr,
  8558. getText,
  8559. isXML,
  8560. tokenize,
  8561. compile,
  8562. select,
  8563. outermostContext,
  8564. sortInput,
  8565. hasDuplicate,
  8566. // Local document vars
  8567. setDocument,
  8568. document,
  8569. docElem,
  8570. documentIsHTML,
  8571. rbuggyQSA,
  8572. rbuggyMatches,
  8573. matches,
  8574. contains,
  8575. // Instance-specific data
  8576. expando = "sizzle" + 1 * new Date(),
  8577. preferredDoc = window.document,
  8578. dirruns = 0,
  8579. done = 0,
  8580. classCache = createCache(),
  8581. tokenCache = createCache(),
  8582. compilerCache = createCache(),
  8583. nonnativeSelectorCache = createCache(),
  8584. sortOrder = function( a, b ) {
  8585. if ( a === b ) {
  8586. hasDuplicate = true;
  8587. }
  8588. return 0;
  8589. },
  8590. // Instance methods
  8591. hasOwn = ({}).hasOwnProperty,
  8592. arr = [],
  8593. pop = arr.pop,
  8594. push_native = arr.push,
  8595. push = arr.push,
  8596. slice = arr.slice,
  8597. // Use a stripped-down indexOf as it's faster than native
  8598. // https://jsperf.com/thor-indexof-vs-for/5
  8599. indexOf = function( list, elem ) {
  8600. var i = 0,
  8601. len = list.length;
  8602. for ( ; i < len; i++ ) {
  8603. if ( list[i] === elem ) {
  8604. return i;
  8605. }
  8606. }
  8607. return -1;
  8608. },
  8609. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8610. // Regular expressions
  8611. // http://www.w3.org/TR/css3-selectors/#whitespace
  8612. whitespace = "[\\x20\\t\\r\\n\\f]",
  8613. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8614. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8615. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8616. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8617. // Operator (capture 2)
  8618. "*([*^$|!~]?=)" + whitespace +
  8619. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8620. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8621. "*\\]",
  8622. pseudos = ":(" + identifier + ")(?:\\((" +
  8623. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8624. // 1. quoted (capture 3; capture 4 or capture 5)
  8625. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8626. // 2. simple (capture 6)
  8627. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8628. // 3. anything else (capture 2)
  8629. ".*" +
  8630. ")\\)|)",
  8631. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8632. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8633. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8634. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8635. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8636. rdescend = new RegExp( whitespace + "|>" ),
  8637. rpseudo = new RegExp( pseudos ),
  8638. ridentifier = new RegExp( "^" + identifier + "$" ),
  8639. matchExpr = {
  8640. "ID": new RegExp( "^#(" + identifier + ")" ),
  8641. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8642. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8643. "ATTR": new RegExp( "^" + attributes ),
  8644. "PSEUDO": new RegExp( "^" + pseudos ),
  8645. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8646. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8647. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8648. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8649. // For use in libraries implementing .is()
  8650. // We use this for POS matching in `select`
  8651. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8652. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8653. },
  8654. rhtml = /HTML$/i,
  8655. rinputs = /^(?:input|select|textarea|button)$/i,
  8656. rheader = /^h\d$/i,
  8657. rnative = /^[^{]+\{\s*\[native \w/,
  8658. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8659. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8660. rsibling = /[+~]/,
  8661. // CSS escapes
  8662. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8663. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8664. funescape = function( _, escaped, escapedWhitespace ) {
  8665. var high = "0x" + escaped - 0x10000;
  8666. // NaN means non-codepoint
  8667. // Support: Firefox<24
  8668. // Workaround erroneous numeric interpretation of +"0x"
  8669. return high !== high || escapedWhitespace ?
  8670. escaped :
  8671. high < 0 ?
  8672. // BMP codepoint
  8673. String.fromCharCode( high + 0x10000 ) :
  8674. // Supplemental Plane codepoint (surrogate pair)
  8675. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8676. },
  8677. // CSS string/identifier serialization
  8678. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8679. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8680. fcssescape = function( ch, asCodePoint ) {
  8681. if ( asCodePoint ) {
  8682. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8683. if ( ch === "\0" ) {
  8684. return "\uFFFD";
  8685. }
  8686. // Control characters and (dependent upon position) numbers get escaped as code points
  8687. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8688. }
  8689. // Other potentially-special ASCII characters get backslash-escaped
  8690. return "\\" + ch;
  8691. },
  8692. // Used for iframes
  8693. // See setDocument()
  8694. // Removing the function wrapper causes a "Permission Denied"
  8695. // error in IE
  8696. unloadHandler = function() {
  8697. setDocument();
  8698. },
  8699. inDisabledFieldset = addCombinator(
  8700. function( elem ) {
  8701. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8702. },
  8703. { dir: "parentNode", next: "legend" }
  8704. );
  8705. // Optimize for push.apply( _, NodeList )
  8706. try {
  8707. push.apply(
  8708. (arr = slice.call( preferredDoc.childNodes )),
  8709. preferredDoc.childNodes
  8710. );
  8711. // Support: Android<4.0
  8712. // Detect silently failing push.apply
  8713. arr[ preferredDoc.childNodes.length ].nodeType;
  8714. } catch ( e ) {
  8715. push = { apply: arr.length ?
  8716. // Leverage slice if possible
  8717. function( target, els ) {
  8718. push_native.apply( target, slice.call(els) );
  8719. } :
  8720. // Support: IE<9
  8721. // Otherwise append directly
  8722. function( target, els ) {
  8723. var j = target.length,
  8724. i = 0;
  8725. // Can't trust NodeList.length
  8726. while ( (target[j++] = els[i++]) ) {}
  8727. target.length = j - 1;
  8728. }
  8729. };
  8730. }
  8731. function Sizzle( selector, context, results, seed ) {
  8732. var m, i, elem, nid, match, groups, newSelector,
  8733. newContext = context && context.ownerDocument,
  8734. // nodeType defaults to 9, since context defaults to document
  8735. nodeType = context ? context.nodeType : 9;
  8736. results = results || [];
  8737. // Return early from calls with invalid selector or context
  8738. if ( typeof selector !== "string" || !selector ||
  8739. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8740. return results;
  8741. }
  8742. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8743. if ( !seed ) {
  8744. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8745. setDocument( context );
  8746. }
  8747. context = context || document;
  8748. if ( documentIsHTML ) {
  8749. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8750. // (excepting DocumentFragment context, where the methods don't exist)
  8751. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8752. // ID selector
  8753. if ( (m = match[1]) ) {
  8754. // Document context
  8755. if ( nodeType === 9 ) {
  8756. if ( (elem = context.getElementById( m )) ) {
  8757. // Support: IE, Opera, Webkit
  8758. // TODO: identify versions
  8759. // getElementById can match elements by name instead of ID
  8760. if ( elem.id === m ) {
  8761. results.push( elem );
  8762. return results;
  8763. }
  8764. } else {
  8765. return results;
  8766. }
  8767. // Element context
  8768. } else {
  8769. // Support: IE, Opera, Webkit
  8770. // TODO: identify versions
  8771. // getElementById can match elements by name instead of ID
  8772. if ( newContext && (elem = newContext.getElementById( m )) &&
  8773. contains( context, elem ) &&
  8774. elem.id === m ) {
  8775. results.push( elem );
  8776. return results;
  8777. }
  8778. }
  8779. // Type selector
  8780. } else if ( match[2] ) {
  8781. push.apply( results, context.getElementsByTagName( selector ) );
  8782. return results;
  8783. // Class selector
  8784. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8785. context.getElementsByClassName ) {
  8786. push.apply( results, context.getElementsByClassName( m ) );
  8787. return results;
  8788. }
  8789. }
  8790. // Take advantage of querySelectorAll
  8791. if ( support.qsa &&
  8792. !nonnativeSelectorCache[ selector + " " ] &&
  8793. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8794. // Support: IE 8 only
  8795. // Exclude object elements
  8796. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8797. newSelector = selector;
  8798. newContext = context;
  8799. // qSA considers elements outside a scoping root when evaluating child or
  8800. // descendant combinators, which is not what we want.
  8801. // In such cases, we work around the behavior by prefixing every selector in the
  8802. // list with an ID selector referencing the scope context.
  8803. // Thanks to Andrew Dupont for this technique.
  8804. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8805. // Capture the context ID, setting it first if necessary
  8806. if ( (nid = context.getAttribute( "id" )) ) {
  8807. nid = nid.replace( rcssescape, fcssescape );
  8808. } else {
  8809. context.setAttribute( "id", (nid = expando) );
  8810. }
  8811. // Prefix every selector in the list
  8812. groups = tokenize( selector );
  8813. i = groups.length;
  8814. while ( i-- ) {
  8815. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8816. }
  8817. newSelector = groups.join( "," );
  8818. // Expand context for sibling selectors
  8819. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8820. context;
  8821. }
  8822. try {
  8823. push.apply( results,
  8824. newContext.querySelectorAll( newSelector )
  8825. );
  8826. return results;
  8827. } catch ( qsaError ) {
  8828. nonnativeSelectorCache( selector, true );
  8829. } finally {
  8830. if ( nid === expando ) {
  8831. context.removeAttribute( "id" );
  8832. }
  8833. }
  8834. }
  8835. }
  8836. }
  8837. // All others
  8838. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8839. }
  8840. /**
  8841. * Create key-value caches of limited size
  8842. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8843. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8844. * deleting the oldest entry
  8845. */
  8846. function createCache() {
  8847. var keys = [];
  8848. function cache( key, value ) {
  8849. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8850. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8851. // Only keep the most recent entries
  8852. delete cache[ keys.shift() ];
  8853. }
  8854. return (cache[ key + " " ] = value);
  8855. }
  8856. return cache;
  8857. }
  8858. /**
  8859. * Mark a function for special use by Sizzle
  8860. * @param {Function} fn The function to mark
  8861. */
  8862. function markFunction( fn ) {
  8863. fn[ expando ] = true;
  8864. return fn;
  8865. }
  8866. /**
  8867. * Support testing using an element
  8868. * @param {Function} fn Passed the created element and returns a boolean result
  8869. */
  8870. function assert( fn ) {
  8871. var el = document.createElement("fieldset");
  8872. try {
  8873. return !!fn( el );
  8874. } catch (e) {
  8875. return false;
  8876. } finally {
  8877. // Remove from its parent by default
  8878. if ( el.parentNode ) {
  8879. el.parentNode.removeChild( el );
  8880. }
  8881. // release memory in IE
  8882. el = null;
  8883. }
  8884. }
  8885. /**
  8886. * Adds the same handler for all of the specified attrs
  8887. * @param {String} attrs Pipe-separated list of attributes
  8888. * @param {Function} handler The method that will be applied
  8889. */
  8890. function addHandle( attrs, handler ) {
  8891. var arr = attrs.split("|"),
  8892. i = arr.length;
  8893. while ( i-- ) {
  8894. Expr.attrHandle[ arr[i] ] = handler;
  8895. }
  8896. }
  8897. /**
  8898. * Checks document order of two siblings
  8899. * @param {Element} a
  8900. * @param {Element} b
  8901. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8902. */
  8903. function siblingCheck( a, b ) {
  8904. var cur = b && a,
  8905. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8906. a.sourceIndex - b.sourceIndex;
  8907. // Use IE sourceIndex if available on both nodes
  8908. if ( diff ) {
  8909. return diff;
  8910. }
  8911. // Check if b follows a
  8912. if ( cur ) {
  8913. while ( (cur = cur.nextSibling) ) {
  8914. if ( cur === b ) {
  8915. return -1;
  8916. }
  8917. }
  8918. }
  8919. return a ? 1 : -1;
  8920. }
  8921. /**
  8922. * Returns a function to use in pseudos for input types
  8923. * @param {String} type
  8924. */
  8925. function createInputPseudo( type ) {
  8926. return function( elem ) {
  8927. var name = elem.nodeName.toLowerCase();
  8928. return name === "input" && elem.type === type;
  8929. };
  8930. }
  8931. /**
  8932. * Returns a function to use in pseudos for buttons
  8933. * @param {String} type
  8934. */
  8935. function createButtonPseudo( type ) {
  8936. return function( elem ) {
  8937. var name = elem.nodeName.toLowerCase();
  8938. return (name === "input" || name === "button") && elem.type === type;
  8939. };
  8940. }
  8941. /**
  8942. * Returns a function to use in pseudos for :enabled/:disabled
  8943. * @param {Boolean} disabled true for :disabled; false for :enabled
  8944. */
  8945. function createDisabledPseudo( disabled ) {
  8946. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8947. return function( elem ) {
  8948. // Only certain elements can match :enabled or :disabled
  8949. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8950. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8951. if ( "form" in elem ) {
  8952. // Check for inherited disabledness on relevant non-disabled elements:
  8953. // * listed form-associated elements in a disabled fieldset
  8954. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8955. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8956. // * option elements in a disabled optgroup
  8957. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8958. // All such elements have a "form" property.
  8959. if ( elem.parentNode && elem.disabled === false ) {
  8960. // Option elements defer to a parent optgroup if present
  8961. if ( "label" in elem ) {
  8962. if ( "label" in elem.parentNode ) {
  8963. return elem.parentNode.disabled === disabled;
  8964. } else {
  8965. return elem.disabled === disabled;
  8966. }
  8967. }
  8968. // Support: IE 6 - 11
  8969. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8970. return elem.isDisabled === disabled ||
  8971. // Where there is no isDisabled, check manually
  8972. /* jshint -W018 */
  8973. elem.isDisabled !== !disabled &&
  8974. inDisabledFieldset( elem ) === disabled;
  8975. }
  8976. return elem.disabled === disabled;
  8977. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8978. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8979. // even exist on them, let alone have a boolean value.
  8980. } else if ( "label" in elem ) {
  8981. return elem.disabled === disabled;
  8982. }
  8983. // Remaining elements are neither :enabled nor :disabled
  8984. return false;
  8985. };
  8986. }
  8987. /**
  8988. * Returns a function to use in pseudos for positionals
  8989. * @param {Function} fn
  8990. */
  8991. function createPositionalPseudo( fn ) {
  8992. return markFunction(function( argument ) {
  8993. argument = +argument;
  8994. return markFunction(function( seed, matches ) {
  8995. var j,
  8996. matchIndexes = fn( [], seed.length, argument ),
  8997. i = matchIndexes.length;
  8998. // Match elements found at the specified indexes
  8999. while ( i-- ) {
  9000. if ( seed[ (j = matchIndexes[i]) ] ) {
  9001. seed[j] = !(matches[j] = seed[j]);
  9002. }
  9003. }
  9004. });
  9005. });
  9006. }
  9007. /**
  9008. * Checks a node for validity as a Sizzle context
  9009. * @param {Element|Object=} context
  9010. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  9011. */
  9012. function testContext( context ) {
  9013. return context && typeof context.getElementsByTagName !== "undefined" && context;
  9014. }
  9015. // Expose support vars for convenience
  9016. support = Sizzle.support = {};
  9017. /**
  9018. * Detects XML nodes
  9019. * @param {Element|Object} elem An element or a document
  9020. * @returns {Boolean} True iff elem is a non-HTML XML node
  9021. */
  9022. isXML = Sizzle.isXML = function( elem ) {
  9023. var namespace = elem.namespaceURI,
  9024. docElem = (elem.ownerDocument || elem).documentElement;
  9025. // Support: IE <=8
  9026. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  9027. // https://bugs.jquery.com/ticket/4833
  9028. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  9029. };
  9030. /**
  9031. * Sets document-related variables once based on the current document
  9032. * @param {Element|Object} [doc] An element or document object to use to set the document
  9033. * @returns {Object} Returns the current document
  9034. */
  9035. setDocument = Sizzle.setDocument = function( node ) {
  9036. var hasCompare, subWindow,
  9037. doc = node ? node.ownerDocument || node : preferredDoc;
  9038. // Return early if doc is invalid or already selected
  9039. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  9040. return document;
  9041. }
  9042. // Update global variables
  9043. document = doc;
  9044. docElem = document.documentElement;
  9045. documentIsHTML = !isXML( document );
  9046. // Support: IE 9-11, Edge
  9047. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  9048. if ( preferredDoc !== document &&
  9049. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  9050. // Support: IE 11, Edge
  9051. if ( subWindow.addEventListener ) {
  9052. subWindow.addEventListener( "unload", unloadHandler, false );
  9053. // Support: IE 9 - 10 only
  9054. } else if ( subWindow.attachEvent ) {
  9055. subWindow.attachEvent( "onunload", unloadHandler );
  9056. }
  9057. }
  9058. /* Attributes
  9059. ---------------------------------------------------------------------- */
  9060. // Support: IE<8
  9061. // Verify that getAttribute really returns attributes and not properties
  9062. // (excepting IE8 booleans)
  9063. support.attributes = assert(function( el ) {
  9064. el.className = "i";
  9065. return !el.getAttribute("className");
  9066. });
  9067. /* getElement(s)By*
  9068. ---------------------------------------------------------------------- */
  9069. // Check if getElementsByTagName("*") returns only elements
  9070. support.getElementsByTagName = assert(function( el ) {
  9071. el.appendChild( document.createComment("") );
  9072. return !el.getElementsByTagName("*").length;
  9073. });
  9074. // Support: IE<9
  9075. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  9076. // Support: IE<10
  9077. // Check if getElementById returns elements by name
  9078. // The broken getElementById methods don't pick up programmatically-set names,
  9079. // so use a roundabout getElementsByName test
  9080. support.getById = assert(function( el ) {
  9081. docElem.appendChild( el ).id = expando;
  9082. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  9083. });
  9084. // ID filter and find
  9085. if ( support.getById ) {
  9086. Expr.filter["ID"] = function( id ) {
  9087. var attrId = id.replace( runescape, funescape );
  9088. return function( elem ) {
  9089. return elem.getAttribute("id") === attrId;
  9090. };
  9091. };
  9092. Expr.find["ID"] = function( id, context ) {
  9093. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9094. var elem = context.getElementById( id );
  9095. return elem ? [ elem ] : [];
  9096. }
  9097. };
  9098. } else {
  9099. Expr.filter["ID"] = function( id ) {
  9100. var attrId = id.replace( runescape, funescape );
  9101. return function( elem ) {
  9102. var node = typeof elem.getAttributeNode !== "undefined" &&
  9103. elem.getAttributeNode("id");
  9104. return node && node.value === attrId;
  9105. };
  9106. };
  9107. // Support: IE 6 - 7 only
  9108. // getElementById is not reliable as a find shortcut
  9109. Expr.find["ID"] = function( id, context ) {
  9110. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9111. var node, i, elems,
  9112. elem = context.getElementById( id );
  9113. if ( elem ) {
  9114. // Verify the id attribute
  9115. node = elem.getAttributeNode("id");
  9116. if ( node && node.value === id ) {
  9117. return [ elem ];
  9118. }
  9119. // Fall back on getElementsByName
  9120. elems = context.getElementsByName( id );
  9121. i = 0;
  9122. while ( (elem = elems[i++]) ) {
  9123. node = elem.getAttributeNode("id");
  9124. if ( node && node.value === id ) {
  9125. return [ elem ];
  9126. }
  9127. }
  9128. }
  9129. return [];
  9130. }
  9131. };
  9132. }
  9133. // Tag
  9134. Expr.find["TAG"] = support.getElementsByTagName ?
  9135. function( tag, context ) {
  9136. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9137. return context.getElementsByTagName( tag );
  9138. // DocumentFragment nodes don't have gEBTN
  9139. } else if ( support.qsa ) {
  9140. return context.querySelectorAll( tag );
  9141. }
  9142. } :
  9143. function( tag, context ) {
  9144. var elem,
  9145. tmp = [],
  9146. i = 0,
  9147. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9148. results = context.getElementsByTagName( tag );
  9149. // Filter out possible comments
  9150. if ( tag === "*" ) {
  9151. while ( (elem = results[i++]) ) {
  9152. if ( elem.nodeType === 1 ) {
  9153. tmp.push( elem );
  9154. }
  9155. }
  9156. return tmp;
  9157. }
  9158. return results;
  9159. };
  9160. // Class
  9161. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9162. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9163. return context.getElementsByClassName( className );
  9164. }
  9165. };
  9166. /* QSA/matchesSelector
  9167. ---------------------------------------------------------------------- */
  9168. // QSA and matchesSelector support
  9169. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9170. rbuggyMatches = [];
  9171. // qSa(:focus) reports false when true (Chrome 21)
  9172. // We allow this because of a bug in IE8/9 that throws an error
  9173. // whenever `document.activeElement` is accessed on an iframe
  9174. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9175. // See https://bugs.jquery.com/ticket/13378
  9176. rbuggyQSA = [];
  9177. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9178. // Build QSA regex
  9179. // Regex strategy adopted from Diego Perini
  9180. assert(function( el ) {
  9181. // Select is set to empty string on purpose
  9182. // This is to test IE's treatment of not explicitly
  9183. // setting a boolean content attribute,
  9184. // since its presence should be enough
  9185. // https://bugs.jquery.com/ticket/12359
  9186. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9187. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9188. "<option selected=''></option></select>";
  9189. // Support: IE8, Opera 11-12.16
  9190. // Nothing should be selected when empty strings follow ^= or $= or *=
  9191. // The test attribute must be unknown in Opera but "safe" for WinRT
  9192. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9193. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9194. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9195. }
  9196. // Support: IE8
  9197. // Boolean attributes and "value" are not treated correctly
  9198. if ( !el.querySelectorAll("[selected]").length ) {
  9199. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9200. }
  9201. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9202. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9203. rbuggyQSA.push("~=");
  9204. }
  9205. // Webkit/Opera - :checked should return selected option elements
  9206. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9207. // IE8 throws error here and will not see later tests
  9208. if ( !el.querySelectorAll(":checked").length ) {
  9209. rbuggyQSA.push(":checked");
  9210. }
  9211. // Support: Safari 8+, iOS 8+
  9212. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9213. // In-page `selector#id sibling-combinator selector` fails
  9214. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9215. rbuggyQSA.push(".#.+[+~]");
  9216. }
  9217. });
  9218. assert(function( el ) {
  9219. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9220. "<select disabled='disabled'><option/></select>";
  9221. // Support: Windows 8 Native Apps
  9222. // The type and name attributes are restricted during .innerHTML assignment
  9223. var input = document.createElement("input");
  9224. input.setAttribute( "type", "hidden" );
  9225. el.appendChild( input ).setAttribute( "name", "D" );
  9226. // Support: IE8
  9227. // Enforce case-sensitivity of name attribute
  9228. if ( el.querySelectorAll("[name=d]").length ) {
  9229. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9230. }
  9231. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9232. // IE8 throws error here and will not see later tests
  9233. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9234. rbuggyQSA.push( ":enabled", ":disabled" );
  9235. }
  9236. // Support: IE9-11+
  9237. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9238. docElem.appendChild( el ).disabled = true;
  9239. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9240. rbuggyQSA.push( ":enabled", ":disabled" );
  9241. }
  9242. // Opera 10-11 does not throw on post-comma invalid pseudos
  9243. el.querySelectorAll("*,:x");
  9244. rbuggyQSA.push(",.*:");
  9245. });
  9246. }
  9247. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9248. docElem.webkitMatchesSelector ||
  9249. docElem.mozMatchesSelector ||
  9250. docElem.oMatchesSelector ||
  9251. docElem.msMatchesSelector) )) ) {
  9252. assert(function( el ) {
  9253. // Check to see if it's possible to do matchesSelector
  9254. // on a disconnected node (IE 9)
  9255. support.disconnectedMatch = matches.call( el, "*" );
  9256. // This should fail with an exception
  9257. // Gecko does not error, returns false instead
  9258. matches.call( el, "[s!='']:x" );
  9259. rbuggyMatches.push( "!=", pseudos );
  9260. });
  9261. }
  9262. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9263. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9264. /* Contains
  9265. ---------------------------------------------------------------------- */
  9266. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9267. // Element contains another
  9268. // Purposefully self-exclusive
  9269. // As in, an element does not contain itself
  9270. contains = hasCompare || rnative.test( docElem.contains ) ?
  9271. function( a, b ) {
  9272. var adown = a.nodeType === 9 ? a.documentElement : a,
  9273. bup = b && b.parentNode;
  9274. return a === bup || !!( bup && bup.nodeType === 1 && (
  9275. adown.contains ?
  9276. adown.contains( bup ) :
  9277. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9278. ));
  9279. } :
  9280. function( a, b ) {
  9281. if ( b ) {
  9282. while ( (b = b.parentNode) ) {
  9283. if ( b === a ) {
  9284. return true;
  9285. }
  9286. }
  9287. }
  9288. return false;
  9289. };
  9290. /* Sorting
  9291. ---------------------------------------------------------------------- */
  9292. // Document order sorting
  9293. sortOrder = hasCompare ?
  9294. function( a, b ) {
  9295. // Flag for duplicate removal
  9296. if ( a === b ) {
  9297. hasDuplicate = true;
  9298. return 0;
  9299. }
  9300. // Sort on method existence if only one input has compareDocumentPosition
  9301. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9302. if ( compare ) {
  9303. return compare;
  9304. }
  9305. // Calculate position if both inputs belong to the same document
  9306. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9307. a.compareDocumentPosition( b ) :
  9308. // Otherwise we know they are disconnected
  9309. 1;
  9310. // Disconnected nodes
  9311. if ( compare & 1 ||
  9312. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9313. // Choose the first element that is related to our preferred document
  9314. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9315. return -1;
  9316. }
  9317. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9318. return 1;
  9319. }
  9320. // Maintain original order
  9321. return sortInput ?
  9322. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9323. 0;
  9324. }
  9325. return compare & 4 ? -1 : 1;
  9326. } :
  9327. function( a, b ) {
  9328. // Exit early if the nodes are identical
  9329. if ( a === b ) {
  9330. hasDuplicate = true;
  9331. return 0;
  9332. }
  9333. var cur,
  9334. i = 0,
  9335. aup = a.parentNode,
  9336. bup = b.parentNode,
  9337. ap = [ a ],
  9338. bp = [ b ];
  9339. // Parentless nodes are either documents or disconnected
  9340. if ( !aup || !bup ) {
  9341. return a === document ? -1 :
  9342. b === document ? 1 :
  9343. aup ? -1 :
  9344. bup ? 1 :
  9345. sortInput ?
  9346. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9347. 0;
  9348. // If the nodes are siblings, we can do a quick check
  9349. } else if ( aup === bup ) {
  9350. return siblingCheck( a, b );
  9351. }
  9352. // Otherwise we need full lists of their ancestors for comparison
  9353. cur = a;
  9354. while ( (cur = cur.parentNode) ) {
  9355. ap.unshift( cur );
  9356. }
  9357. cur = b;
  9358. while ( (cur = cur.parentNode) ) {
  9359. bp.unshift( cur );
  9360. }
  9361. // Walk down the tree looking for a discrepancy
  9362. while ( ap[i] === bp[i] ) {
  9363. i++;
  9364. }
  9365. return i ?
  9366. // Do a sibling check if the nodes have a common ancestor
  9367. siblingCheck( ap[i], bp[i] ) :
  9368. // Otherwise nodes in our document sort first
  9369. ap[i] === preferredDoc ? -1 :
  9370. bp[i] === preferredDoc ? 1 :
  9371. 0;
  9372. };
  9373. return document;
  9374. };
  9375. Sizzle.matches = function( expr, elements ) {
  9376. return Sizzle( expr, null, null, elements );
  9377. };
  9378. Sizzle.matchesSelector = function( elem, expr ) {
  9379. // Set document vars if needed
  9380. if ( ( elem.ownerDocument || elem ) !== document ) {
  9381. setDocument( elem );
  9382. }
  9383. if ( support.matchesSelector && documentIsHTML &&
  9384. !nonnativeSelectorCache[ expr + " " ] &&
  9385. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9386. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9387. try {
  9388. var ret = matches.call( elem, expr );
  9389. // IE 9's matchesSelector returns false on disconnected nodes
  9390. if ( ret || support.disconnectedMatch ||
  9391. // As well, disconnected nodes are said to be in a document
  9392. // fragment in IE 9
  9393. elem.document && elem.document.nodeType !== 11 ) {
  9394. return ret;
  9395. }
  9396. } catch (e) {
  9397. nonnativeSelectorCache( expr, true );
  9398. }
  9399. }
  9400. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9401. };
  9402. Sizzle.contains = function( context, elem ) {
  9403. // Set document vars if needed
  9404. if ( ( context.ownerDocument || context ) !== document ) {
  9405. setDocument( context );
  9406. }
  9407. return contains( context, elem );
  9408. };
  9409. Sizzle.attr = function( elem, name ) {
  9410. // Set document vars if needed
  9411. if ( ( elem.ownerDocument || elem ) !== document ) {
  9412. setDocument( elem );
  9413. }
  9414. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9415. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9416. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9417. fn( elem, name, !documentIsHTML ) :
  9418. undefined;
  9419. return val !== undefined ?
  9420. val :
  9421. support.attributes || !documentIsHTML ?
  9422. elem.getAttribute( name ) :
  9423. (val = elem.getAttributeNode(name)) && val.specified ?
  9424. val.value :
  9425. null;
  9426. };
  9427. Sizzle.escape = function( sel ) {
  9428. return (sel + "").replace( rcssescape, fcssescape );
  9429. };
  9430. Sizzle.error = function( msg ) {
  9431. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9432. };
  9433. /**
  9434. * Document sorting and removing duplicates
  9435. * @param {ArrayLike} results
  9436. */
  9437. Sizzle.uniqueSort = function( results ) {
  9438. var elem,
  9439. duplicates = [],
  9440. j = 0,
  9441. i = 0;
  9442. // Unless we *know* we can detect duplicates, assume their presence
  9443. hasDuplicate = !support.detectDuplicates;
  9444. sortInput = !support.sortStable && results.slice( 0 );
  9445. results.sort( sortOrder );
  9446. if ( hasDuplicate ) {
  9447. while ( (elem = results[i++]) ) {
  9448. if ( elem === results[ i ] ) {
  9449. j = duplicates.push( i );
  9450. }
  9451. }
  9452. while ( j-- ) {
  9453. results.splice( duplicates[ j ], 1 );
  9454. }
  9455. }
  9456. // Clear input after sorting to release objects
  9457. // See https://github.com/jquery/sizzle/pull/225
  9458. sortInput = null;
  9459. return results;
  9460. };
  9461. /**
  9462. * Utility function for retrieving the text value of an array of DOM nodes
  9463. * @param {Array|Element} elem
  9464. */
  9465. getText = Sizzle.getText = function( elem ) {
  9466. var node,
  9467. ret = "",
  9468. i = 0,
  9469. nodeType = elem.nodeType;
  9470. if ( !nodeType ) {
  9471. // If no nodeType, this is expected to be an array
  9472. while ( (node = elem[i++]) ) {
  9473. // Do not traverse comment nodes
  9474. ret += getText( node );
  9475. }
  9476. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9477. // Use textContent for elements
  9478. // innerText usage removed for consistency of new lines (jQuery #11153)
  9479. if ( typeof elem.textContent === "string" ) {
  9480. return elem.textContent;
  9481. } else {
  9482. // Traverse its children
  9483. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9484. ret += getText( elem );
  9485. }
  9486. }
  9487. } else if ( nodeType === 3 || nodeType === 4 ) {
  9488. return elem.nodeValue;
  9489. }
  9490. // Do not include comment or processing instruction nodes
  9491. return ret;
  9492. };
  9493. Expr = Sizzle.selectors = {
  9494. // Can be adjusted by the user
  9495. cacheLength: 50,
  9496. createPseudo: markFunction,
  9497. match: matchExpr,
  9498. attrHandle: {},
  9499. find: {},
  9500. relative: {
  9501. ">": { dir: "parentNode", first: true },
  9502. " ": { dir: "parentNode" },
  9503. "+": { dir: "previousSibling", first: true },
  9504. "~": { dir: "previousSibling" }
  9505. },
  9506. preFilter: {
  9507. "ATTR": function( match ) {
  9508. match[1] = match[1].replace( runescape, funescape );
  9509. // Move the given value to match[3] whether quoted or unquoted
  9510. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9511. if ( match[2] === "~=" ) {
  9512. match[3] = " " + match[3] + " ";
  9513. }
  9514. return match.slice( 0, 4 );
  9515. },
  9516. "CHILD": function( match ) {
  9517. /* matches from matchExpr["CHILD"]
  9518. 1 type (only|nth|...)
  9519. 2 what (child|of-type)
  9520. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9521. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9522. 5 sign of xn-component
  9523. 6 x of xn-component
  9524. 7 sign of y-component
  9525. 8 y of y-component
  9526. */
  9527. match[1] = match[1].toLowerCase();
  9528. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9529. // nth-* requires argument
  9530. if ( !match[3] ) {
  9531. Sizzle.error( match[0] );
  9532. }
  9533. // numeric x and y parameters for Expr.filter.CHILD
  9534. // remember that false/true cast respectively to 0/1
  9535. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9536. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9537. // other types prohibit arguments
  9538. } else if ( match[3] ) {
  9539. Sizzle.error( match[0] );
  9540. }
  9541. return match;
  9542. },
  9543. "PSEUDO": function( match ) {
  9544. var excess,
  9545. unquoted = !match[6] && match[2];
  9546. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9547. return null;
  9548. }
  9549. // Accept quoted arguments as-is
  9550. if ( match[3] ) {
  9551. match[2] = match[4] || match[5] || "";
  9552. // Strip excess characters from unquoted arguments
  9553. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9554. // Get excess from tokenize (recursively)
  9555. (excess = tokenize( unquoted, true )) &&
  9556. // advance to the next closing parenthesis
  9557. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9558. // excess is a negative index
  9559. match[0] = match[0].slice( 0, excess );
  9560. match[2] = unquoted.slice( 0, excess );
  9561. }
  9562. // Return only captures needed by the pseudo filter method (type and argument)
  9563. return match.slice( 0, 3 );
  9564. }
  9565. },
  9566. filter: {
  9567. "TAG": function( nodeNameSelector ) {
  9568. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9569. return nodeNameSelector === "*" ?
  9570. function() { return true; } :
  9571. function( elem ) {
  9572. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9573. };
  9574. },
  9575. "CLASS": function( className ) {
  9576. var pattern = classCache[ className + " " ];
  9577. return pattern ||
  9578. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9579. classCache( className, function( elem ) {
  9580. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9581. });
  9582. },
  9583. "ATTR": function( name, operator, check ) {
  9584. return function( elem ) {
  9585. var result = Sizzle.attr( elem, name );
  9586. if ( result == null ) {
  9587. return operator === "!=";
  9588. }
  9589. if ( !operator ) {
  9590. return true;
  9591. }
  9592. result += "";
  9593. return operator === "=" ? result === check :
  9594. operator === "!=" ? result !== check :
  9595. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9596. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9597. operator === "$=" ? check && result.slice( -check.length ) === check :
  9598. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9599. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9600. false;
  9601. };
  9602. },
  9603. "CHILD": function( type, what, argument, first, last ) {
  9604. var simple = type.slice( 0, 3 ) !== "nth",
  9605. forward = type.slice( -4 ) !== "last",
  9606. ofType = what === "of-type";
  9607. return first === 1 && last === 0 ?
  9608. // Shortcut for :nth-*(n)
  9609. function( elem ) {
  9610. return !!elem.parentNode;
  9611. } :
  9612. function( elem, context, xml ) {
  9613. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9614. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9615. parent = elem.parentNode,
  9616. name = ofType && elem.nodeName.toLowerCase(),
  9617. useCache = !xml && !ofType,
  9618. diff = false;
  9619. if ( parent ) {
  9620. // :(first|last|only)-(child|of-type)
  9621. if ( simple ) {
  9622. while ( dir ) {
  9623. node = elem;
  9624. while ( (node = node[ dir ]) ) {
  9625. if ( ofType ?
  9626. node.nodeName.toLowerCase() === name :
  9627. node.nodeType === 1 ) {
  9628. return false;
  9629. }
  9630. }
  9631. // Reverse direction for :only-* (if we haven't yet done so)
  9632. start = dir = type === "only" && !start && "nextSibling";
  9633. }
  9634. return true;
  9635. }
  9636. start = [ forward ? parent.firstChild : parent.lastChild ];
  9637. // non-xml :nth-child(...) stores cache data on `parent`
  9638. if ( forward && useCache ) {
  9639. // Seek `elem` from a previously-cached index
  9640. // ...in a gzip-friendly way
  9641. node = parent;
  9642. outerCache = node[ expando ] || (node[ expando ] = {});
  9643. // Support: IE <9 only
  9644. // Defend against cloned attroperties (jQuery gh-1709)
  9645. uniqueCache = outerCache[ node.uniqueID ] ||
  9646. (outerCache[ node.uniqueID ] = {});
  9647. cache = uniqueCache[ type ] || [];
  9648. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9649. diff = nodeIndex && cache[ 2 ];
  9650. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9651. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9652. // Fallback to seeking `elem` from the start
  9653. (diff = nodeIndex = 0) || start.pop()) ) {
  9654. // When found, cache indexes on `parent` and break
  9655. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9656. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9657. break;
  9658. }
  9659. }
  9660. } else {
  9661. // Use previously-cached element index if available
  9662. if ( useCache ) {
  9663. // ...in a gzip-friendly way
  9664. node = elem;
  9665. outerCache = node[ expando ] || (node[ expando ] = {});
  9666. // Support: IE <9 only
  9667. // Defend against cloned attroperties (jQuery gh-1709)
  9668. uniqueCache = outerCache[ node.uniqueID ] ||
  9669. (outerCache[ node.uniqueID ] = {});
  9670. cache = uniqueCache[ type ] || [];
  9671. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9672. diff = nodeIndex;
  9673. }
  9674. // xml :nth-child(...)
  9675. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9676. if ( diff === false ) {
  9677. // Use the same loop as above to seek `elem` from the start
  9678. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9679. (diff = nodeIndex = 0) || start.pop()) ) {
  9680. if ( ( ofType ?
  9681. node.nodeName.toLowerCase() === name :
  9682. node.nodeType === 1 ) &&
  9683. ++diff ) {
  9684. // Cache the index of each encountered element
  9685. if ( useCache ) {
  9686. outerCache = node[ expando ] || (node[ expando ] = {});
  9687. // Support: IE <9 only
  9688. // Defend against cloned attroperties (jQuery gh-1709)
  9689. uniqueCache = outerCache[ node.uniqueID ] ||
  9690. (outerCache[ node.uniqueID ] = {});
  9691. uniqueCache[ type ] = [ dirruns, diff ];
  9692. }
  9693. if ( node === elem ) {
  9694. break;
  9695. }
  9696. }
  9697. }
  9698. }
  9699. }
  9700. // Incorporate the offset, then check against cycle size
  9701. diff -= last;
  9702. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9703. }
  9704. };
  9705. },
  9706. "PSEUDO": function( pseudo, argument ) {
  9707. // pseudo-class names are case-insensitive
  9708. // http://www.w3.org/TR/selectors/#pseudo-classes
  9709. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9710. // Remember that setFilters inherits from pseudos
  9711. var args,
  9712. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9713. Sizzle.error( "unsupported pseudo: " + pseudo );
  9714. // The user may use createPseudo to indicate that
  9715. // arguments are needed to create the filter function
  9716. // just as Sizzle does
  9717. if ( fn[ expando ] ) {
  9718. return fn( argument );
  9719. }
  9720. // But maintain support for old signatures
  9721. if ( fn.length > 1 ) {
  9722. args = [ pseudo, pseudo, "", argument ];
  9723. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9724. markFunction(function( seed, matches ) {
  9725. var idx,
  9726. matched = fn( seed, argument ),
  9727. i = matched.length;
  9728. while ( i-- ) {
  9729. idx = indexOf( seed, matched[i] );
  9730. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9731. }
  9732. }) :
  9733. function( elem ) {
  9734. return fn( elem, 0, args );
  9735. };
  9736. }
  9737. return fn;
  9738. }
  9739. },
  9740. pseudos: {
  9741. // Potentially complex pseudos
  9742. "not": markFunction(function( selector ) {
  9743. // Trim the selector passed to compile
  9744. // to avoid treating leading and trailing
  9745. // spaces as combinators
  9746. var input = [],
  9747. results = [],
  9748. matcher = compile( selector.replace( rtrim, "$1" ) );
  9749. return matcher[ expando ] ?
  9750. markFunction(function( seed, matches, context, xml ) {
  9751. var elem,
  9752. unmatched = matcher( seed, null, xml, [] ),
  9753. i = seed.length;
  9754. // Match elements unmatched by `matcher`
  9755. while ( i-- ) {
  9756. if ( (elem = unmatched[i]) ) {
  9757. seed[i] = !(matches[i] = elem);
  9758. }
  9759. }
  9760. }) :
  9761. function( elem, context, xml ) {
  9762. input[0] = elem;
  9763. matcher( input, null, xml, results );
  9764. // Don't keep the element (issue #299)
  9765. input[0] = null;
  9766. return !results.pop();
  9767. };
  9768. }),
  9769. "has": markFunction(function( selector ) {
  9770. return function( elem ) {
  9771. return Sizzle( selector, elem ).length > 0;
  9772. };
  9773. }),
  9774. "contains": markFunction(function( text ) {
  9775. text = text.replace( runescape, funescape );
  9776. return function( elem ) {
  9777. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9778. };
  9779. }),
  9780. // "Whether an element is represented by a :lang() selector
  9781. // is based solely on the element's language value
  9782. // being equal to the identifier C,
  9783. // or beginning with the identifier C immediately followed by "-".
  9784. // The matching of C against the element's language value is performed case-insensitively.
  9785. // The identifier C does not have to be a valid language name."
  9786. // http://www.w3.org/TR/selectors/#lang-pseudo
  9787. "lang": markFunction( function( lang ) {
  9788. // lang value must be a valid identifier
  9789. if ( !ridentifier.test(lang || "") ) {
  9790. Sizzle.error( "unsupported lang: " + lang );
  9791. }
  9792. lang = lang.replace( runescape, funescape ).toLowerCase();
  9793. return function( elem ) {
  9794. var elemLang;
  9795. do {
  9796. if ( (elemLang = documentIsHTML ?
  9797. elem.lang :
  9798. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9799. elemLang = elemLang.toLowerCase();
  9800. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9801. }
  9802. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9803. return false;
  9804. };
  9805. }),
  9806. // Miscellaneous
  9807. "target": function( elem ) {
  9808. var hash = window.location && window.location.hash;
  9809. return hash && hash.slice( 1 ) === elem.id;
  9810. },
  9811. "root": function( elem ) {
  9812. return elem === docElem;
  9813. },
  9814. "focus": function( elem ) {
  9815. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9816. },
  9817. // Boolean properties
  9818. "enabled": createDisabledPseudo( false ),
  9819. "disabled": createDisabledPseudo( true ),
  9820. "checked": function( elem ) {
  9821. // In CSS3, :checked should return both checked and selected elements
  9822. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9823. var nodeName = elem.nodeName.toLowerCase();
  9824. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9825. },
  9826. "selected": function( elem ) {
  9827. // Accessing this property makes selected-by-default
  9828. // options in Safari work properly
  9829. if ( elem.parentNode ) {
  9830. elem.parentNode.selectedIndex;
  9831. }
  9832. return elem.selected === true;
  9833. },
  9834. // Contents
  9835. "empty": function( elem ) {
  9836. // http://www.w3.org/TR/selectors/#empty-pseudo
  9837. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9838. // but not by others (comment: 8; processing instruction: 7; etc.)
  9839. // nodeType < 6 works because attributes (2) do not appear as children
  9840. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9841. if ( elem.nodeType < 6 ) {
  9842. return false;
  9843. }
  9844. }
  9845. return true;
  9846. },
  9847. "parent": function( elem ) {
  9848. return !Expr.pseudos["empty"]( elem );
  9849. },
  9850. // Element/input types
  9851. "header": function( elem ) {
  9852. return rheader.test( elem.nodeName );
  9853. },
  9854. "input": function( elem ) {
  9855. return rinputs.test( elem.nodeName );
  9856. },
  9857. "button": function( elem ) {
  9858. var name = elem.nodeName.toLowerCase();
  9859. return name === "input" && elem.type === "button" || name === "button";
  9860. },
  9861. "text": function( elem ) {
  9862. var attr;
  9863. return elem.nodeName.toLowerCase() === "input" &&
  9864. elem.type === "text" &&
  9865. // Support: IE<8
  9866. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9867. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9868. },
  9869. // Position-in-collection
  9870. "first": createPositionalPseudo(function() {
  9871. return [ 0 ];
  9872. }),
  9873. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9874. return [ length - 1 ];
  9875. }),
  9876. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9877. return [ argument < 0 ? argument + length : argument ];
  9878. }),
  9879. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9880. var i = 0;
  9881. for ( ; i < length; i += 2 ) {
  9882. matchIndexes.push( i );
  9883. }
  9884. return matchIndexes;
  9885. }),
  9886. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9887. var i = 1;
  9888. for ( ; i < length; i += 2 ) {
  9889. matchIndexes.push( i );
  9890. }
  9891. return matchIndexes;
  9892. }),
  9893. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9894. var i = argument < 0 ?
  9895. argument + length :
  9896. argument > length ?
  9897. length :
  9898. argument;
  9899. for ( ; --i >= 0; ) {
  9900. matchIndexes.push( i );
  9901. }
  9902. return matchIndexes;
  9903. }),
  9904. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9905. var i = argument < 0 ? argument + length : argument;
  9906. for ( ; ++i < length; ) {
  9907. matchIndexes.push( i );
  9908. }
  9909. return matchIndexes;
  9910. })
  9911. }
  9912. };
  9913. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9914. // Add button/input type pseudos
  9915. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9916. Expr.pseudos[ i ] = createInputPseudo( i );
  9917. }
  9918. for ( i in { submit: true, reset: true } ) {
  9919. Expr.pseudos[ i ] = createButtonPseudo( i );
  9920. }
  9921. // Easy API for creating new setFilters
  9922. function setFilters() {}
  9923. setFilters.prototype = Expr.filters = Expr.pseudos;
  9924. Expr.setFilters = new setFilters();
  9925. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9926. var matched, match, tokens, type,
  9927. soFar, groups, preFilters,
  9928. cached = tokenCache[ selector + " " ];
  9929. if ( cached ) {
  9930. return parseOnly ? 0 : cached.slice( 0 );
  9931. }
  9932. soFar = selector;
  9933. groups = [];
  9934. preFilters = Expr.preFilter;
  9935. while ( soFar ) {
  9936. // Comma and first run
  9937. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9938. if ( match ) {
  9939. // Don't consume trailing commas as valid
  9940. soFar = soFar.slice( match[0].length ) || soFar;
  9941. }
  9942. groups.push( (tokens = []) );
  9943. }
  9944. matched = false;
  9945. // Combinators
  9946. if ( (match = rcombinators.exec( soFar )) ) {
  9947. matched = match.shift();
  9948. tokens.push({
  9949. value: matched,
  9950. // Cast descendant combinators to space
  9951. type: match[0].replace( rtrim, " " )
  9952. });
  9953. soFar = soFar.slice( matched.length );
  9954. }
  9955. // Filters
  9956. for ( type in Expr.filter ) {
  9957. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9958. (match = preFilters[ type ]( match ))) ) {
  9959. matched = match.shift();
  9960. tokens.push({
  9961. value: matched,
  9962. type: type,
  9963. matches: match
  9964. });
  9965. soFar = soFar.slice( matched.length );
  9966. }
  9967. }
  9968. if ( !matched ) {
  9969. break;
  9970. }
  9971. }
  9972. // Return the length of the invalid excess
  9973. // if we're just parsing
  9974. // Otherwise, throw an error or return tokens
  9975. return parseOnly ?
  9976. soFar.length :
  9977. soFar ?
  9978. Sizzle.error( selector ) :
  9979. // Cache the tokens
  9980. tokenCache( selector, groups ).slice( 0 );
  9981. };
  9982. function toSelector( tokens ) {
  9983. var i = 0,
  9984. len = tokens.length,
  9985. selector = "";
  9986. for ( ; i < len; i++ ) {
  9987. selector += tokens[i].value;
  9988. }
  9989. return selector;
  9990. }
  9991. function addCombinator( matcher, combinator, base ) {
  9992. var dir = combinator.dir,
  9993. skip = combinator.next,
  9994. key = skip || dir,
  9995. checkNonElements = base && key === "parentNode",
  9996. doneName = done++;
  9997. return combinator.first ?
  9998. // Check against closest ancestor/preceding element
  9999. function( elem, context, xml ) {
  10000. while ( (elem = elem[ dir ]) ) {
  10001. if ( elem.nodeType === 1 || checkNonElements ) {
  10002. return matcher( elem, context, xml );
  10003. }
  10004. }
  10005. return false;
  10006. } :
  10007. // Check against all ancestor/preceding elements
  10008. function( elem, context, xml ) {
  10009. var oldCache, uniqueCache, outerCache,
  10010. newCache = [ dirruns, doneName ];
  10011. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  10012. if ( xml ) {
  10013. while ( (elem = elem[ dir ]) ) {
  10014. if ( elem.nodeType === 1 || checkNonElements ) {
  10015. if ( matcher( elem, context, xml ) ) {
  10016. return true;
  10017. }
  10018. }
  10019. }
  10020. } else {
  10021. while ( (elem = elem[ dir ]) ) {
  10022. if ( elem.nodeType === 1 || checkNonElements ) {
  10023. outerCache = elem[ expando ] || (elem[ expando ] = {});
  10024. // Support: IE <9 only
  10025. // Defend against cloned attroperties (jQuery gh-1709)
  10026. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  10027. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  10028. elem = elem[ dir ] || elem;
  10029. } else if ( (oldCache = uniqueCache[ key ]) &&
  10030. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  10031. // Assign to newCache so results back-propagate to previous elements
  10032. return (newCache[ 2 ] = oldCache[ 2 ]);
  10033. } else {
  10034. // Reuse newcache so results back-propagate to previous elements
  10035. uniqueCache[ key ] = newCache;
  10036. // A match means we're done; a fail means we have to keep checking
  10037. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  10038. return true;
  10039. }
  10040. }
  10041. }
  10042. }
  10043. }
  10044. return false;
  10045. };
  10046. }
  10047. function elementMatcher( matchers ) {
  10048. return matchers.length > 1 ?
  10049. function( elem, context, xml ) {
  10050. var i = matchers.length;
  10051. while ( i-- ) {
  10052. if ( !matchers[i]( elem, context, xml ) ) {
  10053. return false;
  10054. }
  10055. }
  10056. return true;
  10057. } :
  10058. matchers[0];
  10059. }
  10060. function multipleContexts( selector, contexts, results ) {
  10061. var i = 0,
  10062. len = contexts.length;
  10063. for ( ; i < len; i++ ) {
  10064. Sizzle( selector, contexts[i], results );
  10065. }
  10066. return results;
  10067. }
  10068. function condense( unmatched, map, filter, context, xml ) {
  10069. var elem,
  10070. newUnmatched = [],
  10071. i = 0,
  10072. len = unmatched.length,
  10073. mapped = map != null;
  10074. for ( ; i < len; i++ ) {
  10075. if ( (elem = unmatched[i]) ) {
  10076. if ( !filter || filter( elem, context, xml ) ) {
  10077. newUnmatched.push( elem );
  10078. if ( mapped ) {
  10079. map.push( i );
  10080. }
  10081. }
  10082. }
  10083. }
  10084. return newUnmatched;
  10085. }
  10086. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  10087. if ( postFilter && !postFilter[ expando ] ) {
  10088. postFilter = setMatcher( postFilter );
  10089. }
  10090. if ( postFinder && !postFinder[ expando ] ) {
  10091. postFinder = setMatcher( postFinder, postSelector );
  10092. }
  10093. return markFunction(function( seed, results, context, xml ) {
  10094. var temp, i, elem,
  10095. preMap = [],
  10096. postMap = [],
  10097. preexisting = results.length,
  10098. // Get initial elements from seed or context
  10099. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  10100. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  10101. matcherIn = preFilter && ( seed || !selector ) ?
  10102. condense( elems, preMap, preFilter, context, xml ) :
  10103. elems,
  10104. matcherOut = matcher ?
  10105. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  10106. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  10107. // ...intermediate processing is necessary
  10108. [] :
  10109. // ...otherwise use results directly
  10110. results :
  10111. matcherIn;
  10112. // Find primary matches
  10113. if ( matcher ) {
  10114. matcher( matcherIn, matcherOut, context, xml );
  10115. }
  10116. // Apply postFilter
  10117. if ( postFilter ) {
  10118. temp = condense( matcherOut, postMap );
  10119. postFilter( temp, [], context, xml );
  10120. // Un-match failing elements by moving them back to matcherIn
  10121. i = temp.length;
  10122. while ( i-- ) {
  10123. if ( (elem = temp[i]) ) {
  10124. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  10125. }
  10126. }
  10127. }
  10128. if ( seed ) {
  10129. if ( postFinder || preFilter ) {
  10130. if ( postFinder ) {
  10131. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10132. temp = [];
  10133. i = matcherOut.length;
  10134. while ( i-- ) {
  10135. if ( (elem = matcherOut[i]) ) {
  10136. // Restore matcherIn since elem is not yet a final match
  10137. temp.push( (matcherIn[i] = elem) );
  10138. }
  10139. }
  10140. postFinder( null, (matcherOut = []), temp, xml );
  10141. }
  10142. // Move matched elements from seed to results to keep them synchronized
  10143. i = matcherOut.length;
  10144. while ( i-- ) {
  10145. if ( (elem = matcherOut[i]) &&
  10146. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10147. seed[temp] = !(results[temp] = elem);
  10148. }
  10149. }
  10150. }
  10151. // Add elements to results, through postFinder if defined
  10152. } else {
  10153. matcherOut = condense(
  10154. matcherOut === results ?
  10155. matcherOut.splice( preexisting, matcherOut.length ) :
  10156. matcherOut
  10157. );
  10158. if ( postFinder ) {
  10159. postFinder( null, results, matcherOut, xml );
  10160. } else {
  10161. push.apply( results, matcherOut );
  10162. }
  10163. }
  10164. });
  10165. }
  10166. function matcherFromTokens( tokens ) {
  10167. var checkContext, matcher, j,
  10168. len = tokens.length,
  10169. leadingRelative = Expr.relative[ tokens[0].type ],
  10170. implicitRelative = leadingRelative || Expr.relative[" "],
  10171. i = leadingRelative ? 1 : 0,
  10172. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10173. matchContext = addCombinator( function( elem ) {
  10174. return elem === checkContext;
  10175. }, implicitRelative, true ),
  10176. matchAnyContext = addCombinator( function( elem ) {
  10177. return indexOf( checkContext, elem ) > -1;
  10178. }, implicitRelative, true ),
  10179. matchers = [ function( elem, context, xml ) {
  10180. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10181. (checkContext = context).nodeType ?
  10182. matchContext( elem, context, xml ) :
  10183. matchAnyContext( elem, context, xml ) );
  10184. // Avoid hanging onto element (issue #299)
  10185. checkContext = null;
  10186. return ret;
  10187. } ];
  10188. for ( ; i < len; i++ ) {
  10189. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10190. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10191. } else {
  10192. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10193. // Return special upon seeing a positional matcher
  10194. if ( matcher[ expando ] ) {
  10195. // Find the next relative operator (if any) for proper handling
  10196. j = ++i;
  10197. for ( ; j < len; j++ ) {
  10198. if ( Expr.relative[ tokens[j].type ] ) {
  10199. break;
  10200. }
  10201. }
  10202. return setMatcher(
  10203. i > 1 && elementMatcher( matchers ),
  10204. i > 1 && toSelector(
  10205. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10206. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10207. ).replace( rtrim, "$1" ),
  10208. matcher,
  10209. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10210. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10211. j < len && toSelector( tokens )
  10212. );
  10213. }
  10214. matchers.push( matcher );
  10215. }
  10216. }
  10217. return elementMatcher( matchers );
  10218. }
  10219. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10220. var bySet = setMatchers.length > 0,
  10221. byElement = elementMatchers.length > 0,
  10222. superMatcher = function( seed, context, xml, results, outermost ) {
  10223. var elem, j, matcher,
  10224. matchedCount = 0,
  10225. i = "0",
  10226. unmatched = seed && [],
  10227. setMatched = [],
  10228. contextBackup = outermostContext,
  10229. // We must always have either seed elements or outermost context
  10230. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10231. // Use integer dirruns iff this is the outermost matcher
  10232. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10233. len = elems.length;
  10234. if ( outermost ) {
  10235. outermostContext = context === document || context || outermost;
  10236. }
  10237. // Add elements passing elementMatchers directly to results
  10238. // Support: IE<9, Safari
  10239. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10240. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10241. if ( byElement && elem ) {
  10242. j = 0;
  10243. if ( !context && elem.ownerDocument !== document ) {
  10244. setDocument( elem );
  10245. xml = !documentIsHTML;
  10246. }
  10247. while ( (matcher = elementMatchers[j++]) ) {
  10248. if ( matcher( elem, context || document, xml) ) {
  10249. results.push( elem );
  10250. break;
  10251. }
  10252. }
  10253. if ( outermost ) {
  10254. dirruns = dirrunsUnique;
  10255. }
  10256. }
  10257. // Track unmatched elements for set filters
  10258. if ( bySet ) {
  10259. // They will have gone through all possible matchers
  10260. if ( (elem = !matcher && elem) ) {
  10261. matchedCount--;
  10262. }
  10263. // Lengthen the array for every element, matched or not
  10264. if ( seed ) {
  10265. unmatched.push( elem );
  10266. }
  10267. }
  10268. }
  10269. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10270. // makes the latter nonnegative.
  10271. matchedCount += i;
  10272. // Apply set filters to unmatched elements
  10273. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10274. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10275. // no element matchers and no seed.
  10276. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10277. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10278. // numerically zero.
  10279. if ( bySet && i !== matchedCount ) {
  10280. j = 0;
  10281. while ( (matcher = setMatchers[j++]) ) {
  10282. matcher( unmatched, setMatched, context, xml );
  10283. }
  10284. if ( seed ) {
  10285. // Reintegrate element matches to eliminate the need for sorting
  10286. if ( matchedCount > 0 ) {
  10287. while ( i-- ) {
  10288. if ( !(unmatched[i] || setMatched[i]) ) {
  10289. setMatched[i] = pop.call( results );
  10290. }
  10291. }
  10292. }
  10293. // Discard index placeholder values to get only actual matches
  10294. setMatched = condense( setMatched );
  10295. }
  10296. // Add matches to results
  10297. push.apply( results, setMatched );
  10298. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10299. if ( outermost && !seed && setMatched.length > 0 &&
  10300. ( matchedCount + setMatchers.length ) > 1 ) {
  10301. Sizzle.uniqueSort( results );
  10302. }
  10303. }
  10304. // Override manipulation of globals by nested matchers
  10305. if ( outermost ) {
  10306. dirruns = dirrunsUnique;
  10307. outermostContext = contextBackup;
  10308. }
  10309. return unmatched;
  10310. };
  10311. return bySet ?
  10312. markFunction( superMatcher ) :
  10313. superMatcher;
  10314. }
  10315. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10316. var i,
  10317. setMatchers = [],
  10318. elementMatchers = [],
  10319. cached = compilerCache[ selector + " " ];
  10320. if ( !cached ) {
  10321. // Generate a function of recursive functions that can be used to check each element
  10322. if ( !match ) {
  10323. match = tokenize( selector );
  10324. }
  10325. i = match.length;
  10326. while ( i-- ) {
  10327. cached = matcherFromTokens( match[i] );
  10328. if ( cached[ expando ] ) {
  10329. setMatchers.push( cached );
  10330. } else {
  10331. elementMatchers.push( cached );
  10332. }
  10333. }
  10334. // Cache the compiled function
  10335. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10336. // Save selector and tokenization
  10337. cached.selector = selector;
  10338. }
  10339. return cached;
  10340. };
  10341. /**
  10342. * A low-level selection function that works with Sizzle's compiled
  10343. * selector functions
  10344. * @param {String|Function} selector A selector or a pre-compiled
  10345. * selector function built with Sizzle.compile
  10346. * @param {Element} context
  10347. * @param {Array} [results]
  10348. * @param {Array} [seed] A set of elements to match against
  10349. */
  10350. select = Sizzle.select = function( selector, context, results, seed ) {
  10351. var i, tokens, token, type, find,
  10352. compiled = typeof selector === "function" && selector,
  10353. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10354. results = results || [];
  10355. // Try to minimize operations if there is only one selector in the list and no seed
  10356. // (the latter of which guarantees us context)
  10357. if ( match.length === 1 ) {
  10358. // Reduce context if the leading compound selector is an ID
  10359. tokens = match[0] = match[0].slice( 0 );
  10360. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10361. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10362. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10363. if ( !context ) {
  10364. return results;
  10365. // Precompiled matchers will still verify ancestry, so step up a level
  10366. } else if ( compiled ) {
  10367. context = context.parentNode;
  10368. }
  10369. selector = selector.slice( tokens.shift().value.length );
  10370. }
  10371. // Fetch a seed set for right-to-left matching
  10372. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10373. while ( i-- ) {
  10374. token = tokens[i];
  10375. // Abort if we hit a combinator
  10376. if ( Expr.relative[ (type = token.type) ] ) {
  10377. break;
  10378. }
  10379. if ( (find = Expr.find[ type ]) ) {
  10380. // Search, expanding context for leading sibling combinators
  10381. if ( (seed = find(
  10382. token.matches[0].replace( runescape, funescape ),
  10383. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10384. )) ) {
  10385. // If seed is empty or no tokens remain, we can return early
  10386. tokens.splice( i, 1 );
  10387. selector = seed.length && toSelector( tokens );
  10388. if ( !selector ) {
  10389. push.apply( results, seed );
  10390. return results;
  10391. }
  10392. break;
  10393. }
  10394. }
  10395. }
  10396. }
  10397. // Compile and execute a filtering function if one is not provided
  10398. // Provide `match` to avoid retokenization if we modified the selector above
  10399. ( compiled || compile( selector, match ) )(
  10400. seed,
  10401. context,
  10402. !documentIsHTML,
  10403. results,
  10404. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10405. );
  10406. return results;
  10407. };
  10408. // One-time assignments
  10409. // Sort stability
  10410. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10411. // Support: Chrome 14-35+
  10412. // Always assume duplicates if they aren't passed to the comparison function
  10413. support.detectDuplicates = !!hasDuplicate;
  10414. // Initialize against the default document
  10415. setDocument();
  10416. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10417. // Detached nodes confoundingly follow *each other*
  10418. support.sortDetached = assert(function( el ) {
  10419. // Should return 1, but returns 4 (following)
  10420. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10421. });
  10422. // Support: IE<8
  10423. // Prevent attribute/property "interpolation"
  10424. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10425. if ( !assert(function( el ) {
  10426. el.innerHTML = "<a href='#'></a>";
  10427. return el.firstChild.getAttribute("href") === "#" ;
  10428. }) ) {
  10429. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10430. if ( !isXML ) {
  10431. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10432. }
  10433. });
  10434. }
  10435. // Support: IE<9
  10436. // Use defaultValue in place of getAttribute("value")
  10437. if ( !support.attributes || !assert(function( el ) {
  10438. el.innerHTML = "<input/>";
  10439. el.firstChild.setAttribute( "value", "" );
  10440. return el.firstChild.getAttribute( "value" ) === "";
  10441. }) ) {
  10442. addHandle( "value", function( elem, name, isXML ) {
  10443. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10444. return elem.defaultValue;
  10445. }
  10446. });
  10447. }
  10448. // Support: IE<9
  10449. // Use getAttributeNode to fetch booleans when getAttribute lies
  10450. if ( !assert(function( el ) {
  10451. return el.getAttribute("disabled") == null;
  10452. }) ) {
  10453. addHandle( booleans, function( elem, name, isXML ) {
  10454. var val;
  10455. if ( !isXML ) {
  10456. return elem[ name ] === true ? name.toLowerCase() :
  10457. (val = elem.getAttributeNode( name )) && val.specified ?
  10458. val.value :
  10459. null;
  10460. }
  10461. });
  10462. }
  10463. return Sizzle;
  10464. })( window );
  10465. jQuery.find = Sizzle;
  10466. jQuery.expr = Sizzle.selectors;
  10467. // Deprecated
  10468. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10469. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10470. jQuery.text = Sizzle.getText;
  10471. jQuery.isXMLDoc = Sizzle.isXML;
  10472. jQuery.contains = Sizzle.contains;
  10473. jQuery.escapeSelector = Sizzle.escape;
  10474. var dir = function( elem, dir, until ) {
  10475. var matched = [],
  10476. truncate = until !== undefined;
  10477. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10478. if ( elem.nodeType === 1 ) {
  10479. if ( truncate && jQuery( elem ).is( until ) ) {
  10480. break;
  10481. }
  10482. matched.push( elem );
  10483. }
  10484. }
  10485. return matched;
  10486. };
  10487. var siblings = function( n, elem ) {
  10488. var matched = [];
  10489. for ( ; n; n = n.nextSibling ) {
  10490. if ( n.nodeType === 1 && n !== elem ) {
  10491. matched.push( n );
  10492. }
  10493. }
  10494. return matched;
  10495. };
  10496. var rneedsContext = jQuery.expr.match.needsContext;
  10497. function nodeName( elem, name ) {
  10498. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10499. };
  10500. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10501. // Implement the identical functionality for filter and not
  10502. function winnow( elements, qualifier, not ) {
  10503. if ( isFunction( qualifier ) ) {
  10504. return jQuery.grep( elements, function( elem, i ) {
  10505. return !!qualifier.call( elem, i, elem ) !== not;
  10506. } );
  10507. }
  10508. // Single element
  10509. if ( qualifier.nodeType ) {
  10510. return jQuery.grep( elements, function( elem ) {
  10511. return ( elem === qualifier ) !== not;
  10512. } );
  10513. }
  10514. // Arraylike of elements (jQuery, arguments, Array)
  10515. if ( typeof qualifier !== "string" ) {
  10516. return jQuery.grep( elements, function( elem ) {
  10517. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10518. } );
  10519. }
  10520. // Filtered directly for both simple and complex selectors
  10521. return jQuery.filter( qualifier, elements, not );
  10522. }
  10523. jQuery.filter = function( expr, elems, not ) {
  10524. var elem = elems[ 0 ];
  10525. if ( not ) {
  10526. expr = ":not(" + expr + ")";
  10527. }
  10528. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10529. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10530. }
  10531. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10532. return elem.nodeType === 1;
  10533. } ) );
  10534. };
  10535. jQuery.fn.extend( {
  10536. find: function( selector ) {
  10537. var i, ret,
  10538. len = this.length,
  10539. self = this;
  10540. if ( typeof selector !== "string" ) {
  10541. return this.pushStack( jQuery( selector ).filter( function() {
  10542. for ( i = 0; i < len; i++ ) {
  10543. if ( jQuery.contains( self[ i ], this ) ) {
  10544. return true;
  10545. }
  10546. }
  10547. } ) );
  10548. }
  10549. ret = this.pushStack( [] );
  10550. for ( i = 0; i < len; i++ ) {
  10551. jQuery.find( selector, self[ i ], ret );
  10552. }
  10553. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10554. },
  10555. filter: function( selector ) {
  10556. return this.pushStack( winnow( this, selector || [], false ) );
  10557. },
  10558. not: function( selector ) {
  10559. return this.pushStack( winnow( this, selector || [], true ) );
  10560. },
  10561. is: function( selector ) {
  10562. return !!winnow(
  10563. this,
  10564. // If this is a positional/relative selector, check membership in the returned set
  10565. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10566. typeof selector === "string" && rneedsContext.test( selector ) ?
  10567. jQuery( selector ) :
  10568. selector || [],
  10569. false
  10570. ).length;
  10571. }
  10572. } );
  10573. // Initialize a jQuery object
  10574. // A central reference to the root jQuery(document)
  10575. var rootjQuery,
  10576. // A simple way to check for HTML strings
  10577. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10578. // Strict HTML recognition (#11290: must start with <)
  10579. // Shortcut simple #id case for speed
  10580. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10581. init = jQuery.fn.init = function( selector, context, root ) {
  10582. var match, elem;
  10583. // HANDLE: $(""), $(null), $(undefined), $(false)
  10584. if ( !selector ) {
  10585. return this;
  10586. }
  10587. // Method init() accepts an alternate rootjQuery
  10588. // so migrate can support jQuery.sub (gh-2101)
  10589. root = root || rootjQuery;
  10590. // Handle HTML strings
  10591. if ( typeof selector === "string" ) {
  10592. if ( selector[ 0 ] === "<" &&
  10593. selector[ selector.length - 1 ] === ">" &&
  10594. selector.length >= 3 ) {
  10595. // Assume that strings that start and end with <> are HTML and skip the regex check
  10596. match = [ null, selector, null ];
  10597. } else {
  10598. match = rquickExpr.exec( selector );
  10599. }
  10600. // Match html or make sure no context is specified for #id
  10601. if ( match && ( match[ 1 ] || !context ) ) {
  10602. // HANDLE: $(html) -> $(array)
  10603. if ( match[ 1 ] ) {
  10604. context = context instanceof jQuery ? context[ 0 ] : context;
  10605. // Option to run scripts is true for back-compat
  10606. // Intentionally let the error be thrown if parseHTML is not present
  10607. jQuery.merge( this, jQuery.parseHTML(
  10608. match[ 1 ],
  10609. context && context.nodeType ? context.ownerDocument || context : document,
  10610. true
  10611. ) );
  10612. // HANDLE: $(html, props)
  10613. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10614. for ( match in context ) {
  10615. // Properties of context are called as methods if possible
  10616. if ( isFunction( this[ match ] ) ) {
  10617. this[ match ]( context[ match ] );
  10618. // ...and otherwise set as attributes
  10619. } else {
  10620. this.attr( match, context[ match ] );
  10621. }
  10622. }
  10623. }
  10624. return this;
  10625. // HANDLE: $(#id)
  10626. } else {
  10627. elem = document.getElementById( match[ 2 ] );
  10628. if ( elem ) {
  10629. // Inject the element directly into the jQuery object
  10630. this[ 0 ] = elem;
  10631. this.length = 1;
  10632. }
  10633. return this;
  10634. }
  10635. // HANDLE: $(expr, $(...))
  10636. } else if ( !context || context.jquery ) {
  10637. return ( context || root ).find( selector );
  10638. // HANDLE: $(expr, context)
  10639. // (which is just equivalent to: $(context).find(expr)
  10640. } else {
  10641. return this.constructor( context ).find( selector );
  10642. }
  10643. // HANDLE: $(DOMElement)
  10644. } else if ( selector.nodeType ) {
  10645. this[ 0 ] = selector;
  10646. this.length = 1;
  10647. return this;
  10648. // HANDLE: $(function)
  10649. // Shortcut for document ready
  10650. } else if ( isFunction( selector ) ) {
  10651. return root.ready !== undefined ?
  10652. root.ready( selector ) :
  10653. // Execute immediately if ready is not present
  10654. selector( jQuery );
  10655. }
  10656. return jQuery.makeArray( selector, this );
  10657. };
  10658. // Give the init function the jQuery prototype for later instantiation
  10659. init.prototype = jQuery.fn;
  10660. // Initialize central reference
  10661. rootjQuery = jQuery( document );
  10662. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10663. // Methods guaranteed to produce a unique set when starting from a unique set
  10664. guaranteedUnique = {
  10665. children: true,
  10666. contents: true,
  10667. next: true,
  10668. prev: true
  10669. };
  10670. jQuery.fn.extend( {
  10671. has: function( target ) {
  10672. var targets = jQuery( target, this ),
  10673. l = targets.length;
  10674. return this.filter( function() {
  10675. var i = 0;
  10676. for ( ; i < l; i++ ) {
  10677. if ( jQuery.contains( this, targets[ i ] ) ) {
  10678. return true;
  10679. }
  10680. }
  10681. } );
  10682. },
  10683. closest: function( selectors, context ) {
  10684. var cur,
  10685. i = 0,
  10686. l = this.length,
  10687. matched = [],
  10688. targets = typeof selectors !== "string" && jQuery( selectors );
  10689. // Positional selectors never match, since there's no _selection_ context
  10690. if ( !rneedsContext.test( selectors ) ) {
  10691. for ( ; i < l; i++ ) {
  10692. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10693. // Always skip document fragments
  10694. if ( cur.nodeType < 11 && ( targets ?
  10695. targets.index( cur ) > -1 :
  10696. // Don't pass non-elements to Sizzle
  10697. cur.nodeType === 1 &&
  10698. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10699. matched.push( cur );
  10700. break;
  10701. }
  10702. }
  10703. }
  10704. }
  10705. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10706. },
  10707. // Determine the position of an element within the set
  10708. index: function( elem ) {
  10709. // No argument, return index in parent
  10710. if ( !elem ) {
  10711. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10712. }
  10713. // Index in selector
  10714. if ( typeof elem === "string" ) {
  10715. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10716. }
  10717. // Locate the position of the desired element
  10718. return indexOf.call( this,
  10719. // If it receives a jQuery object, the first element is used
  10720. elem.jquery ? elem[ 0 ] : elem
  10721. );
  10722. },
  10723. add: function( selector, context ) {
  10724. return this.pushStack(
  10725. jQuery.uniqueSort(
  10726. jQuery.merge( this.get(), jQuery( selector, context ) )
  10727. )
  10728. );
  10729. },
  10730. addBack: function( selector ) {
  10731. return this.add( selector == null ?
  10732. this.prevObject : this.prevObject.filter( selector )
  10733. );
  10734. }
  10735. } );
  10736. function sibling( cur, dir ) {
  10737. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10738. return cur;
  10739. }
  10740. jQuery.each( {
  10741. parent: function( elem ) {
  10742. var parent = elem.parentNode;
  10743. return parent && parent.nodeType !== 11 ? parent : null;
  10744. },
  10745. parents: function( elem ) {
  10746. return dir( elem, "parentNode" );
  10747. },
  10748. parentsUntil: function( elem, i, until ) {
  10749. return dir( elem, "parentNode", until );
  10750. },
  10751. next: function( elem ) {
  10752. return sibling( elem, "nextSibling" );
  10753. },
  10754. prev: function( elem ) {
  10755. return sibling( elem, "previousSibling" );
  10756. },
  10757. nextAll: function( elem ) {
  10758. return dir( elem, "nextSibling" );
  10759. },
  10760. prevAll: function( elem ) {
  10761. return dir( elem, "previousSibling" );
  10762. },
  10763. nextUntil: function( elem, i, until ) {
  10764. return dir( elem, "nextSibling", until );
  10765. },
  10766. prevUntil: function( elem, i, until ) {
  10767. return dir( elem, "previousSibling", until );
  10768. },
  10769. siblings: function( elem ) {
  10770. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10771. },
  10772. children: function( elem ) {
  10773. return siblings( elem.firstChild );
  10774. },
  10775. contents: function( elem ) {
  10776. if ( typeof elem.contentDocument !== "undefined" ) {
  10777. return elem.contentDocument;
  10778. }
  10779. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10780. // Treat the template element as a regular one in browsers that
  10781. // don't support it.
  10782. if ( nodeName( elem, "template" ) ) {
  10783. elem = elem.content || elem;
  10784. }
  10785. return jQuery.merge( [], elem.childNodes );
  10786. }
  10787. }, function( name, fn ) {
  10788. jQuery.fn[ name ] = function( until, selector ) {
  10789. var matched = jQuery.map( this, fn, until );
  10790. if ( name.slice( -5 ) !== "Until" ) {
  10791. selector = until;
  10792. }
  10793. if ( selector && typeof selector === "string" ) {
  10794. matched = jQuery.filter( selector, matched );
  10795. }
  10796. if ( this.length > 1 ) {
  10797. // Remove duplicates
  10798. if ( !guaranteedUnique[ name ] ) {
  10799. jQuery.uniqueSort( matched );
  10800. }
  10801. // Reverse order for parents* and prev-derivatives
  10802. if ( rparentsprev.test( name ) ) {
  10803. matched.reverse();
  10804. }
  10805. }
  10806. return this.pushStack( matched );
  10807. };
  10808. } );
  10809. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10810. // Convert String-formatted options into Object-formatted ones
  10811. function createOptions( options ) {
  10812. var object = {};
  10813. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10814. object[ flag ] = true;
  10815. } );
  10816. return object;
  10817. }
  10818. /*
  10819. * Create a callback list using the following parameters:
  10820. *
  10821. * options: an optional list of space-separated options that will change how
  10822. * the callback list behaves or a more traditional option object
  10823. *
  10824. * By default a callback list will act like an event callback list and can be
  10825. * "fired" multiple times.
  10826. *
  10827. * Possible options:
  10828. *
  10829. * once: will ensure the callback list can only be fired once (like a Deferred)
  10830. *
  10831. * memory: will keep track of previous values and will call any callback added
  10832. * after the list has been fired right away with the latest "memorized"
  10833. * values (like a Deferred)
  10834. *
  10835. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10836. *
  10837. * stopOnFalse: interrupt callings when a callback returns false
  10838. *
  10839. */
  10840. jQuery.Callbacks = function( options ) {
  10841. // Convert options from String-formatted to Object-formatted if needed
  10842. // (we check in cache first)
  10843. options = typeof options === "string" ?
  10844. createOptions( options ) :
  10845. jQuery.extend( {}, options );
  10846. var // Flag to know if list is currently firing
  10847. firing,
  10848. // Last fire value for non-forgettable lists
  10849. memory,
  10850. // Flag to know if list was already fired
  10851. fired,
  10852. // Flag to prevent firing
  10853. locked,
  10854. // Actual callback list
  10855. list = [],
  10856. // Queue of execution data for repeatable lists
  10857. queue = [],
  10858. // Index of currently firing callback (modified by add/remove as needed)
  10859. firingIndex = -1,
  10860. // Fire callbacks
  10861. fire = function() {
  10862. // Enforce single-firing
  10863. locked = locked || options.once;
  10864. // Execute callbacks for all pending executions,
  10865. // respecting firingIndex overrides and runtime changes
  10866. fired = firing = true;
  10867. for ( ; queue.length; firingIndex = -1 ) {
  10868. memory = queue.shift();
  10869. while ( ++firingIndex < list.length ) {
  10870. // Run callback and check for early termination
  10871. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10872. options.stopOnFalse ) {
  10873. // Jump to end and forget the data so .add doesn't re-fire
  10874. firingIndex = list.length;
  10875. memory = false;
  10876. }
  10877. }
  10878. }
  10879. // Forget the data if we're done with it
  10880. if ( !options.memory ) {
  10881. memory = false;
  10882. }
  10883. firing = false;
  10884. // Clean up if we're done firing for good
  10885. if ( locked ) {
  10886. // Keep an empty list if we have data for future add calls
  10887. if ( memory ) {
  10888. list = [];
  10889. // Otherwise, this object is spent
  10890. } else {
  10891. list = "";
  10892. }
  10893. }
  10894. },
  10895. // Actual Callbacks object
  10896. self = {
  10897. // Add a callback or a collection of callbacks to the list
  10898. add: function() {
  10899. if ( list ) {
  10900. // If we have memory from a past run, we should fire after adding
  10901. if ( memory && !firing ) {
  10902. firingIndex = list.length - 1;
  10903. queue.push( memory );
  10904. }
  10905. ( function add( args ) {
  10906. jQuery.each( args, function( _, arg ) {
  10907. if ( isFunction( arg ) ) {
  10908. if ( !options.unique || !self.has( arg ) ) {
  10909. list.push( arg );
  10910. }
  10911. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10912. // Inspect recursively
  10913. add( arg );
  10914. }
  10915. } );
  10916. } )( arguments );
  10917. if ( memory && !firing ) {
  10918. fire();
  10919. }
  10920. }
  10921. return this;
  10922. },
  10923. // Remove a callback from the list
  10924. remove: function() {
  10925. jQuery.each( arguments, function( _, arg ) {
  10926. var index;
  10927. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10928. list.splice( index, 1 );
  10929. // Handle firing indexes
  10930. if ( index <= firingIndex ) {
  10931. firingIndex--;
  10932. }
  10933. }
  10934. } );
  10935. return this;
  10936. },
  10937. // Check if a given callback is in the list.
  10938. // If no argument is given, return whether or not list has callbacks attached.
  10939. has: function( fn ) {
  10940. return fn ?
  10941. jQuery.inArray( fn, list ) > -1 :
  10942. list.length > 0;
  10943. },
  10944. // Remove all callbacks from the list
  10945. empty: function() {
  10946. if ( list ) {
  10947. list = [];
  10948. }
  10949. return this;
  10950. },
  10951. // Disable .fire and .add
  10952. // Abort any current/pending executions
  10953. // Clear all callbacks and values
  10954. disable: function() {
  10955. locked = queue = [];
  10956. list = memory = "";
  10957. return this;
  10958. },
  10959. disabled: function() {
  10960. return !list;
  10961. },
  10962. // Disable .fire
  10963. // Also disable .add unless we have memory (since it would have no effect)
  10964. // Abort any pending executions
  10965. lock: function() {
  10966. locked = queue = [];
  10967. if ( !memory && !firing ) {
  10968. list = memory = "";
  10969. }
  10970. return this;
  10971. },
  10972. locked: function() {
  10973. return !!locked;
  10974. },
  10975. // Call all callbacks with the given context and arguments
  10976. fireWith: function( context, args ) {
  10977. if ( !locked ) {
  10978. args = args || [];
  10979. args = [ context, args.slice ? args.slice() : args ];
  10980. queue.push( args );
  10981. if ( !firing ) {
  10982. fire();
  10983. }
  10984. }
  10985. return this;
  10986. },
  10987. // Call all the callbacks with the given arguments
  10988. fire: function() {
  10989. self.fireWith( this, arguments );
  10990. return this;
  10991. },
  10992. // To know if the callbacks have already been called at least once
  10993. fired: function() {
  10994. return !!fired;
  10995. }
  10996. };
  10997. return self;
  10998. };
  10999. function Identity( v ) {
  11000. return v;
  11001. }
  11002. function Thrower( ex ) {
  11003. throw ex;
  11004. }
  11005. function adoptValue( value, resolve, reject, noValue ) {
  11006. var method;
  11007. try {
  11008. // Check for promise aspect first to privilege synchronous behavior
  11009. if ( value && isFunction( ( method = value.promise ) ) ) {
  11010. method.call( value ).done( resolve ).fail( reject );
  11011. // Other thenables
  11012. } else if ( value && isFunction( ( method = value.then ) ) ) {
  11013. method.call( value, resolve, reject );
  11014. // Other non-thenables
  11015. } else {
  11016. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  11017. // * false: [ value ].slice( 0 ) => resolve( value )
  11018. // * true: [ value ].slice( 1 ) => resolve()
  11019. resolve.apply( undefined, [ value ].slice( noValue ) );
  11020. }
  11021. // For Promises/A+, convert exceptions into rejections
  11022. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  11023. // Deferred#then to conditionally suppress rejection.
  11024. } catch ( value ) {
  11025. // Support: Android 4.0 only
  11026. // Strict mode functions invoked without .call/.apply get global-object context
  11027. reject.apply( undefined, [ value ] );
  11028. }
  11029. }
  11030. jQuery.extend( {
  11031. Deferred: function( func ) {
  11032. var tuples = [
  11033. // action, add listener, callbacks,
  11034. // ... .then handlers, argument index, [final state]
  11035. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  11036. jQuery.Callbacks( "memory" ), 2 ],
  11037. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  11038. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  11039. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  11040. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  11041. ],
  11042. state = "pending",
  11043. promise = {
  11044. state: function() {
  11045. return state;
  11046. },
  11047. always: function() {
  11048. deferred.done( arguments ).fail( arguments );
  11049. return this;
  11050. },
  11051. "catch": function( fn ) {
  11052. return promise.then( null, fn );
  11053. },
  11054. // Keep pipe for back-compat
  11055. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  11056. var fns = arguments;
  11057. return jQuery.Deferred( function( newDefer ) {
  11058. jQuery.each( tuples, function( i, tuple ) {
  11059. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  11060. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  11061. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  11062. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  11063. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  11064. deferred[ tuple[ 1 ] ]( function() {
  11065. var returned = fn && fn.apply( this, arguments );
  11066. if ( returned && isFunction( returned.promise ) ) {
  11067. returned.promise()
  11068. .progress( newDefer.notify )
  11069. .done( newDefer.resolve )
  11070. .fail( newDefer.reject );
  11071. } else {
  11072. newDefer[ tuple[ 0 ] + "With" ](
  11073. this,
  11074. fn ? [ returned ] : arguments
  11075. );
  11076. }
  11077. } );
  11078. } );
  11079. fns = null;
  11080. } ).promise();
  11081. },
  11082. then: function( onFulfilled, onRejected, onProgress ) {
  11083. var maxDepth = 0;
  11084. function resolve( depth, deferred, handler, special ) {
  11085. return function() {
  11086. var that = this,
  11087. args = arguments,
  11088. mightThrow = function() {
  11089. var returned, then;
  11090. // Support: Promises/A+ section 2.3.3.3.3
  11091. // https://promisesaplus.com/#point-59
  11092. // Ignore double-resolution attempts
  11093. if ( depth < maxDepth ) {
  11094. return;
  11095. }
  11096. returned = handler.apply( that, args );
  11097. // Support: Promises/A+ section 2.3.1
  11098. // https://promisesaplus.com/#point-48
  11099. if ( returned === deferred.promise() ) {
  11100. throw new TypeError( "Thenable self-resolution" );
  11101. }
  11102. // Support: Promises/A+ sections 2.3.3.1, 3.5
  11103. // https://promisesaplus.com/#point-54
  11104. // https://promisesaplus.com/#point-75
  11105. // Retrieve `then` only once
  11106. then = returned &&
  11107. // Support: Promises/A+ section 2.3.4
  11108. // https://promisesaplus.com/#point-64
  11109. // Only check objects and functions for thenability
  11110. ( typeof returned === "object" ||
  11111. typeof returned === "function" ) &&
  11112. returned.then;
  11113. // Handle a returned thenable
  11114. if ( isFunction( then ) ) {
  11115. // Special processors (notify) just wait for resolution
  11116. if ( special ) {
  11117. then.call(
  11118. returned,
  11119. resolve( maxDepth, deferred, Identity, special ),
  11120. resolve( maxDepth, deferred, Thrower, special )
  11121. );
  11122. // Normal processors (resolve) also hook into progress
  11123. } else {
  11124. // ...and disregard older resolution values
  11125. maxDepth++;
  11126. then.call(
  11127. returned,
  11128. resolve( maxDepth, deferred, Identity, special ),
  11129. resolve( maxDepth, deferred, Thrower, special ),
  11130. resolve( maxDepth, deferred, Identity,
  11131. deferred.notifyWith )
  11132. );
  11133. }
  11134. // Handle all other returned values
  11135. } else {
  11136. // Only substitute handlers pass on context
  11137. // and multiple values (non-spec behavior)
  11138. if ( handler !== Identity ) {
  11139. that = undefined;
  11140. args = [ returned ];
  11141. }
  11142. // Process the value(s)
  11143. // Default process is resolve
  11144. ( special || deferred.resolveWith )( that, args );
  11145. }
  11146. },
  11147. // Only normal processors (resolve) catch and reject exceptions
  11148. process = special ?
  11149. mightThrow :
  11150. function() {
  11151. try {
  11152. mightThrow();
  11153. } catch ( e ) {
  11154. if ( jQuery.Deferred.exceptionHook ) {
  11155. jQuery.Deferred.exceptionHook( e,
  11156. process.stackTrace );
  11157. }
  11158. // Support: Promises/A+ section 2.3.3.3.4.1
  11159. // https://promisesaplus.com/#point-61
  11160. // Ignore post-resolution exceptions
  11161. if ( depth + 1 >= maxDepth ) {
  11162. // Only substitute handlers pass on context
  11163. // and multiple values (non-spec behavior)
  11164. if ( handler !== Thrower ) {
  11165. that = undefined;
  11166. args = [ e ];
  11167. }
  11168. deferred.rejectWith( that, args );
  11169. }
  11170. }
  11171. };
  11172. // Support: Promises/A+ section 2.3.3.3.1
  11173. // https://promisesaplus.com/#point-57
  11174. // Re-resolve promises immediately to dodge false rejection from
  11175. // subsequent errors
  11176. if ( depth ) {
  11177. process();
  11178. } else {
  11179. // Call an optional hook to record the stack, in case of exception
  11180. // since it's otherwise lost when execution goes async
  11181. if ( jQuery.Deferred.getStackHook ) {
  11182. process.stackTrace = jQuery.Deferred.getStackHook();
  11183. }
  11184. window.setTimeout( process );
  11185. }
  11186. };
  11187. }
  11188. return jQuery.Deferred( function( newDefer ) {
  11189. // progress_handlers.add( ... )
  11190. tuples[ 0 ][ 3 ].add(
  11191. resolve(
  11192. 0,
  11193. newDefer,
  11194. isFunction( onProgress ) ?
  11195. onProgress :
  11196. Identity,
  11197. newDefer.notifyWith
  11198. )
  11199. );
  11200. // fulfilled_handlers.add( ... )
  11201. tuples[ 1 ][ 3 ].add(
  11202. resolve(
  11203. 0,
  11204. newDefer,
  11205. isFunction( onFulfilled ) ?
  11206. onFulfilled :
  11207. Identity
  11208. )
  11209. );
  11210. // rejected_handlers.add( ... )
  11211. tuples[ 2 ][ 3 ].add(
  11212. resolve(
  11213. 0,
  11214. newDefer,
  11215. isFunction( onRejected ) ?
  11216. onRejected :
  11217. Thrower
  11218. )
  11219. );
  11220. } ).promise();
  11221. },
  11222. // Get a promise for this deferred
  11223. // If obj is provided, the promise aspect is added to the object
  11224. promise: function( obj ) {
  11225. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11226. }
  11227. },
  11228. deferred = {};
  11229. // Add list-specific methods
  11230. jQuery.each( tuples, function( i, tuple ) {
  11231. var list = tuple[ 2 ],
  11232. stateString = tuple[ 5 ];
  11233. // promise.progress = list.add
  11234. // promise.done = list.add
  11235. // promise.fail = list.add
  11236. promise[ tuple[ 1 ] ] = list.add;
  11237. // Handle state
  11238. if ( stateString ) {
  11239. list.add(
  11240. function() {
  11241. // state = "resolved" (i.e., fulfilled)
  11242. // state = "rejected"
  11243. state = stateString;
  11244. },
  11245. // rejected_callbacks.disable
  11246. // fulfilled_callbacks.disable
  11247. tuples[ 3 - i ][ 2 ].disable,
  11248. // rejected_handlers.disable
  11249. // fulfilled_handlers.disable
  11250. tuples[ 3 - i ][ 3 ].disable,
  11251. // progress_callbacks.lock
  11252. tuples[ 0 ][ 2 ].lock,
  11253. // progress_handlers.lock
  11254. tuples[ 0 ][ 3 ].lock
  11255. );
  11256. }
  11257. // progress_handlers.fire
  11258. // fulfilled_handlers.fire
  11259. // rejected_handlers.fire
  11260. list.add( tuple[ 3 ].fire );
  11261. // deferred.notify = function() { deferred.notifyWith(...) }
  11262. // deferred.resolve = function() { deferred.resolveWith(...) }
  11263. // deferred.reject = function() { deferred.rejectWith(...) }
  11264. deferred[ tuple[ 0 ] ] = function() {
  11265. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11266. return this;
  11267. };
  11268. // deferred.notifyWith = list.fireWith
  11269. // deferred.resolveWith = list.fireWith
  11270. // deferred.rejectWith = list.fireWith
  11271. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11272. } );
  11273. // Make the deferred a promise
  11274. promise.promise( deferred );
  11275. // Call given func if any
  11276. if ( func ) {
  11277. func.call( deferred, deferred );
  11278. }
  11279. // All done!
  11280. return deferred;
  11281. },
  11282. // Deferred helper
  11283. when: function( singleValue ) {
  11284. var
  11285. // count of uncompleted subordinates
  11286. remaining = arguments.length,
  11287. // count of unprocessed arguments
  11288. i = remaining,
  11289. // subordinate fulfillment data
  11290. resolveContexts = Array( i ),
  11291. resolveValues = slice.call( arguments ),
  11292. // the master Deferred
  11293. master = jQuery.Deferred(),
  11294. // subordinate callback factory
  11295. updateFunc = function( i ) {
  11296. return function( value ) {
  11297. resolveContexts[ i ] = this;
  11298. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11299. if ( !( --remaining ) ) {
  11300. master.resolveWith( resolveContexts, resolveValues );
  11301. }
  11302. };
  11303. };
  11304. // Single- and empty arguments are adopted like Promise.resolve
  11305. if ( remaining <= 1 ) {
  11306. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11307. !remaining );
  11308. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11309. if ( master.state() === "pending" ||
  11310. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11311. return master.then();
  11312. }
  11313. }
  11314. // Multiple arguments are aggregated like Promise.all array elements
  11315. while ( i-- ) {
  11316. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11317. }
  11318. return master.promise();
  11319. }
  11320. } );
  11321. // These usually indicate a programmer mistake during development,
  11322. // warn about them ASAP rather than swallowing them by default.
  11323. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11324. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11325. // Support: IE 8 - 9 only
  11326. // Console exists when dev tools are open, which can happen at any time
  11327. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11328. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11329. }
  11330. };
  11331. jQuery.readyException = function( error ) {
  11332. window.setTimeout( function() {
  11333. throw error;
  11334. } );
  11335. };
  11336. // The deferred used on DOM ready
  11337. var readyList = jQuery.Deferred();
  11338. jQuery.fn.ready = function( fn ) {
  11339. readyList
  11340. .then( fn )
  11341. // Wrap jQuery.readyException in a function so that the lookup
  11342. // happens at the time of error handling instead of callback
  11343. // registration.
  11344. .catch( function( error ) {
  11345. jQuery.readyException( error );
  11346. } );
  11347. return this;
  11348. };
  11349. jQuery.extend( {
  11350. // Is the DOM ready to be used? Set to true once it occurs.
  11351. isReady: false,
  11352. // A counter to track how many items to wait for before
  11353. // the ready event fires. See #6781
  11354. readyWait: 1,
  11355. // Handle when the DOM is ready
  11356. ready: function( wait ) {
  11357. // Abort if there are pending holds or we're already ready
  11358. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11359. return;
  11360. }
  11361. // Remember that the DOM is ready
  11362. jQuery.isReady = true;
  11363. // If a normal DOM Ready event fired, decrement, and wait if need be
  11364. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11365. return;
  11366. }
  11367. // If there are functions bound, to execute
  11368. readyList.resolveWith( document, [ jQuery ] );
  11369. }
  11370. } );
  11371. jQuery.ready.then = readyList.then;
  11372. // The ready event handler and self cleanup method
  11373. function completed() {
  11374. document.removeEventListener( "DOMContentLoaded", completed );
  11375. window.removeEventListener( "load", completed );
  11376. jQuery.ready();
  11377. }
  11378. // Catch cases where $(document).ready() is called
  11379. // after the browser event has already occurred.
  11380. // Support: IE <=9 - 10 only
  11381. // Older IE sometimes signals "interactive" too soon
  11382. if ( document.readyState === "complete" ||
  11383. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11384. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11385. window.setTimeout( jQuery.ready );
  11386. } else {
  11387. // Use the handy event callback
  11388. document.addEventListener( "DOMContentLoaded", completed );
  11389. // A fallback to window.onload, that will always work
  11390. window.addEventListener( "load", completed );
  11391. }
  11392. // Multifunctional method to get and set values of a collection
  11393. // The value/s can optionally be executed if it's a function
  11394. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11395. var i = 0,
  11396. len = elems.length,
  11397. bulk = key == null;
  11398. // Sets many values
  11399. if ( toType( key ) === "object" ) {
  11400. chainable = true;
  11401. for ( i in key ) {
  11402. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11403. }
  11404. // Sets one value
  11405. } else if ( value !== undefined ) {
  11406. chainable = true;
  11407. if ( !isFunction( value ) ) {
  11408. raw = true;
  11409. }
  11410. if ( bulk ) {
  11411. // Bulk operations run against the entire set
  11412. if ( raw ) {
  11413. fn.call( elems, value );
  11414. fn = null;
  11415. // ...except when executing function values
  11416. } else {
  11417. bulk = fn;
  11418. fn = function( elem, key, value ) {
  11419. return bulk.call( jQuery( elem ), value );
  11420. };
  11421. }
  11422. }
  11423. if ( fn ) {
  11424. for ( ; i < len; i++ ) {
  11425. fn(
  11426. elems[ i ], key, raw ?
  11427. value :
  11428. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11429. );
  11430. }
  11431. }
  11432. }
  11433. if ( chainable ) {
  11434. return elems;
  11435. }
  11436. // Gets
  11437. if ( bulk ) {
  11438. return fn.call( elems );
  11439. }
  11440. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11441. };
  11442. // Matches dashed string for camelizing
  11443. var rmsPrefix = /^-ms-/,
  11444. rdashAlpha = /-([a-z])/g;
  11445. // Used by camelCase as callback to replace()
  11446. function fcamelCase( all, letter ) {
  11447. return letter.toUpperCase();
  11448. }
  11449. // Convert dashed to camelCase; used by the css and data modules
  11450. // Support: IE <=9 - 11, Edge 12 - 15
  11451. // Microsoft forgot to hump their vendor prefix (#9572)
  11452. function camelCase( string ) {
  11453. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11454. }
  11455. var acceptData = function( owner ) {
  11456. // Accepts only:
  11457. // - Node
  11458. // - Node.ELEMENT_NODE
  11459. // - Node.DOCUMENT_NODE
  11460. // - Object
  11461. // - Any
  11462. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11463. };
  11464. function Data() {
  11465. this.expando = jQuery.expando + Data.uid++;
  11466. }
  11467. Data.uid = 1;
  11468. Data.prototype = {
  11469. cache: function( owner ) {
  11470. // Check if the owner object already has a cache
  11471. var value = owner[ this.expando ];
  11472. // If not, create one
  11473. if ( !value ) {
  11474. value = {};
  11475. // We can accept data for non-element nodes in modern browsers,
  11476. // but we should not, see #8335.
  11477. // Always return an empty object.
  11478. if ( acceptData( owner ) ) {
  11479. // If it is a node unlikely to be stringify-ed or looped over
  11480. // use plain assignment
  11481. if ( owner.nodeType ) {
  11482. owner[ this.expando ] = value;
  11483. // Otherwise secure it in a non-enumerable property
  11484. // configurable must be true to allow the property to be
  11485. // deleted when data is removed
  11486. } else {
  11487. Object.defineProperty( owner, this.expando, {
  11488. value: value,
  11489. configurable: true
  11490. } );
  11491. }
  11492. }
  11493. }
  11494. return value;
  11495. },
  11496. set: function( owner, data, value ) {
  11497. var prop,
  11498. cache = this.cache( owner );
  11499. // Handle: [ owner, key, value ] args
  11500. // Always use camelCase key (gh-2257)
  11501. if ( typeof data === "string" ) {
  11502. cache[ camelCase( data ) ] = value;
  11503. // Handle: [ owner, { properties } ] args
  11504. } else {
  11505. // Copy the properties one-by-one to the cache object
  11506. for ( prop in data ) {
  11507. cache[ camelCase( prop ) ] = data[ prop ];
  11508. }
  11509. }
  11510. return cache;
  11511. },
  11512. get: function( owner, key ) {
  11513. return key === undefined ?
  11514. this.cache( owner ) :
  11515. // Always use camelCase key (gh-2257)
  11516. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11517. },
  11518. access: function( owner, key, value ) {
  11519. // In cases where either:
  11520. //
  11521. // 1. No key was specified
  11522. // 2. A string key was specified, but no value provided
  11523. //
  11524. // Take the "read" path and allow the get method to determine
  11525. // which value to return, respectively either:
  11526. //
  11527. // 1. The entire cache object
  11528. // 2. The data stored at the key
  11529. //
  11530. if ( key === undefined ||
  11531. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11532. return this.get( owner, key );
  11533. }
  11534. // When the key is not a string, or both a key and value
  11535. // are specified, set or extend (existing objects) with either:
  11536. //
  11537. // 1. An object of properties
  11538. // 2. A key and value
  11539. //
  11540. this.set( owner, key, value );
  11541. // Since the "set" path can have two possible entry points
  11542. // return the expected data based on which path was taken[*]
  11543. return value !== undefined ? value : key;
  11544. },
  11545. remove: function( owner, key ) {
  11546. var i,
  11547. cache = owner[ this.expando ];
  11548. if ( cache === undefined ) {
  11549. return;
  11550. }
  11551. if ( key !== undefined ) {
  11552. // Support array or space separated string of keys
  11553. if ( Array.isArray( key ) ) {
  11554. // If key is an array of keys...
  11555. // We always set camelCase keys, so remove that.
  11556. key = key.map( camelCase );
  11557. } else {
  11558. key = camelCase( key );
  11559. // If a key with the spaces exists, use it.
  11560. // Otherwise, create an array by matching non-whitespace
  11561. key = key in cache ?
  11562. [ key ] :
  11563. ( key.match( rnothtmlwhite ) || [] );
  11564. }
  11565. i = key.length;
  11566. while ( i-- ) {
  11567. delete cache[ key[ i ] ];
  11568. }
  11569. }
  11570. // Remove the expando if there's no more data
  11571. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11572. // Support: Chrome <=35 - 45
  11573. // Webkit & Blink performance suffers when deleting properties
  11574. // from DOM nodes, so set to undefined instead
  11575. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11576. if ( owner.nodeType ) {
  11577. owner[ this.expando ] = undefined;
  11578. } else {
  11579. delete owner[ this.expando ];
  11580. }
  11581. }
  11582. },
  11583. hasData: function( owner ) {
  11584. var cache = owner[ this.expando ];
  11585. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11586. }
  11587. };
  11588. var dataPriv = new Data();
  11589. var dataUser = new Data();
  11590. // Implementation Summary
  11591. //
  11592. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11593. // 2. Improve the module's maintainability by reducing the storage
  11594. // paths to a single mechanism.
  11595. // 3. Use the same single mechanism to support "private" and "user" data.
  11596. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11597. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11598. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11599. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11600. rmultiDash = /[A-Z]/g;
  11601. function getData( data ) {
  11602. if ( data === "true" ) {
  11603. return true;
  11604. }
  11605. if ( data === "false" ) {
  11606. return false;
  11607. }
  11608. if ( data === "null" ) {
  11609. return null;
  11610. }
  11611. // Only convert to a number if it doesn't change the string
  11612. if ( data === +data + "" ) {
  11613. return +data;
  11614. }
  11615. if ( rbrace.test( data ) ) {
  11616. return JSON.parse( data );
  11617. }
  11618. return data;
  11619. }
  11620. function dataAttr( elem, key, data ) {
  11621. var name;
  11622. // If nothing was found internally, try to fetch any
  11623. // data from the HTML5 data-* attribute
  11624. if ( data === undefined && elem.nodeType === 1 ) {
  11625. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11626. data = elem.getAttribute( name );
  11627. if ( typeof data === "string" ) {
  11628. try {
  11629. data = getData( data );
  11630. } catch ( e ) {}
  11631. // Make sure we set the data so it isn't changed later
  11632. dataUser.set( elem, key, data );
  11633. } else {
  11634. data = undefined;
  11635. }
  11636. }
  11637. return data;
  11638. }
  11639. jQuery.extend( {
  11640. hasData: function( elem ) {
  11641. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11642. },
  11643. data: function( elem, name, data ) {
  11644. return dataUser.access( elem, name, data );
  11645. },
  11646. removeData: function( elem, name ) {
  11647. dataUser.remove( elem, name );
  11648. },
  11649. // TODO: Now that all calls to _data and _removeData have been replaced
  11650. // with direct calls to dataPriv methods, these can be deprecated.
  11651. _data: function( elem, name, data ) {
  11652. return dataPriv.access( elem, name, data );
  11653. },
  11654. _removeData: function( elem, name ) {
  11655. dataPriv.remove( elem, name );
  11656. }
  11657. } );
  11658. jQuery.fn.extend( {
  11659. data: function( key, value ) {
  11660. var i, name, data,
  11661. elem = this[ 0 ],
  11662. attrs = elem && elem.attributes;
  11663. // Gets all values
  11664. if ( key === undefined ) {
  11665. if ( this.length ) {
  11666. data = dataUser.get( elem );
  11667. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11668. i = attrs.length;
  11669. while ( i-- ) {
  11670. // Support: IE 11 only
  11671. // The attrs elements can be null (#14894)
  11672. if ( attrs[ i ] ) {
  11673. name = attrs[ i ].name;
  11674. if ( name.indexOf( "data-" ) === 0 ) {
  11675. name = camelCase( name.slice( 5 ) );
  11676. dataAttr( elem, name, data[ name ] );
  11677. }
  11678. }
  11679. }
  11680. dataPriv.set( elem, "hasDataAttrs", true );
  11681. }
  11682. }
  11683. return data;
  11684. }
  11685. // Sets multiple values
  11686. if ( typeof key === "object" ) {
  11687. return this.each( function() {
  11688. dataUser.set( this, key );
  11689. } );
  11690. }
  11691. return access( this, function( value ) {
  11692. var data;
  11693. // The calling jQuery object (element matches) is not empty
  11694. // (and therefore has an element appears at this[ 0 ]) and the
  11695. // `value` parameter was not undefined. An empty jQuery object
  11696. // will result in `undefined` for elem = this[ 0 ] which will
  11697. // throw an exception if an attempt to read a data cache is made.
  11698. if ( elem && value === undefined ) {
  11699. // Attempt to get data from the cache
  11700. // The key will always be camelCased in Data
  11701. data = dataUser.get( elem, key );
  11702. if ( data !== undefined ) {
  11703. return data;
  11704. }
  11705. // Attempt to "discover" the data in
  11706. // HTML5 custom data-* attrs
  11707. data = dataAttr( elem, key );
  11708. if ( data !== undefined ) {
  11709. return data;
  11710. }
  11711. // We tried really hard, but the data doesn't exist.
  11712. return;
  11713. }
  11714. // Set the data...
  11715. this.each( function() {
  11716. // We always store the camelCased key
  11717. dataUser.set( this, key, value );
  11718. } );
  11719. }, null, value, arguments.length > 1, null, true );
  11720. },
  11721. removeData: function( key ) {
  11722. return this.each( function() {
  11723. dataUser.remove( this, key );
  11724. } );
  11725. }
  11726. } );
  11727. jQuery.extend( {
  11728. queue: function( elem, type, data ) {
  11729. var queue;
  11730. if ( elem ) {
  11731. type = ( type || "fx" ) + "queue";
  11732. queue = dataPriv.get( elem, type );
  11733. // Speed up dequeue by getting out quickly if this is just a lookup
  11734. if ( data ) {
  11735. if ( !queue || Array.isArray( data ) ) {
  11736. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11737. } else {
  11738. queue.push( data );
  11739. }
  11740. }
  11741. return queue || [];
  11742. }
  11743. },
  11744. dequeue: function( elem, type ) {
  11745. type = type || "fx";
  11746. var queue = jQuery.queue( elem, type ),
  11747. startLength = queue.length,
  11748. fn = queue.shift(),
  11749. hooks = jQuery._queueHooks( elem, type ),
  11750. next = function() {
  11751. jQuery.dequeue( elem, type );
  11752. };
  11753. // If the fx queue is dequeued, always remove the progress sentinel
  11754. if ( fn === "inprogress" ) {
  11755. fn = queue.shift();
  11756. startLength--;
  11757. }
  11758. if ( fn ) {
  11759. // Add a progress sentinel to prevent the fx queue from being
  11760. // automatically dequeued
  11761. if ( type === "fx" ) {
  11762. queue.unshift( "inprogress" );
  11763. }
  11764. // Clear up the last queue stop function
  11765. delete hooks.stop;
  11766. fn.call( elem, next, hooks );
  11767. }
  11768. if ( !startLength && hooks ) {
  11769. hooks.empty.fire();
  11770. }
  11771. },
  11772. // Not public - generate a queueHooks object, or return the current one
  11773. _queueHooks: function( elem, type ) {
  11774. var key = type + "queueHooks";
  11775. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11776. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11777. dataPriv.remove( elem, [ type + "queue", key ] );
  11778. } )
  11779. } );
  11780. }
  11781. } );
  11782. jQuery.fn.extend( {
  11783. queue: function( type, data ) {
  11784. var setter = 2;
  11785. if ( typeof type !== "string" ) {
  11786. data = type;
  11787. type = "fx";
  11788. setter--;
  11789. }
  11790. if ( arguments.length < setter ) {
  11791. return jQuery.queue( this[ 0 ], type );
  11792. }
  11793. return data === undefined ?
  11794. this :
  11795. this.each( function() {
  11796. var queue = jQuery.queue( this, type, data );
  11797. // Ensure a hooks for this queue
  11798. jQuery._queueHooks( this, type );
  11799. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11800. jQuery.dequeue( this, type );
  11801. }
  11802. } );
  11803. },
  11804. dequeue: function( type ) {
  11805. return this.each( function() {
  11806. jQuery.dequeue( this, type );
  11807. } );
  11808. },
  11809. clearQueue: function( type ) {
  11810. return this.queue( type || "fx", [] );
  11811. },
  11812. // Get a promise resolved when queues of a certain type
  11813. // are emptied (fx is the type by default)
  11814. promise: function( type, obj ) {
  11815. var tmp,
  11816. count = 1,
  11817. defer = jQuery.Deferred(),
  11818. elements = this,
  11819. i = this.length,
  11820. resolve = function() {
  11821. if ( !( --count ) ) {
  11822. defer.resolveWith( elements, [ elements ] );
  11823. }
  11824. };
  11825. if ( typeof type !== "string" ) {
  11826. obj = type;
  11827. type = undefined;
  11828. }
  11829. type = type || "fx";
  11830. while ( i-- ) {
  11831. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11832. if ( tmp && tmp.empty ) {
  11833. count++;
  11834. tmp.empty.add( resolve );
  11835. }
  11836. }
  11837. resolve();
  11838. return defer.promise( obj );
  11839. }
  11840. } );
  11841. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11842. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11843. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11844. var documentElement = document.documentElement;
  11845. var isAttached = function( elem ) {
  11846. return jQuery.contains( elem.ownerDocument, elem );
  11847. },
  11848. composed = { composed: true };
  11849. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11850. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11851. // Support: iOS 10.0-10.2 only
  11852. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11853. // leading to errors. We need to check for `getRootNode`.
  11854. if ( documentElement.getRootNode ) {
  11855. isAttached = function( elem ) {
  11856. return jQuery.contains( elem.ownerDocument, elem ) ||
  11857. elem.getRootNode( composed ) === elem.ownerDocument;
  11858. };
  11859. }
  11860. var isHiddenWithinTree = function( elem, el ) {
  11861. // isHiddenWithinTree might be called from jQuery#filter function;
  11862. // in that case, element will be second argument
  11863. elem = el || elem;
  11864. // Inline style trumps all
  11865. return elem.style.display === "none" ||
  11866. elem.style.display === "" &&
  11867. // Otherwise, check computed style
  11868. // Support: Firefox <=43 - 45
  11869. // Disconnected elements can have computed display: none, so first confirm that elem is
  11870. // in the document.
  11871. isAttached( elem ) &&
  11872. jQuery.css( elem, "display" ) === "none";
  11873. };
  11874. var swap = function( elem, options, callback, args ) {
  11875. var ret, name,
  11876. old = {};
  11877. // Remember the old values, and insert the new ones
  11878. for ( name in options ) {
  11879. old[ name ] = elem.style[ name ];
  11880. elem.style[ name ] = options[ name ];
  11881. }
  11882. ret = callback.apply( elem, args || [] );
  11883. // Revert the old values
  11884. for ( name in options ) {
  11885. elem.style[ name ] = old[ name ];
  11886. }
  11887. return ret;
  11888. };
  11889. function adjustCSS( elem, prop, valueParts, tween ) {
  11890. var adjusted, scale,
  11891. maxIterations = 20,
  11892. currentValue = tween ?
  11893. function() {
  11894. return tween.cur();
  11895. } :
  11896. function() {
  11897. return jQuery.css( elem, prop, "" );
  11898. },
  11899. initial = currentValue(),
  11900. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11901. // Starting value computation is required for potential unit mismatches
  11902. initialInUnit = elem.nodeType &&
  11903. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11904. rcssNum.exec( jQuery.css( elem, prop ) );
  11905. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11906. // Support: Firefox <=54
  11907. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11908. initial = initial / 2;
  11909. // Trust units reported by jQuery.css
  11910. unit = unit || initialInUnit[ 3 ];
  11911. // Iteratively approximate from a nonzero starting point
  11912. initialInUnit = +initial || 1;
  11913. while ( maxIterations-- ) {
  11914. // Evaluate and update our best guess (doubling guesses that zero out).
  11915. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11916. jQuery.style( elem, prop, initialInUnit + unit );
  11917. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11918. maxIterations = 0;
  11919. }
  11920. initialInUnit = initialInUnit / scale;
  11921. }
  11922. initialInUnit = initialInUnit * 2;
  11923. jQuery.style( elem, prop, initialInUnit + unit );
  11924. // Make sure we update the tween properties later on
  11925. valueParts = valueParts || [];
  11926. }
  11927. if ( valueParts ) {
  11928. initialInUnit = +initialInUnit || +initial || 0;
  11929. // Apply relative offset (+=/-=) if specified
  11930. adjusted = valueParts[ 1 ] ?
  11931. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11932. +valueParts[ 2 ];
  11933. if ( tween ) {
  11934. tween.unit = unit;
  11935. tween.start = initialInUnit;
  11936. tween.end = adjusted;
  11937. }
  11938. }
  11939. return adjusted;
  11940. }
  11941. var defaultDisplayMap = {};
  11942. function getDefaultDisplay( elem ) {
  11943. var temp,
  11944. doc = elem.ownerDocument,
  11945. nodeName = elem.nodeName,
  11946. display = defaultDisplayMap[ nodeName ];
  11947. if ( display ) {
  11948. return display;
  11949. }
  11950. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11951. display = jQuery.css( temp, "display" );
  11952. temp.parentNode.removeChild( temp );
  11953. if ( display === "none" ) {
  11954. display = "block";
  11955. }
  11956. defaultDisplayMap[ nodeName ] = display;
  11957. return display;
  11958. }
  11959. function showHide( elements, show ) {
  11960. var display, elem,
  11961. values = [],
  11962. index = 0,
  11963. length = elements.length;
  11964. // Determine new display value for elements that need to change
  11965. for ( ; index < length; index++ ) {
  11966. elem = elements[ index ];
  11967. if ( !elem.style ) {
  11968. continue;
  11969. }
  11970. display = elem.style.display;
  11971. if ( show ) {
  11972. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11973. // check is required in this first loop unless we have a nonempty display value (either
  11974. // inline or about-to-be-restored)
  11975. if ( display === "none" ) {
  11976. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11977. if ( !values[ index ] ) {
  11978. elem.style.display = "";
  11979. }
  11980. }
  11981. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11982. values[ index ] = getDefaultDisplay( elem );
  11983. }
  11984. } else {
  11985. if ( display !== "none" ) {
  11986. values[ index ] = "none";
  11987. // Remember what we're overwriting
  11988. dataPriv.set( elem, "display", display );
  11989. }
  11990. }
  11991. }
  11992. // Set the display of the elements in a second loop to avoid constant reflow
  11993. for ( index = 0; index < length; index++ ) {
  11994. if ( values[ index ] != null ) {
  11995. elements[ index ].style.display = values[ index ];
  11996. }
  11997. }
  11998. return elements;
  11999. }
  12000. jQuery.fn.extend( {
  12001. show: function() {
  12002. return showHide( this, true );
  12003. },
  12004. hide: function() {
  12005. return showHide( this );
  12006. },
  12007. toggle: function( state ) {
  12008. if ( typeof state === "boolean" ) {
  12009. return state ? this.show() : this.hide();
  12010. }
  12011. return this.each( function() {
  12012. if ( isHiddenWithinTree( this ) ) {
  12013. jQuery( this ).show();
  12014. } else {
  12015. jQuery( this ).hide();
  12016. }
  12017. } );
  12018. }
  12019. } );
  12020. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  12021. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  12022. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  12023. // We have to close these tags to support XHTML (#13200)
  12024. var wrapMap = {
  12025. // Support: IE <=9 only
  12026. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  12027. // XHTML parsers do not magically insert elements in the
  12028. // same way that tag soup parsers do. So we cannot shorten
  12029. // this by omitting <tbody> or other required elements.
  12030. thead: [ 1, "<table>", "</table>" ],
  12031. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  12032. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  12033. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  12034. _default: [ 0, "", "" ]
  12035. };
  12036. // Support: IE <=9 only
  12037. wrapMap.optgroup = wrapMap.option;
  12038. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  12039. wrapMap.th = wrapMap.td;
  12040. function getAll( context, tag ) {
  12041. // Support: IE <=9 - 11 only
  12042. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  12043. var ret;
  12044. if ( typeof context.getElementsByTagName !== "undefined" ) {
  12045. ret = context.getElementsByTagName( tag || "*" );
  12046. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  12047. ret = context.querySelectorAll( tag || "*" );
  12048. } else {
  12049. ret = [];
  12050. }
  12051. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  12052. return jQuery.merge( [ context ], ret );
  12053. }
  12054. return ret;
  12055. }
  12056. // Mark scripts as having already been evaluated
  12057. function setGlobalEval( elems, refElements ) {
  12058. var i = 0,
  12059. l = elems.length;
  12060. for ( ; i < l; i++ ) {
  12061. dataPriv.set(
  12062. elems[ i ],
  12063. "globalEval",
  12064. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  12065. );
  12066. }
  12067. }
  12068. var rhtml = /<|&#?\w+;/;
  12069. function buildFragment( elems, context, scripts, selection, ignored ) {
  12070. var elem, tmp, tag, wrap, attached, j,
  12071. fragment = context.createDocumentFragment(),
  12072. nodes = [],
  12073. i = 0,
  12074. l = elems.length;
  12075. for ( ; i < l; i++ ) {
  12076. elem = elems[ i ];
  12077. if ( elem || elem === 0 ) {
  12078. // Add nodes directly
  12079. if ( toType( elem ) === "object" ) {
  12080. // Support: Android <=4.0 only, PhantomJS 1 only
  12081. // push.apply(_, arraylike) throws on ancient WebKit
  12082. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  12083. // Convert non-html into a text node
  12084. } else if ( !rhtml.test( elem ) ) {
  12085. nodes.push( context.createTextNode( elem ) );
  12086. // Convert html into DOM nodes
  12087. } else {
  12088. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  12089. // Deserialize a standard representation
  12090. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  12091. wrap = wrapMap[ tag ] || wrapMap._default;
  12092. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  12093. // Descend through wrappers to the right content
  12094. j = wrap[ 0 ];
  12095. while ( j-- ) {
  12096. tmp = tmp.lastChild;
  12097. }
  12098. // Support: Android <=4.0 only, PhantomJS 1 only
  12099. // push.apply(_, arraylike) throws on ancient WebKit
  12100. jQuery.merge( nodes, tmp.childNodes );
  12101. // Remember the top-level container
  12102. tmp = fragment.firstChild;
  12103. // Ensure the created nodes are orphaned (#12392)
  12104. tmp.textContent = "";
  12105. }
  12106. }
  12107. }
  12108. // Remove wrapper from fragment
  12109. fragment.textContent = "";
  12110. i = 0;
  12111. while ( ( elem = nodes[ i++ ] ) ) {
  12112. // Skip elements already in the context collection (trac-4087)
  12113. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  12114. if ( ignored ) {
  12115. ignored.push( elem );
  12116. }
  12117. continue;
  12118. }
  12119. attached = isAttached( elem );
  12120. // Append to fragment
  12121. tmp = getAll( fragment.appendChild( elem ), "script" );
  12122. // Preserve script evaluation history
  12123. if ( attached ) {
  12124. setGlobalEval( tmp );
  12125. }
  12126. // Capture executables
  12127. if ( scripts ) {
  12128. j = 0;
  12129. while ( ( elem = tmp[ j++ ] ) ) {
  12130. if ( rscriptType.test( elem.type || "" ) ) {
  12131. scripts.push( elem );
  12132. }
  12133. }
  12134. }
  12135. }
  12136. return fragment;
  12137. }
  12138. ( function() {
  12139. var fragment = document.createDocumentFragment(),
  12140. div = fragment.appendChild( document.createElement( "div" ) ),
  12141. input = document.createElement( "input" );
  12142. // Support: Android 4.0 - 4.3 only
  12143. // Check state lost if the name is set (#11217)
  12144. // Support: Windows Web Apps (WWA)
  12145. // `name` and `type` must use .setAttribute for WWA (#14901)
  12146. input.setAttribute( "type", "radio" );
  12147. input.setAttribute( "checked", "checked" );
  12148. input.setAttribute( "name", "t" );
  12149. div.appendChild( input );
  12150. // Support: Android <=4.1 only
  12151. // Older WebKit doesn't clone checked state correctly in fragments
  12152. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12153. // Support: IE <=11 only
  12154. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12155. div.innerHTML = "<textarea>x</textarea>";
  12156. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12157. } )();
  12158. var
  12159. rkeyEvent = /^key/,
  12160. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12161. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12162. function returnTrue() {
  12163. return true;
  12164. }
  12165. function returnFalse() {
  12166. return false;
  12167. }
  12168. // Support: IE <=9 - 11+
  12169. // focus() and blur() are asynchronous, except when they are no-op.
  12170. // So expect focus to be synchronous when the element is already active,
  12171. // and blur to be synchronous when the element is not already active.
  12172. // (focus and blur are always synchronous in other supported browsers,
  12173. // this just defines when we can count on it).
  12174. function expectSync( elem, type ) {
  12175. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12176. }
  12177. // Support: IE <=9 only
  12178. // Accessing document.activeElement can throw unexpectedly
  12179. // https://bugs.jquery.com/ticket/13393
  12180. function safeActiveElement() {
  12181. try {
  12182. return document.activeElement;
  12183. } catch ( err ) { }
  12184. }
  12185. function on( elem, types, selector, data, fn, one ) {
  12186. var origFn, type;
  12187. // Types can be a map of types/handlers
  12188. if ( typeof types === "object" ) {
  12189. // ( types-Object, selector, data )
  12190. if ( typeof selector !== "string" ) {
  12191. // ( types-Object, data )
  12192. data = data || selector;
  12193. selector = undefined;
  12194. }
  12195. for ( type in types ) {
  12196. on( elem, type, selector, data, types[ type ], one );
  12197. }
  12198. return elem;
  12199. }
  12200. if ( data == null && fn == null ) {
  12201. // ( types, fn )
  12202. fn = selector;
  12203. data = selector = undefined;
  12204. } else if ( fn == null ) {
  12205. if ( typeof selector === "string" ) {
  12206. // ( types, selector, fn )
  12207. fn = data;
  12208. data = undefined;
  12209. } else {
  12210. // ( types, data, fn )
  12211. fn = data;
  12212. data = selector;
  12213. selector = undefined;
  12214. }
  12215. }
  12216. if ( fn === false ) {
  12217. fn = returnFalse;
  12218. } else if ( !fn ) {
  12219. return elem;
  12220. }
  12221. if ( one === 1 ) {
  12222. origFn = fn;
  12223. fn = function( event ) {
  12224. // Can use an empty set, since event contains the info
  12225. jQuery().off( event );
  12226. return origFn.apply( this, arguments );
  12227. };
  12228. // Use same guid so caller can remove using origFn
  12229. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12230. }
  12231. return elem.each( function() {
  12232. jQuery.event.add( this, types, fn, data, selector );
  12233. } );
  12234. }
  12235. /*
  12236. * Helper functions for managing events -- not part of the public interface.
  12237. * Props to Dean Edwards' addEvent library for many of the ideas.
  12238. */
  12239. jQuery.event = {
  12240. global: {},
  12241. add: function( elem, types, handler, data, selector ) {
  12242. var handleObjIn, eventHandle, tmp,
  12243. events, t, handleObj,
  12244. special, handlers, type, namespaces, origType,
  12245. elemData = dataPriv.get( elem );
  12246. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12247. if ( !elemData ) {
  12248. return;
  12249. }
  12250. // Caller can pass in an object of custom data in lieu of the handler
  12251. if ( handler.handler ) {
  12252. handleObjIn = handler;
  12253. handler = handleObjIn.handler;
  12254. selector = handleObjIn.selector;
  12255. }
  12256. // Ensure that invalid selectors throw exceptions at attach time
  12257. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12258. if ( selector ) {
  12259. jQuery.find.matchesSelector( documentElement, selector );
  12260. }
  12261. // Make sure that the handler has a unique ID, used to find/remove it later
  12262. if ( !handler.guid ) {
  12263. handler.guid = jQuery.guid++;
  12264. }
  12265. // Init the element's event structure and main handler, if this is the first
  12266. if ( !( events = elemData.events ) ) {
  12267. events = elemData.events = {};
  12268. }
  12269. if ( !( eventHandle = elemData.handle ) ) {
  12270. eventHandle = elemData.handle = function( e ) {
  12271. // Discard the second event of a jQuery.event.trigger() and
  12272. // when an event is called after a page has unloaded
  12273. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12274. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12275. };
  12276. }
  12277. // Handle multiple events separated by a space
  12278. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12279. t = types.length;
  12280. while ( t-- ) {
  12281. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12282. type = origType = tmp[ 1 ];
  12283. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12284. // There *must* be a type, no attaching namespace-only handlers
  12285. if ( !type ) {
  12286. continue;
  12287. }
  12288. // If event changes its type, use the special event handlers for the changed type
  12289. special = jQuery.event.special[ type ] || {};
  12290. // If selector defined, determine special event api type, otherwise given type
  12291. type = ( selector ? special.delegateType : special.bindType ) || type;
  12292. // Update special based on newly reset type
  12293. special = jQuery.event.special[ type ] || {};
  12294. // handleObj is passed to all event handlers
  12295. handleObj = jQuery.extend( {
  12296. type: type,
  12297. origType: origType,
  12298. data: data,
  12299. handler: handler,
  12300. guid: handler.guid,
  12301. selector: selector,
  12302. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12303. namespace: namespaces.join( "." )
  12304. }, handleObjIn );
  12305. // Init the event handler queue if we're the first
  12306. if ( !( handlers = events[ type ] ) ) {
  12307. handlers = events[ type ] = [];
  12308. handlers.delegateCount = 0;
  12309. // Only use addEventListener if the special events handler returns false
  12310. if ( !special.setup ||
  12311. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12312. if ( elem.addEventListener ) {
  12313. elem.addEventListener( type, eventHandle );
  12314. }
  12315. }
  12316. }
  12317. if ( special.add ) {
  12318. special.add.call( elem, handleObj );
  12319. if ( !handleObj.handler.guid ) {
  12320. handleObj.handler.guid = handler.guid;
  12321. }
  12322. }
  12323. // Add to the element's handler list, delegates in front
  12324. if ( selector ) {
  12325. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12326. } else {
  12327. handlers.push( handleObj );
  12328. }
  12329. // Keep track of which events have ever been used, for event optimization
  12330. jQuery.event.global[ type ] = true;
  12331. }
  12332. },
  12333. // Detach an event or set of events from an element
  12334. remove: function( elem, types, handler, selector, mappedTypes ) {
  12335. var j, origCount, tmp,
  12336. events, t, handleObj,
  12337. special, handlers, type, namespaces, origType,
  12338. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12339. if ( !elemData || !( events = elemData.events ) ) {
  12340. return;
  12341. }
  12342. // Once for each type.namespace in types; type may be omitted
  12343. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12344. t = types.length;
  12345. while ( t-- ) {
  12346. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12347. type = origType = tmp[ 1 ];
  12348. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12349. // Unbind all events (on this namespace, if provided) for the element
  12350. if ( !type ) {
  12351. for ( type in events ) {
  12352. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12353. }
  12354. continue;
  12355. }
  12356. special = jQuery.event.special[ type ] || {};
  12357. type = ( selector ? special.delegateType : special.bindType ) || type;
  12358. handlers = events[ type ] || [];
  12359. tmp = tmp[ 2 ] &&
  12360. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12361. // Remove matching events
  12362. origCount = j = handlers.length;
  12363. while ( j-- ) {
  12364. handleObj = handlers[ j ];
  12365. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12366. ( !handler || handler.guid === handleObj.guid ) &&
  12367. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12368. ( !selector || selector === handleObj.selector ||
  12369. selector === "**" && handleObj.selector ) ) {
  12370. handlers.splice( j, 1 );
  12371. if ( handleObj.selector ) {
  12372. handlers.delegateCount--;
  12373. }
  12374. if ( special.remove ) {
  12375. special.remove.call( elem, handleObj );
  12376. }
  12377. }
  12378. }
  12379. // Remove generic event handler if we removed something and no more handlers exist
  12380. // (avoids potential for endless recursion during removal of special event handlers)
  12381. if ( origCount && !handlers.length ) {
  12382. if ( !special.teardown ||
  12383. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12384. jQuery.removeEvent( elem, type, elemData.handle );
  12385. }
  12386. delete events[ type ];
  12387. }
  12388. }
  12389. // Remove data and the expando if it's no longer used
  12390. if ( jQuery.isEmptyObject( events ) ) {
  12391. dataPriv.remove( elem, "handle events" );
  12392. }
  12393. },
  12394. dispatch: function( nativeEvent ) {
  12395. // Make a writable jQuery.Event from the native event object
  12396. var event = jQuery.event.fix( nativeEvent );
  12397. var i, j, ret, matched, handleObj, handlerQueue,
  12398. args = new Array( arguments.length ),
  12399. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12400. special = jQuery.event.special[ event.type ] || {};
  12401. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12402. args[ 0 ] = event;
  12403. for ( i = 1; i < arguments.length; i++ ) {
  12404. args[ i ] = arguments[ i ];
  12405. }
  12406. event.delegateTarget = this;
  12407. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12408. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12409. return;
  12410. }
  12411. // Determine handlers
  12412. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12413. // Run delegates first; they may want to stop propagation beneath us
  12414. i = 0;
  12415. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12416. event.currentTarget = matched.elem;
  12417. j = 0;
  12418. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12419. !event.isImmediatePropagationStopped() ) {
  12420. // If the event is namespaced, then each handler is only invoked if it is
  12421. // specially universal or its namespaces are a superset of the event's.
  12422. if ( !event.rnamespace || handleObj.namespace === false ||
  12423. event.rnamespace.test( handleObj.namespace ) ) {
  12424. event.handleObj = handleObj;
  12425. event.data = handleObj.data;
  12426. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12427. handleObj.handler ).apply( matched.elem, args );
  12428. if ( ret !== undefined ) {
  12429. if ( ( event.result = ret ) === false ) {
  12430. event.preventDefault();
  12431. event.stopPropagation();
  12432. }
  12433. }
  12434. }
  12435. }
  12436. }
  12437. // Call the postDispatch hook for the mapped type
  12438. if ( special.postDispatch ) {
  12439. special.postDispatch.call( this, event );
  12440. }
  12441. return event.result;
  12442. },
  12443. handlers: function( event, handlers ) {
  12444. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12445. handlerQueue = [],
  12446. delegateCount = handlers.delegateCount,
  12447. cur = event.target;
  12448. // Find delegate handlers
  12449. if ( delegateCount &&
  12450. // Support: IE <=9
  12451. // Black-hole SVG <use> instance trees (trac-13180)
  12452. cur.nodeType &&
  12453. // Support: Firefox <=42
  12454. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12455. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12456. // Support: IE 11 only
  12457. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12458. !( event.type === "click" && event.button >= 1 ) ) {
  12459. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12460. // Don't check non-elements (#13208)
  12461. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12462. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12463. matchedHandlers = [];
  12464. matchedSelectors = {};
  12465. for ( i = 0; i < delegateCount; i++ ) {
  12466. handleObj = handlers[ i ];
  12467. // Don't conflict with Object.prototype properties (#13203)
  12468. sel = handleObj.selector + " ";
  12469. if ( matchedSelectors[ sel ] === undefined ) {
  12470. matchedSelectors[ sel ] = handleObj.needsContext ?
  12471. jQuery( sel, this ).index( cur ) > -1 :
  12472. jQuery.find( sel, this, null, [ cur ] ).length;
  12473. }
  12474. if ( matchedSelectors[ sel ] ) {
  12475. matchedHandlers.push( handleObj );
  12476. }
  12477. }
  12478. if ( matchedHandlers.length ) {
  12479. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12480. }
  12481. }
  12482. }
  12483. }
  12484. // Add the remaining (directly-bound) handlers
  12485. cur = this;
  12486. if ( delegateCount < handlers.length ) {
  12487. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12488. }
  12489. return handlerQueue;
  12490. },
  12491. addProp: function( name, hook ) {
  12492. Object.defineProperty( jQuery.Event.prototype, name, {
  12493. enumerable: true,
  12494. configurable: true,
  12495. get: isFunction( hook ) ?
  12496. function() {
  12497. if ( this.originalEvent ) {
  12498. return hook( this.originalEvent );
  12499. }
  12500. } :
  12501. function() {
  12502. if ( this.originalEvent ) {
  12503. return this.originalEvent[ name ];
  12504. }
  12505. },
  12506. set: function( value ) {
  12507. Object.defineProperty( this, name, {
  12508. enumerable: true,
  12509. configurable: true,
  12510. writable: true,
  12511. value: value
  12512. } );
  12513. }
  12514. } );
  12515. },
  12516. fix: function( originalEvent ) {
  12517. return originalEvent[ jQuery.expando ] ?
  12518. originalEvent :
  12519. new jQuery.Event( originalEvent );
  12520. },
  12521. special: {
  12522. load: {
  12523. // Prevent triggered image.load events from bubbling to window.load
  12524. noBubble: true
  12525. },
  12526. click: {
  12527. // Utilize native event to ensure correct state for checkable inputs
  12528. setup: function( data ) {
  12529. // For mutual compressibility with _default, replace `this` access with a local var.
  12530. // `|| data` is dead code meant only to preserve the variable through minification.
  12531. var el = this || data;
  12532. // Claim the first handler
  12533. if ( rcheckableType.test( el.type ) &&
  12534. el.click && nodeName( el, "input" ) ) {
  12535. // dataPriv.set( el, "click", ... )
  12536. leverageNative( el, "click", returnTrue );
  12537. }
  12538. // Return false to allow normal processing in the caller
  12539. return false;
  12540. },
  12541. trigger: function( data ) {
  12542. // For mutual compressibility with _default, replace `this` access with a local var.
  12543. // `|| data` is dead code meant only to preserve the variable through minification.
  12544. var el = this || data;
  12545. // Force setup before triggering a click
  12546. if ( rcheckableType.test( el.type ) &&
  12547. el.click && nodeName( el, "input" ) ) {
  12548. leverageNative( el, "click" );
  12549. }
  12550. // Return non-false to allow normal event-path propagation
  12551. return true;
  12552. },
  12553. // For cross-browser consistency, suppress native .click() on links
  12554. // Also prevent it if we're currently inside a leveraged native-event stack
  12555. _default: function( event ) {
  12556. var target = event.target;
  12557. return rcheckableType.test( target.type ) &&
  12558. target.click && nodeName( target, "input" ) &&
  12559. dataPriv.get( target, "click" ) ||
  12560. nodeName( target, "a" );
  12561. }
  12562. },
  12563. beforeunload: {
  12564. postDispatch: function( event ) {
  12565. // Support: Firefox 20+
  12566. // Firefox doesn't alert if the returnValue field is not set.
  12567. if ( event.result !== undefined && event.originalEvent ) {
  12568. event.originalEvent.returnValue = event.result;
  12569. }
  12570. }
  12571. }
  12572. }
  12573. };
  12574. // Ensure the presence of an event listener that handles manually-triggered
  12575. // synthetic events by interrupting progress until reinvoked in response to
  12576. // *native* events that it fires directly, ensuring that state changes have
  12577. // already occurred before other listeners are invoked.
  12578. function leverageNative( el, type, expectSync ) {
  12579. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12580. if ( !expectSync ) {
  12581. if ( dataPriv.get( el, type ) === undefined ) {
  12582. jQuery.event.add( el, type, returnTrue );
  12583. }
  12584. return;
  12585. }
  12586. // Register the controller as a special universal handler for all event namespaces
  12587. dataPriv.set( el, type, false );
  12588. jQuery.event.add( el, type, {
  12589. namespace: false,
  12590. handler: function( event ) {
  12591. var notAsync, result,
  12592. saved = dataPriv.get( this, type );
  12593. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12594. // Interrupt processing of the outer synthetic .trigger()ed event
  12595. // Saved data should be false in such cases, but might be a leftover capture object
  12596. // from an async native handler (gh-4350)
  12597. if ( !saved.length ) {
  12598. // Store arguments for use when handling the inner native event
  12599. // There will always be at least one argument (an event object), so this array
  12600. // will not be confused with a leftover capture object.
  12601. saved = slice.call( arguments );
  12602. dataPriv.set( this, type, saved );
  12603. // Trigger the native event and capture its result
  12604. // Support: IE <=9 - 11+
  12605. // focus() and blur() are asynchronous
  12606. notAsync = expectSync( this, type );
  12607. this[ type ]();
  12608. result = dataPriv.get( this, type );
  12609. if ( saved !== result || notAsync ) {
  12610. dataPriv.set( this, type, false );
  12611. } else {
  12612. result = {};
  12613. }
  12614. if ( saved !== result ) {
  12615. // Cancel the outer synthetic event
  12616. event.stopImmediatePropagation();
  12617. event.preventDefault();
  12618. return result.value;
  12619. }
  12620. // If this is an inner synthetic event for an event with a bubbling surrogate
  12621. // (focus or blur), assume that the surrogate already propagated from triggering the
  12622. // native event and prevent that from happening again here.
  12623. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12624. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12625. // less bad than duplication.
  12626. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12627. event.stopPropagation();
  12628. }
  12629. // If this is a native event triggered above, everything is now in order
  12630. // Fire an inner synthetic event with the original arguments
  12631. } else if ( saved.length ) {
  12632. // ...and capture the result
  12633. dataPriv.set( this, type, {
  12634. value: jQuery.event.trigger(
  12635. // Support: IE <=9 - 11+
  12636. // Extend with the prototype to reset the above stopImmediatePropagation()
  12637. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12638. saved.slice( 1 ),
  12639. this
  12640. )
  12641. } );
  12642. // Abort handling of the native event
  12643. event.stopImmediatePropagation();
  12644. }
  12645. }
  12646. } );
  12647. }
  12648. jQuery.removeEvent = function( elem, type, handle ) {
  12649. // This "if" is needed for plain objects
  12650. if ( elem.removeEventListener ) {
  12651. elem.removeEventListener( type, handle );
  12652. }
  12653. };
  12654. jQuery.Event = function( src, props ) {
  12655. // Allow instantiation without the 'new' keyword
  12656. if ( !( this instanceof jQuery.Event ) ) {
  12657. return new jQuery.Event( src, props );
  12658. }
  12659. // Event object
  12660. if ( src && src.type ) {
  12661. this.originalEvent = src;
  12662. this.type = src.type;
  12663. // Events bubbling up the document may have been marked as prevented
  12664. // by a handler lower down the tree; reflect the correct value.
  12665. this.isDefaultPrevented = src.defaultPrevented ||
  12666. src.defaultPrevented === undefined &&
  12667. // Support: Android <=2.3 only
  12668. src.returnValue === false ?
  12669. returnTrue :
  12670. returnFalse;
  12671. // Create target properties
  12672. // Support: Safari <=6 - 7 only
  12673. // Target should not be a text node (#504, #13143)
  12674. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12675. src.target.parentNode :
  12676. src.target;
  12677. this.currentTarget = src.currentTarget;
  12678. this.relatedTarget = src.relatedTarget;
  12679. // Event type
  12680. } else {
  12681. this.type = src;
  12682. }
  12683. // Put explicitly provided properties onto the event object
  12684. if ( props ) {
  12685. jQuery.extend( this, props );
  12686. }
  12687. // Create a timestamp if incoming event doesn't have one
  12688. this.timeStamp = src && src.timeStamp || Date.now();
  12689. // Mark it as fixed
  12690. this[ jQuery.expando ] = true;
  12691. };
  12692. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12693. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12694. jQuery.Event.prototype = {
  12695. constructor: jQuery.Event,
  12696. isDefaultPrevented: returnFalse,
  12697. isPropagationStopped: returnFalse,
  12698. isImmediatePropagationStopped: returnFalse,
  12699. isSimulated: false,
  12700. preventDefault: function() {
  12701. var e = this.originalEvent;
  12702. this.isDefaultPrevented = returnTrue;
  12703. if ( e && !this.isSimulated ) {
  12704. e.preventDefault();
  12705. }
  12706. },
  12707. stopPropagation: function() {
  12708. var e = this.originalEvent;
  12709. this.isPropagationStopped = returnTrue;
  12710. if ( e && !this.isSimulated ) {
  12711. e.stopPropagation();
  12712. }
  12713. },
  12714. stopImmediatePropagation: function() {
  12715. var e = this.originalEvent;
  12716. this.isImmediatePropagationStopped = returnTrue;
  12717. if ( e && !this.isSimulated ) {
  12718. e.stopImmediatePropagation();
  12719. }
  12720. this.stopPropagation();
  12721. }
  12722. };
  12723. // Includes all common event props including KeyEvent and MouseEvent specific props
  12724. jQuery.each( {
  12725. altKey: true,
  12726. bubbles: true,
  12727. cancelable: true,
  12728. changedTouches: true,
  12729. ctrlKey: true,
  12730. detail: true,
  12731. eventPhase: true,
  12732. metaKey: true,
  12733. pageX: true,
  12734. pageY: true,
  12735. shiftKey: true,
  12736. view: true,
  12737. "char": true,
  12738. code: true,
  12739. charCode: true,
  12740. key: true,
  12741. keyCode: true,
  12742. button: true,
  12743. buttons: true,
  12744. clientX: true,
  12745. clientY: true,
  12746. offsetX: true,
  12747. offsetY: true,
  12748. pointerId: true,
  12749. pointerType: true,
  12750. screenX: true,
  12751. screenY: true,
  12752. targetTouches: true,
  12753. toElement: true,
  12754. touches: true,
  12755. which: function( event ) {
  12756. var button = event.button;
  12757. // Add which for key events
  12758. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12759. return event.charCode != null ? event.charCode : event.keyCode;
  12760. }
  12761. // Add which for click: 1 === left; 2 === middle; 3 === right
  12762. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12763. if ( button & 1 ) {
  12764. return 1;
  12765. }
  12766. if ( button & 2 ) {
  12767. return 3;
  12768. }
  12769. if ( button & 4 ) {
  12770. return 2;
  12771. }
  12772. return 0;
  12773. }
  12774. return event.which;
  12775. }
  12776. }, jQuery.event.addProp );
  12777. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12778. jQuery.event.special[ type ] = {
  12779. // Utilize native event if possible so blur/focus sequence is correct
  12780. setup: function() {
  12781. // Claim the first handler
  12782. // dataPriv.set( this, "focus", ... )
  12783. // dataPriv.set( this, "blur", ... )
  12784. leverageNative( this, type, expectSync );
  12785. // Return false to allow normal processing in the caller
  12786. return false;
  12787. },
  12788. trigger: function() {
  12789. // Force setup before trigger
  12790. leverageNative( this, type );
  12791. // Return non-false to allow normal event-path propagation
  12792. return true;
  12793. },
  12794. delegateType: delegateType
  12795. };
  12796. } );
  12797. // Create mouseenter/leave events using mouseover/out and event-time checks
  12798. // so that event delegation works in jQuery.
  12799. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12800. //
  12801. // Support: Safari 7 only
  12802. // Safari sends mouseenter too often; see:
  12803. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12804. // for the description of the bug (it existed in older Chrome versions as well).
  12805. jQuery.each( {
  12806. mouseenter: "mouseover",
  12807. mouseleave: "mouseout",
  12808. pointerenter: "pointerover",
  12809. pointerleave: "pointerout"
  12810. }, function( orig, fix ) {
  12811. jQuery.event.special[ orig ] = {
  12812. delegateType: fix,
  12813. bindType: fix,
  12814. handle: function( event ) {
  12815. var ret,
  12816. target = this,
  12817. related = event.relatedTarget,
  12818. handleObj = event.handleObj;
  12819. // For mouseenter/leave call the handler if related is outside the target.
  12820. // NB: No relatedTarget if the mouse left/entered the browser window
  12821. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12822. event.type = handleObj.origType;
  12823. ret = handleObj.handler.apply( this, arguments );
  12824. event.type = fix;
  12825. }
  12826. return ret;
  12827. }
  12828. };
  12829. } );
  12830. jQuery.fn.extend( {
  12831. on: function( types, selector, data, fn ) {
  12832. return on( this, types, selector, data, fn );
  12833. },
  12834. one: function( types, selector, data, fn ) {
  12835. return on( this, types, selector, data, fn, 1 );
  12836. },
  12837. off: function( types, selector, fn ) {
  12838. var handleObj, type;
  12839. if ( types && types.preventDefault && types.handleObj ) {
  12840. // ( event ) dispatched jQuery.Event
  12841. handleObj = types.handleObj;
  12842. jQuery( types.delegateTarget ).off(
  12843. handleObj.namespace ?
  12844. handleObj.origType + "." + handleObj.namespace :
  12845. handleObj.origType,
  12846. handleObj.selector,
  12847. handleObj.handler
  12848. );
  12849. return this;
  12850. }
  12851. if ( typeof types === "object" ) {
  12852. // ( types-object [, selector] )
  12853. for ( type in types ) {
  12854. this.off( type, selector, types[ type ] );
  12855. }
  12856. return this;
  12857. }
  12858. if ( selector === false || typeof selector === "function" ) {
  12859. // ( types [, fn] )
  12860. fn = selector;
  12861. selector = undefined;
  12862. }
  12863. if ( fn === false ) {
  12864. fn = returnFalse;
  12865. }
  12866. return this.each( function() {
  12867. jQuery.event.remove( this, types, fn, selector );
  12868. } );
  12869. }
  12870. } );
  12871. var
  12872. /* eslint-disable max-len */
  12873. // See https://github.com/eslint/eslint/issues/3229
  12874. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12875. /* eslint-enable */
  12876. // Support: IE <=10 - 11, Edge 12 - 13 only
  12877. // In IE/Edge using regex groups here causes severe slowdowns.
  12878. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12879. rnoInnerhtml = /<script|<style|<link/i,
  12880. // checked="checked" or checked
  12881. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12882. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12883. // Prefer a tbody over its parent table for containing new rows
  12884. function manipulationTarget( elem, content ) {
  12885. if ( nodeName( elem, "table" ) &&
  12886. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12887. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12888. }
  12889. return elem;
  12890. }
  12891. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12892. function disableScript( elem ) {
  12893. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12894. return elem;
  12895. }
  12896. function restoreScript( elem ) {
  12897. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12898. elem.type = elem.type.slice( 5 );
  12899. } else {
  12900. elem.removeAttribute( "type" );
  12901. }
  12902. return elem;
  12903. }
  12904. function cloneCopyEvent( src, dest ) {
  12905. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12906. if ( dest.nodeType !== 1 ) {
  12907. return;
  12908. }
  12909. // 1. Copy private data: events, handlers, etc.
  12910. if ( dataPriv.hasData( src ) ) {
  12911. pdataOld = dataPriv.access( src );
  12912. pdataCur = dataPriv.set( dest, pdataOld );
  12913. events = pdataOld.events;
  12914. if ( events ) {
  12915. delete pdataCur.handle;
  12916. pdataCur.events = {};
  12917. for ( type in events ) {
  12918. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12919. jQuery.event.add( dest, type, events[ type ][ i ] );
  12920. }
  12921. }
  12922. }
  12923. }
  12924. // 2. Copy user data
  12925. if ( dataUser.hasData( src ) ) {
  12926. udataOld = dataUser.access( src );
  12927. udataCur = jQuery.extend( {}, udataOld );
  12928. dataUser.set( dest, udataCur );
  12929. }
  12930. }
  12931. // Fix IE bugs, see support tests
  12932. function fixInput( src, dest ) {
  12933. var nodeName = dest.nodeName.toLowerCase();
  12934. // Fails to persist the checked state of a cloned checkbox or radio button.
  12935. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12936. dest.checked = src.checked;
  12937. // Fails to return the selected option to the default selected state when cloning options
  12938. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12939. dest.defaultValue = src.defaultValue;
  12940. }
  12941. }
  12942. function domManip( collection, args, callback, ignored ) {
  12943. // Flatten any nested arrays
  12944. args = concat.apply( [], args );
  12945. var fragment, first, scripts, hasScripts, node, doc,
  12946. i = 0,
  12947. l = collection.length,
  12948. iNoClone = l - 1,
  12949. value = args[ 0 ],
  12950. valueIsFunction = isFunction( value );
  12951. // We can't cloneNode fragments that contain checked, in WebKit
  12952. if ( valueIsFunction ||
  12953. ( l > 1 && typeof value === "string" &&
  12954. !support.checkClone && rchecked.test( value ) ) ) {
  12955. return collection.each( function( index ) {
  12956. var self = collection.eq( index );
  12957. if ( valueIsFunction ) {
  12958. args[ 0 ] = value.call( this, index, self.html() );
  12959. }
  12960. domManip( self, args, callback, ignored );
  12961. } );
  12962. }
  12963. if ( l ) {
  12964. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12965. first = fragment.firstChild;
  12966. if ( fragment.childNodes.length === 1 ) {
  12967. fragment = first;
  12968. }
  12969. // Require either new content or an interest in ignored elements to invoke the callback
  12970. if ( first || ignored ) {
  12971. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12972. hasScripts = scripts.length;
  12973. // Use the original fragment for the last item
  12974. // instead of the first because it can end up
  12975. // being emptied incorrectly in certain situations (#8070).
  12976. for ( ; i < l; i++ ) {
  12977. node = fragment;
  12978. if ( i !== iNoClone ) {
  12979. node = jQuery.clone( node, true, true );
  12980. // Keep references to cloned scripts for later restoration
  12981. if ( hasScripts ) {
  12982. // Support: Android <=4.0 only, PhantomJS 1 only
  12983. // push.apply(_, arraylike) throws on ancient WebKit
  12984. jQuery.merge( scripts, getAll( node, "script" ) );
  12985. }
  12986. }
  12987. callback.call( collection[ i ], node, i );
  12988. }
  12989. if ( hasScripts ) {
  12990. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12991. // Reenable scripts
  12992. jQuery.map( scripts, restoreScript );
  12993. // Evaluate executable scripts on first document insertion
  12994. for ( i = 0; i < hasScripts; i++ ) {
  12995. node = scripts[ i ];
  12996. if ( rscriptType.test( node.type || "" ) &&
  12997. !dataPriv.access( node, "globalEval" ) &&
  12998. jQuery.contains( doc, node ) ) {
  12999. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  13000. // Optional AJAX dependency, but won't run scripts if not present
  13001. if ( jQuery._evalUrl && !node.noModule ) {
  13002. jQuery._evalUrl( node.src, {
  13003. nonce: node.nonce || node.getAttribute( "nonce" )
  13004. } );
  13005. }
  13006. } else {
  13007. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  13008. }
  13009. }
  13010. }
  13011. }
  13012. }
  13013. }
  13014. return collection;
  13015. }
  13016. function remove( elem, selector, keepData ) {
  13017. var node,
  13018. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  13019. i = 0;
  13020. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  13021. if ( !keepData && node.nodeType === 1 ) {
  13022. jQuery.cleanData( getAll( node ) );
  13023. }
  13024. if ( node.parentNode ) {
  13025. if ( keepData && isAttached( node ) ) {
  13026. setGlobalEval( getAll( node, "script" ) );
  13027. }
  13028. node.parentNode.removeChild( node );
  13029. }
  13030. }
  13031. return elem;
  13032. }
  13033. jQuery.extend( {
  13034. htmlPrefilter: function( html ) {
  13035. return html.replace( rxhtmlTag, "<$1></$2>" );
  13036. },
  13037. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  13038. var i, l, srcElements, destElements,
  13039. clone = elem.cloneNode( true ),
  13040. inPage = isAttached( elem );
  13041. // Fix IE cloning issues
  13042. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  13043. !jQuery.isXMLDoc( elem ) ) {
  13044. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  13045. destElements = getAll( clone );
  13046. srcElements = getAll( elem );
  13047. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13048. fixInput( srcElements[ i ], destElements[ i ] );
  13049. }
  13050. }
  13051. // Copy the events from the original to the clone
  13052. if ( dataAndEvents ) {
  13053. if ( deepDataAndEvents ) {
  13054. srcElements = srcElements || getAll( elem );
  13055. destElements = destElements || getAll( clone );
  13056. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13057. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  13058. }
  13059. } else {
  13060. cloneCopyEvent( elem, clone );
  13061. }
  13062. }
  13063. // Preserve script evaluation history
  13064. destElements = getAll( clone, "script" );
  13065. if ( destElements.length > 0 ) {
  13066. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  13067. }
  13068. // Return the cloned set
  13069. return clone;
  13070. },
  13071. cleanData: function( elems ) {
  13072. var data, elem, type,
  13073. special = jQuery.event.special,
  13074. i = 0;
  13075. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  13076. if ( acceptData( elem ) ) {
  13077. if ( ( data = elem[ dataPriv.expando ] ) ) {
  13078. if ( data.events ) {
  13079. for ( type in data.events ) {
  13080. if ( special[ type ] ) {
  13081. jQuery.event.remove( elem, type );
  13082. // This is a shortcut to avoid jQuery.event.remove's overhead
  13083. } else {
  13084. jQuery.removeEvent( elem, type, data.handle );
  13085. }
  13086. }
  13087. }
  13088. // Support: Chrome <=35 - 45+
  13089. // Assign undefined instead of using delete, see Data#remove
  13090. elem[ dataPriv.expando ] = undefined;
  13091. }
  13092. if ( elem[ dataUser.expando ] ) {
  13093. // Support: Chrome <=35 - 45+
  13094. // Assign undefined instead of using delete, see Data#remove
  13095. elem[ dataUser.expando ] = undefined;
  13096. }
  13097. }
  13098. }
  13099. }
  13100. } );
  13101. jQuery.fn.extend( {
  13102. detach: function( selector ) {
  13103. return remove( this, selector, true );
  13104. },
  13105. remove: function( selector ) {
  13106. return remove( this, selector );
  13107. },
  13108. text: function( value ) {
  13109. return access( this, function( value ) {
  13110. return value === undefined ?
  13111. jQuery.text( this ) :
  13112. this.empty().each( function() {
  13113. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13114. this.textContent = value;
  13115. }
  13116. } );
  13117. }, null, value, arguments.length );
  13118. },
  13119. append: function() {
  13120. return domManip( this, arguments, function( elem ) {
  13121. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13122. var target = manipulationTarget( this, elem );
  13123. target.appendChild( elem );
  13124. }
  13125. } );
  13126. },
  13127. prepend: function() {
  13128. return domManip( this, arguments, function( elem ) {
  13129. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13130. var target = manipulationTarget( this, elem );
  13131. target.insertBefore( elem, target.firstChild );
  13132. }
  13133. } );
  13134. },
  13135. before: function() {
  13136. return domManip( this, arguments, function( elem ) {
  13137. if ( this.parentNode ) {
  13138. this.parentNode.insertBefore( elem, this );
  13139. }
  13140. } );
  13141. },
  13142. after: function() {
  13143. return domManip( this, arguments, function( elem ) {
  13144. if ( this.parentNode ) {
  13145. this.parentNode.insertBefore( elem, this.nextSibling );
  13146. }
  13147. } );
  13148. },
  13149. empty: function() {
  13150. var elem,
  13151. i = 0;
  13152. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13153. if ( elem.nodeType === 1 ) {
  13154. // Prevent memory leaks
  13155. jQuery.cleanData( getAll( elem, false ) );
  13156. // Remove any remaining nodes
  13157. elem.textContent = "";
  13158. }
  13159. }
  13160. return this;
  13161. },
  13162. clone: function( dataAndEvents, deepDataAndEvents ) {
  13163. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13164. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13165. return this.map( function() {
  13166. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13167. } );
  13168. },
  13169. html: function( value ) {
  13170. return access( this, function( value ) {
  13171. var elem = this[ 0 ] || {},
  13172. i = 0,
  13173. l = this.length;
  13174. if ( value === undefined && elem.nodeType === 1 ) {
  13175. return elem.innerHTML;
  13176. }
  13177. // See if we can take a shortcut and just use innerHTML
  13178. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13179. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13180. value = jQuery.htmlPrefilter( value );
  13181. try {
  13182. for ( ; i < l; i++ ) {
  13183. elem = this[ i ] || {};
  13184. // Remove element nodes and prevent memory leaks
  13185. if ( elem.nodeType === 1 ) {
  13186. jQuery.cleanData( getAll( elem, false ) );
  13187. elem.innerHTML = value;
  13188. }
  13189. }
  13190. elem = 0;
  13191. // If using innerHTML throws an exception, use the fallback method
  13192. } catch ( e ) {}
  13193. }
  13194. if ( elem ) {
  13195. this.empty().append( value );
  13196. }
  13197. }, null, value, arguments.length );
  13198. },
  13199. replaceWith: function() {
  13200. var ignored = [];
  13201. // Make the changes, replacing each non-ignored context element with the new content
  13202. return domManip( this, arguments, function( elem ) {
  13203. var parent = this.parentNode;
  13204. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13205. jQuery.cleanData( getAll( this ) );
  13206. if ( parent ) {
  13207. parent.replaceChild( elem, this );
  13208. }
  13209. }
  13210. // Force callback invocation
  13211. }, ignored );
  13212. }
  13213. } );
  13214. jQuery.each( {
  13215. appendTo: "append",
  13216. prependTo: "prepend",
  13217. insertBefore: "before",
  13218. insertAfter: "after",
  13219. replaceAll: "replaceWith"
  13220. }, function( name, original ) {
  13221. jQuery.fn[ name ] = function( selector ) {
  13222. var elems,
  13223. ret = [],
  13224. insert = jQuery( selector ),
  13225. last = insert.length - 1,
  13226. i = 0;
  13227. for ( ; i <= last; i++ ) {
  13228. elems = i === last ? this : this.clone( true );
  13229. jQuery( insert[ i ] )[ original ]( elems );
  13230. // Support: Android <=4.0 only, PhantomJS 1 only
  13231. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13232. push.apply( ret, elems.get() );
  13233. }
  13234. return this.pushStack( ret );
  13235. };
  13236. } );
  13237. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13238. var getStyles = function( elem ) {
  13239. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13240. // IE throws on elements created in popups
  13241. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13242. var view = elem.ownerDocument.defaultView;
  13243. if ( !view || !view.opener ) {
  13244. view = window;
  13245. }
  13246. return view.getComputedStyle( elem );
  13247. };
  13248. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13249. ( function() {
  13250. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13251. // so they're executed at the same time to save the second computation.
  13252. function computeStyleTests() {
  13253. // This is a singleton, we need to execute it only once
  13254. if ( !div ) {
  13255. return;
  13256. }
  13257. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13258. "margin-top:1px;padding:0;border:0";
  13259. div.style.cssText =
  13260. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13261. "margin:auto;border:1px;padding:1px;" +
  13262. "width:60%;top:1%";
  13263. documentElement.appendChild( container ).appendChild( div );
  13264. var divStyle = window.getComputedStyle( div );
  13265. pixelPositionVal = divStyle.top !== "1%";
  13266. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13267. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13268. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13269. // Some styles come back with percentage values, even though they shouldn't
  13270. div.style.right = "60%";
  13271. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13272. // Support: IE 9 - 11 only
  13273. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13274. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13275. // Support: IE 9 only
  13276. // Detect overflow:scroll screwiness (gh-3699)
  13277. // Support: Chrome <=64
  13278. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13279. div.style.position = "absolute";
  13280. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13281. documentElement.removeChild( container );
  13282. // Nullify the div so it wouldn't be stored in the memory and
  13283. // it will also be a sign that checks already performed
  13284. div = null;
  13285. }
  13286. function roundPixelMeasures( measure ) {
  13287. return Math.round( parseFloat( measure ) );
  13288. }
  13289. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13290. reliableMarginLeftVal,
  13291. container = document.createElement( "div" ),
  13292. div = document.createElement( "div" );
  13293. // Finish early in limited (non-browser) environments
  13294. if ( !div.style ) {
  13295. return;
  13296. }
  13297. // Support: IE <=9 - 11 only
  13298. // Style of cloned element affects source element cloned (#8908)
  13299. div.style.backgroundClip = "content-box";
  13300. div.cloneNode( true ).style.backgroundClip = "";
  13301. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13302. jQuery.extend( support, {
  13303. boxSizingReliable: function() {
  13304. computeStyleTests();
  13305. return boxSizingReliableVal;
  13306. },
  13307. pixelBoxStyles: function() {
  13308. computeStyleTests();
  13309. return pixelBoxStylesVal;
  13310. },
  13311. pixelPosition: function() {
  13312. computeStyleTests();
  13313. return pixelPositionVal;
  13314. },
  13315. reliableMarginLeft: function() {
  13316. computeStyleTests();
  13317. return reliableMarginLeftVal;
  13318. },
  13319. scrollboxSize: function() {
  13320. computeStyleTests();
  13321. return scrollboxSizeVal;
  13322. }
  13323. } );
  13324. } )();
  13325. function curCSS( elem, name, computed ) {
  13326. var width, minWidth, maxWidth, ret,
  13327. // Support: Firefox 51+
  13328. // Retrieving style before computed somehow
  13329. // fixes an issue with getting wrong values
  13330. // on detached elements
  13331. style = elem.style;
  13332. computed = computed || getStyles( elem );
  13333. // getPropertyValue is needed for:
  13334. // .css('filter') (IE 9 only, #12537)
  13335. // .css('--customProperty) (#3144)
  13336. if ( computed ) {
  13337. ret = computed.getPropertyValue( name ) || computed[ name ];
  13338. if ( ret === "" && !isAttached( elem ) ) {
  13339. ret = jQuery.style( elem, name );
  13340. }
  13341. // A tribute to the "awesome hack by Dean Edwards"
  13342. // Android Browser returns percentage for some values,
  13343. // but width seems to be reliably pixels.
  13344. // This is against the CSSOM draft spec:
  13345. // https://drafts.csswg.org/cssom/#resolved-values
  13346. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13347. // Remember the original values
  13348. width = style.width;
  13349. minWidth = style.minWidth;
  13350. maxWidth = style.maxWidth;
  13351. // Put in the new values to get a computed value out
  13352. style.minWidth = style.maxWidth = style.width = ret;
  13353. ret = computed.width;
  13354. // Revert the changed values
  13355. style.width = width;
  13356. style.minWidth = minWidth;
  13357. style.maxWidth = maxWidth;
  13358. }
  13359. }
  13360. return ret !== undefined ?
  13361. // Support: IE <=9 - 11 only
  13362. // IE returns zIndex value as an integer.
  13363. ret + "" :
  13364. ret;
  13365. }
  13366. function addGetHookIf( conditionFn, hookFn ) {
  13367. // Define the hook, we'll check on the first run if it's really needed.
  13368. return {
  13369. get: function() {
  13370. if ( conditionFn() ) {
  13371. // Hook not needed (or it's not possible to use it due
  13372. // to missing dependency), remove it.
  13373. delete this.get;
  13374. return;
  13375. }
  13376. // Hook needed; redefine it so that the support test is not executed again.
  13377. return ( this.get = hookFn ).apply( this, arguments );
  13378. }
  13379. };
  13380. }
  13381. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13382. emptyStyle = document.createElement( "div" ).style,
  13383. vendorProps = {};
  13384. // Return a vendor-prefixed property or undefined
  13385. function vendorPropName( name ) {
  13386. // Check for vendor prefixed names
  13387. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13388. i = cssPrefixes.length;
  13389. while ( i-- ) {
  13390. name = cssPrefixes[ i ] + capName;
  13391. if ( name in emptyStyle ) {
  13392. return name;
  13393. }
  13394. }
  13395. }
  13396. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13397. function finalPropName( name ) {
  13398. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13399. if ( final ) {
  13400. return final;
  13401. }
  13402. if ( name in emptyStyle ) {
  13403. return name;
  13404. }
  13405. return vendorProps[ name ] = vendorPropName( name ) || name;
  13406. }
  13407. var
  13408. // Swappable if display is none or starts with table
  13409. // except "table", "table-cell", or "table-caption"
  13410. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13411. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13412. rcustomProp = /^--/,
  13413. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13414. cssNormalTransform = {
  13415. letterSpacing: "0",
  13416. fontWeight: "400"
  13417. };
  13418. function setPositiveNumber( elem, value, subtract ) {
  13419. // Any relative (+/-) values have already been
  13420. // normalized at this point
  13421. var matches = rcssNum.exec( value );
  13422. return matches ?
  13423. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13424. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13425. value;
  13426. }
  13427. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13428. var i = dimension === "width" ? 1 : 0,
  13429. extra = 0,
  13430. delta = 0;
  13431. // Adjustment may not be necessary
  13432. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13433. return 0;
  13434. }
  13435. for ( ; i < 4; i += 2 ) {
  13436. // Both box models exclude margin
  13437. if ( box === "margin" ) {
  13438. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13439. }
  13440. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13441. if ( !isBorderBox ) {
  13442. // Add padding
  13443. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13444. // For "border" or "margin", add border
  13445. if ( box !== "padding" ) {
  13446. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13447. // But still keep track of it otherwise
  13448. } else {
  13449. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13450. }
  13451. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13452. // "padding" or "margin"
  13453. } else {
  13454. // For "content", subtract padding
  13455. if ( box === "content" ) {
  13456. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13457. }
  13458. // For "content" or "padding", subtract border
  13459. if ( box !== "margin" ) {
  13460. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13461. }
  13462. }
  13463. }
  13464. // Account for positive content-box scroll gutter when requested by providing computedVal
  13465. if ( !isBorderBox && computedVal >= 0 ) {
  13466. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13467. // Assuming integer scroll gutter, subtract the rest and round down
  13468. delta += Math.max( 0, Math.ceil(
  13469. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13470. computedVal -
  13471. delta -
  13472. extra -
  13473. 0.5
  13474. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13475. // Use an explicit zero to avoid NaN (gh-3964)
  13476. ) ) || 0;
  13477. }
  13478. return delta;
  13479. }
  13480. function getWidthOrHeight( elem, dimension, extra ) {
  13481. // Start with computed style
  13482. var styles = getStyles( elem ),
  13483. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13484. // Fake content-box until we know it's needed to know the true value.
  13485. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13486. isBorderBox = boxSizingNeeded &&
  13487. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13488. valueIsBorderBox = isBorderBox,
  13489. val = curCSS( elem, dimension, styles ),
  13490. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13491. // Support: Firefox <=54
  13492. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13493. if ( rnumnonpx.test( val ) ) {
  13494. if ( !extra ) {
  13495. return val;
  13496. }
  13497. val = "auto";
  13498. }
  13499. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13500. // This happens for inline elements with no explicit setting (gh-3571)
  13501. // Support: Android <=4.1 - 4.3 only
  13502. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13503. // Support: IE 9-11 only
  13504. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13505. // We use getClientRects() to check for hidden/disconnected.
  13506. // In those cases, the computed value can be trusted to be border-box
  13507. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13508. val === "auto" ||
  13509. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13510. elem.getClientRects().length ) {
  13511. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13512. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13513. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13514. // retrieved value as a content box dimension.
  13515. valueIsBorderBox = offsetProp in elem;
  13516. if ( valueIsBorderBox ) {
  13517. val = elem[ offsetProp ];
  13518. }
  13519. }
  13520. // Normalize "" and auto
  13521. val = parseFloat( val ) || 0;
  13522. // Adjust for the element's box model
  13523. return ( val +
  13524. boxModelAdjustment(
  13525. elem,
  13526. dimension,
  13527. extra || ( isBorderBox ? "border" : "content" ),
  13528. valueIsBorderBox,
  13529. styles,
  13530. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13531. val
  13532. )
  13533. ) + "px";
  13534. }
  13535. jQuery.extend( {
  13536. // Add in style property hooks for overriding the default
  13537. // behavior of getting and setting a style property
  13538. cssHooks: {
  13539. opacity: {
  13540. get: function( elem, computed ) {
  13541. if ( computed ) {
  13542. // We should always get a number back from opacity
  13543. var ret = curCSS( elem, "opacity" );
  13544. return ret === "" ? "1" : ret;
  13545. }
  13546. }
  13547. }
  13548. },
  13549. // Don't automatically add "px" to these possibly-unitless properties
  13550. cssNumber: {
  13551. "animationIterationCount": true,
  13552. "columnCount": true,
  13553. "fillOpacity": true,
  13554. "flexGrow": true,
  13555. "flexShrink": true,
  13556. "fontWeight": true,
  13557. "gridArea": true,
  13558. "gridColumn": true,
  13559. "gridColumnEnd": true,
  13560. "gridColumnStart": true,
  13561. "gridRow": true,
  13562. "gridRowEnd": true,
  13563. "gridRowStart": true,
  13564. "lineHeight": true,
  13565. "opacity": true,
  13566. "order": true,
  13567. "orphans": true,
  13568. "widows": true,
  13569. "zIndex": true,
  13570. "zoom": true
  13571. },
  13572. // Add in properties whose names you wish to fix before
  13573. // setting or getting the value
  13574. cssProps: {},
  13575. // Get and set the style property on a DOM Node
  13576. style: function( elem, name, value, extra ) {
  13577. // Don't set styles on text and comment nodes
  13578. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13579. return;
  13580. }
  13581. // Make sure that we're working with the right name
  13582. var ret, type, hooks,
  13583. origName = camelCase( name ),
  13584. isCustomProp = rcustomProp.test( name ),
  13585. style = elem.style;
  13586. // Make sure that we're working with the right name. We don't
  13587. // want to query the value if it is a CSS custom property
  13588. // since they are user-defined.
  13589. if ( !isCustomProp ) {
  13590. name = finalPropName( origName );
  13591. }
  13592. // Gets hook for the prefixed version, then unprefixed version
  13593. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13594. // Check if we're setting a value
  13595. if ( value !== undefined ) {
  13596. type = typeof value;
  13597. // Convert "+=" or "-=" to relative numbers (#7345)
  13598. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13599. value = adjustCSS( elem, name, ret );
  13600. // Fixes bug #9237
  13601. type = "number";
  13602. }
  13603. // Make sure that null and NaN values aren't set (#7116)
  13604. if ( value == null || value !== value ) {
  13605. return;
  13606. }
  13607. // If a number was passed in, add the unit (except for certain CSS properties)
  13608. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13609. // "px" to a few hardcoded values.
  13610. if ( type === "number" && !isCustomProp ) {
  13611. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13612. }
  13613. // background-* props affect original clone's values
  13614. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13615. style[ name ] = "inherit";
  13616. }
  13617. // If a hook was provided, use that value, otherwise just set the specified value
  13618. if ( !hooks || !( "set" in hooks ) ||
  13619. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13620. if ( isCustomProp ) {
  13621. style.setProperty( name, value );
  13622. } else {
  13623. style[ name ] = value;
  13624. }
  13625. }
  13626. } else {
  13627. // If a hook was provided get the non-computed value from there
  13628. if ( hooks && "get" in hooks &&
  13629. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13630. return ret;
  13631. }
  13632. // Otherwise just get the value from the style object
  13633. return style[ name ];
  13634. }
  13635. },
  13636. css: function( elem, name, extra, styles ) {
  13637. var val, num, hooks,
  13638. origName = camelCase( name ),
  13639. isCustomProp = rcustomProp.test( name );
  13640. // Make sure that we're working with the right name. We don't
  13641. // want to modify the value if it is a CSS custom property
  13642. // since they are user-defined.
  13643. if ( !isCustomProp ) {
  13644. name = finalPropName( origName );
  13645. }
  13646. // Try prefixed name followed by the unprefixed name
  13647. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13648. // If a hook was provided get the computed value from there
  13649. if ( hooks && "get" in hooks ) {
  13650. val = hooks.get( elem, true, extra );
  13651. }
  13652. // Otherwise, if a way to get the computed value exists, use that
  13653. if ( val === undefined ) {
  13654. val = curCSS( elem, name, styles );
  13655. }
  13656. // Convert "normal" to computed value
  13657. if ( val === "normal" && name in cssNormalTransform ) {
  13658. val = cssNormalTransform[ name ];
  13659. }
  13660. // Make numeric if forced or a qualifier was provided and val looks numeric
  13661. if ( extra === "" || extra ) {
  13662. num = parseFloat( val );
  13663. return extra === true || isFinite( num ) ? num || 0 : val;
  13664. }
  13665. return val;
  13666. }
  13667. } );
  13668. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13669. jQuery.cssHooks[ dimension ] = {
  13670. get: function( elem, computed, extra ) {
  13671. if ( computed ) {
  13672. // Certain elements can have dimension info if we invisibly show them
  13673. // but it must have a current display style that would benefit
  13674. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13675. // Support: Safari 8+
  13676. // Table columns in Safari have non-zero offsetWidth & zero
  13677. // getBoundingClientRect().width unless display is changed.
  13678. // Support: IE <=11 only
  13679. // Running getBoundingClientRect on a disconnected node
  13680. // in IE throws an error.
  13681. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13682. swap( elem, cssShow, function() {
  13683. return getWidthOrHeight( elem, dimension, extra );
  13684. } ) :
  13685. getWidthOrHeight( elem, dimension, extra );
  13686. }
  13687. },
  13688. set: function( elem, value, extra ) {
  13689. var matches,
  13690. styles = getStyles( elem ),
  13691. // Only read styles.position if the test has a chance to fail
  13692. // to avoid forcing a reflow.
  13693. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13694. styles.position === "absolute",
  13695. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13696. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13697. isBorderBox = boxSizingNeeded &&
  13698. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13699. subtract = extra ?
  13700. boxModelAdjustment(
  13701. elem,
  13702. dimension,
  13703. extra,
  13704. isBorderBox,
  13705. styles
  13706. ) :
  13707. 0;
  13708. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13709. // faking a content-box to get border and padding (gh-3699)
  13710. if ( isBorderBox && scrollboxSizeBuggy ) {
  13711. subtract -= Math.ceil(
  13712. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13713. parseFloat( styles[ dimension ] ) -
  13714. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13715. 0.5
  13716. );
  13717. }
  13718. // Convert to pixels if value adjustment is needed
  13719. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13720. ( matches[ 3 ] || "px" ) !== "px" ) {
  13721. elem.style[ dimension ] = value;
  13722. value = jQuery.css( elem, dimension );
  13723. }
  13724. return setPositiveNumber( elem, value, subtract );
  13725. }
  13726. };
  13727. } );
  13728. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13729. function( elem, computed ) {
  13730. if ( computed ) {
  13731. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13732. elem.getBoundingClientRect().left -
  13733. swap( elem, { marginLeft: 0 }, function() {
  13734. return elem.getBoundingClientRect().left;
  13735. } )
  13736. ) + "px";
  13737. }
  13738. }
  13739. );
  13740. // These hooks are used by animate to expand properties
  13741. jQuery.each( {
  13742. margin: "",
  13743. padding: "",
  13744. border: "Width"
  13745. }, function( prefix, suffix ) {
  13746. jQuery.cssHooks[ prefix + suffix ] = {
  13747. expand: function( value ) {
  13748. var i = 0,
  13749. expanded = {},
  13750. // Assumes a single number if not a string
  13751. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13752. for ( ; i < 4; i++ ) {
  13753. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13754. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13755. }
  13756. return expanded;
  13757. }
  13758. };
  13759. if ( prefix !== "margin" ) {
  13760. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13761. }
  13762. } );
  13763. jQuery.fn.extend( {
  13764. css: function( name, value ) {
  13765. return access( this, function( elem, name, value ) {
  13766. var styles, len,
  13767. map = {},
  13768. i = 0;
  13769. if ( Array.isArray( name ) ) {
  13770. styles = getStyles( elem );
  13771. len = name.length;
  13772. for ( ; i < len; i++ ) {
  13773. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13774. }
  13775. return map;
  13776. }
  13777. return value !== undefined ?
  13778. jQuery.style( elem, name, value ) :
  13779. jQuery.css( elem, name );
  13780. }, name, value, arguments.length > 1 );
  13781. }
  13782. } );
  13783. function Tween( elem, options, prop, end, easing ) {
  13784. return new Tween.prototype.init( elem, options, prop, end, easing );
  13785. }
  13786. jQuery.Tween = Tween;
  13787. Tween.prototype = {
  13788. constructor: Tween,
  13789. init: function( elem, options, prop, end, easing, unit ) {
  13790. this.elem = elem;
  13791. this.prop = prop;
  13792. this.easing = easing || jQuery.easing._default;
  13793. this.options = options;
  13794. this.start = this.now = this.cur();
  13795. this.end = end;
  13796. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13797. },
  13798. cur: function() {
  13799. var hooks = Tween.propHooks[ this.prop ];
  13800. return hooks && hooks.get ?
  13801. hooks.get( this ) :
  13802. Tween.propHooks._default.get( this );
  13803. },
  13804. run: function( percent ) {
  13805. var eased,
  13806. hooks = Tween.propHooks[ this.prop ];
  13807. if ( this.options.duration ) {
  13808. this.pos = eased = jQuery.easing[ this.easing ](
  13809. percent, this.options.duration * percent, 0, 1, this.options.duration
  13810. );
  13811. } else {
  13812. this.pos = eased = percent;
  13813. }
  13814. this.now = ( this.end - this.start ) * eased + this.start;
  13815. if ( this.options.step ) {
  13816. this.options.step.call( this.elem, this.now, this );
  13817. }
  13818. if ( hooks && hooks.set ) {
  13819. hooks.set( this );
  13820. } else {
  13821. Tween.propHooks._default.set( this );
  13822. }
  13823. return this;
  13824. }
  13825. };
  13826. Tween.prototype.init.prototype = Tween.prototype;
  13827. Tween.propHooks = {
  13828. _default: {
  13829. get: function( tween ) {
  13830. var result;
  13831. // Use a property on the element directly when it is not a DOM element,
  13832. // or when there is no matching style property that exists.
  13833. if ( tween.elem.nodeType !== 1 ||
  13834. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13835. return tween.elem[ tween.prop ];
  13836. }
  13837. // Passing an empty string as a 3rd parameter to .css will automatically
  13838. // attempt a parseFloat and fallback to a string if the parse fails.
  13839. // Simple values such as "10px" are parsed to Float;
  13840. // complex values such as "rotate(1rad)" are returned as-is.
  13841. result = jQuery.css( tween.elem, tween.prop, "" );
  13842. // Empty strings, null, undefined and "auto" are converted to 0.
  13843. return !result || result === "auto" ? 0 : result;
  13844. },
  13845. set: function( tween ) {
  13846. // Use step hook for back compat.
  13847. // Use cssHook if its there.
  13848. // Use .style if available and use plain properties where available.
  13849. if ( jQuery.fx.step[ tween.prop ] ) {
  13850. jQuery.fx.step[ tween.prop ]( tween );
  13851. } else if ( tween.elem.nodeType === 1 && (
  13852. jQuery.cssHooks[ tween.prop ] ||
  13853. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13854. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13855. } else {
  13856. tween.elem[ tween.prop ] = tween.now;
  13857. }
  13858. }
  13859. }
  13860. };
  13861. // Support: IE <=9 only
  13862. // Panic based approach to setting things on disconnected nodes
  13863. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13864. set: function( tween ) {
  13865. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13866. tween.elem[ tween.prop ] = tween.now;
  13867. }
  13868. }
  13869. };
  13870. jQuery.easing = {
  13871. linear: function( p ) {
  13872. return p;
  13873. },
  13874. swing: function( p ) {
  13875. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13876. },
  13877. _default: "swing"
  13878. };
  13879. jQuery.fx = Tween.prototype.init;
  13880. // Back compat <1.8 extension point
  13881. jQuery.fx.step = {};
  13882. var
  13883. fxNow, inProgress,
  13884. rfxtypes = /^(?:toggle|show|hide)$/,
  13885. rrun = /queueHooks$/;
  13886. function schedule() {
  13887. if ( inProgress ) {
  13888. if ( document.hidden === false && window.requestAnimationFrame ) {
  13889. window.requestAnimationFrame( schedule );
  13890. } else {
  13891. window.setTimeout( schedule, jQuery.fx.interval );
  13892. }
  13893. jQuery.fx.tick();
  13894. }
  13895. }
  13896. // Animations created synchronously will run synchronously
  13897. function createFxNow() {
  13898. window.setTimeout( function() {
  13899. fxNow = undefined;
  13900. } );
  13901. return ( fxNow = Date.now() );
  13902. }
  13903. // Generate parameters to create a standard animation
  13904. function genFx( type, includeWidth ) {
  13905. var which,
  13906. i = 0,
  13907. attrs = { height: type };
  13908. // If we include width, step value is 1 to do all cssExpand values,
  13909. // otherwise step value is 2 to skip over Left and Right
  13910. includeWidth = includeWidth ? 1 : 0;
  13911. for ( ; i < 4; i += 2 - includeWidth ) {
  13912. which = cssExpand[ i ];
  13913. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13914. }
  13915. if ( includeWidth ) {
  13916. attrs.opacity = attrs.width = type;
  13917. }
  13918. return attrs;
  13919. }
  13920. function createTween( value, prop, animation ) {
  13921. var tween,
  13922. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13923. index = 0,
  13924. length = collection.length;
  13925. for ( ; index < length; index++ ) {
  13926. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13927. // We're done with this property
  13928. return tween;
  13929. }
  13930. }
  13931. }
  13932. function defaultPrefilter( elem, props, opts ) {
  13933. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13934. isBox = "width" in props || "height" in props,
  13935. anim = this,
  13936. orig = {},
  13937. style = elem.style,
  13938. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13939. dataShow = dataPriv.get( elem, "fxshow" );
  13940. // Queue-skipping animations hijack the fx hooks
  13941. if ( !opts.queue ) {
  13942. hooks = jQuery._queueHooks( elem, "fx" );
  13943. if ( hooks.unqueued == null ) {
  13944. hooks.unqueued = 0;
  13945. oldfire = hooks.empty.fire;
  13946. hooks.empty.fire = function() {
  13947. if ( !hooks.unqueued ) {
  13948. oldfire();
  13949. }
  13950. };
  13951. }
  13952. hooks.unqueued++;
  13953. anim.always( function() {
  13954. // Ensure the complete handler is called before this completes
  13955. anim.always( function() {
  13956. hooks.unqueued--;
  13957. if ( !jQuery.queue( elem, "fx" ).length ) {
  13958. hooks.empty.fire();
  13959. }
  13960. } );
  13961. } );
  13962. }
  13963. // Detect show/hide animations
  13964. for ( prop in props ) {
  13965. value = props[ prop ];
  13966. if ( rfxtypes.test( value ) ) {
  13967. delete props[ prop ];
  13968. toggle = toggle || value === "toggle";
  13969. if ( value === ( hidden ? "hide" : "show" ) ) {
  13970. // Pretend to be hidden if this is a "show" and
  13971. // there is still data from a stopped show/hide
  13972. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13973. hidden = true;
  13974. // Ignore all other no-op show/hide data
  13975. } else {
  13976. continue;
  13977. }
  13978. }
  13979. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13980. }
  13981. }
  13982. // Bail out if this is a no-op like .hide().hide()
  13983. propTween = !jQuery.isEmptyObject( props );
  13984. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13985. return;
  13986. }
  13987. // Restrict "overflow" and "display" styles during box animations
  13988. if ( isBox && elem.nodeType === 1 ) {
  13989. // Support: IE <=9 - 11, Edge 12 - 15
  13990. // Record all 3 overflow attributes because IE does not infer the shorthand
  13991. // from identically-valued overflowX and overflowY and Edge just mirrors
  13992. // the overflowX value there.
  13993. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13994. // Identify a display type, preferring old show/hide data over the CSS cascade
  13995. restoreDisplay = dataShow && dataShow.display;
  13996. if ( restoreDisplay == null ) {
  13997. restoreDisplay = dataPriv.get( elem, "display" );
  13998. }
  13999. display = jQuery.css( elem, "display" );
  14000. if ( display === "none" ) {
  14001. if ( restoreDisplay ) {
  14002. display = restoreDisplay;
  14003. } else {
  14004. // Get nonempty value(s) by temporarily forcing visibility
  14005. showHide( [ elem ], true );
  14006. restoreDisplay = elem.style.display || restoreDisplay;
  14007. display = jQuery.css( elem, "display" );
  14008. showHide( [ elem ] );
  14009. }
  14010. }
  14011. // Animate inline elements as inline-block
  14012. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  14013. if ( jQuery.css( elem, "float" ) === "none" ) {
  14014. // Restore the original display value at the end of pure show/hide animations
  14015. if ( !propTween ) {
  14016. anim.done( function() {
  14017. style.display = restoreDisplay;
  14018. } );
  14019. if ( restoreDisplay == null ) {
  14020. display = style.display;
  14021. restoreDisplay = display === "none" ? "" : display;
  14022. }
  14023. }
  14024. style.display = "inline-block";
  14025. }
  14026. }
  14027. }
  14028. if ( opts.overflow ) {
  14029. style.overflow = "hidden";
  14030. anim.always( function() {
  14031. style.overflow = opts.overflow[ 0 ];
  14032. style.overflowX = opts.overflow[ 1 ];
  14033. style.overflowY = opts.overflow[ 2 ];
  14034. } );
  14035. }
  14036. // Implement show/hide animations
  14037. propTween = false;
  14038. for ( prop in orig ) {
  14039. // General show/hide setup for this element animation
  14040. if ( !propTween ) {
  14041. if ( dataShow ) {
  14042. if ( "hidden" in dataShow ) {
  14043. hidden = dataShow.hidden;
  14044. }
  14045. } else {
  14046. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  14047. }
  14048. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  14049. if ( toggle ) {
  14050. dataShow.hidden = !hidden;
  14051. }
  14052. // Show elements before animating them
  14053. if ( hidden ) {
  14054. showHide( [ elem ], true );
  14055. }
  14056. /* eslint-disable no-loop-func */
  14057. anim.done( function() {
  14058. /* eslint-enable no-loop-func */
  14059. // The final step of a "hide" animation is actually hiding the element
  14060. if ( !hidden ) {
  14061. showHide( [ elem ] );
  14062. }
  14063. dataPriv.remove( elem, "fxshow" );
  14064. for ( prop in orig ) {
  14065. jQuery.style( elem, prop, orig[ prop ] );
  14066. }
  14067. } );
  14068. }
  14069. // Per-property setup
  14070. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  14071. if ( !( prop in dataShow ) ) {
  14072. dataShow[ prop ] = propTween.start;
  14073. if ( hidden ) {
  14074. propTween.end = propTween.start;
  14075. propTween.start = 0;
  14076. }
  14077. }
  14078. }
  14079. }
  14080. function propFilter( props, specialEasing ) {
  14081. var index, name, easing, value, hooks;
  14082. // camelCase, specialEasing and expand cssHook pass
  14083. for ( index in props ) {
  14084. name = camelCase( index );
  14085. easing = specialEasing[ name ];
  14086. value = props[ index ];
  14087. if ( Array.isArray( value ) ) {
  14088. easing = value[ 1 ];
  14089. value = props[ index ] = value[ 0 ];
  14090. }
  14091. if ( index !== name ) {
  14092. props[ name ] = value;
  14093. delete props[ index ];
  14094. }
  14095. hooks = jQuery.cssHooks[ name ];
  14096. if ( hooks && "expand" in hooks ) {
  14097. value = hooks.expand( value );
  14098. delete props[ name ];
  14099. // Not quite $.extend, this won't overwrite existing keys.
  14100. // Reusing 'index' because we have the correct "name"
  14101. for ( index in value ) {
  14102. if ( !( index in props ) ) {
  14103. props[ index ] = value[ index ];
  14104. specialEasing[ index ] = easing;
  14105. }
  14106. }
  14107. } else {
  14108. specialEasing[ name ] = easing;
  14109. }
  14110. }
  14111. }
  14112. function Animation( elem, properties, options ) {
  14113. var result,
  14114. stopped,
  14115. index = 0,
  14116. length = Animation.prefilters.length,
  14117. deferred = jQuery.Deferred().always( function() {
  14118. // Don't match elem in the :animated selector
  14119. delete tick.elem;
  14120. } ),
  14121. tick = function() {
  14122. if ( stopped ) {
  14123. return false;
  14124. }
  14125. var currentTime = fxNow || createFxNow(),
  14126. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  14127. // Support: Android 2.3 only
  14128. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  14129. temp = remaining / animation.duration || 0,
  14130. percent = 1 - temp,
  14131. index = 0,
  14132. length = animation.tweens.length;
  14133. for ( ; index < length; index++ ) {
  14134. animation.tweens[ index ].run( percent );
  14135. }
  14136. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14137. // If there's more to do, yield
  14138. if ( percent < 1 && length ) {
  14139. return remaining;
  14140. }
  14141. // If this was an empty animation, synthesize a final progress notification
  14142. if ( !length ) {
  14143. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14144. }
  14145. // Resolve the animation and report its conclusion
  14146. deferred.resolveWith( elem, [ animation ] );
  14147. return false;
  14148. },
  14149. animation = deferred.promise( {
  14150. elem: elem,
  14151. props: jQuery.extend( {}, properties ),
  14152. opts: jQuery.extend( true, {
  14153. specialEasing: {},
  14154. easing: jQuery.easing._default
  14155. }, options ),
  14156. originalProperties: properties,
  14157. originalOptions: options,
  14158. startTime: fxNow || createFxNow(),
  14159. duration: options.duration,
  14160. tweens: [],
  14161. createTween: function( prop, end ) {
  14162. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14163. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14164. animation.tweens.push( tween );
  14165. return tween;
  14166. },
  14167. stop: function( gotoEnd ) {
  14168. var index = 0,
  14169. // If we are going to the end, we want to run all the tweens
  14170. // otherwise we skip this part
  14171. length = gotoEnd ? animation.tweens.length : 0;
  14172. if ( stopped ) {
  14173. return this;
  14174. }
  14175. stopped = true;
  14176. for ( ; index < length; index++ ) {
  14177. animation.tweens[ index ].run( 1 );
  14178. }
  14179. // Resolve when we played the last frame; otherwise, reject
  14180. if ( gotoEnd ) {
  14181. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14182. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14183. } else {
  14184. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14185. }
  14186. return this;
  14187. }
  14188. } ),
  14189. props = animation.props;
  14190. propFilter( props, animation.opts.specialEasing );
  14191. for ( ; index < length; index++ ) {
  14192. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14193. if ( result ) {
  14194. if ( isFunction( result.stop ) ) {
  14195. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14196. result.stop.bind( result );
  14197. }
  14198. return result;
  14199. }
  14200. }
  14201. jQuery.map( props, createTween, animation );
  14202. if ( isFunction( animation.opts.start ) ) {
  14203. animation.opts.start.call( elem, animation );
  14204. }
  14205. // Attach callbacks from options
  14206. animation
  14207. .progress( animation.opts.progress )
  14208. .done( animation.opts.done, animation.opts.complete )
  14209. .fail( animation.opts.fail )
  14210. .always( animation.opts.always );
  14211. jQuery.fx.timer(
  14212. jQuery.extend( tick, {
  14213. elem: elem,
  14214. anim: animation,
  14215. queue: animation.opts.queue
  14216. } )
  14217. );
  14218. return animation;
  14219. }
  14220. jQuery.Animation = jQuery.extend( Animation, {
  14221. tweeners: {
  14222. "*": [ function( prop, value ) {
  14223. var tween = this.createTween( prop, value );
  14224. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14225. return tween;
  14226. } ]
  14227. },
  14228. tweener: function( props, callback ) {
  14229. if ( isFunction( props ) ) {
  14230. callback = props;
  14231. props = [ "*" ];
  14232. } else {
  14233. props = props.match( rnothtmlwhite );
  14234. }
  14235. var prop,
  14236. index = 0,
  14237. length = props.length;
  14238. for ( ; index < length; index++ ) {
  14239. prop = props[ index ];
  14240. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14241. Animation.tweeners[ prop ].unshift( callback );
  14242. }
  14243. },
  14244. prefilters: [ defaultPrefilter ],
  14245. prefilter: function( callback, prepend ) {
  14246. if ( prepend ) {
  14247. Animation.prefilters.unshift( callback );
  14248. } else {
  14249. Animation.prefilters.push( callback );
  14250. }
  14251. }
  14252. } );
  14253. jQuery.speed = function( speed, easing, fn ) {
  14254. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14255. complete: fn || !fn && easing ||
  14256. isFunction( speed ) && speed,
  14257. duration: speed,
  14258. easing: fn && easing || easing && !isFunction( easing ) && easing
  14259. };
  14260. // Go to the end state if fx are off
  14261. if ( jQuery.fx.off ) {
  14262. opt.duration = 0;
  14263. } else {
  14264. if ( typeof opt.duration !== "number" ) {
  14265. if ( opt.duration in jQuery.fx.speeds ) {
  14266. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14267. } else {
  14268. opt.duration = jQuery.fx.speeds._default;
  14269. }
  14270. }
  14271. }
  14272. // Normalize opt.queue - true/undefined/null -> "fx"
  14273. if ( opt.queue == null || opt.queue === true ) {
  14274. opt.queue = "fx";
  14275. }
  14276. // Queueing
  14277. opt.old = opt.complete;
  14278. opt.complete = function() {
  14279. if ( isFunction( opt.old ) ) {
  14280. opt.old.call( this );
  14281. }
  14282. if ( opt.queue ) {
  14283. jQuery.dequeue( this, opt.queue );
  14284. }
  14285. };
  14286. return opt;
  14287. };
  14288. jQuery.fn.extend( {
  14289. fadeTo: function( speed, to, easing, callback ) {
  14290. // Show any hidden elements after setting opacity to 0
  14291. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14292. // Animate to the value specified
  14293. .end().animate( { opacity: to }, speed, easing, callback );
  14294. },
  14295. animate: function( prop, speed, easing, callback ) {
  14296. var empty = jQuery.isEmptyObject( prop ),
  14297. optall = jQuery.speed( speed, easing, callback ),
  14298. doAnimation = function() {
  14299. // Operate on a copy of prop so per-property easing won't be lost
  14300. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14301. // Empty animations, or finishing resolves immediately
  14302. if ( empty || dataPriv.get( this, "finish" ) ) {
  14303. anim.stop( true );
  14304. }
  14305. };
  14306. doAnimation.finish = doAnimation;
  14307. return empty || optall.queue === false ?
  14308. this.each( doAnimation ) :
  14309. this.queue( optall.queue, doAnimation );
  14310. },
  14311. stop: function( type, clearQueue, gotoEnd ) {
  14312. var stopQueue = function( hooks ) {
  14313. var stop = hooks.stop;
  14314. delete hooks.stop;
  14315. stop( gotoEnd );
  14316. };
  14317. if ( typeof type !== "string" ) {
  14318. gotoEnd = clearQueue;
  14319. clearQueue = type;
  14320. type = undefined;
  14321. }
  14322. if ( clearQueue && type !== false ) {
  14323. this.queue( type || "fx", [] );
  14324. }
  14325. return this.each( function() {
  14326. var dequeue = true,
  14327. index = type != null && type + "queueHooks",
  14328. timers = jQuery.timers,
  14329. data = dataPriv.get( this );
  14330. if ( index ) {
  14331. if ( data[ index ] && data[ index ].stop ) {
  14332. stopQueue( data[ index ] );
  14333. }
  14334. } else {
  14335. for ( index in data ) {
  14336. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14337. stopQueue( data[ index ] );
  14338. }
  14339. }
  14340. }
  14341. for ( index = timers.length; index--; ) {
  14342. if ( timers[ index ].elem === this &&
  14343. ( type == null || timers[ index ].queue === type ) ) {
  14344. timers[ index ].anim.stop( gotoEnd );
  14345. dequeue = false;
  14346. timers.splice( index, 1 );
  14347. }
  14348. }
  14349. // Start the next in the queue if the last step wasn't forced.
  14350. // Timers currently will call their complete callbacks, which
  14351. // will dequeue but only if they were gotoEnd.
  14352. if ( dequeue || !gotoEnd ) {
  14353. jQuery.dequeue( this, type );
  14354. }
  14355. } );
  14356. },
  14357. finish: function( type ) {
  14358. if ( type !== false ) {
  14359. type = type || "fx";
  14360. }
  14361. return this.each( function() {
  14362. var index,
  14363. data = dataPriv.get( this ),
  14364. queue = data[ type + "queue" ],
  14365. hooks = data[ type + "queueHooks" ],
  14366. timers = jQuery.timers,
  14367. length = queue ? queue.length : 0;
  14368. // Enable finishing flag on private data
  14369. data.finish = true;
  14370. // Empty the queue first
  14371. jQuery.queue( this, type, [] );
  14372. if ( hooks && hooks.stop ) {
  14373. hooks.stop.call( this, true );
  14374. }
  14375. // Look for any active animations, and finish them
  14376. for ( index = timers.length; index--; ) {
  14377. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14378. timers[ index ].anim.stop( true );
  14379. timers.splice( index, 1 );
  14380. }
  14381. }
  14382. // Look for any animations in the old queue and finish them
  14383. for ( index = 0; index < length; index++ ) {
  14384. if ( queue[ index ] && queue[ index ].finish ) {
  14385. queue[ index ].finish.call( this );
  14386. }
  14387. }
  14388. // Turn off finishing flag
  14389. delete data.finish;
  14390. } );
  14391. }
  14392. } );
  14393. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14394. var cssFn = jQuery.fn[ name ];
  14395. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14396. return speed == null || typeof speed === "boolean" ?
  14397. cssFn.apply( this, arguments ) :
  14398. this.animate( genFx( name, true ), speed, easing, callback );
  14399. };
  14400. } );
  14401. // Generate shortcuts for custom animations
  14402. jQuery.each( {
  14403. slideDown: genFx( "show" ),
  14404. slideUp: genFx( "hide" ),
  14405. slideToggle: genFx( "toggle" ),
  14406. fadeIn: { opacity: "show" },
  14407. fadeOut: { opacity: "hide" },
  14408. fadeToggle: { opacity: "toggle" }
  14409. }, function( name, props ) {
  14410. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14411. return this.animate( props, speed, easing, callback );
  14412. };
  14413. } );
  14414. jQuery.timers = [];
  14415. jQuery.fx.tick = function() {
  14416. var timer,
  14417. i = 0,
  14418. timers = jQuery.timers;
  14419. fxNow = Date.now();
  14420. for ( ; i < timers.length; i++ ) {
  14421. timer = timers[ i ];
  14422. // Run the timer and safely remove it when done (allowing for external removal)
  14423. if ( !timer() && timers[ i ] === timer ) {
  14424. timers.splice( i--, 1 );
  14425. }
  14426. }
  14427. if ( !timers.length ) {
  14428. jQuery.fx.stop();
  14429. }
  14430. fxNow = undefined;
  14431. };
  14432. jQuery.fx.timer = function( timer ) {
  14433. jQuery.timers.push( timer );
  14434. jQuery.fx.start();
  14435. };
  14436. jQuery.fx.interval = 13;
  14437. jQuery.fx.start = function() {
  14438. if ( inProgress ) {
  14439. return;
  14440. }
  14441. inProgress = true;
  14442. schedule();
  14443. };
  14444. jQuery.fx.stop = function() {
  14445. inProgress = null;
  14446. };
  14447. jQuery.fx.speeds = {
  14448. slow: 600,
  14449. fast: 200,
  14450. // Default speed
  14451. _default: 400
  14452. };
  14453. // Based off of the plugin by Clint Helfers, with permission.
  14454. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14455. jQuery.fn.delay = function( time, type ) {
  14456. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14457. type = type || "fx";
  14458. return this.queue( type, function( next, hooks ) {
  14459. var timeout = window.setTimeout( next, time );
  14460. hooks.stop = function() {
  14461. window.clearTimeout( timeout );
  14462. };
  14463. } );
  14464. };
  14465. ( function() {
  14466. var input = document.createElement( "input" ),
  14467. select = document.createElement( "select" ),
  14468. opt = select.appendChild( document.createElement( "option" ) );
  14469. input.type = "checkbox";
  14470. // Support: Android <=4.3 only
  14471. // Default value for a checkbox should be "on"
  14472. support.checkOn = input.value !== "";
  14473. // Support: IE <=11 only
  14474. // Must access selectedIndex to make default options select
  14475. support.optSelected = opt.selected;
  14476. // Support: IE <=11 only
  14477. // An input loses its value after becoming a radio
  14478. input = document.createElement( "input" );
  14479. input.value = "t";
  14480. input.type = "radio";
  14481. support.radioValue = input.value === "t";
  14482. } )();
  14483. var boolHook,
  14484. attrHandle = jQuery.expr.attrHandle;
  14485. jQuery.fn.extend( {
  14486. attr: function( name, value ) {
  14487. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14488. },
  14489. removeAttr: function( name ) {
  14490. return this.each( function() {
  14491. jQuery.removeAttr( this, name );
  14492. } );
  14493. }
  14494. } );
  14495. jQuery.extend( {
  14496. attr: function( elem, name, value ) {
  14497. var ret, hooks,
  14498. nType = elem.nodeType;
  14499. // Don't get/set attributes on text, comment and attribute nodes
  14500. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14501. return;
  14502. }
  14503. // Fallback to prop when attributes are not supported
  14504. if ( typeof elem.getAttribute === "undefined" ) {
  14505. return jQuery.prop( elem, name, value );
  14506. }
  14507. // Attribute hooks are determined by the lowercase version
  14508. // Grab necessary hook if one is defined
  14509. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14510. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14511. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14512. }
  14513. if ( value !== undefined ) {
  14514. if ( value === null ) {
  14515. jQuery.removeAttr( elem, name );
  14516. return;
  14517. }
  14518. if ( hooks && "set" in hooks &&
  14519. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14520. return ret;
  14521. }
  14522. elem.setAttribute( name, value + "" );
  14523. return value;
  14524. }
  14525. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14526. return ret;
  14527. }
  14528. ret = jQuery.find.attr( elem, name );
  14529. // Non-existent attributes return null, we normalize to undefined
  14530. return ret == null ? undefined : ret;
  14531. },
  14532. attrHooks: {
  14533. type: {
  14534. set: function( elem, value ) {
  14535. if ( !support.radioValue && value === "radio" &&
  14536. nodeName( elem, "input" ) ) {
  14537. var val = elem.value;
  14538. elem.setAttribute( "type", value );
  14539. if ( val ) {
  14540. elem.value = val;
  14541. }
  14542. return value;
  14543. }
  14544. }
  14545. }
  14546. },
  14547. removeAttr: function( elem, value ) {
  14548. var name,
  14549. i = 0,
  14550. // Attribute names can contain non-HTML whitespace characters
  14551. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14552. attrNames = value && value.match( rnothtmlwhite );
  14553. if ( attrNames && elem.nodeType === 1 ) {
  14554. while ( ( name = attrNames[ i++ ] ) ) {
  14555. elem.removeAttribute( name );
  14556. }
  14557. }
  14558. }
  14559. } );
  14560. // Hooks for boolean attributes
  14561. boolHook = {
  14562. set: function( elem, value, name ) {
  14563. if ( value === false ) {
  14564. // Remove boolean attributes when set to false
  14565. jQuery.removeAttr( elem, name );
  14566. } else {
  14567. elem.setAttribute( name, name );
  14568. }
  14569. return name;
  14570. }
  14571. };
  14572. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14573. var getter = attrHandle[ name ] || jQuery.find.attr;
  14574. attrHandle[ name ] = function( elem, name, isXML ) {
  14575. var ret, handle,
  14576. lowercaseName = name.toLowerCase();
  14577. if ( !isXML ) {
  14578. // Avoid an infinite loop by temporarily removing this function from the getter
  14579. handle = attrHandle[ lowercaseName ];
  14580. attrHandle[ lowercaseName ] = ret;
  14581. ret = getter( elem, name, isXML ) != null ?
  14582. lowercaseName :
  14583. null;
  14584. attrHandle[ lowercaseName ] = handle;
  14585. }
  14586. return ret;
  14587. };
  14588. } );
  14589. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14590. rclickable = /^(?:a|area)$/i;
  14591. jQuery.fn.extend( {
  14592. prop: function( name, value ) {
  14593. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14594. },
  14595. removeProp: function( name ) {
  14596. return this.each( function() {
  14597. delete this[ jQuery.propFix[ name ] || name ];
  14598. } );
  14599. }
  14600. } );
  14601. jQuery.extend( {
  14602. prop: function( elem, name, value ) {
  14603. var ret, hooks,
  14604. nType = elem.nodeType;
  14605. // Don't get/set properties on text, comment and attribute nodes
  14606. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14607. return;
  14608. }
  14609. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14610. // Fix name and attach hooks
  14611. name = jQuery.propFix[ name ] || name;
  14612. hooks = jQuery.propHooks[ name ];
  14613. }
  14614. if ( value !== undefined ) {
  14615. if ( hooks && "set" in hooks &&
  14616. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14617. return ret;
  14618. }
  14619. return ( elem[ name ] = value );
  14620. }
  14621. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14622. return ret;
  14623. }
  14624. return elem[ name ];
  14625. },
  14626. propHooks: {
  14627. tabIndex: {
  14628. get: function( elem ) {
  14629. // Support: IE <=9 - 11 only
  14630. // elem.tabIndex doesn't always return the
  14631. // correct value when it hasn't been explicitly set
  14632. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14633. // Use proper attribute retrieval(#12072)
  14634. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14635. if ( tabindex ) {
  14636. return parseInt( tabindex, 10 );
  14637. }
  14638. if (
  14639. rfocusable.test( elem.nodeName ) ||
  14640. rclickable.test( elem.nodeName ) &&
  14641. elem.href
  14642. ) {
  14643. return 0;
  14644. }
  14645. return -1;
  14646. }
  14647. }
  14648. },
  14649. propFix: {
  14650. "for": "htmlFor",
  14651. "class": "className"
  14652. }
  14653. } );
  14654. // Support: IE <=11 only
  14655. // Accessing the selectedIndex property
  14656. // forces the browser to respect setting selected
  14657. // on the option
  14658. // The getter ensures a default option is selected
  14659. // when in an optgroup
  14660. // eslint rule "no-unused-expressions" is disabled for this code
  14661. // since it considers such accessions noop
  14662. if ( !support.optSelected ) {
  14663. jQuery.propHooks.selected = {
  14664. get: function( elem ) {
  14665. /* eslint no-unused-expressions: "off" */
  14666. var parent = elem.parentNode;
  14667. if ( parent && parent.parentNode ) {
  14668. parent.parentNode.selectedIndex;
  14669. }
  14670. return null;
  14671. },
  14672. set: function( elem ) {
  14673. /* eslint no-unused-expressions: "off" */
  14674. var parent = elem.parentNode;
  14675. if ( parent ) {
  14676. parent.selectedIndex;
  14677. if ( parent.parentNode ) {
  14678. parent.parentNode.selectedIndex;
  14679. }
  14680. }
  14681. }
  14682. };
  14683. }
  14684. jQuery.each( [
  14685. "tabIndex",
  14686. "readOnly",
  14687. "maxLength",
  14688. "cellSpacing",
  14689. "cellPadding",
  14690. "rowSpan",
  14691. "colSpan",
  14692. "useMap",
  14693. "frameBorder",
  14694. "contentEditable"
  14695. ], function() {
  14696. jQuery.propFix[ this.toLowerCase() ] = this;
  14697. } );
  14698. // Strip and collapse whitespace according to HTML spec
  14699. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14700. function stripAndCollapse( value ) {
  14701. var tokens = value.match( rnothtmlwhite ) || [];
  14702. return tokens.join( " " );
  14703. }
  14704. function getClass( elem ) {
  14705. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14706. }
  14707. function classesToArray( value ) {
  14708. if ( Array.isArray( value ) ) {
  14709. return value;
  14710. }
  14711. if ( typeof value === "string" ) {
  14712. return value.match( rnothtmlwhite ) || [];
  14713. }
  14714. return [];
  14715. }
  14716. jQuery.fn.extend( {
  14717. addClass: function( value ) {
  14718. var classes, elem, cur, curValue, clazz, j, finalValue,
  14719. i = 0;
  14720. if ( isFunction( value ) ) {
  14721. return this.each( function( j ) {
  14722. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14723. } );
  14724. }
  14725. classes = classesToArray( value );
  14726. if ( classes.length ) {
  14727. while ( ( elem = this[ i++ ] ) ) {
  14728. curValue = getClass( elem );
  14729. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14730. if ( cur ) {
  14731. j = 0;
  14732. while ( ( clazz = classes[ j++ ] ) ) {
  14733. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14734. cur += clazz + " ";
  14735. }
  14736. }
  14737. // Only assign if different to avoid unneeded rendering.
  14738. finalValue = stripAndCollapse( cur );
  14739. if ( curValue !== finalValue ) {
  14740. elem.setAttribute( "class", finalValue );
  14741. }
  14742. }
  14743. }
  14744. }
  14745. return this;
  14746. },
  14747. removeClass: function( value ) {
  14748. var classes, elem, cur, curValue, clazz, j, finalValue,
  14749. i = 0;
  14750. if ( isFunction( value ) ) {
  14751. return this.each( function( j ) {
  14752. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14753. } );
  14754. }
  14755. if ( !arguments.length ) {
  14756. return this.attr( "class", "" );
  14757. }
  14758. classes = classesToArray( value );
  14759. if ( classes.length ) {
  14760. while ( ( elem = this[ i++ ] ) ) {
  14761. curValue = getClass( elem );
  14762. // This expression is here for better compressibility (see addClass)
  14763. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14764. if ( cur ) {
  14765. j = 0;
  14766. while ( ( clazz = classes[ j++ ] ) ) {
  14767. // Remove *all* instances
  14768. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14769. cur = cur.replace( " " + clazz + " ", " " );
  14770. }
  14771. }
  14772. // Only assign if different to avoid unneeded rendering.
  14773. finalValue = stripAndCollapse( cur );
  14774. if ( curValue !== finalValue ) {
  14775. elem.setAttribute( "class", finalValue );
  14776. }
  14777. }
  14778. }
  14779. }
  14780. return this;
  14781. },
  14782. toggleClass: function( value, stateVal ) {
  14783. var type = typeof value,
  14784. isValidValue = type === "string" || Array.isArray( value );
  14785. if ( typeof stateVal === "boolean" && isValidValue ) {
  14786. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14787. }
  14788. if ( isFunction( value ) ) {
  14789. return this.each( function( i ) {
  14790. jQuery( this ).toggleClass(
  14791. value.call( this, i, getClass( this ), stateVal ),
  14792. stateVal
  14793. );
  14794. } );
  14795. }
  14796. return this.each( function() {
  14797. var className, i, self, classNames;
  14798. if ( isValidValue ) {
  14799. // Toggle individual class names
  14800. i = 0;
  14801. self = jQuery( this );
  14802. classNames = classesToArray( value );
  14803. while ( ( className = classNames[ i++ ] ) ) {
  14804. // Check each className given, space separated list
  14805. if ( self.hasClass( className ) ) {
  14806. self.removeClass( className );
  14807. } else {
  14808. self.addClass( className );
  14809. }
  14810. }
  14811. // Toggle whole class name
  14812. } else if ( value === undefined || type === "boolean" ) {
  14813. className = getClass( this );
  14814. if ( className ) {
  14815. // Store className if set
  14816. dataPriv.set( this, "__className__", className );
  14817. }
  14818. // If the element has a class name or if we're passed `false`,
  14819. // then remove the whole classname (if there was one, the above saved it).
  14820. // Otherwise bring back whatever was previously saved (if anything),
  14821. // falling back to the empty string if nothing was stored.
  14822. if ( this.setAttribute ) {
  14823. this.setAttribute( "class",
  14824. className || value === false ?
  14825. "" :
  14826. dataPriv.get( this, "__className__" ) || ""
  14827. );
  14828. }
  14829. }
  14830. } );
  14831. },
  14832. hasClass: function( selector ) {
  14833. var className, elem,
  14834. i = 0;
  14835. className = " " + selector + " ";
  14836. while ( ( elem = this[ i++ ] ) ) {
  14837. if ( elem.nodeType === 1 &&
  14838. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14839. return true;
  14840. }
  14841. }
  14842. return false;
  14843. }
  14844. } );
  14845. var rreturn = /\r/g;
  14846. jQuery.fn.extend( {
  14847. val: function( value ) {
  14848. var hooks, ret, valueIsFunction,
  14849. elem = this[ 0 ];
  14850. if ( !arguments.length ) {
  14851. if ( elem ) {
  14852. hooks = jQuery.valHooks[ elem.type ] ||
  14853. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14854. if ( hooks &&
  14855. "get" in hooks &&
  14856. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14857. ) {
  14858. return ret;
  14859. }
  14860. ret = elem.value;
  14861. // Handle most common string cases
  14862. if ( typeof ret === "string" ) {
  14863. return ret.replace( rreturn, "" );
  14864. }
  14865. // Handle cases where value is null/undef or number
  14866. return ret == null ? "" : ret;
  14867. }
  14868. return;
  14869. }
  14870. valueIsFunction = isFunction( value );
  14871. return this.each( function( i ) {
  14872. var val;
  14873. if ( this.nodeType !== 1 ) {
  14874. return;
  14875. }
  14876. if ( valueIsFunction ) {
  14877. val = value.call( this, i, jQuery( this ).val() );
  14878. } else {
  14879. val = value;
  14880. }
  14881. // Treat null/undefined as ""; convert numbers to string
  14882. if ( val == null ) {
  14883. val = "";
  14884. } else if ( typeof val === "number" ) {
  14885. val += "";
  14886. } else if ( Array.isArray( val ) ) {
  14887. val = jQuery.map( val, function( value ) {
  14888. return value == null ? "" : value + "";
  14889. } );
  14890. }
  14891. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14892. // If set returns undefined, fall back to normal setting
  14893. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14894. this.value = val;
  14895. }
  14896. } );
  14897. }
  14898. } );
  14899. jQuery.extend( {
  14900. valHooks: {
  14901. option: {
  14902. get: function( elem ) {
  14903. var val = jQuery.find.attr( elem, "value" );
  14904. return val != null ?
  14905. val :
  14906. // Support: IE <=10 - 11 only
  14907. // option.text throws exceptions (#14686, #14858)
  14908. // Strip and collapse whitespace
  14909. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14910. stripAndCollapse( jQuery.text( elem ) );
  14911. }
  14912. },
  14913. select: {
  14914. get: function( elem ) {
  14915. var value, option, i,
  14916. options = elem.options,
  14917. index = elem.selectedIndex,
  14918. one = elem.type === "select-one",
  14919. values = one ? null : [],
  14920. max = one ? index + 1 : options.length;
  14921. if ( index < 0 ) {
  14922. i = max;
  14923. } else {
  14924. i = one ? index : 0;
  14925. }
  14926. // Loop through all the selected options
  14927. for ( ; i < max; i++ ) {
  14928. option = options[ i ];
  14929. // Support: IE <=9 only
  14930. // IE8-9 doesn't update selected after form reset (#2551)
  14931. if ( ( option.selected || i === index ) &&
  14932. // Don't return options that are disabled or in a disabled optgroup
  14933. !option.disabled &&
  14934. ( !option.parentNode.disabled ||
  14935. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14936. // Get the specific value for the option
  14937. value = jQuery( option ).val();
  14938. // We don't need an array for one selects
  14939. if ( one ) {
  14940. return value;
  14941. }
  14942. // Multi-Selects return an array
  14943. values.push( value );
  14944. }
  14945. }
  14946. return values;
  14947. },
  14948. set: function( elem, value ) {
  14949. var optionSet, option,
  14950. options = elem.options,
  14951. values = jQuery.makeArray( value ),
  14952. i = options.length;
  14953. while ( i-- ) {
  14954. option = options[ i ];
  14955. /* eslint-disable no-cond-assign */
  14956. if ( option.selected =
  14957. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14958. ) {
  14959. optionSet = true;
  14960. }
  14961. /* eslint-enable no-cond-assign */
  14962. }
  14963. // Force browsers to behave consistently when non-matching value is set
  14964. if ( !optionSet ) {
  14965. elem.selectedIndex = -1;
  14966. }
  14967. return values;
  14968. }
  14969. }
  14970. }
  14971. } );
  14972. // Radios and checkboxes getter/setter
  14973. jQuery.each( [ "radio", "checkbox" ], function() {
  14974. jQuery.valHooks[ this ] = {
  14975. set: function( elem, value ) {
  14976. if ( Array.isArray( value ) ) {
  14977. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14978. }
  14979. }
  14980. };
  14981. if ( !support.checkOn ) {
  14982. jQuery.valHooks[ this ].get = function( elem ) {
  14983. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14984. };
  14985. }
  14986. } );
  14987. // Return jQuery for attributes-only inclusion
  14988. support.focusin = "onfocusin" in window;
  14989. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14990. stopPropagationCallback = function( e ) {
  14991. e.stopPropagation();
  14992. };
  14993. jQuery.extend( jQuery.event, {
  14994. trigger: function( event, data, elem, onlyHandlers ) {
  14995. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14996. eventPath = [ elem || document ],
  14997. type = hasOwn.call( event, "type" ) ? event.type : event,
  14998. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14999. cur = lastElement = tmp = elem = elem || document;
  15000. // Don't do events on text and comment nodes
  15001. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  15002. return;
  15003. }
  15004. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  15005. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  15006. return;
  15007. }
  15008. if ( type.indexOf( "." ) > -1 ) {
  15009. // Namespaced trigger; create a regexp to match event type in handle()
  15010. namespaces = type.split( "." );
  15011. type = namespaces.shift();
  15012. namespaces.sort();
  15013. }
  15014. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  15015. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  15016. event = event[ jQuery.expando ] ?
  15017. event :
  15018. new jQuery.Event( type, typeof event === "object" && event );
  15019. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  15020. event.isTrigger = onlyHandlers ? 2 : 3;
  15021. event.namespace = namespaces.join( "." );
  15022. event.rnamespace = event.namespace ?
  15023. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  15024. null;
  15025. // Clean up the event in case it is being reused
  15026. event.result = undefined;
  15027. if ( !event.target ) {
  15028. event.target = elem;
  15029. }
  15030. // Clone any incoming data and prepend the event, creating the handler arg list
  15031. data = data == null ?
  15032. [ event ] :
  15033. jQuery.makeArray( data, [ event ] );
  15034. // Allow special events to draw outside the lines
  15035. special = jQuery.event.special[ type ] || {};
  15036. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  15037. return;
  15038. }
  15039. // Determine event propagation path in advance, per W3C events spec (#9951)
  15040. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  15041. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  15042. bubbleType = special.delegateType || type;
  15043. if ( !rfocusMorph.test( bubbleType + type ) ) {
  15044. cur = cur.parentNode;
  15045. }
  15046. for ( ; cur; cur = cur.parentNode ) {
  15047. eventPath.push( cur );
  15048. tmp = cur;
  15049. }
  15050. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  15051. if ( tmp === ( elem.ownerDocument || document ) ) {
  15052. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  15053. }
  15054. }
  15055. // Fire handlers on the event path
  15056. i = 0;
  15057. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  15058. lastElement = cur;
  15059. event.type = i > 1 ?
  15060. bubbleType :
  15061. special.bindType || type;
  15062. // jQuery handler
  15063. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  15064. dataPriv.get( cur, "handle" );
  15065. if ( handle ) {
  15066. handle.apply( cur, data );
  15067. }
  15068. // Native handler
  15069. handle = ontype && cur[ ontype ];
  15070. if ( handle && handle.apply && acceptData( cur ) ) {
  15071. event.result = handle.apply( cur, data );
  15072. if ( event.result === false ) {
  15073. event.preventDefault();
  15074. }
  15075. }
  15076. }
  15077. event.type = type;
  15078. // If nobody prevented the default action, do it now
  15079. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  15080. if ( ( !special._default ||
  15081. special._default.apply( eventPath.pop(), data ) === false ) &&
  15082. acceptData( elem ) ) {
  15083. // Call a native DOM method on the target with the same name as the event.
  15084. // Don't do default actions on window, that's where global variables be (#6170)
  15085. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  15086. // Don't re-trigger an onFOO event when we call its FOO() method
  15087. tmp = elem[ ontype ];
  15088. if ( tmp ) {
  15089. elem[ ontype ] = null;
  15090. }
  15091. // Prevent re-triggering of the same event, since we already bubbled it above
  15092. jQuery.event.triggered = type;
  15093. if ( event.isPropagationStopped() ) {
  15094. lastElement.addEventListener( type, stopPropagationCallback );
  15095. }
  15096. elem[ type ]();
  15097. if ( event.isPropagationStopped() ) {
  15098. lastElement.removeEventListener( type, stopPropagationCallback );
  15099. }
  15100. jQuery.event.triggered = undefined;
  15101. if ( tmp ) {
  15102. elem[ ontype ] = tmp;
  15103. }
  15104. }
  15105. }
  15106. }
  15107. return event.result;
  15108. },
  15109. // Piggyback on a donor event to simulate a different one
  15110. // Used only for `focus(in | out)` events
  15111. simulate: function( type, elem, event ) {
  15112. var e = jQuery.extend(
  15113. new jQuery.Event(),
  15114. event,
  15115. {
  15116. type: type,
  15117. isSimulated: true
  15118. }
  15119. );
  15120. jQuery.event.trigger( e, null, elem );
  15121. }
  15122. } );
  15123. jQuery.fn.extend( {
  15124. trigger: function( type, data ) {
  15125. return this.each( function() {
  15126. jQuery.event.trigger( type, data, this );
  15127. } );
  15128. },
  15129. triggerHandler: function( type, data ) {
  15130. var elem = this[ 0 ];
  15131. if ( elem ) {
  15132. return jQuery.event.trigger( type, data, elem, true );
  15133. }
  15134. }
  15135. } );
  15136. // Support: Firefox <=44
  15137. // Firefox doesn't have focus(in | out) events
  15138. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15139. //
  15140. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15141. // focus(in | out) events fire after focus & blur events,
  15142. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15143. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15144. if ( !support.focusin ) {
  15145. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15146. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15147. var handler = function( event ) {
  15148. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15149. };
  15150. jQuery.event.special[ fix ] = {
  15151. setup: function() {
  15152. var doc = this.ownerDocument || this,
  15153. attaches = dataPriv.access( doc, fix );
  15154. if ( !attaches ) {
  15155. doc.addEventListener( orig, handler, true );
  15156. }
  15157. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15158. },
  15159. teardown: function() {
  15160. var doc = this.ownerDocument || this,
  15161. attaches = dataPriv.access( doc, fix ) - 1;
  15162. if ( !attaches ) {
  15163. doc.removeEventListener( orig, handler, true );
  15164. dataPriv.remove( doc, fix );
  15165. } else {
  15166. dataPriv.access( doc, fix, attaches );
  15167. }
  15168. }
  15169. };
  15170. } );
  15171. }
  15172. var location = window.location;
  15173. var nonce = Date.now();
  15174. var rquery = ( /\?/ );
  15175. // Cross-browser xml parsing
  15176. jQuery.parseXML = function( data ) {
  15177. var xml;
  15178. if ( !data || typeof data !== "string" ) {
  15179. return null;
  15180. }
  15181. // Support: IE 9 - 11 only
  15182. // IE throws on parseFromString with invalid input.
  15183. try {
  15184. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15185. } catch ( e ) {
  15186. xml = undefined;
  15187. }
  15188. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15189. jQuery.error( "Invalid XML: " + data );
  15190. }
  15191. return xml;
  15192. };
  15193. var
  15194. rbracket = /\[\]$/,
  15195. rCRLF = /\r?\n/g,
  15196. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15197. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15198. function buildParams( prefix, obj, traditional, add ) {
  15199. var name;
  15200. if ( Array.isArray( obj ) ) {
  15201. // Serialize array item.
  15202. jQuery.each( obj, function( i, v ) {
  15203. if ( traditional || rbracket.test( prefix ) ) {
  15204. // Treat each array item as a scalar.
  15205. add( prefix, v );
  15206. } else {
  15207. // Item is non-scalar (array or object), encode its numeric index.
  15208. buildParams(
  15209. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15210. v,
  15211. traditional,
  15212. add
  15213. );
  15214. }
  15215. } );
  15216. } else if ( !traditional && toType( obj ) === "object" ) {
  15217. // Serialize object item.
  15218. for ( name in obj ) {
  15219. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15220. }
  15221. } else {
  15222. // Serialize scalar item.
  15223. add( prefix, obj );
  15224. }
  15225. }
  15226. // Serialize an array of form elements or a set of
  15227. // key/values into a query string
  15228. jQuery.param = function( a, traditional ) {
  15229. var prefix,
  15230. s = [],
  15231. add = function( key, valueOrFunction ) {
  15232. // If value is a function, invoke it and use its return value
  15233. var value = isFunction( valueOrFunction ) ?
  15234. valueOrFunction() :
  15235. valueOrFunction;
  15236. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15237. encodeURIComponent( value == null ? "" : value );
  15238. };
  15239. if ( a == null ) {
  15240. return "";
  15241. }
  15242. // If an array was passed in, assume that it is an array of form elements.
  15243. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15244. // Serialize the form elements
  15245. jQuery.each( a, function() {
  15246. add( this.name, this.value );
  15247. } );
  15248. } else {
  15249. // If traditional, encode the "old" way (the way 1.3.2 or older
  15250. // did it), otherwise encode params recursively.
  15251. for ( prefix in a ) {
  15252. buildParams( prefix, a[ prefix ], traditional, add );
  15253. }
  15254. }
  15255. // Return the resulting serialization
  15256. return s.join( "&" );
  15257. };
  15258. jQuery.fn.extend( {
  15259. serialize: function() {
  15260. return jQuery.param( this.serializeArray() );
  15261. },
  15262. serializeArray: function() {
  15263. return this.map( function() {
  15264. // Can add propHook for "elements" to filter or add form elements
  15265. var elements = jQuery.prop( this, "elements" );
  15266. return elements ? jQuery.makeArray( elements ) : this;
  15267. } )
  15268. .filter( function() {
  15269. var type = this.type;
  15270. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15271. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15272. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15273. ( this.checked || !rcheckableType.test( type ) );
  15274. } )
  15275. .map( function( i, elem ) {
  15276. var val = jQuery( this ).val();
  15277. if ( val == null ) {
  15278. return null;
  15279. }
  15280. if ( Array.isArray( val ) ) {
  15281. return jQuery.map( val, function( val ) {
  15282. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15283. } );
  15284. }
  15285. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15286. } ).get();
  15287. }
  15288. } );
  15289. var
  15290. r20 = /%20/g,
  15291. rhash = /#.*$/,
  15292. rantiCache = /([?&])_=[^&]*/,
  15293. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15294. // #7653, #8125, #8152: local protocol detection
  15295. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15296. rnoContent = /^(?:GET|HEAD)$/,
  15297. rprotocol = /^\/\//,
  15298. /* Prefilters
  15299. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15300. * 2) These are called:
  15301. * - BEFORE asking for a transport
  15302. * - AFTER param serialization (s.data is a string if s.processData is true)
  15303. * 3) key is the dataType
  15304. * 4) the catchall symbol "*" can be used
  15305. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15306. */
  15307. prefilters = {},
  15308. /* Transports bindings
  15309. * 1) key is the dataType
  15310. * 2) the catchall symbol "*" can be used
  15311. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15312. */
  15313. transports = {},
  15314. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15315. allTypes = "*/".concat( "*" ),
  15316. // Anchor tag for parsing the document origin
  15317. originAnchor = document.createElement( "a" );
  15318. originAnchor.href = location.href;
  15319. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15320. function addToPrefiltersOrTransports( structure ) {
  15321. // dataTypeExpression is optional and defaults to "*"
  15322. return function( dataTypeExpression, func ) {
  15323. if ( typeof dataTypeExpression !== "string" ) {
  15324. func = dataTypeExpression;
  15325. dataTypeExpression = "*";
  15326. }
  15327. var dataType,
  15328. i = 0,
  15329. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15330. if ( isFunction( func ) ) {
  15331. // For each dataType in the dataTypeExpression
  15332. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15333. // Prepend if requested
  15334. if ( dataType[ 0 ] === "+" ) {
  15335. dataType = dataType.slice( 1 ) || "*";
  15336. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15337. // Otherwise append
  15338. } else {
  15339. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15340. }
  15341. }
  15342. }
  15343. };
  15344. }
  15345. // Base inspection function for prefilters and transports
  15346. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15347. var inspected = {},
  15348. seekingTransport = ( structure === transports );
  15349. function inspect( dataType ) {
  15350. var selected;
  15351. inspected[ dataType ] = true;
  15352. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15353. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15354. if ( typeof dataTypeOrTransport === "string" &&
  15355. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15356. options.dataTypes.unshift( dataTypeOrTransport );
  15357. inspect( dataTypeOrTransport );
  15358. return false;
  15359. } else if ( seekingTransport ) {
  15360. return !( selected = dataTypeOrTransport );
  15361. }
  15362. } );
  15363. return selected;
  15364. }
  15365. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15366. }
  15367. // A special extend for ajax options
  15368. // that takes "flat" options (not to be deep extended)
  15369. // Fixes #9887
  15370. function ajaxExtend( target, src ) {
  15371. var key, deep,
  15372. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15373. for ( key in src ) {
  15374. if ( src[ key ] !== undefined ) {
  15375. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15376. }
  15377. }
  15378. if ( deep ) {
  15379. jQuery.extend( true, target, deep );
  15380. }
  15381. return target;
  15382. }
  15383. /* Handles responses to an ajax request:
  15384. * - finds the right dataType (mediates between content-type and expected dataType)
  15385. * - returns the corresponding response
  15386. */
  15387. function ajaxHandleResponses( s, jqXHR, responses ) {
  15388. var ct, type, finalDataType, firstDataType,
  15389. contents = s.contents,
  15390. dataTypes = s.dataTypes;
  15391. // Remove auto dataType and get content-type in the process
  15392. while ( dataTypes[ 0 ] === "*" ) {
  15393. dataTypes.shift();
  15394. if ( ct === undefined ) {
  15395. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15396. }
  15397. }
  15398. // Check if we're dealing with a known content-type
  15399. if ( ct ) {
  15400. for ( type in contents ) {
  15401. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15402. dataTypes.unshift( type );
  15403. break;
  15404. }
  15405. }
  15406. }
  15407. // Check to see if we have a response for the expected dataType
  15408. if ( dataTypes[ 0 ] in responses ) {
  15409. finalDataType = dataTypes[ 0 ];
  15410. } else {
  15411. // Try convertible dataTypes
  15412. for ( type in responses ) {
  15413. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15414. finalDataType = type;
  15415. break;
  15416. }
  15417. if ( !firstDataType ) {
  15418. firstDataType = type;
  15419. }
  15420. }
  15421. // Or just use first one
  15422. finalDataType = finalDataType || firstDataType;
  15423. }
  15424. // If we found a dataType
  15425. // We add the dataType to the list if needed
  15426. // and return the corresponding response
  15427. if ( finalDataType ) {
  15428. if ( finalDataType !== dataTypes[ 0 ] ) {
  15429. dataTypes.unshift( finalDataType );
  15430. }
  15431. return responses[ finalDataType ];
  15432. }
  15433. }
  15434. /* Chain conversions given the request and the original response
  15435. * Also sets the responseXXX fields on the jqXHR instance
  15436. */
  15437. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15438. var conv2, current, conv, tmp, prev,
  15439. converters = {},
  15440. // Work with a copy of dataTypes in case we need to modify it for conversion
  15441. dataTypes = s.dataTypes.slice();
  15442. // Create converters map with lowercased keys
  15443. if ( dataTypes[ 1 ] ) {
  15444. for ( conv in s.converters ) {
  15445. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15446. }
  15447. }
  15448. current = dataTypes.shift();
  15449. // Convert to each sequential dataType
  15450. while ( current ) {
  15451. if ( s.responseFields[ current ] ) {
  15452. jqXHR[ s.responseFields[ current ] ] = response;
  15453. }
  15454. // Apply the dataFilter if provided
  15455. if ( !prev && isSuccess && s.dataFilter ) {
  15456. response = s.dataFilter( response, s.dataType );
  15457. }
  15458. prev = current;
  15459. current = dataTypes.shift();
  15460. if ( current ) {
  15461. // There's only work to do if current dataType is non-auto
  15462. if ( current === "*" ) {
  15463. current = prev;
  15464. // Convert response if prev dataType is non-auto and differs from current
  15465. } else if ( prev !== "*" && prev !== current ) {
  15466. // Seek a direct converter
  15467. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15468. // If none found, seek a pair
  15469. if ( !conv ) {
  15470. for ( conv2 in converters ) {
  15471. // If conv2 outputs current
  15472. tmp = conv2.split( " " );
  15473. if ( tmp[ 1 ] === current ) {
  15474. // If prev can be converted to accepted input
  15475. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15476. converters[ "* " + tmp[ 0 ] ];
  15477. if ( conv ) {
  15478. // Condense equivalence converters
  15479. if ( conv === true ) {
  15480. conv = converters[ conv2 ];
  15481. // Otherwise, insert the intermediate dataType
  15482. } else if ( converters[ conv2 ] !== true ) {
  15483. current = tmp[ 0 ];
  15484. dataTypes.unshift( tmp[ 1 ] );
  15485. }
  15486. break;
  15487. }
  15488. }
  15489. }
  15490. }
  15491. // Apply converter (if not an equivalence)
  15492. if ( conv !== true ) {
  15493. // Unless errors are allowed to bubble, catch and return them
  15494. if ( conv && s.throws ) {
  15495. response = conv( response );
  15496. } else {
  15497. try {
  15498. response = conv( response );
  15499. } catch ( e ) {
  15500. return {
  15501. state: "parsererror",
  15502. error: conv ? e : "No conversion from " + prev + " to " + current
  15503. };
  15504. }
  15505. }
  15506. }
  15507. }
  15508. }
  15509. }
  15510. return { state: "success", data: response };
  15511. }
  15512. jQuery.extend( {
  15513. // Counter for holding the number of active queries
  15514. active: 0,
  15515. // Last-Modified header cache for next request
  15516. lastModified: {},
  15517. etag: {},
  15518. ajaxSettings: {
  15519. url: location.href,
  15520. type: "GET",
  15521. isLocal: rlocalProtocol.test( location.protocol ),
  15522. global: true,
  15523. processData: true,
  15524. async: true,
  15525. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15526. /*
  15527. timeout: 0,
  15528. data: null,
  15529. dataType: null,
  15530. username: null,
  15531. password: null,
  15532. cache: null,
  15533. throws: false,
  15534. traditional: false,
  15535. headers: {},
  15536. */
  15537. accepts: {
  15538. "*": allTypes,
  15539. text: "text/plain",
  15540. html: "text/html",
  15541. xml: "application/xml, text/xml",
  15542. json: "application/json, text/javascript"
  15543. },
  15544. contents: {
  15545. xml: /\bxml\b/,
  15546. html: /\bhtml/,
  15547. json: /\bjson\b/
  15548. },
  15549. responseFields: {
  15550. xml: "responseXML",
  15551. text: "responseText",
  15552. json: "responseJSON"
  15553. },
  15554. // Data converters
  15555. // Keys separate source (or catchall "*") and destination types with a single space
  15556. converters: {
  15557. // Convert anything to text
  15558. "* text": String,
  15559. // Text to html (true = no transformation)
  15560. "text html": true,
  15561. // Evaluate text as a json expression
  15562. "text json": JSON.parse,
  15563. // Parse text as xml
  15564. "text xml": jQuery.parseXML
  15565. },
  15566. // For options that shouldn't be deep extended:
  15567. // you can add your own custom options here if
  15568. // and when you create one that shouldn't be
  15569. // deep extended (see ajaxExtend)
  15570. flatOptions: {
  15571. url: true,
  15572. context: true
  15573. }
  15574. },
  15575. // Creates a full fledged settings object into target
  15576. // with both ajaxSettings and settings fields.
  15577. // If target is omitted, writes into ajaxSettings.
  15578. ajaxSetup: function( target, settings ) {
  15579. return settings ?
  15580. // Building a settings object
  15581. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15582. // Extending ajaxSettings
  15583. ajaxExtend( jQuery.ajaxSettings, target );
  15584. },
  15585. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15586. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15587. // Main method
  15588. ajax: function( url, options ) {
  15589. // If url is an object, simulate pre-1.5 signature
  15590. if ( typeof url === "object" ) {
  15591. options = url;
  15592. url = undefined;
  15593. }
  15594. // Force options to be an object
  15595. options = options || {};
  15596. var transport,
  15597. // URL without anti-cache param
  15598. cacheURL,
  15599. // Response headers
  15600. responseHeadersString,
  15601. responseHeaders,
  15602. // timeout handle
  15603. timeoutTimer,
  15604. // Url cleanup var
  15605. urlAnchor,
  15606. // Request state (becomes false upon send and true upon completion)
  15607. completed,
  15608. // To know if global events are to be dispatched
  15609. fireGlobals,
  15610. // Loop variable
  15611. i,
  15612. // uncached part of the url
  15613. uncached,
  15614. // Create the final options object
  15615. s = jQuery.ajaxSetup( {}, options ),
  15616. // Callbacks context
  15617. callbackContext = s.context || s,
  15618. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15619. globalEventContext = s.context &&
  15620. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15621. jQuery( callbackContext ) :
  15622. jQuery.event,
  15623. // Deferreds
  15624. deferred = jQuery.Deferred(),
  15625. completeDeferred = jQuery.Callbacks( "once memory" ),
  15626. // Status-dependent callbacks
  15627. statusCode = s.statusCode || {},
  15628. // Headers (they are sent all at once)
  15629. requestHeaders = {},
  15630. requestHeadersNames = {},
  15631. // Default abort message
  15632. strAbort = "canceled",
  15633. // Fake xhr
  15634. jqXHR = {
  15635. readyState: 0,
  15636. // Builds headers hashtable if needed
  15637. getResponseHeader: function( key ) {
  15638. var match;
  15639. if ( completed ) {
  15640. if ( !responseHeaders ) {
  15641. responseHeaders = {};
  15642. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15643. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15644. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15645. .concat( match[ 2 ] );
  15646. }
  15647. }
  15648. match = responseHeaders[ key.toLowerCase() + " " ];
  15649. }
  15650. return match == null ? null : match.join( ", " );
  15651. },
  15652. // Raw string
  15653. getAllResponseHeaders: function() {
  15654. return completed ? responseHeadersString : null;
  15655. },
  15656. // Caches the header
  15657. setRequestHeader: function( name, value ) {
  15658. if ( completed == null ) {
  15659. name = requestHeadersNames[ name.toLowerCase() ] =
  15660. requestHeadersNames[ name.toLowerCase() ] || name;
  15661. requestHeaders[ name ] = value;
  15662. }
  15663. return this;
  15664. },
  15665. // Overrides response content-type header
  15666. overrideMimeType: function( type ) {
  15667. if ( completed == null ) {
  15668. s.mimeType = type;
  15669. }
  15670. return this;
  15671. },
  15672. // Status-dependent callbacks
  15673. statusCode: function( map ) {
  15674. var code;
  15675. if ( map ) {
  15676. if ( completed ) {
  15677. // Execute the appropriate callbacks
  15678. jqXHR.always( map[ jqXHR.status ] );
  15679. } else {
  15680. // Lazy-add the new callbacks in a way that preserves old ones
  15681. for ( code in map ) {
  15682. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15683. }
  15684. }
  15685. }
  15686. return this;
  15687. },
  15688. // Cancel the request
  15689. abort: function( statusText ) {
  15690. var finalText = statusText || strAbort;
  15691. if ( transport ) {
  15692. transport.abort( finalText );
  15693. }
  15694. done( 0, finalText );
  15695. return this;
  15696. }
  15697. };
  15698. // Attach deferreds
  15699. deferred.promise( jqXHR );
  15700. // Add protocol if not provided (prefilters might expect it)
  15701. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15702. // We also use the url parameter if available
  15703. s.url = ( ( url || s.url || location.href ) + "" )
  15704. .replace( rprotocol, location.protocol + "//" );
  15705. // Alias method option to type as per ticket #12004
  15706. s.type = options.method || options.type || s.method || s.type;
  15707. // Extract dataTypes list
  15708. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15709. // A cross-domain request is in order when the origin doesn't match the current origin.
  15710. if ( s.crossDomain == null ) {
  15711. urlAnchor = document.createElement( "a" );
  15712. // Support: IE <=8 - 11, Edge 12 - 15
  15713. // IE throws exception on accessing the href property if url is malformed,
  15714. // e.g. http://example.com:80x/
  15715. try {
  15716. urlAnchor.href = s.url;
  15717. // Support: IE <=8 - 11 only
  15718. // Anchor's host property isn't correctly set when s.url is relative
  15719. urlAnchor.href = urlAnchor.href;
  15720. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15721. urlAnchor.protocol + "//" + urlAnchor.host;
  15722. } catch ( e ) {
  15723. // If there is an error parsing the URL, assume it is crossDomain,
  15724. // it can be rejected by the transport if it is invalid
  15725. s.crossDomain = true;
  15726. }
  15727. }
  15728. // Convert data if not already a string
  15729. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15730. s.data = jQuery.param( s.data, s.traditional );
  15731. }
  15732. // Apply prefilters
  15733. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15734. // If request was aborted inside a prefilter, stop there
  15735. if ( completed ) {
  15736. return jqXHR;
  15737. }
  15738. // We can fire global events as of now if asked to
  15739. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15740. fireGlobals = jQuery.event && s.global;
  15741. // Watch for a new set of requests
  15742. if ( fireGlobals && jQuery.active++ === 0 ) {
  15743. jQuery.event.trigger( "ajaxStart" );
  15744. }
  15745. // Uppercase the type
  15746. s.type = s.type.toUpperCase();
  15747. // Determine if request has content
  15748. s.hasContent = !rnoContent.test( s.type );
  15749. // Save the URL in case we're toying with the If-Modified-Since
  15750. // and/or If-None-Match header later on
  15751. // Remove hash to simplify url manipulation
  15752. cacheURL = s.url.replace( rhash, "" );
  15753. // More options handling for requests with no content
  15754. if ( !s.hasContent ) {
  15755. // Remember the hash so we can put it back
  15756. uncached = s.url.slice( cacheURL.length );
  15757. // If data is available and should be processed, append data to url
  15758. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15759. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15760. // #9682: remove data so that it's not used in an eventual retry
  15761. delete s.data;
  15762. }
  15763. // Add or update anti-cache param if needed
  15764. if ( s.cache === false ) {
  15765. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15766. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15767. }
  15768. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15769. s.url = cacheURL + uncached;
  15770. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15771. } else if ( s.data && s.processData &&
  15772. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15773. s.data = s.data.replace( r20, "+" );
  15774. }
  15775. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15776. if ( s.ifModified ) {
  15777. if ( jQuery.lastModified[ cacheURL ] ) {
  15778. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15779. }
  15780. if ( jQuery.etag[ cacheURL ] ) {
  15781. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15782. }
  15783. }
  15784. // Set the correct header, if data is being sent
  15785. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15786. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15787. }
  15788. // Set the Accepts header for the server, depending on the dataType
  15789. jqXHR.setRequestHeader(
  15790. "Accept",
  15791. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15792. s.accepts[ s.dataTypes[ 0 ] ] +
  15793. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15794. s.accepts[ "*" ]
  15795. );
  15796. // Check for headers option
  15797. for ( i in s.headers ) {
  15798. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15799. }
  15800. // Allow custom headers/mimetypes and early abort
  15801. if ( s.beforeSend &&
  15802. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15803. // Abort if not done already and return
  15804. return jqXHR.abort();
  15805. }
  15806. // Aborting is no longer a cancellation
  15807. strAbort = "abort";
  15808. // Install callbacks on deferreds
  15809. completeDeferred.add( s.complete );
  15810. jqXHR.done( s.success );
  15811. jqXHR.fail( s.error );
  15812. // Get transport
  15813. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15814. // If no transport, we auto-abort
  15815. if ( !transport ) {
  15816. done( -1, "No Transport" );
  15817. } else {
  15818. jqXHR.readyState = 1;
  15819. // Send global event
  15820. if ( fireGlobals ) {
  15821. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15822. }
  15823. // If request was aborted inside ajaxSend, stop there
  15824. if ( completed ) {
  15825. return jqXHR;
  15826. }
  15827. // Timeout
  15828. if ( s.async && s.timeout > 0 ) {
  15829. timeoutTimer = window.setTimeout( function() {
  15830. jqXHR.abort( "timeout" );
  15831. }, s.timeout );
  15832. }
  15833. try {
  15834. completed = false;
  15835. transport.send( requestHeaders, done );
  15836. } catch ( e ) {
  15837. // Rethrow post-completion exceptions
  15838. if ( completed ) {
  15839. throw e;
  15840. }
  15841. // Propagate others as results
  15842. done( -1, e );
  15843. }
  15844. }
  15845. // Callback for when everything is done
  15846. function done( status, nativeStatusText, responses, headers ) {
  15847. var isSuccess, success, error, response, modified,
  15848. statusText = nativeStatusText;
  15849. // Ignore repeat invocations
  15850. if ( completed ) {
  15851. return;
  15852. }
  15853. completed = true;
  15854. // Clear timeout if it exists
  15855. if ( timeoutTimer ) {
  15856. window.clearTimeout( timeoutTimer );
  15857. }
  15858. // Dereference transport for early garbage collection
  15859. // (no matter how long the jqXHR object will be used)
  15860. transport = undefined;
  15861. // Cache response headers
  15862. responseHeadersString = headers || "";
  15863. // Set readyState
  15864. jqXHR.readyState = status > 0 ? 4 : 0;
  15865. // Determine if successful
  15866. isSuccess = status >= 200 && status < 300 || status === 304;
  15867. // Get response data
  15868. if ( responses ) {
  15869. response = ajaxHandleResponses( s, jqXHR, responses );
  15870. }
  15871. // Convert no matter what (that way responseXXX fields are always set)
  15872. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15873. // If successful, handle type chaining
  15874. if ( isSuccess ) {
  15875. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15876. if ( s.ifModified ) {
  15877. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15878. if ( modified ) {
  15879. jQuery.lastModified[ cacheURL ] = modified;
  15880. }
  15881. modified = jqXHR.getResponseHeader( "etag" );
  15882. if ( modified ) {
  15883. jQuery.etag[ cacheURL ] = modified;
  15884. }
  15885. }
  15886. // if no content
  15887. if ( status === 204 || s.type === "HEAD" ) {
  15888. statusText = "nocontent";
  15889. // if not modified
  15890. } else if ( status === 304 ) {
  15891. statusText = "notmodified";
  15892. // If we have data, let's convert it
  15893. } else {
  15894. statusText = response.state;
  15895. success = response.data;
  15896. error = response.error;
  15897. isSuccess = !error;
  15898. }
  15899. } else {
  15900. // Extract error from statusText and normalize for non-aborts
  15901. error = statusText;
  15902. if ( status || !statusText ) {
  15903. statusText = "error";
  15904. if ( status < 0 ) {
  15905. status = 0;
  15906. }
  15907. }
  15908. }
  15909. // Set data for the fake xhr object
  15910. jqXHR.status = status;
  15911. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15912. // Success/Error
  15913. if ( isSuccess ) {
  15914. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15915. } else {
  15916. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15917. }
  15918. // Status-dependent callbacks
  15919. jqXHR.statusCode( statusCode );
  15920. statusCode = undefined;
  15921. if ( fireGlobals ) {
  15922. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15923. [ jqXHR, s, isSuccess ? success : error ] );
  15924. }
  15925. // Complete
  15926. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15927. if ( fireGlobals ) {
  15928. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15929. // Handle the global AJAX counter
  15930. if ( !( --jQuery.active ) ) {
  15931. jQuery.event.trigger( "ajaxStop" );
  15932. }
  15933. }
  15934. }
  15935. return jqXHR;
  15936. },
  15937. getJSON: function( url, data, callback ) {
  15938. return jQuery.get( url, data, callback, "json" );
  15939. },
  15940. getScript: function( url, callback ) {
  15941. return jQuery.get( url, undefined, callback, "script" );
  15942. }
  15943. } );
  15944. jQuery.each( [ "get", "post" ], function( i, method ) {
  15945. jQuery[ method ] = function( url, data, callback, type ) {
  15946. // Shift arguments if data argument was omitted
  15947. if ( isFunction( data ) ) {
  15948. type = type || callback;
  15949. callback = data;
  15950. data = undefined;
  15951. }
  15952. // The url can be an options object (which then must have .url)
  15953. return jQuery.ajax( jQuery.extend( {
  15954. url: url,
  15955. type: method,
  15956. dataType: type,
  15957. data: data,
  15958. success: callback
  15959. }, jQuery.isPlainObject( url ) && url ) );
  15960. };
  15961. } );
  15962. jQuery._evalUrl = function( url, options ) {
  15963. return jQuery.ajax( {
  15964. url: url,
  15965. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15966. type: "GET",
  15967. dataType: "script",
  15968. cache: true,
  15969. async: false,
  15970. global: false,
  15971. // Only evaluate the response if it is successful (gh-4126)
  15972. // dataFilter is not invoked for failure responses, so using it instead
  15973. // of the default converter is kludgy but it works.
  15974. converters: {
  15975. "text script": function() {}
  15976. },
  15977. dataFilter: function( response ) {
  15978. jQuery.globalEval( response, options );
  15979. }
  15980. } );
  15981. };
  15982. jQuery.fn.extend( {
  15983. wrapAll: function( html ) {
  15984. var wrap;
  15985. if ( this[ 0 ] ) {
  15986. if ( isFunction( html ) ) {
  15987. html = html.call( this[ 0 ] );
  15988. }
  15989. // The elements to wrap the target around
  15990. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15991. if ( this[ 0 ].parentNode ) {
  15992. wrap.insertBefore( this[ 0 ] );
  15993. }
  15994. wrap.map( function() {
  15995. var elem = this;
  15996. while ( elem.firstElementChild ) {
  15997. elem = elem.firstElementChild;
  15998. }
  15999. return elem;
  16000. } ).append( this );
  16001. }
  16002. return this;
  16003. },
  16004. wrapInner: function( html ) {
  16005. if ( isFunction( html ) ) {
  16006. return this.each( function( i ) {
  16007. jQuery( this ).wrapInner( html.call( this, i ) );
  16008. } );
  16009. }
  16010. return this.each( function() {
  16011. var self = jQuery( this ),
  16012. contents = self.contents();
  16013. if ( contents.length ) {
  16014. contents.wrapAll( html );
  16015. } else {
  16016. self.append( html );
  16017. }
  16018. } );
  16019. },
  16020. wrap: function( html ) {
  16021. var htmlIsFunction = isFunction( html );
  16022. return this.each( function( i ) {
  16023. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  16024. } );
  16025. },
  16026. unwrap: function( selector ) {
  16027. this.parent( selector ).not( "body" ).each( function() {
  16028. jQuery( this ).replaceWith( this.childNodes );
  16029. } );
  16030. return this;
  16031. }
  16032. } );
  16033. jQuery.expr.pseudos.hidden = function( elem ) {
  16034. return !jQuery.expr.pseudos.visible( elem );
  16035. };
  16036. jQuery.expr.pseudos.visible = function( elem ) {
  16037. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  16038. };
  16039. jQuery.ajaxSettings.xhr = function() {
  16040. try {
  16041. return new window.XMLHttpRequest();
  16042. } catch ( e ) {}
  16043. };
  16044. var xhrSuccessStatus = {
  16045. // File protocol always yields status code 0, assume 200
  16046. 0: 200,
  16047. // Support: IE <=9 only
  16048. // #1450: sometimes IE returns 1223 when it should be 204
  16049. 1223: 204
  16050. },
  16051. xhrSupported = jQuery.ajaxSettings.xhr();
  16052. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  16053. support.ajax = xhrSupported = !!xhrSupported;
  16054. jQuery.ajaxTransport( function( options ) {
  16055. var callback, errorCallback;
  16056. // Cross domain only allowed if supported through XMLHttpRequest
  16057. if ( support.cors || xhrSupported && !options.crossDomain ) {
  16058. return {
  16059. send: function( headers, complete ) {
  16060. var i,
  16061. xhr = options.xhr();
  16062. xhr.open(
  16063. options.type,
  16064. options.url,
  16065. options.async,
  16066. options.username,
  16067. options.password
  16068. );
  16069. // Apply custom fields if provided
  16070. if ( options.xhrFields ) {
  16071. for ( i in options.xhrFields ) {
  16072. xhr[ i ] = options.xhrFields[ i ];
  16073. }
  16074. }
  16075. // Override mime type if needed
  16076. if ( options.mimeType && xhr.overrideMimeType ) {
  16077. xhr.overrideMimeType( options.mimeType );
  16078. }
  16079. // X-Requested-With header
  16080. // For cross-domain requests, seeing as conditions for a preflight are
  16081. // akin to a jigsaw puzzle, we simply never set it to be sure.
  16082. // (it can always be set on a per-request basis or even using ajaxSetup)
  16083. // For same-domain requests, won't change header if already provided.
  16084. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  16085. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  16086. }
  16087. // Set headers
  16088. for ( i in headers ) {
  16089. xhr.setRequestHeader( i, headers[ i ] );
  16090. }
  16091. // Callback
  16092. callback = function( type ) {
  16093. return function() {
  16094. if ( callback ) {
  16095. callback = errorCallback = xhr.onload =
  16096. xhr.onerror = xhr.onabort = xhr.ontimeout =
  16097. xhr.onreadystatechange = null;
  16098. if ( type === "abort" ) {
  16099. xhr.abort();
  16100. } else if ( type === "error" ) {
  16101. // Support: IE <=9 only
  16102. // On a manual native abort, IE9 throws
  16103. // errors on any property access that is not readyState
  16104. if ( typeof xhr.status !== "number" ) {
  16105. complete( 0, "error" );
  16106. } else {
  16107. complete(
  16108. // File: protocol always yields status 0; see #8605, #14207
  16109. xhr.status,
  16110. xhr.statusText
  16111. );
  16112. }
  16113. } else {
  16114. complete(
  16115. xhrSuccessStatus[ xhr.status ] || xhr.status,
  16116. xhr.statusText,
  16117. // Support: IE <=9 only
  16118. // IE9 has no XHR2 but throws on binary (trac-11426)
  16119. // For XHR2 non-text, let the caller handle it (gh-2498)
  16120. ( xhr.responseType || "text" ) !== "text" ||
  16121. typeof xhr.responseText !== "string" ?
  16122. { binary: xhr.response } :
  16123. { text: xhr.responseText },
  16124. xhr.getAllResponseHeaders()
  16125. );
  16126. }
  16127. }
  16128. };
  16129. };
  16130. // Listen to events
  16131. xhr.onload = callback();
  16132. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16133. // Support: IE 9 only
  16134. // Use onreadystatechange to replace onabort
  16135. // to handle uncaught aborts
  16136. if ( xhr.onabort !== undefined ) {
  16137. xhr.onabort = errorCallback;
  16138. } else {
  16139. xhr.onreadystatechange = function() {
  16140. // Check readyState before timeout as it changes
  16141. if ( xhr.readyState === 4 ) {
  16142. // Allow onerror to be called first,
  16143. // but that will not handle a native abort
  16144. // Also, save errorCallback to a variable
  16145. // as xhr.onerror cannot be accessed
  16146. window.setTimeout( function() {
  16147. if ( callback ) {
  16148. errorCallback();
  16149. }
  16150. } );
  16151. }
  16152. };
  16153. }
  16154. // Create the abort callback
  16155. callback = callback( "abort" );
  16156. try {
  16157. // Do send the request (this may raise an exception)
  16158. xhr.send( options.hasContent && options.data || null );
  16159. } catch ( e ) {
  16160. // #14683: Only rethrow if this hasn't been notified as an error yet
  16161. if ( callback ) {
  16162. throw e;
  16163. }
  16164. }
  16165. },
  16166. abort: function() {
  16167. if ( callback ) {
  16168. callback();
  16169. }
  16170. }
  16171. };
  16172. }
  16173. } );
  16174. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16175. jQuery.ajaxPrefilter( function( s ) {
  16176. if ( s.crossDomain ) {
  16177. s.contents.script = false;
  16178. }
  16179. } );
  16180. // Install script dataType
  16181. jQuery.ajaxSetup( {
  16182. accepts: {
  16183. script: "text/javascript, application/javascript, " +
  16184. "application/ecmascript, application/x-ecmascript"
  16185. },
  16186. contents: {
  16187. script: /\b(?:java|ecma)script\b/
  16188. },
  16189. converters: {
  16190. "text script": function( text ) {
  16191. jQuery.globalEval( text );
  16192. return text;
  16193. }
  16194. }
  16195. } );
  16196. // Handle cache's special case and crossDomain
  16197. jQuery.ajaxPrefilter( "script", function( s ) {
  16198. if ( s.cache === undefined ) {
  16199. s.cache = false;
  16200. }
  16201. if ( s.crossDomain ) {
  16202. s.type = "GET";
  16203. }
  16204. } );
  16205. // Bind script tag hack transport
  16206. jQuery.ajaxTransport( "script", function( s ) {
  16207. // This transport only deals with cross domain or forced-by-attrs requests
  16208. if ( s.crossDomain || s.scriptAttrs ) {
  16209. var script, callback;
  16210. return {
  16211. send: function( _, complete ) {
  16212. script = jQuery( "<script>" )
  16213. .attr( s.scriptAttrs || {} )
  16214. .prop( { charset: s.scriptCharset, src: s.url } )
  16215. .on( "load error", callback = function( evt ) {
  16216. script.remove();
  16217. callback = null;
  16218. if ( evt ) {
  16219. complete( evt.type === "error" ? 404 : 200, evt.type );
  16220. }
  16221. } );
  16222. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16223. document.head.appendChild( script[ 0 ] );
  16224. },
  16225. abort: function() {
  16226. if ( callback ) {
  16227. callback();
  16228. }
  16229. }
  16230. };
  16231. }
  16232. } );
  16233. var oldCallbacks = [],
  16234. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16235. // Default jsonp settings
  16236. jQuery.ajaxSetup( {
  16237. jsonp: "callback",
  16238. jsonpCallback: function() {
  16239. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16240. this[ callback ] = true;
  16241. return callback;
  16242. }
  16243. } );
  16244. // Detect, normalize options and install callbacks for jsonp requests
  16245. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16246. var callbackName, overwritten, responseContainer,
  16247. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16248. "url" :
  16249. typeof s.data === "string" &&
  16250. ( s.contentType || "" )
  16251. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16252. rjsonp.test( s.data ) && "data"
  16253. );
  16254. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16255. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16256. // Get callback name, remembering preexisting value associated with it
  16257. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16258. s.jsonpCallback() :
  16259. s.jsonpCallback;
  16260. // Insert callback into url or form data
  16261. if ( jsonProp ) {
  16262. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16263. } else if ( s.jsonp !== false ) {
  16264. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16265. }
  16266. // Use data converter to retrieve json after script execution
  16267. s.converters[ "script json" ] = function() {
  16268. if ( !responseContainer ) {
  16269. jQuery.error( callbackName + " was not called" );
  16270. }
  16271. return responseContainer[ 0 ];
  16272. };
  16273. // Force json dataType
  16274. s.dataTypes[ 0 ] = "json";
  16275. // Install callback
  16276. overwritten = window[ callbackName ];
  16277. window[ callbackName ] = function() {
  16278. responseContainer = arguments;
  16279. };
  16280. // Clean-up function (fires after converters)
  16281. jqXHR.always( function() {
  16282. // If previous value didn't exist - remove it
  16283. if ( overwritten === undefined ) {
  16284. jQuery( window ).removeProp( callbackName );
  16285. // Otherwise restore preexisting value
  16286. } else {
  16287. window[ callbackName ] = overwritten;
  16288. }
  16289. // Save back as free
  16290. if ( s[ callbackName ] ) {
  16291. // Make sure that re-using the options doesn't screw things around
  16292. s.jsonpCallback = originalSettings.jsonpCallback;
  16293. // Save the callback name for future use
  16294. oldCallbacks.push( callbackName );
  16295. }
  16296. // Call if it was a function and we have a response
  16297. if ( responseContainer && isFunction( overwritten ) ) {
  16298. overwritten( responseContainer[ 0 ] );
  16299. }
  16300. responseContainer = overwritten = undefined;
  16301. } );
  16302. // Delegate to script
  16303. return "script";
  16304. }
  16305. } );
  16306. // Support: Safari 8 only
  16307. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16308. // collapse sibling forms: the second one becomes a child of the first one.
  16309. // Because of that, this security measure has to be disabled in Safari 8.
  16310. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16311. support.createHTMLDocument = ( function() {
  16312. var body = document.implementation.createHTMLDocument( "" ).body;
  16313. body.innerHTML = "<form></form><form></form>";
  16314. return body.childNodes.length === 2;
  16315. } )();
  16316. // Argument "data" should be string of html
  16317. // context (optional): If specified, the fragment will be created in this context,
  16318. // defaults to document
  16319. // keepScripts (optional): If true, will include scripts passed in the html string
  16320. jQuery.parseHTML = function( data, context, keepScripts ) {
  16321. if ( typeof data !== "string" ) {
  16322. return [];
  16323. }
  16324. if ( typeof context === "boolean" ) {
  16325. keepScripts = context;
  16326. context = false;
  16327. }
  16328. var base, parsed, scripts;
  16329. if ( !context ) {
  16330. // Stop scripts or inline event handlers from being executed immediately
  16331. // by using document.implementation
  16332. if ( support.createHTMLDocument ) {
  16333. context = document.implementation.createHTMLDocument( "" );
  16334. // Set the base href for the created document
  16335. // so any parsed elements with URLs
  16336. // are based on the document's URL (gh-2965)
  16337. base = context.createElement( "base" );
  16338. base.href = document.location.href;
  16339. context.head.appendChild( base );
  16340. } else {
  16341. context = document;
  16342. }
  16343. }
  16344. parsed = rsingleTag.exec( data );
  16345. scripts = !keepScripts && [];
  16346. // Single tag
  16347. if ( parsed ) {
  16348. return [ context.createElement( parsed[ 1 ] ) ];
  16349. }
  16350. parsed = buildFragment( [ data ], context, scripts );
  16351. if ( scripts && scripts.length ) {
  16352. jQuery( scripts ).remove();
  16353. }
  16354. return jQuery.merge( [], parsed.childNodes );
  16355. };
  16356. /**
  16357. * Load a url into a page
  16358. */
  16359. jQuery.fn.load = function( url, params, callback ) {
  16360. var selector, type, response,
  16361. self = this,
  16362. off = url.indexOf( " " );
  16363. if ( off > -1 ) {
  16364. selector = stripAndCollapse( url.slice( off ) );
  16365. url = url.slice( 0, off );
  16366. }
  16367. // If it's a function
  16368. if ( isFunction( params ) ) {
  16369. // We assume that it's the callback
  16370. callback = params;
  16371. params = undefined;
  16372. // Otherwise, build a param string
  16373. } else if ( params && typeof params === "object" ) {
  16374. type = "POST";
  16375. }
  16376. // If we have elements to modify, make the request
  16377. if ( self.length > 0 ) {
  16378. jQuery.ajax( {
  16379. url: url,
  16380. // If "type" variable is undefined, then "GET" method will be used.
  16381. // Make value of this field explicit since
  16382. // user can override it through ajaxSetup method
  16383. type: type || "GET",
  16384. dataType: "html",
  16385. data: params
  16386. } ).done( function( responseText ) {
  16387. // Save response for use in complete callback
  16388. response = arguments;
  16389. self.html( selector ?
  16390. // If a selector was specified, locate the right elements in a dummy div
  16391. // Exclude scripts to avoid IE 'Permission Denied' errors
  16392. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16393. // Otherwise use the full result
  16394. responseText );
  16395. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16396. // but they are ignored because response was set above.
  16397. // If it fails, this function gets "jqXHR", "status", "error"
  16398. } ).always( callback && function( jqXHR, status ) {
  16399. self.each( function() {
  16400. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16401. } );
  16402. } );
  16403. }
  16404. return this;
  16405. };
  16406. // Attach a bunch of functions for handling common AJAX events
  16407. jQuery.each( [
  16408. "ajaxStart",
  16409. "ajaxStop",
  16410. "ajaxComplete",
  16411. "ajaxError",
  16412. "ajaxSuccess",
  16413. "ajaxSend"
  16414. ], function( i, type ) {
  16415. jQuery.fn[ type ] = function( fn ) {
  16416. return this.on( type, fn );
  16417. };
  16418. } );
  16419. jQuery.expr.pseudos.animated = function( elem ) {
  16420. return jQuery.grep( jQuery.timers, function( fn ) {
  16421. return elem === fn.elem;
  16422. } ).length;
  16423. };
  16424. jQuery.offset = {
  16425. setOffset: function( elem, options, i ) {
  16426. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16427. position = jQuery.css( elem, "position" ),
  16428. curElem = jQuery( elem ),
  16429. props = {};
  16430. // Set position first, in-case top/left are set even on static elem
  16431. if ( position === "static" ) {
  16432. elem.style.position = "relative";
  16433. }
  16434. curOffset = curElem.offset();
  16435. curCSSTop = jQuery.css( elem, "top" );
  16436. curCSSLeft = jQuery.css( elem, "left" );
  16437. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16438. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16439. // Need to be able to calculate position if either
  16440. // top or left is auto and position is either absolute or fixed
  16441. if ( calculatePosition ) {
  16442. curPosition = curElem.position();
  16443. curTop = curPosition.top;
  16444. curLeft = curPosition.left;
  16445. } else {
  16446. curTop = parseFloat( curCSSTop ) || 0;
  16447. curLeft = parseFloat( curCSSLeft ) || 0;
  16448. }
  16449. if ( isFunction( options ) ) {
  16450. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16451. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16452. }
  16453. if ( options.top != null ) {
  16454. props.top = ( options.top - curOffset.top ) + curTop;
  16455. }
  16456. if ( options.left != null ) {
  16457. props.left = ( options.left - curOffset.left ) + curLeft;
  16458. }
  16459. if ( "using" in options ) {
  16460. options.using.call( elem, props );
  16461. } else {
  16462. curElem.css( props );
  16463. }
  16464. }
  16465. };
  16466. jQuery.fn.extend( {
  16467. // offset() relates an element's border box to the document origin
  16468. offset: function( options ) {
  16469. // Preserve chaining for setter
  16470. if ( arguments.length ) {
  16471. return options === undefined ?
  16472. this :
  16473. this.each( function( i ) {
  16474. jQuery.offset.setOffset( this, options, i );
  16475. } );
  16476. }
  16477. var rect, win,
  16478. elem = this[ 0 ];
  16479. if ( !elem ) {
  16480. return;
  16481. }
  16482. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16483. // Support: IE <=11 only
  16484. // Running getBoundingClientRect on a
  16485. // disconnected node in IE throws an error
  16486. if ( !elem.getClientRects().length ) {
  16487. return { top: 0, left: 0 };
  16488. }
  16489. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16490. rect = elem.getBoundingClientRect();
  16491. win = elem.ownerDocument.defaultView;
  16492. return {
  16493. top: rect.top + win.pageYOffset,
  16494. left: rect.left + win.pageXOffset
  16495. };
  16496. },
  16497. // position() relates an element's margin box to its offset parent's padding box
  16498. // This corresponds to the behavior of CSS absolute positioning
  16499. position: function() {
  16500. if ( !this[ 0 ] ) {
  16501. return;
  16502. }
  16503. var offsetParent, offset, doc,
  16504. elem = this[ 0 ],
  16505. parentOffset = { top: 0, left: 0 };
  16506. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16507. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16508. // Assume position:fixed implies availability of getBoundingClientRect
  16509. offset = elem.getBoundingClientRect();
  16510. } else {
  16511. offset = this.offset();
  16512. // Account for the *real* offset parent, which can be the document or its root element
  16513. // when a statically positioned element is identified
  16514. doc = elem.ownerDocument;
  16515. offsetParent = elem.offsetParent || doc.documentElement;
  16516. while ( offsetParent &&
  16517. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16518. jQuery.css( offsetParent, "position" ) === "static" ) {
  16519. offsetParent = offsetParent.parentNode;
  16520. }
  16521. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16522. // Incorporate borders into its offset, since they are outside its content origin
  16523. parentOffset = jQuery( offsetParent ).offset();
  16524. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16525. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16526. }
  16527. }
  16528. // Subtract parent offsets and element margins
  16529. return {
  16530. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16531. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16532. };
  16533. },
  16534. // This method will return documentElement in the following cases:
  16535. // 1) For the element inside the iframe without offsetParent, this method will return
  16536. // documentElement of the parent window
  16537. // 2) For the hidden or detached element
  16538. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16539. //
  16540. // but those exceptions were never presented as a real life use-cases
  16541. // and might be considered as more preferable results.
  16542. //
  16543. // This logic, however, is not guaranteed and can change at any point in the future
  16544. offsetParent: function() {
  16545. return this.map( function() {
  16546. var offsetParent = this.offsetParent;
  16547. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16548. offsetParent = offsetParent.offsetParent;
  16549. }
  16550. return offsetParent || documentElement;
  16551. } );
  16552. }
  16553. } );
  16554. // Create scrollLeft and scrollTop methods
  16555. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16556. var top = "pageYOffset" === prop;
  16557. jQuery.fn[ method ] = function( val ) {
  16558. return access( this, function( elem, method, val ) {
  16559. // Coalesce documents and windows
  16560. var win;
  16561. if ( isWindow( elem ) ) {
  16562. win = elem;
  16563. } else if ( elem.nodeType === 9 ) {
  16564. win = elem.defaultView;
  16565. }
  16566. if ( val === undefined ) {
  16567. return win ? win[ prop ] : elem[ method ];
  16568. }
  16569. if ( win ) {
  16570. win.scrollTo(
  16571. !top ? val : win.pageXOffset,
  16572. top ? val : win.pageYOffset
  16573. );
  16574. } else {
  16575. elem[ method ] = val;
  16576. }
  16577. }, method, val, arguments.length );
  16578. };
  16579. } );
  16580. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16581. // Add the top/left cssHooks using jQuery.fn.position
  16582. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16583. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16584. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16585. // rather than make the css module depend on the offset module, just check for it here
  16586. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16587. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16588. function( elem, computed ) {
  16589. if ( computed ) {
  16590. computed = curCSS( elem, prop );
  16591. // If curCSS returns percentage, fallback to offset
  16592. return rnumnonpx.test( computed ) ?
  16593. jQuery( elem ).position()[ prop ] + "px" :
  16594. computed;
  16595. }
  16596. }
  16597. );
  16598. } );
  16599. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16600. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16601. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16602. function( defaultExtra, funcName ) {
  16603. // Margin is only for outerHeight, outerWidth
  16604. jQuery.fn[ funcName ] = function( margin, value ) {
  16605. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16606. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16607. return access( this, function( elem, type, value ) {
  16608. var doc;
  16609. if ( isWindow( elem ) ) {
  16610. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16611. return funcName.indexOf( "outer" ) === 0 ?
  16612. elem[ "inner" + name ] :
  16613. elem.document.documentElement[ "client" + name ];
  16614. }
  16615. // Get document width or height
  16616. if ( elem.nodeType === 9 ) {
  16617. doc = elem.documentElement;
  16618. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16619. // whichever is greatest
  16620. return Math.max(
  16621. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16622. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16623. doc[ "client" + name ]
  16624. );
  16625. }
  16626. return value === undefined ?
  16627. // Get width or height on the element, requesting but not forcing parseFloat
  16628. jQuery.css( elem, type, extra ) :
  16629. // Set width or height on the element
  16630. jQuery.style( elem, type, value, extra );
  16631. }, type, chainable ? margin : undefined, chainable );
  16632. };
  16633. } );
  16634. } );
  16635. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16636. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16637. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16638. function( i, name ) {
  16639. // Handle event binding
  16640. jQuery.fn[ name ] = function( data, fn ) {
  16641. return arguments.length > 0 ?
  16642. this.on( name, null, data, fn ) :
  16643. this.trigger( name );
  16644. };
  16645. } );
  16646. jQuery.fn.extend( {
  16647. hover: function( fnOver, fnOut ) {
  16648. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16649. }
  16650. } );
  16651. jQuery.fn.extend( {
  16652. bind: function( types, data, fn ) {
  16653. return this.on( types, null, data, fn );
  16654. },
  16655. unbind: function( types, fn ) {
  16656. return this.off( types, null, fn );
  16657. },
  16658. delegate: function( selector, types, data, fn ) {
  16659. return this.on( types, selector, data, fn );
  16660. },
  16661. undelegate: function( selector, types, fn ) {
  16662. // ( namespace ) or ( selector, types [, fn] )
  16663. return arguments.length === 1 ?
  16664. this.off( selector, "**" ) :
  16665. this.off( types, selector || "**", fn );
  16666. }
  16667. } );
  16668. // Bind a function to a context, optionally partially applying any
  16669. // arguments.
  16670. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16671. // However, it is not slated for removal any time soon
  16672. jQuery.proxy = function( fn, context ) {
  16673. var tmp, args, proxy;
  16674. if ( typeof context === "string" ) {
  16675. tmp = fn[ context ];
  16676. context = fn;
  16677. fn = tmp;
  16678. }
  16679. // Quick check to determine if target is callable, in the spec
  16680. // this throws a TypeError, but we will just return undefined.
  16681. if ( !isFunction( fn ) ) {
  16682. return undefined;
  16683. }
  16684. // Simulated bind
  16685. args = slice.call( arguments, 2 );
  16686. proxy = function() {
  16687. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16688. };
  16689. // Set the guid of unique handler to the same of original handler, so it can be removed
  16690. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16691. return proxy;
  16692. };
  16693. jQuery.holdReady = function( hold ) {
  16694. if ( hold ) {
  16695. jQuery.readyWait++;
  16696. } else {
  16697. jQuery.ready( true );
  16698. }
  16699. };
  16700. jQuery.isArray = Array.isArray;
  16701. jQuery.parseJSON = JSON.parse;
  16702. jQuery.nodeName = nodeName;
  16703. jQuery.isFunction = isFunction;
  16704. jQuery.isWindow = isWindow;
  16705. jQuery.camelCase = camelCase;
  16706. jQuery.type = toType;
  16707. jQuery.now = Date.now;
  16708. jQuery.isNumeric = function( obj ) {
  16709. // As of jQuery 3.0, isNumeric is limited to
  16710. // strings and numbers (primitives or objects)
  16711. // that can be coerced to finite numbers (gh-2662)
  16712. var type = jQuery.type( obj );
  16713. return ( type === "number" || type === "string" ) &&
  16714. // parseFloat NaNs numeric-cast false positives ("")
  16715. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16716. // subtraction forces infinities to NaN
  16717. !isNaN( obj - parseFloat( obj ) );
  16718. };
  16719. // Register as a named AMD module, since jQuery can be concatenated with other
  16720. // files that may use define, but not via a proper concatenation script that
  16721. // understands anonymous AMD modules. A named AMD is safest and most robust
  16722. // way to register. Lowercase jquery is used because AMD module names are
  16723. // derived from file names, and jQuery is normally delivered in a lowercase
  16724. // file name. Do this after creating the global so that if an AMD module wants
  16725. // to call noConflict to hide this version of jQuery, it will work.
  16726. // Note that for maximum portability, libraries that are not jQuery should
  16727. // declare themselves as anonymous modules, and avoid setting a global if an
  16728. // AMD loader is present. jQuery is a special case. For more information, see
  16729. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16730. if ( true ) {
  16731. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16732. return jQuery;
  16733. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16734. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16735. }
  16736. var
  16737. // Map over jQuery in case of overwrite
  16738. _jQuery = window.jQuery,
  16739. // Map over the $ in case of overwrite
  16740. _$ = window.$;
  16741. jQuery.noConflict = function( deep ) {
  16742. if ( window.$ === jQuery ) {
  16743. window.$ = _$;
  16744. }
  16745. if ( deep && window.jQuery === jQuery ) {
  16746. window.jQuery = _jQuery;
  16747. }
  16748. return jQuery;
  16749. };
  16750. // Expose jQuery and $ identifiers, even in AMD
  16751. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16752. // and CommonJS for browser emulators (#13566)
  16753. if ( !noGlobal ) {
  16754. window.jQuery = window.$ = jQuery;
  16755. }
  16756. return jQuery;
  16757. } );
  16758. /***/ }),
  16759. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16760. /*!************************************************!*\
  16761. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16762. \************************************************/
  16763. /*! exports provided: default */
  16764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16765. "use strict";
  16766. __webpack_require__.r(__webpack_exports__);
  16767. var classCallCheck = function (instance, Constructor) {
  16768. if (!(instance instanceof Constructor)) {
  16769. throw new TypeError("Cannot call a class as a function");
  16770. }
  16771. };
  16772. var createClass = function () {
  16773. function defineProperties(target, props) {
  16774. for (var i = 0; i < props.length; i++) {
  16775. var descriptor = props[i];
  16776. descriptor.enumerable = descriptor.enumerable || false;
  16777. descriptor.configurable = true;
  16778. if ("value" in descriptor) descriptor.writable = true;
  16779. Object.defineProperty(target, descriptor.key, descriptor);
  16780. }
  16781. }
  16782. return function (Constructor, protoProps, staticProps) {
  16783. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16784. if (staticProps) defineProperties(Constructor, staticProps);
  16785. return Constructor;
  16786. };
  16787. }();
  16788. var _extends = Object.assign || function (target) {
  16789. for (var i = 1; i < arguments.length; i++) {
  16790. var source = arguments[i];
  16791. for (var key in source) {
  16792. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16793. target[key] = source[key];
  16794. }
  16795. }
  16796. }
  16797. return target;
  16798. };
  16799. var inherits = function (subClass, superClass) {
  16800. if (typeof superClass !== "function" && superClass !== null) {
  16801. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16802. }
  16803. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16804. constructor: {
  16805. value: subClass,
  16806. enumerable: false,
  16807. writable: true,
  16808. configurable: true
  16809. }
  16810. });
  16811. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16812. };
  16813. var possibleConstructorReturn = function (self, call) {
  16814. if (!self) {
  16815. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16816. }
  16817. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16818. };
  16819. var Connector = function () {
  16820. /**
  16821. * Create a new class instance.
  16822. */
  16823. function Connector(options) {
  16824. classCallCheck(this, Connector);
  16825. /**
  16826. * Default connector options.
  16827. */
  16828. this._defaultOptions = {
  16829. auth: {
  16830. headers: {}
  16831. },
  16832. authEndpoint: '/broadcasting/auth',
  16833. broadcaster: 'pusher',
  16834. csrfToken: null,
  16835. host: null,
  16836. key: null,
  16837. namespace: 'App.Events'
  16838. };
  16839. this.setOptions(options);
  16840. this.connect();
  16841. }
  16842. /**
  16843. * Merge the custom options with the defaults.
  16844. */
  16845. createClass(Connector, [{
  16846. key: 'setOptions',
  16847. value: function setOptions(options) {
  16848. this.options = _extends(this._defaultOptions, options);
  16849. if (this.csrfToken()) {
  16850. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16851. }
  16852. return options;
  16853. }
  16854. /**
  16855. * Extract the CSRF token from the page.
  16856. */
  16857. }, {
  16858. key: 'csrfToken',
  16859. value: function csrfToken() {
  16860. var selector = void 0;
  16861. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16862. return window['Laravel'].csrfToken;
  16863. } else if (this.options.csrfToken) {
  16864. return this.options.csrfToken;
  16865. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16866. return selector.getAttribute('content');
  16867. }
  16868. return null;
  16869. }
  16870. }]);
  16871. return Connector;
  16872. }();
  16873. /**
  16874. * This class represents a basic channel.
  16875. */
  16876. var Channel = function () {
  16877. function Channel() {
  16878. classCallCheck(this, Channel);
  16879. }
  16880. createClass(Channel, [{
  16881. key: 'listenForWhisper',
  16882. /**
  16883. * Listen for a whisper event on the channel instance.
  16884. */
  16885. value: function listenForWhisper(event, callback) {
  16886. return this.listen('.client-' + event, callback);
  16887. }
  16888. /**
  16889. * Listen for an event on the channel instance.
  16890. */
  16891. }, {
  16892. key: 'notification',
  16893. value: function notification(callback) {
  16894. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16895. }
  16896. /**
  16897. * Stop listening for a whispser event on the channel instance.
  16898. */
  16899. }, {
  16900. key: 'stopListeningForWhisper',
  16901. value: function stopListeningForWhisper(event) {
  16902. return this.stopListening('.client-' + event);
  16903. }
  16904. }]);
  16905. return Channel;
  16906. }();
  16907. /**
  16908. * Event name formatter
  16909. */
  16910. var EventFormatter = function () {
  16911. /**
  16912. * Create a new class instance.
  16913. */
  16914. function EventFormatter(namespace) {
  16915. classCallCheck(this, EventFormatter);
  16916. this.setNamespace(namespace);
  16917. }
  16918. /**
  16919. * Format the given event name.
  16920. */
  16921. createClass(EventFormatter, [{
  16922. key: 'format',
  16923. value: function format(event) {
  16924. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16925. return event.substr(1);
  16926. } else if (this.namespace) {
  16927. event = this.namespace + '.' + event;
  16928. }
  16929. return event.replace(/\./g, '\\');
  16930. }
  16931. /**
  16932. * Set the event namespace.
  16933. */
  16934. }, {
  16935. key: 'setNamespace',
  16936. value: function setNamespace(value) {
  16937. this.namespace = value;
  16938. }
  16939. }]);
  16940. return EventFormatter;
  16941. }();
  16942. /**
  16943. * This class represents a Pusher channel.
  16944. */
  16945. var PusherChannel = function (_Channel) {
  16946. inherits(PusherChannel, _Channel);
  16947. /**
  16948. * Create a new class instance.
  16949. */
  16950. function PusherChannel(pusher, name, options) {
  16951. classCallCheck(this, PusherChannel);
  16952. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16953. _this.name = name;
  16954. _this.pusher = pusher;
  16955. _this.options = options;
  16956. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16957. _this.subscribe();
  16958. return _this;
  16959. }
  16960. /**
  16961. * Subscribe to a Pusher channel.
  16962. */
  16963. createClass(PusherChannel, [{
  16964. key: 'subscribe',
  16965. value: function subscribe() {
  16966. this.subscription = this.pusher.subscribe(this.name);
  16967. }
  16968. /**
  16969. * Unsubscribe from a Pusher channel.
  16970. */
  16971. }, {
  16972. key: 'unsubscribe',
  16973. value: function unsubscribe() {
  16974. this.pusher.unsubscribe(this.name);
  16975. }
  16976. /**
  16977. * Listen for an event on the channel instance.
  16978. */
  16979. }, {
  16980. key: 'listen',
  16981. value: function listen(event, callback) {
  16982. this.on(this.eventFormatter.format(event), callback);
  16983. return this;
  16984. }
  16985. /**
  16986. * Stop listening for an event on the channel instance.
  16987. */
  16988. }, {
  16989. key: 'stopListening',
  16990. value: function stopListening(event) {
  16991. this.subscription.unbind(this.eventFormatter.format(event));
  16992. return this;
  16993. }
  16994. /**
  16995. * Bind a channel to an event.
  16996. */
  16997. }, {
  16998. key: 'on',
  16999. value: function on(event, callback) {
  17000. this.subscription.bind(event, callback);
  17001. return this;
  17002. }
  17003. }]);
  17004. return PusherChannel;
  17005. }(Channel);
  17006. /**
  17007. * This class represents a Pusher private channel.
  17008. */
  17009. var PusherPrivateChannel = function (_PusherChannel) {
  17010. inherits(PusherPrivateChannel, _PusherChannel);
  17011. function PusherPrivateChannel() {
  17012. classCallCheck(this, PusherPrivateChannel);
  17013. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  17014. }
  17015. createClass(PusherPrivateChannel, [{
  17016. key: 'whisper',
  17017. /**
  17018. * Trigger client event on the channel.
  17019. */
  17020. value: function whisper(eventName, data) {
  17021. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  17022. return this;
  17023. }
  17024. }]);
  17025. return PusherPrivateChannel;
  17026. }(PusherChannel);
  17027. /**
  17028. * This class represents a Pusher presence channel.
  17029. */
  17030. var PusherPresenceChannel = function (_PusherChannel) {
  17031. inherits(PusherPresenceChannel, _PusherChannel);
  17032. function PusherPresenceChannel() {
  17033. classCallCheck(this, PusherPresenceChannel);
  17034. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  17035. }
  17036. createClass(PusherPresenceChannel, [{
  17037. key: 'here',
  17038. /**
  17039. * Register a callback to be called anytime the member list changes.
  17040. */
  17041. value: function here(callback) {
  17042. this.on('pusher:subscription_succeeded', function (data) {
  17043. callback(Object.keys(data.members).map(function (k) {
  17044. return data.members[k];
  17045. }));
  17046. });
  17047. return this;
  17048. }
  17049. /**
  17050. * Listen for someone joining the channel.
  17051. */
  17052. }, {
  17053. key: 'joining',
  17054. value: function joining(callback) {
  17055. this.on('pusher:member_added', function (member) {
  17056. callback(member.info);
  17057. });
  17058. return this;
  17059. }
  17060. /**
  17061. * Listen for someone leaving the channel.
  17062. */
  17063. }, {
  17064. key: 'leaving',
  17065. value: function leaving(callback) {
  17066. this.on('pusher:member_removed', function (member) {
  17067. callback(member.info);
  17068. });
  17069. return this;
  17070. }
  17071. /**
  17072. * Trigger client event on the channel.
  17073. */
  17074. }, {
  17075. key: 'whisper',
  17076. value: function whisper(eventName, data) {
  17077. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  17078. return this;
  17079. }
  17080. }]);
  17081. return PusherPresenceChannel;
  17082. }(PusherChannel);
  17083. /**
  17084. * This class represents a Socket.io channel.
  17085. */
  17086. var SocketIoChannel = function (_Channel) {
  17087. inherits(SocketIoChannel, _Channel);
  17088. /**
  17089. * Create a new class instance.
  17090. */
  17091. function SocketIoChannel(socket, name, options) {
  17092. classCallCheck(this, SocketIoChannel);
  17093. /**
  17094. * The event callbacks applied to the channel.
  17095. */
  17096. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  17097. _this.events = {};
  17098. _this.name = name;
  17099. _this.socket = socket;
  17100. _this.options = options;
  17101. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  17102. _this.subscribe();
  17103. _this.configureReconnector();
  17104. return _this;
  17105. }
  17106. /**
  17107. * Subscribe to a Socket.io channel.
  17108. */
  17109. createClass(SocketIoChannel, [{
  17110. key: 'subscribe',
  17111. value: function subscribe() {
  17112. this.socket.emit('subscribe', {
  17113. channel: this.name,
  17114. auth: this.options.auth || {}
  17115. });
  17116. }
  17117. /**
  17118. * Unsubscribe from channel and ubind event callbacks.
  17119. */
  17120. }, {
  17121. key: 'unsubscribe',
  17122. value: function unsubscribe() {
  17123. this.unbind();
  17124. this.socket.emit('unsubscribe', {
  17125. channel: this.name,
  17126. auth: this.options.auth || {}
  17127. });
  17128. }
  17129. /**
  17130. * Listen for an event on the channel instance.
  17131. */
  17132. }, {
  17133. key: 'listen',
  17134. value: function listen(event, callback) {
  17135. this.on(this.eventFormatter.format(event), callback);
  17136. return this;
  17137. }
  17138. /**
  17139. * Stop listening for an event on the channel instance.
  17140. */
  17141. }, {
  17142. key: 'stopListening',
  17143. value: function stopListening(event) {
  17144. var name = this.eventFormatter.format(event);
  17145. this.socket.removeListener(name);
  17146. delete this.events[name];
  17147. return this;
  17148. }
  17149. /**
  17150. * Bind the channel's socket to an event and store the callback.
  17151. */
  17152. }, {
  17153. key: 'on',
  17154. value: function on(event, callback) {
  17155. var _this2 = this;
  17156. var listener = function listener(channel, data) {
  17157. if (_this2.name == channel) {
  17158. callback(data);
  17159. }
  17160. };
  17161. this.socket.on(event, listener);
  17162. this.bind(event, listener);
  17163. }
  17164. /**
  17165. * Attach a 'reconnect' listener and bind the event.
  17166. */
  17167. }, {
  17168. key: 'configureReconnector',
  17169. value: function configureReconnector() {
  17170. var _this3 = this;
  17171. var listener = function listener() {
  17172. _this3.subscribe();
  17173. };
  17174. this.socket.on('reconnect', listener);
  17175. this.bind('reconnect', listener);
  17176. }
  17177. /**
  17178. * Bind the channel's socket to an event and store the callback.
  17179. */
  17180. }, {
  17181. key: 'bind',
  17182. value: function bind(event, callback) {
  17183. this.events[event] = this.events[event] || [];
  17184. this.events[event].push(callback);
  17185. }
  17186. /**
  17187. * Unbind the channel's socket from all stored event callbacks.
  17188. */
  17189. }, {
  17190. key: 'unbind',
  17191. value: function unbind() {
  17192. var _this4 = this;
  17193. Object.keys(this.events).forEach(function (event) {
  17194. _this4.events[event].forEach(function (callback) {
  17195. _this4.socket.removeListener(event, callback);
  17196. });
  17197. delete _this4.events[event];
  17198. });
  17199. }
  17200. }]);
  17201. return SocketIoChannel;
  17202. }(Channel);
  17203. /**
  17204. * This class represents a Socket.io presence channel.
  17205. */
  17206. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17207. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17208. function SocketIoPrivateChannel() {
  17209. classCallCheck(this, SocketIoPrivateChannel);
  17210. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17211. }
  17212. createClass(SocketIoPrivateChannel, [{
  17213. key: 'whisper',
  17214. /**
  17215. * Trigger client event on the channel.
  17216. */
  17217. value: function whisper(eventName, data) {
  17218. this.socket.emit('client event', {
  17219. channel: this.name,
  17220. event: 'client-' + eventName,
  17221. data: data
  17222. });
  17223. return this;
  17224. }
  17225. }]);
  17226. return SocketIoPrivateChannel;
  17227. }(SocketIoChannel);
  17228. /**
  17229. * This class represents a Socket.io presence channel.
  17230. */
  17231. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17232. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17233. function SocketIoPresenceChannel() {
  17234. classCallCheck(this, SocketIoPresenceChannel);
  17235. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17236. }
  17237. createClass(SocketIoPresenceChannel, [{
  17238. key: 'here',
  17239. /**
  17240. * Register a callback to be called anytime the member list changes.
  17241. */
  17242. value: function here(callback) {
  17243. this.on('presence:subscribed', function (members) {
  17244. callback(members.map(function (m) {
  17245. return m.user_info;
  17246. }));
  17247. });
  17248. return this;
  17249. }
  17250. /**
  17251. * Listen for someone joining the channel.
  17252. */
  17253. }, {
  17254. key: 'joining',
  17255. value: function joining(callback) {
  17256. this.on('presence:joining', function (member) {
  17257. return callback(member.user_info);
  17258. });
  17259. return this;
  17260. }
  17261. /**
  17262. * Listen for someone leaving the channel.
  17263. */
  17264. }, {
  17265. key: 'leaving',
  17266. value: function leaving(callback) {
  17267. this.on('presence:leaving', function (member) {
  17268. return callback(member.user_info);
  17269. });
  17270. return this;
  17271. }
  17272. }]);
  17273. return SocketIoPresenceChannel;
  17274. }(SocketIoPrivateChannel);
  17275. /**
  17276. * This class represents a null channel.
  17277. */
  17278. var NullChannel = function (_Channel) {
  17279. inherits(NullChannel, _Channel);
  17280. function NullChannel() {
  17281. classCallCheck(this, NullChannel);
  17282. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17283. }
  17284. createClass(NullChannel, [{
  17285. key: 'subscribe',
  17286. /**
  17287. * Subscribe to a channel.
  17288. */
  17289. value: function subscribe() {}
  17290. //
  17291. /**
  17292. * Unsubscribe from a channel.
  17293. */
  17294. }, {
  17295. key: 'unsubscribe',
  17296. value: function unsubscribe() {}
  17297. //
  17298. /**
  17299. * Listen for an event on the channel instance.
  17300. */
  17301. }, {
  17302. key: 'listen',
  17303. value: function listen(event, callback) {
  17304. return this;
  17305. }
  17306. /**
  17307. * Stop listening for an event on the channel instance.
  17308. */
  17309. }, {
  17310. key: 'stopListening',
  17311. value: function stopListening(event) {
  17312. return this;
  17313. }
  17314. /**
  17315. * Bind a channel to an event.
  17316. */
  17317. }, {
  17318. key: 'on',
  17319. value: function on(event, callback) {
  17320. return this;
  17321. }
  17322. }]);
  17323. return NullChannel;
  17324. }(Channel);
  17325. /**
  17326. * This class represents a null private channel.
  17327. */
  17328. var NullPrivateChannel = function (_NullChannel) {
  17329. inherits(NullPrivateChannel, _NullChannel);
  17330. function NullPrivateChannel() {
  17331. classCallCheck(this, NullPrivateChannel);
  17332. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17333. }
  17334. createClass(NullPrivateChannel, [{
  17335. key: 'whisper',
  17336. /**
  17337. * Trigger client event on the channel.
  17338. */
  17339. value: function whisper(eventName, data) {
  17340. return this;
  17341. }
  17342. }]);
  17343. return NullPrivateChannel;
  17344. }(NullChannel);
  17345. /**
  17346. * This class represents a null presence channel.
  17347. */
  17348. var NullPresenceChannel = function (_NullChannel) {
  17349. inherits(NullPresenceChannel, _NullChannel);
  17350. function NullPresenceChannel() {
  17351. classCallCheck(this, NullPresenceChannel);
  17352. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17353. }
  17354. createClass(NullPresenceChannel, [{
  17355. key: 'here',
  17356. /**
  17357. * Register a callback to be called anytime the member list changes.
  17358. */
  17359. value: function here(callback) {
  17360. return this;
  17361. }
  17362. /**
  17363. * Listen for someone joining the channel.
  17364. */
  17365. }, {
  17366. key: 'joining',
  17367. value: function joining(callback) {
  17368. return this;
  17369. }
  17370. /**
  17371. * Listen for someone leaving the channel.
  17372. */
  17373. }, {
  17374. key: 'leaving',
  17375. value: function leaving(callback) {
  17376. return this;
  17377. }
  17378. /**
  17379. * Trigger client event on the channel.
  17380. */
  17381. }, {
  17382. key: 'whisper',
  17383. value: function whisper(eventName, data) {
  17384. return this;
  17385. }
  17386. }]);
  17387. return NullPresenceChannel;
  17388. }(NullChannel);
  17389. /**
  17390. * This class creates a connector to Pusher.
  17391. */
  17392. var PusherConnector = function (_Connector) {
  17393. inherits(PusherConnector, _Connector);
  17394. function PusherConnector() {
  17395. classCallCheck(this, PusherConnector);
  17396. /**
  17397. * All of the subscribed channel names.
  17398. */
  17399. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17400. _this.channels = {};
  17401. return _this;
  17402. }
  17403. /**
  17404. * Create a fresh Pusher connection.
  17405. */
  17406. createClass(PusherConnector, [{
  17407. key: 'connect',
  17408. value: function connect() {
  17409. if (typeof this.options.client !== 'undefined') {
  17410. this.pusher = this.options.client;
  17411. } else {
  17412. this.pusher = new Pusher(this.options.key, this.options);
  17413. }
  17414. }
  17415. /**
  17416. * Listen for an event on a channel instance.
  17417. */
  17418. }, {
  17419. key: 'listen',
  17420. value: function listen(name, event, callback) {
  17421. return this.channel(name).listen(event, callback);
  17422. }
  17423. /**
  17424. * Get a channel instance by name.
  17425. */
  17426. }, {
  17427. key: 'channel',
  17428. value: function channel(name) {
  17429. if (!this.channels[name]) {
  17430. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17431. }
  17432. return this.channels[name];
  17433. }
  17434. /**
  17435. * Get a private channel instance by name.
  17436. */
  17437. }, {
  17438. key: 'privateChannel',
  17439. value: function privateChannel(name) {
  17440. if (!this.channels['private-' + name]) {
  17441. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17442. }
  17443. return this.channels['private-' + name];
  17444. }
  17445. /**
  17446. * Get a presence channel instance by name.
  17447. */
  17448. }, {
  17449. key: 'presenceChannel',
  17450. value: function presenceChannel(name) {
  17451. if (!this.channels['presence-' + name]) {
  17452. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17453. }
  17454. return this.channels['presence-' + name];
  17455. }
  17456. /**
  17457. * Leave the given channel, as well as its private and presence variants.
  17458. */
  17459. }, {
  17460. key: 'leave',
  17461. value: function leave(name) {
  17462. var _this2 = this;
  17463. var channels = [name, 'private-' + name, 'presence-' + name];
  17464. channels.forEach(function (name, index) {
  17465. _this2.leaveChannel(name);
  17466. });
  17467. }
  17468. /**
  17469. * Leave the given channel.
  17470. */
  17471. }, {
  17472. key: 'leaveChannel',
  17473. value: function leaveChannel(name) {
  17474. if (this.channels[name]) {
  17475. this.channels[name].unsubscribe();
  17476. delete this.channels[name];
  17477. }
  17478. }
  17479. /**
  17480. * Get the socket ID for the connection.
  17481. */
  17482. }, {
  17483. key: 'socketId',
  17484. value: function socketId() {
  17485. return this.pusher.connection.socket_id;
  17486. }
  17487. /**
  17488. * Disconnect Pusher connection.
  17489. */
  17490. }, {
  17491. key: 'disconnect',
  17492. value: function disconnect() {
  17493. this.pusher.disconnect();
  17494. }
  17495. }]);
  17496. return PusherConnector;
  17497. }(Connector);
  17498. /**
  17499. * This class creates a connnector to a Socket.io server.
  17500. */
  17501. var SocketIoConnector = function (_Connector) {
  17502. inherits(SocketIoConnector, _Connector);
  17503. function SocketIoConnector() {
  17504. classCallCheck(this, SocketIoConnector);
  17505. /**
  17506. * All of the subscribed channel names.
  17507. */
  17508. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17509. _this.channels = {};
  17510. return _this;
  17511. }
  17512. /**
  17513. * Create a fresh Socket.io connection.
  17514. */
  17515. createClass(SocketIoConnector, [{
  17516. key: 'connect',
  17517. value: function connect() {
  17518. var io = this.getSocketIO();
  17519. this.socket = io(this.options.host, this.options);
  17520. return this.socket;
  17521. }
  17522. /**
  17523. * Get socket.io module from global scope or options.
  17524. */
  17525. }, {
  17526. key: 'getSocketIO',
  17527. value: function getSocketIO() {
  17528. if (typeof this.options.client !== 'undefined') {
  17529. return this.options.client;
  17530. }
  17531. if (typeof io !== 'undefined') {
  17532. return io;
  17533. }
  17534. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17535. }
  17536. /**
  17537. * Listen for an event on a channel instance.
  17538. */
  17539. }, {
  17540. key: 'listen',
  17541. value: function listen(name, event, callback) {
  17542. return this.channel(name).listen(event, callback);
  17543. }
  17544. /**
  17545. * Get a channel instance by name.
  17546. */
  17547. }, {
  17548. key: 'channel',
  17549. value: function channel(name) {
  17550. if (!this.channels[name]) {
  17551. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17552. }
  17553. return this.channels[name];
  17554. }
  17555. /**
  17556. * Get a private channel instance by name.
  17557. */
  17558. }, {
  17559. key: 'privateChannel',
  17560. value: function privateChannel(name) {
  17561. if (!this.channels['private-' + name]) {
  17562. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17563. }
  17564. return this.channels['private-' + name];
  17565. }
  17566. /**
  17567. * Get a presence channel instance by name.
  17568. */
  17569. }, {
  17570. key: 'presenceChannel',
  17571. value: function presenceChannel(name) {
  17572. if (!this.channels['presence-' + name]) {
  17573. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17574. }
  17575. return this.channels['presence-' + name];
  17576. }
  17577. /**
  17578. * Leave the given channel, as well as its private and presence variants.
  17579. */
  17580. }, {
  17581. key: 'leave',
  17582. value: function leave(name) {
  17583. var _this2 = this;
  17584. var channels = [name, 'private-' + name, 'presence-' + name];
  17585. channels.forEach(function (name) {
  17586. _this2.leaveChannel(name);
  17587. });
  17588. }
  17589. /**
  17590. * Leave the given channel.
  17591. */
  17592. }, {
  17593. key: 'leaveChannel',
  17594. value: function leaveChannel(name) {
  17595. if (this.channels[name]) {
  17596. this.channels[name].unsubscribe();
  17597. delete this.channels[name];
  17598. }
  17599. }
  17600. /**
  17601. * Get the socket ID for the connection.
  17602. */
  17603. }, {
  17604. key: 'socketId',
  17605. value: function socketId() {
  17606. return this.socket.id;
  17607. }
  17608. /**
  17609. * Disconnect Socketio connection.
  17610. */
  17611. }, {
  17612. key: 'disconnect',
  17613. value: function disconnect() {
  17614. this.socket.disconnect();
  17615. }
  17616. }]);
  17617. return SocketIoConnector;
  17618. }(Connector);
  17619. /**
  17620. * This class creates a null connector.
  17621. */
  17622. var NullConnector = function (_Connector) {
  17623. inherits(NullConnector, _Connector);
  17624. function NullConnector() {
  17625. classCallCheck(this, NullConnector);
  17626. /**
  17627. * All of the subscribed channel names.
  17628. */
  17629. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17630. _this.channels = {};
  17631. return _this;
  17632. }
  17633. /**
  17634. * Create a fresh connection.
  17635. */
  17636. createClass(NullConnector, [{
  17637. key: 'connect',
  17638. value: function connect() {}
  17639. //
  17640. /**
  17641. * Listen for an event on a channel instance.
  17642. */
  17643. }, {
  17644. key: 'listen',
  17645. value: function listen(name, event, callback) {
  17646. return new NullChannel();
  17647. }
  17648. /**
  17649. * Get a channel instance by name.
  17650. */
  17651. }, {
  17652. key: 'channel',
  17653. value: function channel(name) {
  17654. return new NullChannel();
  17655. }
  17656. /**
  17657. * Get a private channel instance by name.
  17658. */
  17659. }, {
  17660. key: 'privateChannel',
  17661. value: function privateChannel(name) {
  17662. return new NullPrivateChannel();
  17663. }
  17664. /**
  17665. * Get a presence channel instance by name.
  17666. */
  17667. }, {
  17668. key: 'presenceChannel',
  17669. value: function presenceChannel(name) {
  17670. return new NullPresenceChannel();
  17671. }
  17672. /**
  17673. * Leave the given channel, as well as its private and presence variants.
  17674. */
  17675. }, {
  17676. key: 'leave',
  17677. value: function leave(name) {}
  17678. //
  17679. /**
  17680. * Leave the given channel.
  17681. */
  17682. }, {
  17683. key: 'leaveChannel',
  17684. value: function leaveChannel(name) {}
  17685. //
  17686. /**
  17687. * Get the socket ID for the connection.
  17688. */
  17689. }, {
  17690. key: 'socketId',
  17691. value: function socketId() {
  17692. return 'fake-socket-id';
  17693. }
  17694. /**
  17695. * Disconnect the connection.
  17696. */
  17697. }, {
  17698. key: 'disconnect',
  17699. value: function disconnect() {
  17700. //
  17701. }
  17702. }]);
  17703. return NullConnector;
  17704. }(Connector);
  17705. /**
  17706. * This class is the primary API for interacting with broadcasting.
  17707. */
  17708. var Echo = function () {
  17709. /**
  17710. * Create a new class instance.
  17711. */
  17712. function Echo(options) {
  17713. classCallCheck(this, Echo);
  17714. this.options = options;
  17715. this.connect();
  17716. if (!this.options.withoutInterceptors) {
  17717. this.registerInterceptors();
  17718. }
  17719. }
  17720. /**
  17721. * Get a channel instance by name.
  17722. */
  17723. createClass(Echo, [{
  17724. key: 'channel',
  17725. value: function channel(_channel) {
  17726. return this.connector.channel(_channel);
  17727. }
  17728. /**
  17729. * Create a new connection.
  17730. */
  17731. }, {
  17732. key: 'connect',
  17733. value: function connect() {
  17734. if (this.options.broadcaster == 'pusher') {
  17735. this.connector = new PusherConnector(this.options);
  17736. } else if (this.options.broadcaster == 'socket.io') {
  17737. this.connector = new SocketIoConnector(this.options);
  17738. } else if (this.options.broadcaster == 'null') {
  17739. this.connector = new NullConnector(this.options);
  17740. } else if (typeof this.options.broadcaster == 'function') {
  17741. this.connector = new this.options.broadcaster(this.options);
  17742. }
  17743. }
  17744. /**
  17745. * Disconnect from the Echo server.
  17746. */
  17747. }, {
  17748. key: 'disconnect',
  17749. value: function disconnect() {
  17750. this.connector.disconnect();
  17751. }
  17752. /**
  17753. * Get a presence channel instance by name.
  17754. */
  17755. }, {
  17756. key: 'join',
  17757. value: function join(channel) {
  17758. return this.connector.presenceChannel(channel);
  17759. }
  17760. /**
  17761. * Leave the given channel, as well as its private and presence variants.
  17762. */
  17763. }, {
  17764. key: 'leave',
  17765. value: function leave(channel) {
  17766. this.connector.leave(channel);
  17767. }
  17768. /**
  17769. * Leave the given channel.
  17770. */
  17771. }, {
  17772. key: 'leaveChannel',
  17773. value: function leaveChannel(channel) {
  17774. this.connector.leaveChannel(channel);
  17775. }
  17776. /**
  17777. * Listen for an event on a channel instance.
  17778. */
  17779. }, {
  17780. key: 'listen',
  17781. value: function listen(channel, event, callback) {
  17782. return this.connector.listen(channel, event, callback);
  17783. }
  17784. /**
  17785. * Get a private channel instance by name.
  17786. */
  17787. }, {
  17788. key: 'private',
  17789. value: function _private(channel) {
  17790. return this.connector.privateChannel(channel);
  17791. }
  17792. /**
  17793. * Get the Socket ID for the connection.
  17794. */
  17795. }, {
  17796. key: 'socketId',
  17797. value: function socketId() {
  17798. return this.connector.socketId();
  17799. }
  17800. /**
  17801. * Register 3rd party request interceptiors. These are used to automatically
  17802. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17803. */
  17804. }, {
  17805. key: 'registerInterceptors',
  17806. value: function registerInterceptors() {
  17807. if (typeof Vue === 'function' && Vue.http) {
  17808. this.registerVueRequestInterceptor();
  17809. }
  17810. if (typeof axios === 'function') {
  17811. this.registerAxiosRequestInterceptor();
  17812. }
  17813. if (typeof jQuery === 'function') {
  17814. this.registerjQueryAjaxSetup();
  17815. }
  17816. }
  17817. /**
  17818. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17819. */
  17820. }, {
  17821. key: 'registerVueRequestInterceptor',
  17822. value: function registerVueRequestInterceptor() {
  17823. var _this = this;
  17824. Vue.http.interceptors.push(function (request, next) {
  17825. if (_this.socketId()) {
  17826. request.headers.set('X-Socket-ID', _this.socketId());
  17827. }
  17828. next();
  17829. });
  17830. }
  17831. /**
  17832. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17833. */
  17834. }, {
  17835. key: 'registerAxiosRequestInterceptor',
  17836. value: function registerAxiosRequestInterceptor() {
  17837. var _this2 = this;
  17838. axios.interceptors.request.use(function (config) {
  17839. if (_this2.socketId()) {
  17840. config.headers['X-Socket-Id'] = _this2.socketId();
  17841. }
  17842. return config;
  17843. });
  17844. }
  17845. /**
  17846. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17847. */
  17848. }, {
  17849. key: 'registerjQueryAjaxSetup',
  17850. value: function registerjQueryAjaxSetup() {
  17851. var _this3 = this;
  17852. if (typeof jQuery.ajax != 'undefined') {
  17853. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17854. if (_this3.socketId()) {
  17855. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17856. }
  17857. });
  17858. }
  17859. }
  17860. }]);
  17861. return Echo;
  17862. }();
  17863. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17864. /***/ }),
  17865. /***/ "./node_modules/lodash/lodash.js":
  17866. /*!***************************************!*\
  17867. !*** ./node_modules/lodash/lodash.js ***!
  17868. \***************************************/
  17869. /*! no static exports found */
  17870. /***/ (function(module, exports, __webpack_require__) {
  17871. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17872. * @license
  17873. * Lodash <https://lodash.com/>
  17874. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17875. * Released under MIT license <https://lodash.com/license>
  17876. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17877. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17878. */
  17879. ;(function() {
  17880. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17881. var undefined;
  17882. /** Used as the semantic version number. */
  17883. var VERSION = '4.17.15';
  17884. /** Used as the size to enable large array optimizations. */
  17885. var LARGE_ARRAY_SIZE = 200;
  17886. /** Error message constants. */
  17887. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17888. FUNC_ERROR_TEXT = 'Expected a function';
  17889. /** Used to stand-in for `undefined` hash values. */
  17890. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17891. /** Used as the maximum memoize cache size. */
  17892. var MAX_MEMOIZE_SIZE = 500;
  17893. /** Used as the internal argument placeholder. */
  17894. var PLACEHOLDER = '__lodash_placeholder__';
  17895. /** Used to compose bitmasks for cloning. */
  17896. var CLONE_DEEP_FLAG = 1,
  17897. CLONE_FLAT_FLAG = 2,
  17898. CLONE_SYMBOLS_FLAG = 4;
  17899. /** Used to compose bitmasks for value comparisons. */
  17900. var COMPARE_PARTIAL_FLAG = 1,
  17901. COMPARE_UNORDERED_FLAG = 2;
  17902. /** Used to compose bitmasks for function metadata. */
  17903. var WRAP_BIND_FLAG = 1,
  17904. WRAP_BIND_KEY_FLAG = 2,
  17905. WRAP_CURRY_BOUND_FLAG = 4,
  17906. WRAP_CURRY_FLAG = 8,
  17907. WRAP_CURRY_RIGHT_FLAG = 16,
  17908. WRAP_PARTIAL_FLAG = 32,
  17909. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17910. WRAP_ARY_FLAG = 128,
  17911. WRAP_REARG_FLAG = 256,
  17912. WRAP_FLIP_FLAG = 512;
  17913. /** Used as default options for `_.truncate`. */
  17914. var DEFAULT_TRUNC_LENGTH = 30,
  17915. DEFAULT_TRUNC_OMISSION = '...';
  17916. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17917. var HOT_COUNT = 800,
  17918. HOT_SPAN = 16;
  17919. /** Used to indicate the type of lazy iteratees. */
  17920. var LAZY_FILTER_FLAG = 1,
  17921. LAZY_MAP_FLAG = 2,
  17922. LAZY_WHILE_FLAG = 3;
  17923. /** Used as references for various `Number` constants. */
  17924. var INFINITY = 1 / 0,
  17925. MAX_SAFE_INTEGER = 9007199254740991,
  17926. MAX_INTEGER = 1.7976931348623157e+308,
  17927. NAN = 0 / 0;
  17928. /** Used as references for the maximum length and index of an array. */
  17929. var MAX_ARRAY_LENGTH = 4294967295,
  17930. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17931. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17932. /** Used to associate wrap methods with their bit flags. */
  17933. var wrapFlags = [
  17934. ['ary', WRAP_ARY_FLAG],
  17935. ['bind', WRAP_BIND_FLAG],
  17936. ['bindKey', WRAP_BIND_KEY_FLAG],
  17937. ['curry', WRAP_CURRY_FLAG],
  17938. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17939. ['flip', WRAP_FLIP_FLAG],
  17940. ['partial', WRAP_PARTIAL_FLAG],
  17941. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17942. ['rearg', WRAP_REARG_FLAG]
  17943. ];
  17944. /** `Object#toString` result references. */
  17945. var argsTag = '[object Arguments]',
  17946. arrayTag = '[object Array]',
  17947. asyncTag = '[object AsyncFunction]',
  17948. boolTag = '[object Boolean]',
  17949. dateTag = '[object Date]',
  17950. domExcTag = '[object DOMException]',
  17951. errorTag = '[object Error]',
  17952. funcTag = '[object Function]',
  17953. genTag = '[object GeneratorFunction]',
  17954. mapTag = '[object Map]',
  17955. numberTag = '[object Number]',
  17956. nullTag = '[object Null]',
  17957. objectTag = '[object Object]',
  17958. promiseTag = '[object Promise]',
  17959. proxyTag = '[object Proxy]',
  17960. regexpTag = '[object RegExp]',
  17961. setTag = '[object Set]',
  17962. stringTag = '[object String]',
  17963. symbolTag = '[object Symbol]',
  17964. undefinedTag = '[object Undefined]',
  17965. weakMapTag = '[object WeakMap]',
  17966. weakSetTag = '[object WeakSet]';
  17967. var arrayBufferTag = '[object ArrayBuffer]',
  17968. dataViewTag = '[object DataView]',
  17969. float32Tag = '[object Float32Array]',
  17970. float64Tag = '[object Float64Array]',
  17971. int8Tag = '[object Int8Array]',
  17972. int16Tag = '[object Int16Array]',
  17973. int32Tag = '[object Int32Array]',
  17974. uint8Tag = '[object Uint8Array]',
  17975. uint8ClampedTag = '[object Uint8ClampedArray]',
  17976. uint16Tag = '[object Uint16Array]',
  17977. uint32Tag = '[object Uint32Array]';
  17978. /** Used to match empty string literals in compiled template source. */
  17979. var reEmptyStringLeading = /\b__p \+= '';/g,
  17980. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17981. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17982. /** Used to match HTML entities and HTML characters. */
  17983. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17984. reUnescapedHtml = /[&<>"']/g,
  17985. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17986. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17987. /** Used to match template delimiters. */
  17988. var reEscape = /<%-([\s\S]+?)%>/g,
  17989. reEvaluate = /<%([\s\S]+?)%>/g,
  17990. reInterpolate = /<%=([\s\S]+?)%>/g;
  17991. /** Used to match property names within property paths. */
  17992. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17993. reIsPlainProp = /^\w*$/,
  17994. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17995. /**
  17996. * Used to match `RegExp`
  17997. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17998. */
  17999. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  18000. reHasRegExpChar = RegExp(reRegExpChar.source);
  18001. /** Used to match leading and trailing whitespace. */
  18002. var reTrim = /^\s+|\s+$/g,
  18003. reTrimStart = /^\s+/,
  18004. reTrimEnd = /\s+$/;
  18005. /** Used to match wrap detail comments. */
  18006. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  18007. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  18008. reSplitDetails = /,? & /;
  18009. /** Used to match words composed of alphanumeric characters. */
  18010. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  18011. /** Used to match backslashes in property paths. */
  18012. var reEscapeChar = /\\(\\)?/g;
  18013. /**
  18014. * Used to match
  18015. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  18016. */
  18017. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  18018. /** Used to match `RegExp` flags from their coerced string values. */
  18019. var reFlags = /\w*$/;
  18020. /** Used to detect bad signed hexadecimal string values. */
  18021. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  18022. /** Used to detect binary string values. */
  18023. var reIsBinary = /^0b[01]+$/i;
  18024. /** Used to detect host constructors (Safari). */
  18025. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  18026. /** Used to detect octal string values. */
  18027. var reIsOctal = /^0o[0-7]+$/i;
  18028. /** Used to detect unsigned integer values. */
  18029. var reIsUint = /^(?:0|[1-9]\d*)$/;
  18030. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  18031. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  18032. /** Used to ensure capturing order of template delimiters. */
  18033. var reNoMatch = /($^)/;
  18034. /** Used to match unescaped characters in compiled string literals. */
  18035. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  18036. /** Used to compose unicode character classes. */
  18037. var rsAstralRange = '\\ud800-\\udfff',
  18038. rsComboMarksRange = '\\u0300-\\u036f',
  18039. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  18040. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  18041. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  18042. rsDingbatRange = '\\u2700-\\u27bf',
  18043. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  18044. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  18045. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  18046. rsPunctuationRange = '\\u2000-\\u206f',
  18047. 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',
  18048. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  18049. rsVarRange = '\\ufe0e\\ufe0f',
  18050. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  18051. /** Used to compose unicode capture groups. */
  18052. var rsApos = "['\u2019]",
  18053. rsAstral = '[' + rsAstralRange + ']',
  18054. rsBreak = '[' + rsBreakRange + ']',
  18055. rsCombo = '[' + rsComboRange + ']',
  18056. rsDigits = '\\d+',
  18057. rsDingbat = '[' + rsDingbatRange + ']',
  18058. rsLower = '[' + rsLowerRange + ']',
  18059. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  18060. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  18061. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  18062. rsNonAstral = '[^' + rsAstralRange + ']',
  18063. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  18064. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  18065. rsUpper = '[' + rsUpperRange + ']',
  18066. rsZWJ = '\\u200d';
  18067. /** Used to compose unicode regexes. */
  18068. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  18069. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  18070. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  18071. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  18072. reOptMod = rsModifier + '?',
  18073. rsOptVar = '[' + rsVarRange + ']?',
  18074. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  18075. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  18076. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  18077. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  18078. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  18079. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  18080. /** Used to match apostrophes. */
  18081. var reApos = RegExp(rsApos, 'g');
  18082. /**
  18083. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  18084. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  18085. */
  18086. var reComboMark = RegExp(rsCombo, 'g');
  18087. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  18088. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  18089. /** Used to match complex or compound words. */
  18090. var reUnicodeWord = RegExp([
  18091. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  18092. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  18093. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  18094. rsUpper + '+' + rsOptContrUpper,
  18095. rsOrdUpper,
  18096. rsOrdLower,
  18097. rsDigits,
  18098. rsEmoji
  18099. ].join('|'), 'g');
  18100. /** 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/). */
  18101. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  18102. /** Used to detect strings that need a more robust regexp to match words. */
  18103. 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 ]/;
  18104. /** Used to assign default `context` object properties. */
  18105. var contextProps = [
  18106. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  18107. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  18108. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  18109. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  18110. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  18111. ];
  18112. /** Used to make template sourceURLs easier to identify. */
  18113. var templateCounter = -1;
  18114. /** Used to identify `toStringTag` values of typed arrays. */
  18115. var typedArrayTags = {};
  18116. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  18117. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  18118. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  18119. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  18120. typedArrayTags[uint32Tag] = true;
  18121. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  18122. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  18123. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  18124. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  18125. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  18126. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  18127. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  18128. typedArrayTags[weakMapTag] = false;
  18129. /** Used to identify `toStringTag` values supported by `_.clone`. */
  18130. var cloneableTags = {};
  18131. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18132. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18133. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18134. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18135. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18136. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18137. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18138. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18139. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18140. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18141. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18142. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18143. cloneableTags[weakMapTag] = false;
  18144. /** Used to map Latin Unicode letters to basic Latin letters. */
  18145. var deburredLetters = {
  18146. // Latin-1 Supplement block.
  18147. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18148. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18149. '\xc7': 'C', '\xe7': 'c',
  18150. '\xd0': 'D', '\xf0': 'd',
  18151. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18152. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18153. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18154. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18155. '\xd1': 'N', '\xf1': 'n',
  18156. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18157. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18158. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18159. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18160. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18161. '\xc6': 'Ae', '\xe6': 'ae',
  18162. '\xde': 'Th', '\xfe': 'th',
  18163. '\xdf': 'ss',
  18164. // Latin Extended-A block.
  18165. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18166. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18167. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18168. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18169. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18170. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18171. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18172. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18173. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18174. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18175. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18176. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18177. '\u0134': 'J', '\u0135': 'j',
  18178. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18179. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18180. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18181. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18182. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18183. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18184. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18185. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18186. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18187. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18188. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18189. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18190. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18191. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18192. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18193. '\u0174': 'W', '\u0175': 'w',
  18194. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18195. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18196. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18197. '\u0132': 'IJ', '\u0133': 'ij',
  18198. '\u0152': 'Oe', '\u0153': 'oe',
  18199. '\u0149': "'n", '\u017f': 's'
  18200. };
  18201. /** Used to map characters to HTML entities. */
  18202. var htmlEscapes = {
  18203. '&': '&amp;',
  18204. '<': '&lt;',
  18205. '>': '&gt;',
  18206. '"': '&quot;',
  18207. "'": '&#39;'
  18208. };
  18209. /** Used to map HTML entities to characters. */
  18210. var htmlUnescapes = {
  18211. '&amp;': '&',
  18212. '&lt;': '<',
  18213. '&gt;': '>',
  18214. '&quot;': '"',
  18215. '&#39;': "'"
  18216. };
  18217. /** Used to escape characters for inclusion in compiled string literals. */
  18218. var stringEscapes = {
  18219. '\\': '\\',
  18220. "'": "'",
  18221. '\n': 'n',
  18222. '\r': 'r',
  18223. '\u2028': 'u2028',
  18224. '\u2029': 'u2029'
  18225. };
  18226. /** Built-in method references without a dependency on `root`. */
  18227. var freeParseFloat = parseFloat,
  18228. freeParseInt = parseInt;
  18229. /** Detect free variable `global` from Node.js. */
  18230. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18231. /** Detect free variable `self`. */
  18232. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18233. /** Used as a reference to the global object. */
  18234. var root = freeGlobal || freeSelf || Function('return this')();
  18235. /** Detect free variable `exports`. */
  18236. var freeExports = true && exports && !exports.nodeType && exports;
  18237. /** Detect free variable `module`. */
  18238. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18239. /** Detect the popular CommonJS extension `module.exports`. */
  18240. var moduleExports = freeModule && freeModule.exports === freeExports;
  18241. /** Detect free variable `process` from Node.js. */
  18242. var freeProcess = moduleExports && freeGlobal.process;
  18243. /** Used to access faster Node.js helpers. */
  18244. var nodeUtil = (function() {
  18245. try {
  18246. // Use `util.types` for Node.js 10+.
  18247. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18248. if (types) {
  18249. return types;
  18250. }
  18251. // Legacy `process.binding('util')` for Node.js < 10.
  18252. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18253. } catch (e) {}
  18254. }());
  18255. /* Node.js helper references. */
  18256. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18257. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18258. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18259. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18260. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18261. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18262. /*--------------------------------------------------------------------------*/
  18263. /**
  18264. * A faster alternative to `Function#apply`, this function invokes `func`
  18265. * with the `this` binding of `thisArg` and the arguments of `args`.
  18266. *
  18267. * @private
  18268. * @param {Function} func The function to invoke.
  18269. * @param {*} thisArg The `this` binding of `func`.
  18270. * @param {Array} args The arguments to invoke `func` with.
  18271. * @returns {*} Returns the result of `func`.
  18272. */
  18273. function apply(func, thisArg, args) {
  18274. switch (args.length) {
  18275. case 0: return func.call(thisArg);
  18276. case 1: return func.call(thisArg, args[0]);
  18277. case 2: return func.call(thisArg, args[0], args[1]);
  18278. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18279. }
  18280. return func.apply(thisArg, args);
  18281. }
  18282. /**
  18283. * A specialized version of `baseAggregator` for arrays.
  18284. *
  18285. * @private
  18286. * @param {Array} [array] The array to iterate over.
  18287. * @param {Function} setter The function to set `accumulator` values.
  18288. * @param {Function} iteratee The iteratee to transform keys.
  18289. * @param {Object} accumulator The initial aggregated object.
  18290. * @returns {Function} Returns `accumulator`.
  18291. */
  18292. function arrayAggregator(array, setter, iteratee, accumulator) {
  18293. var index = -1,
  18294. length = array == null ? 0 : array.length;
  18295. while (++index < length) {
  18296. var value = array[index];
  18297. setter(accumulator, value, iteratee(value), array);
  18298. }
  18299. return accumulator;
  18300. }
  18301. /**
  18302. * A specialized version of `_.forEach` for arrays without support for
  18303. * iteratee shorthands.
  18304. *
  18305. * @private
  18306. * @param {Array} [array] The array to iterate over.
  18307. * @param {Function} iteratee The function invoked per iteration.
  18308. * @returns {Array} Returns `array`.
  18309. */
  18310. function arrayEach(array, iteratee) {
  18311. var index = -1,
  18312. length = array == null ? 0 : array.length;
  18313. while (++index < length) {
  18314. if (iteratee(array[index], index, array) === false) {
  18315. break;
  18316. }
  18317. }
  18318. return array;
  18319. }
  18320. /**
  18321. * A specialized version of `_.forEachRight` for arrays without support for
  18322. * iteratee shorthands.
  18323. *
  18324. * @private
  18325. * @param {Array} [array] The array to iterate over.
  18326. * @param {Function} iteratee The function invoked per iteration.
  18327. * @returns {Array} Returns `array`.
  18328. */
  18329. function arrayEachRight(array, iteratee) {
  18330. var length = array == null ? 0 : array.length;
  18331. while (length--) {
  18332. if (iteratee(array[length], length, array) === false) {
  18333. break;
  18334. }
  18335. }
  18336. return array;
  18337. }
  18338. /**
  18339. * A specialized version of `_.every` for arrays without support for
  18340. * iteratee shorthands.
  18341. *
  18342. * @private
  18343. * @param {Array} [array] The array to iterate over.
  18344. * @param {Function} predicate The function invoked per iteration.
  18345. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18346. * else `false`.
  18347. */
  18348. function arrayEvery(array, predicate) {
  18349. var index = -1,
  18350. length = array == null ? 0 : array.length;
  18351. while (++index < length) {
  18352. if (!predicate(array[index], index, array)) {
  18353. return false;
  18354. }
  18355. }
  18356. return true;
  18357. }
  18358. /**
  18359. * A specialized version of `_.filter` for arrays without support for
  18360. * iteratee shorthands.
  18361. *
  18362. * @private
  18363. * @param {Array} [array] The array to iterate over.
  18364. * @param {Function} predicate The function invoked per iteration.
  18365. * @returns {Array} Returns the new filtered array.
  18366. */
  18367. function arrayFilter(array, predicate) {
  18368. var index = -1,
  18369. length = array == null ? 0 : array.length,
  18370. resIndex = 0,
  18371. result = [];
  18372. while (++index < length) {
  18373. var value = array[index];
  18374. if (predicate(value, index, array)) {
  18375. result[resIndex++] = value;
  18376. }
  18377. }
  18378. return result;
  18379. }
  18380. /**
  18381. * A specialized version of `_.includes` for arrays without support for
  18382. * specifying an index to search from.
  18383. *
  18384. * @private
  18385. * @param {Array} [array] The array to inspect.
  18386. * @param {*} target The value to search for.
  18387. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18388. */
  18389. function arrayIncludes(array, value) {
  18390. var length = array == null ? 0 : array.length;
  18391. return !!length && baseIndexOf(array, value, 0) > -1;
  18392. }
  18393. /**
  18394. * This function is like `arrayIncludes` except that it accepts a comparator.
  18395. *
  18396. * @private
  18397. * @param {Array} [array] The array to inspect.
  18398. * @param {*} target The value to search for.
  18399. * @param {Function} comparator The comparator invoked per element.
  18400. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18401. */
  18402. function arrayIncludesWith(array, value, comparator) {
  18403. var index = -1,
  18404. length = array == null ? 0 : array.length;
  18405. while (++index < length) {
  18406. if (comparator(value, array[index])) {
  18407. return true;
  18408. }
  18409. }
  18410. return false;
  18411. }
  18412. /**
  18413. * A specialized version of `_.map` for arrays without support for iteratee
  18414. * shorthands.
  18415. *
  18416. * @private
  18417. * @param {Array} [array] The array to iterate over.
  18418. * @param {Function} iteratee The function invoked per iteration.
  18419. * @returns {Array} Returns the new mapped array.
  18420. */
  18421. function arrayMap(array, iteratee) {
  18422. var index = -1,
  18423. length = array == null ? 0 : array.length,
  18424. result = Array(length);
  18425. while (++index < length) {
  18426. result[index] = iteratee(array[index], index, array);
  18427. }
  18428. return result;
  18429. }
  18430. /**
  18431. * Appends the elements of `values` to `array`.
  18432. *
  18433. * @private
  18434. * @param {Array} array The array to modify.
  18435. * @param {Array} values The values to append.
  18436. * @returns {Array} Returns `array`.
  18437. */
  18438. function arrayPush(array, values) {
  18439. var index = -1,
  18440. length = values.length,
  18441. offset = array.length;
  18442. while (++index < length) {
  18443. array[offset + index] = values[index];
  18444. }
  18445. return array;
  18446. }
  18447. /**
  18448. * A specialized version of `_.reduce` for arrays without support for
  18449. * iteratee shorthands.
  18450. *
  18451. * @private
  18452. * @param {Array} [array] The array to iterate over.
  18453. * @param {Function} iteratee The function invoked per iteration.
  18454. * @param {*} [accumulator] The initial value.
  18455. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18456. * the initial value.
  18457. * @returns {*} Returns the accumulated value.
  18458. */
  18459. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18460. var index = -1,
  18461. length = array == null ? 0 : array.length;
  18462. if (initAccum && length) {
  18463. accumulator = array[++index];
  18464. }
  18465. while (++index < length) {
  18466. accumulator = iteratee(accumulator, array[index], index, array);
  18467. }
  18468. return accumulator;
  18469. }
  18470. /**
  18471. * A specialized version of `_.reduceRight` for arrays without support for
  18472. * iteratee shorthands.
  18473. *
  18474. * @private
  18475. * @param {Array} [array] The array to iterate over.
  18476. * @param {Function} iteratee The function invoked per iteration.
  18477. * @param {*} [accumulator] The initial value.
  18478. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18479. * the initial value.
  18480. * @returns {*} Returns the accumulated value.
  18481. */
  18482. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18483. var length = array == null ? 0 : array.length;
  18484. if (initAccum && length) {
  18485. accumulator = array[--length];
  18486. }
  18487. while (length--) {
  18488. accumulator = iteratee(accumulator, array[length], length, array);
  18489. }
  18490. return accumulator;
  18491. }
  18492. /**
  18493. * A specialized version of `_.some` for arrays without support for iteratee
  18494. * shorthands.
  18495. *
  18496. * @private
  18497. * @param {Array} [array] The array to iterate over.
  18498. * @param {Function} predicate The function invoked per iteration.
  18499. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18500. * else `false`.
  18501. */
  18502. function arraySome(array, predicate) {
  18503. var index = -1,
  18504. length = array == null ? 0 : array.length;
  18505. while (++index < length) {
  18506. if (predicate(array[index], index, array)) {
  18507. return true;
  18508. }
  18509. }
  18510. return false;
  18511. }
  18512. /**
  18513. * Gets the size of an ASCII `string`.
  18514. *
  18515. * @private
  18516. * @param {string} string The string inspect.
  18517. * @returns {number} Returns the string size.
  18518. */
  18519. var asciiSize = baseProperty('length');
  18520. /**
  18521. * Converts an ASCII `string` to an array.
  18522. *
  18523. * @private
  18524. * @param {string} string The string to convert.
  18525. * @returns {Array} Returns the converted array.
  18526. */
  18527. function asciiToArray(string) {
  18528. return string.split('');
  18529. }
  18530. /**
  18531. * Splits an ASCII `string` into an array of its words.
  18532. *
  18533. * @private
  18534. * @param {string} The string to inspect.
  18535. * @returns {Array} Returns the words of `string`.
  18536. */
  18537. function asciiWords(string) {
  18538. return string.match(reAsciiWord) || [];
  18539. }
  18540. /**
  18541. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18542. * without support for iteratee shorthands, which iterates over `collection`
  18543. * using `eachFunc`.
  18544. *
  18545. * @private
  18546. * @param {Array|Object} collection The collection to inspect.
  18547. * @param {Function} predicate The function invoked per iteration.
  18548. * @param {Function} eachFunc The function to iterate over `collection`.
  18549. * @returns {*} Returns the found element or its key, else `undefined`.
  18550. */
  18551. function baseFindKey(collection, predicate, eachFunc) {
  18552. var result;
  18553. eachFunc(collection, function(value, key, collection) {
  18554. if (predicate(value, key, collection)) {
  18555. result = key;
  18556. return false;
  18557. }
  18558. });
  18559. return result;
  18560. }
  18561. /**
  18562. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18563. * support for iteratee shorthands.
  18564. *
  18565. * @private
  18566. * @param {Array} array The array to inspect.
  18567. * @param {Function} predicate The function invoked per iteration.
  18568. * @param {number} fromIndex The index to search from.
  18569. * @param {boolean} [fromRight] Specify iterating from right to left.
  18570. * @returns {number} Returns the index of the matched value, else `-1`.
  18571. */
  18572. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18573. var length = array.length,
  18574. index = fromIndex + (fromRight ? 1 : -1);
  18575. while ((fromRight ? index-- : ++index < length)) {
  18576. if (predicate(array[index], index, array)) {
  18577. return index;
  18578. }
  18579. }
  18580. return -1;
  18581. }
  18582. /**
  18583. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18584. *
  18585. * @private
  18586. * @param {Array} array The array to inspect.
  18587. * @param {*} value The value to search for.
  18588. * @param {number} fromIndex The index to search from.
  18589. * @returns {number} Returns the index of the matched value, else `-1`.
  18590. */
  18591. function baseIndexOf(array, value, fromIndex) {
  18592. return value === value
  18593. ? strictIndexOf(array, value, fromIndex)
  18594. : baseFindIndex(array, baseIsNaN, fromIndex);
  18595. }
  18596. /**
  18597. * This function is like `baseIndexOf` except that it accepts a comparator.
  18598. *
  18599. * @private
  18600. * @param {Array} array The array to inspect.
  18601. * @param {*} value The value to search for.
  18602. * @param {number} fromIndex The index to search from.
  18603. * @param {Function} comparator The comparator invoked per element.
  18604. * @returns {number} Returns the index of the matched value, else `-1`.
  18605. */
  18606. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18607. var index = fromIndex - 1,
  18608. length = array.length;
  18609. while (++index < length) {
  18610. if (comparator(array[index], value)) {
  18611. return index;
  18612. }
  18613. }
  18614. return -1;
  18615. }
  18616. /**
  18617. * The base implementation of `_.isNaN` without support for number objects.
  18618. *
  18619. * @private
  18620. * @param {*} value The value to check.
  18621. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18622. */
  18623. function baseIsNaN(value) {
  18624. return value !== value;
  18625. }
  18626. /**
  18627. * The base implementation of `_.mean` and `_.meanBy` without support for
  18628. * iteratee shorthands.
  18629. *
  18630. * @private
  18631. * @param {Array} array The array to iterate over.
  18632. * @param {Function} iteratee The function invoked per iteration.
  18633. * @returns {number} Returns the mean.
  18634. */
  18635. function baseMean(array, iteratee) {
  18636. var length = array == null ? 0 : array.length;
  18637. return length ? (baseSum(array, iteratee) / length) : NAN;
  18638. }
  18639. /**
  18640. * The base implementation of `_.property` without support for deep paths.
  18641. *
  18642. * @private
  18643. * @param {string} key The key of the property to get.
  18644. * @returns {Function} Returns the new accessor function.
  18645. */
  18646. function baseProperty(key) {
  18647. return function(object) {
  18648. return object == null ? undefined : object[key];
  18649. };
  18650. }
  18651. /**
  18652. * The base implementation of `_.propertyOf` without support for deep paths.
  18653. *
  18654. * @private
  18655. * @param {Object} object The object to query.
  18656. * @returns {Function} Returns the new accessor function.
  18657. */
  18658. function basePropertyOf(object) {
  18659. return function(key) {
  18660. return object == null ? undefined : object[key];
  18661. };
  18662. }
  18663. /**
  18664. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18665. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18666. *
  18667. * @private
  18668. * @param {Array|Object} collection The collection to iterate over.
  18669. * @param {Function} iteratee The function invoked per iteration.
  18670. * @param {*} accumulator The initial value.
  18671. * @param {boolean} initAccum Specify using the first or last element of
  18672. * `collection` as the initial value.
  18673. * @param {Function} eachFunc The function to iterate over `collection`.
  18674. * @returns {*} Returns the accumulated value.
  18675. */
  18676. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18677. eachFunc(collection, function(value, index, collection) {
  18678. accumulator = initAccum
  18679. ? (initAccum = false, value)
  18680. : iteratee(accumulator, value, index, collection);
  18681. });
  18682. return accumulator;
  18683. }
  18684. /**
  18685. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18686. * sort order of `array` and replaces criteria objects with their corresponding
  18687. * values.
  18688. *
  18689. * @private
  18690. * @param {Array} array The array to sort.
  18691. * @param {Function} comparer The function to define sort order.
  18692. * @returns {Array} Returns `array`.
  18693. */
  18694. function baseSortBy(array, comparer) {
  18695. var length = array.length;
  18696. array.sort(comparer);
  18697. while (length--) {
  18698. array[length] = array[length].value;
  18699. }
  18700. return array;
  18701. }
  18702. /**
  18703. * The base implementation of `_.sum` and `_.sumBy` without support for
  18704. * iteratee shorthands.
  18705. *
  18706. * @private
  18707. * @param {Array} array The array to iterate over.
  18708. * @param {Function} iteratee The function invoked per iteration.
  18709. * @returns {number} Returns the sum.
  18710. */
  18711. function baseSum(array, iteratee) {
  18712. var result,
  18713. index = -1,
  18714. length = array.length;
  18715. while (++index < length) {
  18716. var current = iteratee(array[index]);
  18717. if (current !== undefined) {
  18718. result = result === undefined ? current : (result + current);
  18719. }
  18720. }
  18721. return result;
  18722. }
  18723. /**
  18724. * The base implementation of `_.times` without support for iteratee shorthands
  18725. * or max array length checks.
  18726. *
  18727. * @private
  18728. * @param {number} n The number of times to invoke `iteratee`.
  18729. * @param {Function} iteratee The function invoked per iteration.
  18730. * @returns {Array} Returns the array of results.
  18731. */
  18732. function baseTimes(n, iteratee) {
  18733. var index = -1,
  18734. result = Array(n);
  18735. while (++index < n) {
  18736. result[index] = iteratee(index);
  18737. }
  18738. return result;
  18739. }
  18740. /**
  18741. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18742. * of key-value pairs for `object` corresponding to the property names of `props`.
  18743. *
  18744. * @private
  18745. * @param {Object} object The object to query.
  18746. * @param {Array} props The property names to get values for.
  18747. * @returns {Object} Returns the key-value pairs.
  18748. */
  18749. function baseToPairs(object, props) {
  18750. return arrayMap(props, function(key) {
  18751. return [key, object[key]];
  18752. });
  18753. }
  18754. /**
  18755. * The base implementation of `_.unary` without support for storing metadata.
  18756. *
  18757. * @private
  18758. * @param {Function} func The function to cap arguments for.
  18759. * @returns {Function} Returns the new capped function.
  18760. */
  18761. function baseUnary(func) {
  18762. return function(value) {
  18763. return func(value);
  18764. };
  18765. }
  18766. /**
  18767. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18768. * array of `object` property values corresponding to the property names
  18769. * of `props`.
  18770. *
  18771. * @private
  18772. * @param {Object} object The object to query.
  18773. * @param {Array} props The property names to get values for.
  18774. * @returns {Object} Returns the array of property values.
  18775. */
  18776. function baseValues(object, props) {
  18777. return arrayMap(props, function(key) {
  18778. return object[key];
  18779. });
  18780. }
  18781. /**
  18782. * Checks if a `cache` value for `key` exists.
  18783. *
  18784. * @private
  18785. * @param {Object} cache The cache to query.
  18786. * @param {string} key The key of the entry to check.
  18787. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18788. */
  18789. function cacheHas(cache, key) {
  18790. return cache.has(key);
  18791. }
  18792. /**
  18793. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18794. * that is not found in the character symbols.
  18795. *
  18796. * @private
  18797. * @param {Array} strSymbols The string symbols to inspect.
  18798. * @param {Array} chrSymbols The character symbols to find.
  18799. * @returns {number} Returns the index of the first unmatched string symbol.
  18800. */
  18801. function charsStartIndex(strSymbols, chrSymbols) {
  18802. var index = -1,
  18803. length = strSymbols.length;
  18804. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18805. return index;
  18806. }
  18807. /**
  18808. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18809. * that is not found in the character symbols.
  18810. *
  18811. * @private
  18812. * @param {Array} strSymbols The string symbols to inspect.
  18813. * @param {Array} chrSymbols The character symbols to find.
  18814. * @returns {number} Returns the index of the last unmatched string symbol.
  18815. */
  18816. function charsEndIndex(strSymbols, chrSymbols) {
  18817. var index = strSymbols.length;
  18818. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18819. return index;
  18820. }
  18821. /**
  18822. * Gets the number of `placeholder` occurrences in `array`.
  18823. *
  18824. * @private
  18825. * @param {Array} array The array to inspect.
  18826. * @param {*} placeholder The placeholder to search for.
  18827. * @returns {number} Returns the placeholder count.
  18828. */
  18829. function countHolders(array, placeholder) {
  18830. var length = array.length,
  18831. result = 0;
  18832. while (length--) {
  18833. if (array[length] === placeholder) {
  18834. ++result;
  18835. }
  18836. }
  18837. return result;
  18838. }
  18839. /**
  18840. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18841. * letters to basic Latin letters.
  18842. *
  18843. * @private
  18844. * @param {string} letter The matched letter to deburr.
  18845. * @returns {string} Returns the deburred letter.
  18846. */
  18847. var deburrLetter = basePropertyOf(deburredLetters);
  18848. /**
  18849. * Used by `_.escape` to convert characters to HTML entities.
  18850. *
  18851. * @private
  18852. * @param {string} chr The matched character to escape.
  18853. * @returns {string} Returns the escaped character.
  18854. */
  18855. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18856. /**
  18857. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18858. *
  18859. * @private
  18860. * @param {string} chr The matched character to escape.
  18861. * @returns {string} Returns the escaped character.
  18862. */
  18863. function escapeStringChar(chr) {
  18864. return '\\' + stringEscapes[chr];
  18865. }
  18866. /**
  18867. * Gets the value at `key` of `object`.
  18868. *
  18869. * @private
  18870. * @param {Object} [object] The object to query.
  18871. * @param {string} key The key of the property to get.
  18872. * @returns {*} Returns the property value.
  18873. */
  18874. function getValue(object, key) {
  18875. return object == null ? undefined : object[key];
  18876. }
  18877. /**
  18878. * Checks if `string` contains Unicode symbols.
  18879. *
  18880. * @private
  18881. * @param {string} string The string to inspect.
  18882. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18883. */
  18884. function hasUnicode(string) {
  18885. return reHasUnicode.test(string);
  18886. }
  18887. /**
  18888. * Checks if `string` contains a word composed of Unicode symbols.
  18889. *
  18890. * @private
  18891. * @param {string} string The string to inspect.
  18892. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18893. */
  18894. function hasUnicodeWord(string) {
  18895. return reHasUnicodeWord.test(string);
  18896. }
  18897. /**
  18898. * Converts `iterator` to an array.
  18899. *
  18900. * @private
  18901. * @param {Object} iterator The iterator to convert.
  18902. * @returns {Array} Returns the converted array.
  18903. */
  18904. function iteratorToArray(iterator) {
  18905. var data,
  18906. result = [];
  18907. while (!(data = iterator.next()).done) {
  18908. result.push(data.value);
  18909. }
  18910. return result;
  18911. }
  18912. /**
  18913. * Converts `map` to its key-value pairs.
  18914. *
  18915. * @private
  18916. * @param {Object} map The map to convert.
  18917. * @returns {Array} Returns the key-value pairs.
  18918. */
  18919. function mapToArray(map) {
  18920. var index = -1,
  18921. result = Array(map.size);
  18922. map.forEach(function(value, key) {
  18923. result[++index] = [key, value];
  18924. });
  18925. return result;
  18926. }
  18927. /**
  18928. * Creates a unary function that invokes `func` with its argument transformed.
  18929. *
  18930. * @private
  18931. * @param {Function} func The function to wrap.
  18932. * @param {Function} transform The argument transform.
  18933. * @returns {Function} Returns the new function.
  18934. */
  18935. function overArg(func, transform) {
  18936. return function(arg) {
  18937. return func(transform(arg));
  18938. };
  18939. }
  18940. /**
  18941. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18942. * and returns an array of their indexes.
  18943. *
  18944. * @private
  18945. * @param {Array} array The array to modify.
  18946. * @param {*} placeholder The placeholder to replace.
  18947. * @returns {Array} Returns the new array of placeholder indexes.
  18948. */
  18949. function replaceHolders(array, placeholder) {
  18950. var index = -1,
  18951. length = array.length,
  18952. resIndex = 0,
  18953. result = [];
  18954. while (++index < length) {
  18955. var value = array[index];
  18956. if (value === placeholder || value === PLACEHOLDER) {
  18957. array[index] = PLACEHOLDER;
  18958. result[resIndex++] = index;
  18959. }
  18960. }
  18961. return result;
  18962. }
  18963. /**
  18964. * Converts `set` to an array of its values.
  18965. *
  18966. * @private
  18967. * @param {Object} set The set to convert.
  18968. * @returns {Array} Returns the values.
  18969. */
  18970. function setToArray(set) {
  18971. var index = -1,
  18972. result = Array(set.size);
  18973. set.forEach(function(value) {
  18974. result[++index] = value;
  18975. });
  18976. return result;
  18977. }
  18978. /**
  18979. * Converts `set` to its value-value pairs.
  18980. *
  18981. * @private
  18982. * @param {Object} set The set to convert.
  18983. * @returns {Array} Returns the value-value pairs.
  18984. */
  18985. function setToPairs(set) {
  18986. var index = -1,
  18987. result = Array(set.size);
  18988. set.forEach(function(value) {
  18989. result[++index] = [value, value];
  18990. });
  18991. return result;
  18992. }
  18993. /**
  18994. * A specialized version of `_.indexOf` which performs strict equality
  18995. * comparisons of values, i.e. `===`.
  18996. *
  18997. * @private
  18998. * @param {Array} array The array to inspect.
  18999. * @param {*} value The value to search for.
  19000. * @param {number} fromIndex The index to search from.
  19001. * @returns {number} Returns the index of the matched value, else `-1`.
  19002. */
  19003. function strictIndexOf(array, value, fromIndex) {
  19004. var index = fromIndex - 1,
  19005. length = array.length;
  19006. while (++index < length) {
  19007. if (array[index] === value) {
  19008. return index;
  19009. }
  19010. }
  19011. return -1;
  19012. }
  19013. /**
  19014. * A specialized version of `_.lastIndexOf` which performs strict equality
  19015. * comparisons of values, i.e. `===`.
  19016. *
  19017. * @private
  19018. * @param {Array} array The array to inspect.
  19019. * @param {*} value The value to search for.
  19020. * @param {number} fromIndex The index to search from.
  19021. * @returns {number} Returns the index of the matched value, else `-1`.
  19022. */
  19023. function strictLastIndexOf(array, value, fromIndex) {
  19024. var index = fromIndex + 1;
  19025. while (index--) {
  19026. if (array[index] === value) {
  19027. return index;
  19028. }
  19029. }
  19030. return index;
  19031. }
  19032. /**
  19033. * Gets the number of symbols in `string`.
  19034. *
  19035. * @private
  19036. * @param {string} string The string to inspect.
  19037. * @returns {number} Returns the string size.
  19038. */
  19039. function stringSize(string) {
  19040. return hasUnicode(string)
  19041. ? unicodeSize(string)
  19042. : asciiSize(string);
  19043. }
  19044. /**
  19045. * Converts `string` to an array.
  19046. *
  19047. * @private
  19048. * @param {string} string The string to convert.
  19049. * @returns {Array} Returns the converted array.
  19050. */
  19051. function stringToArray(string) {
  19052. return hasUnicode(string)
  19053. ? unicodeToArray(string)
  19054. : asciiToArray(string);
  19055. }
  19056. /**
  19057. * Used by `_.unescape` to convert HTML entities to characters.
  19058. *
  19059. * @private
  19060. * @param {string} chr The matched character to unescape.
  19061. * @returns {string} Returns the unescaped character.
  19062. */
  19063. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  19064. /**
  19065. * Gets the size of a Unicode `string`.
  19066. *
  19067. * @private
  19068. * @param {string} string The string inspect.
  19069. * @returns {number} Returns the string size.
  19070. */
  19071. function unicodeSize(string) {
  19072. var result = reUnicode.lastIndex = 0;
  19073. while (reUnicode.test(string)) {
  19074. ++result;
  19075. }
  19076. return result;
  19077. }
  19078. /**
  19079. * Converts a Unicode `string` to an array.
  19080. *
  19081. * @private
  19082. * @param {string} string The string to convert.
  19083. * @returns {Array} Returns the converted array.
  19084. */
  19085. function unicodeToArray(string) {
  19086. return string.match(reUnicode) || [];
  19087. }
  19088. /**
  19089. * Splits a Unicode `string` into an array of its words.
  19090. *
  19091. * @private
  19092. * @param {string} The string to inspect.
  19093. * @returns {Array} Returns the words of `string`.
  19094. */
  19095. function unicodeWords(string) {
  19096. return string.match(reUnicodeWord) || [];
  19097. }
  19098. /*--------------------------------------------------------------------------*/
  19099. /**
  19100. * Create a new pristine `lodash` function using the `context` object.
  19101. *
  19102. * @static
  19103. * @memberOf _
  19104. * @since 1.1.0
  19105. * @category Util
  19106. * @param {Object} [context=root] The context object.
  19107. * @returns {Function} Returns a new `lodash` function.
  19108. * @example
  19109. *
  19110. * _.mixin({ 'foo': _.constant('foo') });
  19111. *
  19112. * var lodash = _.runInContext();
  19113. * lodash.mixin({ 'bar': lodash.constant('bar') });
  19114. *
  19115. * _.isFunction(_.foo);
  19116. * // => true
  19117. * _.isFunction(_.bar);
  19118. * // => false
  19119. *
  19120. * lodash.isFunction(lodash.foo);
  19121. * // => false
  19122. * lodash.isFunction(lodash.bar);
  19123. * // => true
  19124. *
  19125. * // Create a suped-up `defer` in Node.js.
  19126. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  19127. */
  19128. var runInContext = (function runInContext(context) {
  19129. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  19130. /** Built-in constructor references. */
  19131. var Array = context.Array,
  19132. Date = context.Date,
  19133. Error = context.Error,
  19134. Function = context.Function,
  19135. Math = context.Math,
  19136. Object = context.Object,
  19137. RegExp = context.RegExp,
  19138. String = context.String,
  19139. TypeError = context.TypeError;
  19140. /** Used for built-in method references. */
  19141. var arrayProto = Array.prototype,
  19142. funcProto = Function.prototype,
  19143. objectProto = Object.prototype;
  19144. /** Used to detect overreaching core-js shims. */
  19145. var coreJsData = context['__core-js_shared__'];
  19146. /** Used to resolve the decompiled source of functions. */
  19147. var funcToString = funcProto.toString;
  19148. /** Used to check objects for own properties. */
  19149. var hasOwnProperty = objectProto.hasOwnProperty;
  19150. /** Used to generate unique IDs. */
  19151. var idCounter = 0;
  19152. /** Used to detect methods masquerading as native. */
  19153. var maskSrcKey = (function() {
  19154. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19155. return uid ? ('Symbol(src)_1.' + uid) : '';
  19156. }());
  19157. /**
  19158. * Used to resolve the
  19159. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19160. * of values.
  19161. */
  19162. var nativeObjectToString = objectProto.toString;
  19163. /** Used to infer the `Object` constructor. */
  19164. var objectCtorString = funcToString.call(Object);
  19165. /** Used to restore the original `_` reference in `_.noConflict`. */
  19166. var oldDash = root._;
  19167. /** Used to detect if a method is native. */
  19168. var reIsNative = RegExp('^' +
  19169. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19170. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19171. );
  19172. /** Built-in value references. */
  19173. var Buffer = moduleExports ? context.Buffer : undefined,
  19174. Symbol = context.Symbol,
  19175. Uint8Array = context.Uint8Array,
  19176. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19177. getPrototype = overArg(Object.getPrototypeOf, Object),
  19178. objectCreate = Object.create,
  19179. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19180. splice = arrayProto.splice,
  19181. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19182. symIterator = Symbol ? Symbol.iterator : undefined,
  19183. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19184. var defineProperty = (function() {
  19185. try {
  19186. var func = getNative(Object, 'defineProperty');
  19187. func({}, '', {});
  19188. return func;
  19189. } catch (e) {}
  19190. }());
  19191. /** Mocked built-ins. */
  19192. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19193. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19194. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19195. /* Built-in method references for those with the same name as other `lodash` methods. */
  19196. var nativeCeil = Math.ceil,
  19197. nativeFloor = Math.floor,
  19198. nativeGetSymbols = Object.getOwnPropertySymbols,
  19199. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19200. nativeIsFinite = context.isFinite,
  19201. nativeJoin = arrayProto.join,
  19202. nativeKeys = overArg(Object.keys, Object),
  19203. nativeMax = Math.max,
  19204. nativeMin = Math.min,
  19205. nativeNow = Date.now,
  19206. nativeParseInt = context.parseInt,
  19207. nativeRandom = Math.random,
  19208. nativeReverse = arrayProto.reverse;
  19209. /* Built-in method references that are verified to be native. */
  19210. var DataView = getNative(context, 'DataView'),
  19211. Map = getNative(context, 'Map'),
  19212. Promise = getNative(context, 'Promise'),
  19213. Set = getNative(context, 'Set'),
  19214. WeakMap = getNative(context, 'WeakMap'),
  19215. nativeCreate = getNative(Object, 'create');
  19216. /** Used to store function metadata. */
  19217. var metaMap = WeakMap && new WeakMap;
  19218. /** Used to lookup unminified function names. */
  19219. var realNames = {};
  19220. /** Used to detect maps, sets, and weakmaps. */
  19221. var dataViewCtorString = toSource(DataView),
  19222. mapCtorString = toSource(Map),
  19223. promiseCtorString = toSource(Promise),
  19224. setCtorString = toSource(Set),
  19225. weakMapCtorString = toSource(WeakMap);
  19226. /** Used to convert symbols to primitives and strings. */
  19227. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19228. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19229. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19230. /*------------------------------------------------------------------------*/
  19231. /**
  19232. * Creates a `lodash` object which wraps `value` to enable implicit method
  19233. * chain sequences. Methods that operate on and return arrays, collections,
  19234. * and functions can be chained together. Methods that retrieve a single value
  19235. * or may return a primitive value will automatically end the chain sequence
  19236. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19237. * with `_#value`.
  19238. *
  19239. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19240. * enabled using `_.chain`.
  19241. *
  19242. * The execution of chained methods is lazy, that is, it's deferred until
  19243. * `_#value` is implicitly or explicitly called.
  19244. *
  19245. * Lazy evaluation allows several methods to support shortcut fusion.
  19246. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19247. * the creation of intermediate arrays and can greatly reduce the number of
  19248. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19249. * fusion if the section is applied to an array and iteratees accept only
  19250. * one argument. The heuristic for whether a section qualifies for shortcut
  19251. * fusion is subject to change.
  19252. *
  19253. * Chaining is supported in custom builds as long as the `_#value` method is
  19254. * directly or indirectly included in the build.
  19255. *
  19256. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19257. *
  19258. * The wrapper `Array` methods are:
  19259. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19260. *
  19261. * The wrapper `String` methods are:
  19262. * `replace` and `split`
  19263. *
  19264. * The wrapper methods that support shortcut fusion are:
  19265. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19266. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19267. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19268. *
  19269. * The chainable wrapper methods are:
  19270. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19271. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19272. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19273. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19274. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19275. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19276. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19277. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19278. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19279. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19280. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19281. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19282. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19283. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19284. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19285. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19286. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19287. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19288. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19289. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19290. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19291. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19292. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19293. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19294. *
  19295. * The wrapper methods that are **not** chainable by default are:
  19296. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19297. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19298. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19299. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19300. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19301. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19302. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19303. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19304. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19305. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19306. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19307. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19308. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19309. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19310. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19311. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19312. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19313. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19314. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19315. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19316. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19317. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19318. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19319. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19320. * `upperFirst`, `value`, and `words`
  19321. *
  19322. * @name _
  19323. * @constructor
  19324. * @category Seq
  19325. * @param {*} value The value to wrap in a `lodash` instance.
  19326. * @returns {Object} Returns the new `lodash` wrapper instance.
  19327. * @example
  19328. *
  19329. * function square(n) {
  19330. * return n * n;
  19331. * }
  19332. *
  19333. * var wrapped = _([1, 2, 3]);
  19334. *
  19335. * // Returns an unwrapped value.
  19336. * wrapped.reduce(_.add);
  19337. * // => 6
  19338. *
  19339. * // Returns a wrapped value.
  19340. * var squares = wrapped.map(square);
  19341. *
  19342. * _.isArray(squares);
  19343. * // => false
  19344. *
  19345. * _.isArray(squares.value());
  19346. * // => true
  19347. */
  19348. function lodash(value) {
  19349. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19350. if (value instanceof LodashWrapper) {
  19351. return value;
  19352. }
  19353. if (hasOwnProperty.call(value, '__wrapped__')) {
  19354. return wrapperClone(value);
  19355. }
  19356. }
  19357. return new LodashWrapper(value);
  19358. }
  19359. /**
  19360. * The base implementation of `_.create` without support for assigning
  19361. * properties to the created object.
  19362. *
  19363. * @private
  19364. * @param {Object} proto The object to inherit from.
  19365. * @returns {Object} Returns the new object.
  19366. */
  19367. var baseCreate = (function() {
  19368. function object() {}
  19369. return function(proto) {
  19370. if (!isObject(proto)) {
  19371. return {};
  19372. }
  19373. if (objectCreate) {
  19374. return objectCreate(proto);
  19375. }
  19376. object.prototype = proto;
  19377. var result = new object;
  19378. object.prototype = undefined;
  19379. return result;
  19380. };
  19381. }());
  19382. /**
  19383. * The function whose prototype chain sequence wrappers inherit from.
  19384. *
  19385. * @private
  19386. */
  19387. function baseLodash() {
  19388. // No operation performed.
  19389. }
  19390. /**
  19391. * The base constructor for creating `lodash` wrapper objects.
  19392. *
  19393. * @private
  19394. * @param {*} value The value to wrap.
  19395. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19396. */
  19397. function LodashWrapper(value, chainAll) {
  19398. this.__wrapped__ = value;
  19399. this.__actions__ = [];
  19400. this.__chain__ = !!chainAll;
  19401. this.__index__ = 0;
  19402. this.__values__ = undefined;
  19403. }
  19404. /**
  19405. * By default, the template delimiters used by lodash are like those in
  19406. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19407. * following template settings to use alternative delimiters.
  19408. *
  19409. * @static
  19410. * @memberOf _
  19411. * @type {Object}
  19412. */
  19413. lodash.templateSettings = {
  19414. /**
  19415. * Used to detect `data` property values to be HTML-escaped.
  19416. *
  19417. * @memberOf _.templateSettings
  19418. * @type {RegExp}
  19419. */
  19420. 'escape': reEscape,
  19421. /**
  19422. * Used to detect code to be evaluated.
  19423. *
  19424. * @memberOf _.templateSettings
  19425. * @type {RegExp}
  19426. */
  19427. 'evaluate': reEvaluate,
  19428. /**
  19429. * Used to detect `data` property values to inject.
  19430. *
  19431. * @memberOf _.templateSettings
  19432. * @type {RegExp}
  19433. */
  19434. 'interpolate': reInterpolate,
  19435. /**
  19436. * Used to reference the data object in the template text.
  19437. *
  19438. * @memberOf _.templateSettings
  19439. * @type {string}
  19440. */
  19441. 'variable': '',
  19442. /**
  19443. * Used to import variables into the compiled template.
  19444. *
  19445. * @memberOf _.templateSettings
  19446. * @type {Object}
  19447. */
  19448. 'imports': {
  19449. /**
  19450. * A reference to the `lodash` function.
  19451. *
  19452. * @memberOf _.templateSettings.imports
  19453. * @type {Function}
  19454. */
  19455. '_': lodash
  19456. }
  19457. };
  19458. // Ensure wrappers are instances of `baseLodash`.
  19459. lodash.prototype = baseLodash.prototype;
  19460. lodash.prototype.constructor = lodash;
  19461. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19462. LodashWrapper.prototype.constructor = LodashWrapper;
  19463. /*------------------------------------------------------------------------*/
  19464. /**
  19465. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19466. *
  19467. * @private
  19468. * @constructor
  19469. * @param {*} value The value to wrap.
  19470. */
  19471. function LazyWrapper(value) {
  19472. this.__wrapped__ = value;
  19473. this.__actions__ = [];
  19474. this.__dir__ = 1;
  19475. this.__filtered__ = false;
  19476. this.__iteratees__ = [];
  19477. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19478. this.__views__ = [];
  19479. }
  19480. /**
  19481. * Creates a clone of the lazy wrapper object.
  19482. *
  19483. * @private
  19484. * @name clone
  19485. * @memberOf LazyWrapper
  19486. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19487. */
  19488. function lazyClone() {
  19489. var result = new LazyWrapper(this.__wrapped__);
  19490. result.__actions__ = copyArray(this.__actions__);
  19491. result.__dir__ = this.__dir__;
  19492. result.__filtered__ = this.__filtered__;
  19493. result.__iteratees__ = copyArray(this.__iteratees__);
  19494. result.__takeCount__ = this.__takeCount__;
  19495. result.__views__ = copyArray(this.__views__);
  19496. return result;
  19497. }
  19498. /**
  19499. * Reverses the direction of lazy iteration.
  19500. *
  19501. * @private
  19502. * @name reverse
  19503. * @memberOf LazyWrapper
  19504. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19505. */
  19506. function lazyReverse() {
  19507. if (this.__filtered__) {
  19508. var result = new LazyWrapper(this);
  19509. result.__dir__ = -1;
  19510. result.__filtered__ = true;
  19511. } else {
  19512. result = this.clone();
  19513. result.__dir__ *= -1;
  19514. }
  19515. return result;
  19516. }
  19517. /**
  19518. * Extracts the unwrapped value from its lazy wrapper.
  19519. *
  19520. * @private
  19521. * @name value
  19522. * @memberOf LazyWrapper
  19523. * @returns {*} Returns the unwrapped value.
  19524. */
  19525. function lazyValue() {
  19526. var array = this.__wrapped__.value(),
  19527. dir = this.__dir__,
  19528. isArr = isArray(array),
  19529. isRight = dir < 0,
  19530. arrLength = isArr ? array.length : 0,
  19531. view = getView(0, arrLength, this.__views__),
  19532. start = view.start,
  19533. end = view.end,
  19534. length = end - start,
  19535. index = isRight ? end : (start - 1),
  19536. iteratees = this.__iteratees__,
  19537. iterLength = iteratees.length,
  19538. resIndex = 0,
  19539. takeCount = nativeMin(length, this.__takeCount__);
  19540. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19541. return baseWrapperValue(array, this.__actions__);
  19542. }
  19543. var result = [];
  19544. outer:
  19545. while (length-- && resIndex < takeCount) {
  19546. index += dir;
  19547. var iterIndex = -1,
  19548. value = array[index];
  19549. while (++iterIndex < iterLength) {
  19550. var data = iteratees[iterIndex],
  19551. iteratee = data.iteratee,
  19552. type = data.type,
  19553. computed = iteratee(value);
  19554. if (type == LAZY_MAP_FLAG) {
  19555. value = computed;
  19556. } else if (!computed) {
  19557. if (type == LAZY_FILTER_FLAG) {
  19558. continue outer;
  19559. } else {
  19560. break outer;
  19561. }
  19562. }
  19563. }
  19564. result[resIndex++] = value;
  19565. }
  19566. return result;
  19567. }
  19568. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19569. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19570. LazyWrapper.prototype.constructor = LazyWrapper;
  19571. /*------------------------------------------------------------------------*/
  19572. /**
  19573. * Creates a hash object.
  19574. *
  19575. * @private
  19576. * @constructor
  19577. * @param {Array} [entries] The key-value pairs to cache.
  19578. */
  19579. function Hash(entries) {
  19580. var index = -1,
  19581. length = entries == null ? 0 : entries.length;
  19582. this.clear();
  19583. while (++index < length) {
  19584. var entry = entries[index];
  19585. this.set(entry[0], entry[1]);
  19586. }
  19587. }
  19588. /**
  19589. * Removes all key-value entries from the hash.
  19590. *
  19591. * @private
  19592. * @name clear
  19593. * @memberOf Hash
  19594. */
  19595. function hashClear() {
  19596. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19597. this.size = 0;
  19598. }
  19599. /**
  19600. * Removes `key` and its value from the hash.
  19601. *
  19602. * @private
  19603. * @name delete
  19604. * @memberOf Hash
  19605. * @param {Object} hash The hash to modify.
  19606. * @param {string} key The key of the value to remove.
  19607. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19608. */
  19609. function hashDelete(key) {
  19610. var result = this.has(key) && delete this.__data__[key];
  19611. this.size -= result ? 1 : 0;
  19612. return result;
  19613. }
  19614. /**
  19615. * Gets the hash value for `key`.
  19616. *
  19617. * @private
  19618. * @name get
  19619. * @memberOf Hash
  19620. * @param {string} key The key of the value to get.
  19621. * @returns {*} Returns the entry value.
  19622. */
  19623. function hashGet(key) {
  19624. var data = this.__data__;
  19625. if (nativeCreate) {
  19626. var result = data[key];
  19627. return result === HASH_UNDEFINED ? undefined : result;
  19628. }
  19629. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19630. }
  19631. /**
  19632. * Checks if a hash value for `key` exists.
  19633. *
  19634. * @private
  19635. * @name has
  19636. * @memberOf Hash
  19637. * @param {string} key The key of the entry to check.
  19638. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19639. */
  19640. function hashHas(key) {
  19641. var data = this.__data__;
  19642. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19643. }
  19644. /**
  19645. * Sets the hash `key` to `value`.
  19646. *
  19647. * @private
  19648. * @name set
  19649. * @memberOf Hash
  19650. * @param {string} key The key of the value to set.
  19651. * @param {*} value The value to set.
  19652. * @returns {Object} Returns the hash instance.
  19653. */
  19654. function hashSet(key, value) {
  19655. var data = this.__data__;
  19656. this.size += this.has(key) ? 0 : 1;
  19657. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19658. return this;
  19659. }
  19660. // Add methods to `Hash`.
  19661. Hash.prototype.clear = hashClear;
  19662. Hash.prototype['delete'] = hashDelete;
  19663. Hash.prototype.get = hashGet;
  19664. Hash.prototype.has = hashHas;
  19665. Hash.prototype.set = hashSet;
  19666. /*------------------------------------------------------------------------*/
  19667. /**
  19668. * Creates an list cache object.
  19669. *
  19670. * @private
  19671. * @constructor
  19672. * @param {Array} [entries] The key-value pairs to cache.
  19673. */
  19674. function ListCache(entries) {
  19675. var index = -1,
  19676. length = entries == null ? 0 : entries.length;
  19677. this.clear();
  19678. while (++index < length) {
  19679. var entry = entries[index];
  19680. this.set(entry[0], entry[1]);
  19681. }
  19682. }
  19683. /**
  19684. * Removes all key-value entries from the list cache.
  19685. *
  19686. * @private
  19687. * @name clear
  19688. * @memberOf ListCache
  19689. */
  19690. function listCacheClear() {
  19691. this.__data__ = [];
  19692. this.size = 0;
  19693. }
  19694. /**
  19695. * Removes `key` and its value from the list cache.
  19696. *
  19697. * @private
  19698. * @name delete
  19699. * @memberOf ListCache
  19700. * @param {string} key The key of the value to remove.
  19701. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19702. */
  19703. function listCacheDelete(key) {
  19704. var data = this.__data__,
  19705. index = assocIndexOf(data, key);
  19706. if (index < 0) {
  19707. return false;
  19708. }
  19709. var lastIndex = data.length - 1;
  19710. if (index == lastIndex) {
  19711. data.pop();
  19712. } else {
  19713. splice.call(data, index, 1);
  19714. }
  19715. --this.size;
  19716. return true;
  19717. }
  19718. /**
  19719. * Gets the list cache value for `key`.
  19720. *
  19721. * @private
  19722. * @name get
  19723. * @memberOf ListCache
  19724. * @param {string} key The key of the value to get.
  19725. * @returns {*} Returns the entry value.
  19726. */
  19727. function listCacheGet(key) {
  19728. var data = this.__data__,
  19729. index = assocIndexOf(data, key);
  19730. return index < 0 ? undefined : data[index][1];
  19731. }
  19732. /**
  19733. * Checks if a list cache value for `key` exists.
  19734. *
  19735. * @private
  19736. * @name has
  19737. * @memberOf ListCache
  19738. * @param {string} key The key of the entry to check.
  19739. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19740. */
  19741. function listCacheHas(key) {
  19742. return assocIndexOf(this.__data__, key) > -1;
  19743. }
  19744. /**
  19745. * Sets the list cache `key` to `value`.
  19746. *
  19747. * @private
  19748. * @name set
  19749. * @memberOf ListCache
  19750. * @param {string} key The key of the value to set.
  19751. * @param {*} value The value to set.
  19752. * @returns {Object} Returns the list cache instance.
  19753. */
  19754. function listCacheSet(key, value) {
  19755. var data = this.__data__,
  19756. index = assocIndexOf(data, key);
  19757. if (index < 0) {
  19758. ++this.size;
  19759. data.push([key, value]);
  19760. } else {
  19761. data[index][1] = value;
  19762. }
  19763. return this;
  19764. }
  19765. // Add methods to `ListCache`.
  19766. ListCache.prototype.clear = listCacheClear;
  19767. ListCache.prototype['delete'] = listCacheDelete;
  19768. ListCache.prototype.get = listCacheGet;
  19769. ListCache.prototype.has = listCacheHas;
  19770. ListCache.prototype.set = listCacheSet;
  19771. /*------------------------------------------------------------------------*/
  19772. /**
  19773. * Creates a map cache object to store key-value pairs.
  19774. *
  19775. * @private
  19776. * @constructor
  19777. * @param {Array} [entries] The key-value pairs to cache.
  19778. */
  19779. function MapCache(entries) {
  19780. var index = -1,
  19781. length = entries == null ? 0 : entries.length;
  19782. this.clear();
  19783. while (++index < length) {
  19784. var entry = entries[index];
  19785. this.set(entry[0], entry[1]);
  19786. }
  19787. }
  19788. /**
  19789. * Removes all key-value entries from the map.
  19790. *
  19791. * @private
  19792. * @name clear
  19793. * @memberOf MapCache
  19794. */
  19795. function mapCacheClear() {
  19796. this.size = 0;
  19797. this.__data__ = {
  19798. 'hash': new Hash,
  19799. 'map': new (Map || ListCache),
  19800. 'string': new Hash
  19801. };
  19802. }
  19803. /**
  19804. * Removes `key` and its value from the map.
  19805. *
  19806. * @private
  19807. * @name delete
  19808. * @memberOf MapCache
  19809. * @param {string} key The key of the value to remove.
  19810. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19811. */
  19812. function mapCacheDelete(key) {
  19813. var result = getMapData(this, key)['delete'](key);
  19814. this.size -= result ? 1 : 0;
  19815. return result;
  19816. }
  19817. /**
  19818. * Gets the map value for `key`.
  19819. *
  19820. * @private
  19821. * @name get
  19822. * @memberOf MapCache
  19823. * @param {string} key The key of the value to get.
  19824. * @returns {*} Returns the entry value.
  19825. */
  19826. function mapCacheGet(key) {
  19827. return getMapData(this, key).get(key);
  19828. }
  19829. /**
  19830. * Checks if a map value for `key` exists.
  19831. *
  19832. * @private
  19833. * @name has
  19834. * @memberOf MapCache
  19835. * @param {string} key The key of the entry to check.
  19836. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19837. */
  19838. function mapCacheHas(key) {
  19839. return getMapData(this, key).has(key);
  19840. }
  19841. /**
  19842. * Sets the map `key` to `value`.
  19843. *
  19844. * @private
  19845. * @name set
  19846. * @memberOf MapCache
  19847. * @param {string} key The key of the value to set.
  19848. * @param {*} value The value to set.
  19849. * @returns {Object} Returns the map cache instance.
  19850. */
  19851. function mapCacheSet(key, value) {
  19852. var data = getMapData(this, key),
  19853. size = data.size;
  19854. data.set(key, value);
  19855. this.size += data.size == size ? 0 : 1;
  19856. return this;
  19857. }
  19858. // Add methods to `MapCache`.
  19859. MapCache.prototype.clear = mapCacheClear;
  19860. MapCache.prototype['delete'] = mapCacheDelete;
  19861. MapCache.prototype.get = mapCacheGet;
  19862. MapCache.prototype.has = mapCacheHas;
  19863. MapCache.prototype.set = mapCacheSet;
  19864. /*------------------------------------------------------------------------*/
  19865. /**
  19866. *
  19867. * Creates an array cache object to store unique values.
  19868. *
  19869. * @private
  19870. * @constructor
  19871. * @param {Array} [values] The values to cache.
  19872. */
  19873. function SetCache(values) {
  19874. var index = -1,
  19875. length = values == null ? 0 : values.length;
  19876. this.__data__ = new MapCache;
  19877. while (++index < length) {
  19878. this.add(values[index]);
  19879. }
  19880. }
  19881. /**
  19882. * Adds `value` to the array cache.
  19883. *
  19884. * @private
  19885. * @name add
  19886. * @memberOf SetCache
  19887. * @alias push
  19888. * @param {*} value The value to cache.
  19889. * @returns {Object} Returns the cache instance.
  19890. */
  19891. function setCacheAdd(value) {
  19892. this.__data__.set(value, HASH_UNDEFINED);
  19893. return this;
  19894. }
  19895. /**
  19896. * Checks if `value` is in the array cache.
  19897. *
  19898. * @private
  19899. * @name has
  19900. * @memberOf SetCache
  19901. * @param {*} value The value to search for.
  19902. * @returns {number} Returns `true` if `value` is found, else `false`.
  19903. */
  19904. function setCacheHas(value) {
  19905. return this.__data__.has(value);
  19906. }
  19907. // Add methods to `SetCache`.
  19908. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19909. SetCache.prototype.has = setCacheHas;
  19910. /*------------------------------------------------------------------------*/
  19911. /**
  19912. * Creates a stack cache object to store key-value pairs.
  19913. *
  19914. * @private
  19915. * @constructor
  19916. * @param {Array} [entries] The key-value pairs to cache.
  19917. */
  19918. function Stack(entries) {
  19919. var data = this.__data__ = new ListCache(entries);
  19920. this.size = data.size;
  19921. }
  19922. /**
  19923. * Removes all key-value entries from the stack.
  19924. *
  19925. * @private
  19926. * @name clear
  19927. * @memberOf Stack
  19928. */
  19929. function stackClear() {
  19930. this.__data__ = new ListCache;
  19931. this.size = 0;
  19932. }
  19933. /**
  19934. * Removes `key` and its value from the stack.
  19935. *
  19936. * @private
  19937. * @name delete
  19938. * @memberOf Stack
  19939. * @param {string} key The key of the value to remove.
  19940. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19941. */
  19942. function stackDelete(key) {
  19943. var data = this.__data__,
  19944. result = data['delete'](key);
  19945. this.size = data.size;
  19946. return result;
  19947. }
  19948. /**
  19949. * Gets the stack value for `key`.
  19950. *
  19951. * @private
  19952. * @name get
  19953. * @memberOf Stack
  19954. * @param {string} key The key of the value to get.
  19955. * @returns {*} Returns the entry value.
  19956. */
  19957. function stackGet(key) {
  19958. return this.__data__.get(key);
  19959. }
  19960. /**
  19961. * Checks if a stack value for `key` exists.
  19962. *
  19963. * @private
  19964. * @name has
  19965. * @memberOf Stack
  19966. * @param {string} key The key of the entry to check.
  19967. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19968. */
  19969. function stackHas(key) {
  19970. return this.__data__.has(key);
  19971. }
  19972. /**
  19973. * Sets the stack `key` to `value`.
  19974. *
  19975. * @private
  19976. * @name set
  19977. * @memberOf Stack
  19978. * @param {string} key The key of the value to set.
  19979. * @param {*} value The value to set.
  19980. * @returns {Object} Returns the stack cache instance.
  19981. */
  19982. function stackSet(key, value) {
  19983. var data = this.__data__;
  19984. if (data instanceof ListCache) {
  19985. var pairs = data.__data__;
  19986. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19987. pairs.push([key, value]);
  19988. this.size = ++data.size;
  19989. return this;
  19990. }
  19991. data = this.__data__ = new MapCache(pairs);
  19992. }
  19993. data.set(key, value);
  19994. this.size = data.size;
  19995. return this;
  19996. }
  19997. // Add methods to `Stack`.
  19998. Stack.prototype.clear = stackClear;
  19999. Stack.prototype['delete'] = stackDelete;
  20000. Stack.prototype.get = stackGet;
  20001. Stack.prototype.has = stackHas;
  20002. Stack.prototype.set = stackSet;
  20003. /*------------------------------------------------------------------------*/
  20004. /**
  20005. * Creates an array of the enumerable property names of the array-like `value`.
  20006. *
  20007. * @private
  20008. * @param {*} value The value to query.
  20009. * @param {boolean} inherited Specify returning inherited property names.
  20010. * @returns {Array} Returns the array of property names.
  20011. */
  20012. function arrayLikeKeys(value, inherited) {
  20013. var isArr = isArray(value),
  20014. isArg = !isArr && isArguments(value),
  20015. isBuff = !isArr && !isArg && isBuffer(value),
  20016. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  20017. skipIndexes = isArr || isArg || isBuff || isType,
  20018. result = skipIndexes ? baseTimes(value.length, String) : [],
  20019. length = result.length;
  20020. for (var key in value) {
  20021. if ((inherited || hasOwnProperty.call(value, key)) &&
  20022. !(skipIndexes && (
  20023. // Safari 9 has enumerable `arguments.length` in strict mode.
  20024. key == 'length' ||
  20025. // Node.js 0.10 has enumerable non-index properties on buffers.
  20026. (isBuff && (key == 'offset' || key == 'parent')) ||
  20027. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  20028. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  20029. // Skip index properties.
  20030. isIndex(key, length)
  20031. ))) {
  20032. result.push(key);
  20033. }
  20034. }
  20035. return result;
  20036. }
  20037. /**
  20038. * A specialized version of `_.sample` for arrays.
  20039. *
  20040. * @private
  20041. * @param {Array} array The array to sample.
  20042. * @returns {*} Returns the random element.
  20043. */
  20044. function arraySample(array) {
  20045. var length = array.length;
  20046. return length ? array[baseRandom(0, length - 1)] : undefined;
  20047. }
  20048. /**
  20049. * A specialized version of `_.sampleSize` for arrays.
  20050. *
  20051. * @private
  20052. * @param {Array} array The array to sample.
  20053. * @param {number} n The number of elements to sample.
  20054. * @returns {Array} Returns the random elements.
  20055. */
  20056. function arraySampleSize(array, n) {
  20057. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  20058. }
  20059. /**
  20060. * A specialized version of `_.shuffle` for arrays.
  20061. *
  20062. * @private
  20063. * @param {Array} array The array to shuffle.
  20064. * @returns {Array} Returns the new shuffled array.
  20065. */
  20066. function arrayShuffle(array) {
  20067. return shuffleSelf(copyArray(array));
  20068. }
  20069. /**
  20070. * This function is like `assignValue` except that it doesn't assign
  20071. * `undefined` values.
  20072. *
  20073. * @private
  20074. * @param {Object} object The object to modify.
  20075. * @param {string} key The key of the property to assign.
  20076. * @param {*} value The value to assign.
  20077. */
  20078. function assignMergeValue(object, key, value) {
  20079. if ((value !== undefined && !eq(object[key], value)) ||
  20080. (value === undefined && !(key in object))) {
  20081. baseAssignValue(object, key, value);
  20082. }
  20083. }
  20084. /**
  20085. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  20086. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20087. * for equality comparisons.
  20088. *
  20089. * @private
  20090. * @param {Object} object The object to modify.
  20091. * @param {string} key The key of the property to assign.
  20092. * @param {*} value The value to assign.
  20093. */
  20094. function assignValue(object, key, value) {
  20095. var objValue = object[key];
  20096. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  20097. (value === undefined && !(key in object))) {
  20098. baseAssignValue(object, key, value);
  20099. }
  20100. }
  20101. /**
  20102. * Gets the index at which the `key` is found in `array` of key-value pairs.
  20103. *
  20104. * @private
  20105. * @param {Array} array The array to inspect.
  20106. * @param {*} key The key to search for.
  20107. * @returns {number} Returns the index of the matched value, else `-1`.
  20108. */
  20109. function assocIndexOf(array, key) {
  20110. var length = array.length;
  20111. while (length--) {
  20112. if (eq(array[length][0], key)) {
  20113. return length;
  20114. }
  20115. }
  20116. return -1;
  20117. }
  20118. /**
  20119. * Aggregates elements of `collection` on `accumulator` with keys transformed
  20120. * by `iteratee` and values set by `setter`.
  20121. *
  20122. * @private
  20123. * @param {Array|Object} collection The collection to iterate over.
  20124. * @param {Function} setter The function to set `accumulator` values.
  20125. * @param {Function} iteratee The iteratee to transform keys.
  20126. * @param {Object} accumulator The initial aggregated object.
  20127. * @returns {Function} Returns `accumulator`.
  20128. */
  20129. function baseAggregator(collection, setter, iteratee, accumulator) {
  20130. baseEach(collection, function(value, key, collection) {
  20131. setter(accumulator, value, iteratee(value), collection);
  20132. });
  20133. return accumulator;
  20134. }
  20135. /**
  20136. * The base implementation of `_.assign` without support for multiple sources
  20137. * or `customizer` functions.
  20138. *
  20139. * @private
  20140. * @param {Object} object The destination object.
  20141. * @param {Object} source The source object.
  20142. * @returns {Object} Returns `object`.
  20143. */
  20144. function baseAssign(object, source) {
  20145. return object && copyObject(source, keys(source), object);
  20146. }
  20147. /**
  20148. * The base implementation of `_.assignIn` without support for multiple sources
  20149. * or `customizer` functions.
  20150. *
  20151. * @private
  20152. * @param {Object} object The destination object.
  20153. * @param {Object} source The source object.
  20154. * @returns {Object} Returns `object`.
  20155. */
  20156. function baseAssignIn(object, source) {
  20157. return object && copyObject(source, keysIn(source), object);
  20158. }
  20159. /**
  20160. * The base implementation of `assignValue` and `assignMergeValue` without
  20161. * value checks.
  20162. *
  20163. * @private
  20164. * @param {Object} object The object to modify.
  20165. * @param {string} key The key of the property to assign.
  20166. * @param {*} value The value to assign.
  20167. */
  20168. function baseAssignValue(object, key, value) {
  20169. if (key == '__proto__' && defineProperty) {
  20170. defineProperty(object, key, {
  20171. 'configurable': true,
  20172. 'enumerable': true,
  20173. 'value': value,
  20174. 'writable': true
  20175. });
  20176. } else {
  20177. object[key] = value;
  20178. }
  20179. }
  20180. /**
  20181. * The base implementation of `_.at` without support for individual paths.
  20182. *
  20183. * @private
  20184. * @param {Object} object The object to iterate over.
  20185. * @param {string[]} paths The property paths to pick.
  20186. * @returns {Array} Returns the picked elements.
  20187. */
  20188. function baseAt(object, paths) {
  20189. var index = -1,
  20190. length = paths.length,
  20191. result = Array(length),
  20192. skip = object == null;
  20193. while (++index < length) {
  20194. result[index] = skip ? undefined : get(object, paths[index]);
  20195. }
  20196. return result;
  20197. }
  20198. /**
  20199. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20200. *
  20201. * @private
  20202. * @param {number} number The number to clamp.
  20203. * @param {number} [lower] The lower bound.
  20204. * @param {number} upper The upper bound.
  20205. * @returns {number} Returns the clamped number.
  20206. */
  20207. function baseClamp(number, lower, upper) {
  20208. if (number === number) {
  20209. if (upper !== undefined) {
  20210. number = number <= upper ? number : upper;
  20211. }
  20212. if (lower !== undefined) {
  20213. number = number >= lower ? number : lower;
  20214. }
  20215. }
  20216. return number;
  20217. }
  20218. /**
  20219. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20220. * traversed objects.
  20221. *
  20222. * @private
  20223. * @param {*} value The value to clone.
  20224. * @param {boolean} bitmask The bitmask flags.
  20225. * 1 - Deep clone
  20226. * 2 - Flatten inherited properties
  20227. * 4 - Clone symbols
  20228. * @param {Function} [customizer] The function to customize cloning.
  20229. * @param {string} [key] The key of `value`.
  20230. * @param {Object} [object] The parent object of `value`.
  20231. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20232. * @returns {*} Returns the cloned value.
  20233. */
  20234. function baseClone(value, bitmask, customizer, key, object, stack) {
  20235. var result,
  20236. isDeep = bitmask & CLONE_DEEP_FLAG,
  20237. isFlat = bitmask & CLONE_FLAT_FLAG,
  20238. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20239. if (customizer) {
  20240. result = object ? customizer(value, key, object, stack) : customizer(value);
  20241. }
  20242. if (result !== undefined) {
  20243. return result;
  20244. }
  20245. if (!isObject(value)) {
  20246. return value;
  20247. }
  20248. var isArr = isArray(value);
  20249. if (isArr) {
  20250. result = initCloneArray(value);
  20251. if (!isDeep) {
  20252. return copyArray(value, result);
  20253. }
  20254. } else {
  20255. var tag = getTag(value),
  20256. isFunc = tag == funcTag || tag == genTag;
  20257. if (isBuffer(value)) {
  20258. return cloneBuffer(value, isDeep);
  20259. }
  20260. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20261. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20262. if (!isDeep) {
  20263. return isFlat
  20264. ? copySymbolsIn(value, baseAssignIn(result, value))
  20265. : copySymbols(value, baseAssign(result, value));
  20266. }
  20267. } else {
  20268. if (!cloneableTags[tag]) {
  20269. return object ? value : {};
  20270. }
  20271. result = initCloneByTag(value, tag, isDeep);
  20272. }
  20273. }
  20274. // Check for circular references and return its corresponding clone.
  20275. stack || (stack = new Stack);
  20276. var stacked = stack.get(value);
  20277. if (stacked) {
  20278. return stacked;
  20279. }
  20280. stack.set(value, result);
  20281. if (isSet(value)) {
  20282. value.forEach(function(subValue) {
  20283. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20284. });
  20285. } else if (isMap(value)) {
  20286. value.forEach(function(subValue, key) {
  20287. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20288. });
  20289. }
  20290. var keysFunc = isFull
  20291. ? (isFlat ? getAllKeysIn : getAllKeys)
  20292. : (isFlat ? keysIn : keys);
  20293. var props = isArr ? undefined : keysFunc(value);
  20294. arrayEach(props || value, function(subValue, key) {
  20295. if (props) {
  20296. key = subValue;
  20297. subValue = value[key];
  20298. }
  20299. // Recursively populate clone (susceptible to call stack limits).
  20300. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20301. });
  20302. return result;
  20303. }
  20304. /**
  20305. * The base implementation of `_.conforms` which doesn't clone `source`.
  20306. *
  20307. * @private
  20308. * @param {Object} source The object of property predicates to conform to.
  20309. * @returns {Function} Returns the new spec function.
  20310. */
  20311. function baseConforms(source) {
  20312. var props = keys(source);
  20313. return function(object) {
  20314. return baseConformsTo(object, source, props);
  20315. };
  20316. }
  20317. /**
  20318. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20319. *
  20320. * @private
  20321. * @param {Object} object The object to inspect.
  20322. * @param {Object} source The object of property predicates to conform to.
  20323. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20324. */
  20325. function baseConformsTo(object, source, props) {
  20326. var length = props.length;
  20327. if (object == null) {
  20328. return !length;
  20329. }
  20330. object = Object(object);
  20331. while (length--) {
  20332. var key = props[length],
  20333. predicate = source[key],
  20334. value = object[key];
  20335. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20336. return false;
  20337. }
  20338. }
  20339. return true;
  20340. }
  20341. /**
  20342. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20343. * to provide to `func`.
  20344. *
  20345. * @private
  20346. * @param {Function} func The function to delay.
  20347. * @param {number} wait The number of milliseconds to delay invocation.
  20348. * @param {Array} args The arguments to provide to `func`.
  20349. * @returns {number|Object} Returns the timer id or timeout object.
  20350. */
  20351. function baseDelay(func, wait, args) {
  20352. if (typeof func != 'function') {
  20353. throw new TypeError(FUNC_ERROR_TEXT);
  20354. }
  20355. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20356. }
  20357. /**
  20358. * The base implementation of methods like `_.difference` without support
  20359. * for excluding multiple arrays or iteratee shorthands.
  20360. *
  20361. * @private
  20362. * @param {Array} array The array to inspect.
  20363. * @param {Array} values The values to exclude.
  20364. * @param {Function} [iteratee] The iteratee invoked per element.
  20365. * @param {Function} [comparator] The comparator invoked per element.
  20366. * @returns {Array} Returns the new array of filtered values.
  20367. */
  20368. function baseDifference(array, values, iteratee, comparator) {
  20369. var index = -1,
  20370. includes = arrayIncludes,
  20371. isCommon = true,
  20372. length = array.length,
  20373. result = [],
  20374. valuesLength = values.length;
  20375. if (!length) {
  20376. return result;
  20377. }
  20378. if (iteratee) {
  20379. values = arrayMap(values, baseUnary(iteratee));
  20380. }
  20381. if (comparator) {
  20382. includes = arrayIncludesWith;
  20383. isCommon = false;
  20384. }
  20385. else if (values.length >= LARGE_ARRAY_SIZE) {
  20386. includes = cacheHas;
  20387. isCommon = false;
  20388. values = new SetCache(values);
  20389. }
  20390. outer:
  20391. while (++index < length) {
  20392. var value = array[index],
  20393. computed = iteratee == null ? value : iteratee(value);
  20394. value = (comparator || value !== 0) ? value : 0;
  20395. if (isCommon && computed === computed) {
  20396. var valuesIndex = valuesLength;
  20397. while (valuesIndex--) {
  20398. if (values[valuesIndex] === computed) {
  20399. continue outer;
  20400. }
  20401. }
  20402. result.push(value);
  20403. }
  20404. else if (!includes(values, computed, comparator)) {
  20405. result.push(value);
  20406. }
  20407. }
  20408. return result;
  20409. }
  20410. /**
  20411. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20412. *
  20413. * @private
  20414. * @param {Array|Object} collection The collection to iterate over.
  20415. * @param {Function} iteratee The function invoked per iteration.
  20416. * @returns {Array|Object} Returns `collection`.
  20417. */
  20418. var baseEach = createBaseEach(baseForOwn);
  20419. /**
  20420. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20421. *
  20422. * @private
  20423. * @param {Array|Object} collection The collection to iterate over.
  20424. * @param {Function} iteratee The function invoked per iteration.
  20425. * @returns {Array|Object} Returns `collection`.
  20426. */
  20427. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20428. /**
  20429. * The base implementation of `_.every` without support for iteratee shorthands.
  20430. *
  20431. * @private
  20432. * @param {Array|Object} collection The collection to iterate over.
  20433. * @param {Function} predicate The function invoked per iteration.
  20434. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20435. * else `false`
  20436. */
  20437. function baseEvery(collection, predicate) {
  20438. var result = true;
  20439. baseEach(collection, function(value, index, collection) {
  20440. result = !!predicate(value, index, collection);
  20441. return result;
  20442. });
  20443. return result;
  20444. }
  20445. /**
  20446. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20447. * `comparator` to determine the extremum value.
  20448. *
  20449. * @private
  20450. * @param {Array} array The array to iterate over.
  20451. * @param {Function} iteratee The iteratee invoked per iteration.
  20452. * @param {Function} comparator The comparator used to compare values.
  20453. * @returns {*} Returns the extremum value.
  20454. */
  20455. function baseExtremum(array, iteratee, comparator) {
  20456. var index = -1,
  20457. length = array.length;
  20458. while (++index < length) {
  20459. var value = array[index],
  20460. current = iteratee(value);
  20461. if (current != null && (computed === undefined
  20462. ? (current === current && !isSymbol(current))
  20463. : comparator(current, computed)
  20464. )) {
  20465. var computed = current,
  20466. result = value;
  20467. }
  20468. }
  20469. return result;
  20470. }
  20471. /**
  20472. * The base implementation of `_.fill` without an iteratee call guard.
  20473. *
  20474. * @private
  20475. * @param {Array} array The array to fill.
  20476. * @param {*} value The value to fill `array` with.
  20477. * @param {number} [start=0] The start position.
  20478. * @param {number} [end=array.length] The end position.
  20479. * @returns {Array} Returns `array`.
  20480. */
  20481. function baseFill(array, value, start, end) {
  20482. var length = array.length;
  20483. start = toInteger(start);
  20484. if (start < 0) {
  20485. start = -start > length ? 0 : (length + start);
  20486. }
  20487. end = (end === undefined || end > length) ? length : toInteger(end);
  20488. if (end < 0) {
  20489. end += length;
  20490. }
  20491. end = start > end ? 0 : toLength(end);
  20492. while (start < end) {
  20493. array[start++] = value;
  20494. }
  20495. return array;
  20496. }
  20497. /**
  20498. * The base implementation of `_.filter` without support for iteratee shorthands.
  20499. *
  20500. * @private
  20501. * @param {Array|Object} collection The collection to iterate over.
  20502. * @param {Function} predicate The function invoked per iteration.
  20503. * @returns {Array} Returns the new filtered array.
  20504. */
  20505. function baseFilter(collection, predicate) {
  20506. var result = [];
  20507. baseEach(collection, function(value, index, collection) {
  20508. if (predicate(value, index, collection)) {
  20509. result.push(value);
  20510. }
  20511. });
  20512. return result;
  20513. }
  20514. /**
  20515. * The base implementation of `_.flatten` with support for restricting flattening.
  20516. *
  20517. * @private
  20518. * @param {Array} array The array to flatten.
  20519. * @param {number} depth The maximum recursion depth.
  20520. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20521. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20522. * @param {Array} [result=[]] The initial result value.
  20523. * @returns {Array} Returns the new flattened array.
  20524. */
  20525. function baseFlatten(array, depth, predicate, isStrict, result) {
  20526. var index = -1,
  20527. length = array.length;
  20528. predicate || (predicate = isFlattenable);
  20529. result || (result = []);
  20530. while (++index < length) {
  20531. var value = array[index];
  20532. if (depth > 0 && predicate(value)) {
  20533. if (depth > 1) {
  20534. // Recursively flatten arrays (susceptible to call stack limits).
  20535. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20536. } else {
  20537. arrayPush(result, value);
  20538. }
  20539. } else if (!isStrict) {
  20540. result[result.length] = value;
  20541. }
  20542. }
  20543. return result;
  20544. }
  20545. /**
  20546. * The base implementation of `baseForOwn` which iterates over `object`
  20547. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20548. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20549. *
  20550. * @private
  20551. * @param {Object} object The object to iterate over.
  20552. * @param {Function} iteratee The function invoked per iteration.
  20553. * @param {Function} keysFunc The function to get the keys of `object`.
  20554. * @returns {Object} Returns `object`.
  20555. */
  20556. var baseFor = createBaseFor();
  20557. /**
  20558. * This function is like `baseFor` except that it iterates over properties
  20559. * in the opposite order.
  20560. *
  20561. * @private
  20562. * @param {Object} object The object to iterate over.
  20563. * @param {Function} iteratee The function invoked per iteration.
  20564. * @param {Function} keysFunc The function to get the keys of `object`.
  20565. * @returns {Object} Returns `object`.
  20566. */
  20567. var baseForRight = createBaseFor(true);
  20568. /**
  20569. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20570. *
  20571. * @private
  20572. * @param {Object} object The object to iterate over.
  20573. * @param {Function} iteratee The function invoked per iteration.
  20574. * @returns {Object} Returns `object`.
  20575. */
  20576. function baseForOwn(object, iteratee) {
  20577. return object && baseFor(object, iteratee, keys);
  20578. }
  20579. /**
  20580. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20581. *
  20582. * @private
  20583. * @param {Object} object The object to iterate over.
  20584. * @param {Function} iteratee The function invoked per iteration.
  20585. * @returns {Object} Returns `object`.
  20586. */
  20587. function baseForOwnRight(object, iteratee) {
  20588. return object && baseForRight(object, iteratee, keys);
  20589. }
  20590. /**
  20591. * The base implementation of `_.functions` which creates an array of
  20592. * `object` function property names filtered from `props`.
  20593. *
  20594. * @private
  20595. * @param {Object} object The object to inspect.
  20596. * @param {Array} props The property names to filter.
  20597. * @returns {Array} Returns the function names.
  20598. */
  20599. function baseFunctions(object, props) {
  20600. return arrayFilter(props, function(key) {
  20601. return isFunction(object[key]);
  20602. });
  20603. }
  20604. /**
  20605. * The base implementation of `_.get` without support for default values.
  20606. *
  20607. * @private
  20608. * @param {Object} object The object to query.
  20609. * @param {Array|string} path The path of the property to get.
  20610. * @returns {*} Returns the resolved value.
  20611. */
  20612. function baseGet(object, path) {
  20613. path = castPath(path, object);
  20614. var index = 0,
  20615. length = path.length;
  20616. while (object != null && index < length) {
  20617. object = object[toKey(path[index++])];
  20618. }
  20619. return (index && index == length) ? object : undefined;
  20620. }
  20621. /**
  20622. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20623. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20624. * symbols of `object`.
  20625. *
  20626. * @private
  20627. * @param {Object} object The object to query.
  20628. * @param {Function} keysFunc The function to get the keys of `object`.
  20629. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20630. * @returns {Array} Returns the array of property names and symbols.
  20631. */
  20632. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20633. var result = keysFunc(object);
  20634. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20635. }
  20636. /**
  20637. * The base implementation of `getTag` without fallbacks for buggy environments.
  20638. *
  20639. * @private
  20640. * @param {*} value The value to query.
  20641. * @returns {string} Returns the `toStringTag`.
  20642. */
  20643. function baseGetTag(value) {
  20644. if (value == null) {
  20645. return value === undefined ? undefinedTag : nullTag;
  20646. }
  20647. return (symToStringTag && symToStringTag in Object(value))
  20648. ? getRawTag(value)
  20649. : objectToString(value);
  20650. }
  20651. /**
  20652. * The base implementation of `_.gt` which doesn't coerce arguments.
  20653. *
  20654. * @private
  20655. * @param {*} value The value to compare.
  20656. * @param {*} other The other value to compare.
  20657. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20658. * else `false`.
  20659. */
  20660. function baseGt(value, other) {
  20661. return value > other;
  20662. }
  20663. /**
  20664. * The base implementation of `_.has` without support for deep paths.
  20665. *
  20666. * @private
  20667. * @param {Object} [object] The object to query.
  20668. * @param {Array|string} key The key to check.
  20669. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20670. */
  20671. function baseHas(object, key) {
  20672. return object != null && hasOwnProperty.call(object, key);
  20673. }
  20674. /**
  20675. * The base implementation of `_.hasIn` without support for deep paths.
  20676. *
  20677. * @private
  20678. * @param {Object} [object] The object to query.
  20679. * @param {Array|string} key The key to check.
  20680. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20681. */
  20682. function baseHasIn(object, key) {
  20683. return object != null && key in Object(object);
  20684. }
  20685. /**
  20686. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20687. *
  20688. * @private
  20689. * @param {number} number The number to check.
  20690. * @param {number} start The start of the range.
  20691. * @param {number} end The end of the range.
  20692. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20693. */
  20694. function baseInRange(number, start, end) {
  20695. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20696. }
  20697. /**
  20698. * The base implementation of methods like `_.intersection`, without support
  20699. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20700. *
  20701. * @private
  20702. * @param {Array} arrays The arrays to inspect.
  20703. * @param {Function} [iteratee] The iteratee invoked per element.
  20704. * @param {Function} [comparator] The comparator invoked per element.
  20705. * @returns {Array} Returns the new array of shared values.
  20706. */
  20707. function baseIntersection(arrays, iteratee, comparator) {
  20708. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20709. length = arrays[0].length,
  20710. othLength = arrays.length,
  20711. othIndex = othLength,
  20712. caches = Array(othLength),
  20713. maxLength = Infinity,
  20714. result = [];
  20715. while (othIndex--) {
  20716. var array = arrays[othIndex];
  20717. if (othIndex && iteratee) {
  20718. array = arrayMap(array, baseUnary(iteratee));
  20719. }
  20720. maxLength = nativeMin(array.length, maxLength);
  20721. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20722. ? new SetCache(othIndex && array)
  20723. : undefined;
  20724. }
  20725. array = arrays[0];
  20726. var index = -1,
  20727. seen = caches[0];
  20728. outer:
  20729. while (++index < length && result.length < maxLength) {
  20730. var value = array[index],
  20731. computed = iteratee ? iteratee(value) : value;
  20732. value = (comparator || value !== 0) ? value : 0;
  20733. if (!(seen
  20734. ? cacheHas(seen, computed)
  20735. : includes(result, computed, comparator)
  20736. )) {
  20737. othIndex = othLength;
  20738. while (--othIndex) {
  20739. var cache = caches[othIndex];
  20740. if (!(cache
  20741. ? cacheHas(cache, computed)
  20742. : includes(arrays[othIndex], computed, comparator))
  20743. ) {
  20744. continue outer;
  20745. }
  20746. }
  20747. if (seen) {
  20748. seen.push(computed);
  20749. }
  20750. result.push(value);
  20751. }
  20752. }
  20753. return result;
  20754. }
  20755. /**
  20756. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20757. * `object` with values transformed by `iteratee` and set by `setter`.
  20758. *
  20759. * @private
  20760. * @param {Object} object The object to iterate over.
  20761. * @param {Function} setter The function to set `accumulator` values.
  20762. * @param {Function} iteratee The iteratee to transform values.
  20763. * @param {Object} accumulator The initial inverted object.
  20764. * @returns {Function} Returns `accumulator`.
  20765. */
  20766. function baseInverter(object, setter, iteratee, accumulator) {
  20767. baseForOwn(object, function(value, key, object) {
  20768. setter(accumulator, iteratee(value), key, object);
  20769. });
  20770. return accumulator;
  20771. }
  20772. /**
  20773. * The base implementation of `_.invoke` without support for individual
  20774. * method arguments.
  20775. *
  20776. * @private
  20777. * @param {Object} object The object to query.
  20778. * @param {Array|string} path The path of the method to invoke.
  20779. * @param {Array} args The arguments to invoke the method with.
  20780. * @returns {*} Returns the result of the invoked method.
  20781. */
  20782. function baseInvoke(object, path, args) {
  20783. path = castPath(path, object);
  20784. object = parent(object, path);
  20785. var func = object == null ? object : object[toKey(last(path))];
  20786. return func == null ? undefined : apply(func, object, args);
  20787. }
  20788. /**
  20789. * The base implementation of `_.isArguments`.
  20790. *
  20791. * @private
  20792. * @param {*} value The value to check.
  20793. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20794. */
  20795. function baseIsArguments(value) {
  20796. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20797. }
  20798. /**
  20799. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20800. *
  20801. * @private
  20802. * @param {*} value The value to check.
  20803. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20804. */
  20805. function baseIsArrayBuffer(value) {
  20806. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20807. }
  20808. /**
  20809. * The base implementation of `_.isDate` without Node.js optimizations.
  20810. *
  20811. * @private
  20812. * @param {*} value The value to check.
  20813. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20814. */
  20815. function baseIsDate(value) {
  20816. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20817. }
  20818. /**
  20819. * The base implementation of `_.isEqual` which supports partial comparisons
  20820. * and tracks traversed objects.
  20821. *
  20822. * @private
  20823. * @param {*} value The value to compare.
  20824. * @param {*} other The other value to compare.
  20825. * @param {boolean} bitmask The bitmask flags.
  20826. * 1 - Unordered comparison
  20827. * 2 - Partial comparison
  20828. * @param {Function} [customizer] The function to customize comparisons.
  20829. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20830. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20831. */
  20832. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20833. if (value === other) {
  20834. return true;
  20835. }
  20836. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20837. return value !== value && other !== other;
  20838. }
  20839. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20840. }
  20841. /**
  20842. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20843. * deep comparisons and tracks traversed objects enabling objects with circular
  20844. * references to be compared.
  20845. *
  20846. * @private
  20847. * @param {Object} object The object to compare.
  20848. * @param {Object} other The other object to compare.
  20849. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20850. * @param {Function} customizer The function to customize comparisons.
  20851. * @param {Function} equalFunc The function to determine equivalents of values.
  20852. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20853. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20854. */
  20855. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20856. var objIsArr = isArray(object),
  20857. othIsArr = isArray(other),
  20858. objTag = objIsArr ? arrayTag : getTag(object),
  20859. othTag = othIsArr ? arrayTag : getTag(other);
  20860. objTag = objTag == argsTag ? objectTag : objTag;
  20861. othTag = othTag == argsTag ? objectTag : othTag;
  20862. var objIsObj = objTag == objectTag,
  20863. othIsObj = othTag == objectTag,
  20864. isSameTag = objTag == othTag;
  20865. if (isSameTag && isBuffer(object)) {
  20866. if (!isBuffer(other)) {
  20867. return false;
  20868. }
  20869. objIsArr = true;
  20870. objIsObj = false;
  20871. }
  20872. if (isSameTag && !objIsObj) {
  20873. stack || (stack = new Stack);
  20874. return (objIsArr || isTypedArray(object))
  20875. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20876. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20877. }
  20878. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20879. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20880. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20881. if (objIsWrapped || othIsWrapped) {
  20882. var objUnwrapped = objIsWrapped ? object.value() : object,
  20883. othUnwrapped = othIsWrapped ? other.value() : other;
  20884. stack || (stack = new Stack);
  20885. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20886. }
  20887. }
  20888. if (!isSameTag) {
  20889. return false;
  20890. }
  20891. stack || (stack = new Stack);
  20892. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20893. }
  20894. /**
  20895. * The base implementation of `_.isMap` without Node.js optimizations.
  20896. *
  20897. * @private
  20898. * @param {*} value The value to check.
  20899. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20900. */
  20901. function baseIsMap(value) {
  20902. return isObjectLike(value) && getTag(value) == mapTag;
  20903. }
  20904. /**
  20905. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20906. *
  20907. * @private
  20908. * @param {Object} object The object to inspect.
  20909. * @param {Object} source The object of property values to match.
  20910. * @param {Array} matchData The property names, values, and compare flags to match.
  20911. * @param {Function} [customizer] The function to customize comparisons.
  20912. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20913. */
  20914. function baseIsMatch(object, source, matchData, customizer) {
  20915. var index = matchData.length,
  20916. length = index,
  20917. noCustomizer = !customizer;
  20918. if (object == null) {
  20919. return !length;
  20920. }
  20921. object = Object(object);
  20922. while (index--) {
  20923. var data = matchData[index];
  20924. if ((noCustomizer && data[2])
  20925. ? data[1] !== object[data[0]]
  20926. : !(data[0] in object)
  20927. ) {
  20928. return false;
  20929. }
  20930. }
  20931. while (++index < length) {
  20932. data = matchData[index];
  20933. var key = data[0],
  20934. objValue = object[key],
  20935. srcValue = data[1];
  20936. if (noCustomizer && data[2]) {
  20937. if (objValue === undefined && !(key in object)) {
  20938. return false;
  20939. }
  20940. } else {
  20941. var stack = new Stack;
  20942. if (customizer) {
  20943. var result = customizer(objValue, srcValue, key, object, source, stack);
  20944. }
  20945. if (!(result === undefined
  20946. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20947. : result
  20948. )) {
  20949. return false;
  20950. }
  20951. }
  20952. }
  20953. return true;
  20954. }
  20955. /**
  20956. * The base implementation of `_.isNative` without bad shim checks.
  20957. *
  20958. * @private
  20959. * @param {*} value The value to check.
  20960. * @returns {boolean} Returns `true` if `value` is a native function,
  20961. * else `false`.
  20962. */
  20963. function baseIsNative(value) {
  20964. if (!isObject(value) || isMasked(value)) {
  20965. return false;
  20966. }
  20967. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20968. return pattern.test(toSource(value));
  20969. }
  20970. /**
  20971. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20972. *
  20973. * @private
  20974. * @param {*} value The value to check.
  20975. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20976. */
  20977. function baseIsRegExp(value) {
  20978. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20979. }
  20980. /**
  20981. * The base implementation of `_.isSet` without Node.js optimizations.
  20982. *
  20983. * @private
  20984. * @param {*} value The value to check.
  20985. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20986. */
  20987. function baseIsSet(value) {
  20988. return isObjectLike(value) && getTag(value) == setTag;
  20989. }
  20990. /**
  20991. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20992. *
  20993. * @private
  20994. * @param {*} value The value to check.
  20995. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20996. */
  20997. function baseIsTypedArray(value) {
  20998. return isObjectLike(value) &&
  20999. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  21000. }
  21001. /**
  21002. * The base implementation of `_.iteratee`.
  21003. *
  21004. * @private
  21005. * @param {*} [value=_.identity] The value to convert to an iteratee.
  21006. * @returns {Function} Returns the iteratee.
  21007. */
  21008. function baseIteratee(value) {
  21009. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  21010. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  21011. if (typeof value == 'function') {
  21012. return value;
  21013. }
  21014. if (value == null) {
  21015. return identity;
  21016. }
  21017. if (typeof value == 'object') {
  21018. return isArray(value)
  21019. ? baseMatchesProperty(value[0], value[1])
  21020. : baseMatches(value);
  21021. }
  21022. return property(value);
  21023. }
  21024. /**
  21025. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  21026. *
  21027. * @private
  21028. * @param {Object} object The object to query.
  21029. * @returns {Array} Returns the array of property names.
  21030. */
  21031. function baseKeys(object) {
  21032. if (!isPrototype(object)) {
  21033. return nativeKeys(object);
  21034. }
  21035. var result = [];
  21036. for (var key in Object(object)) {
  21037. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  21038. result.push(key);
  21039. }
  21040. }
  21041. return result;
  21042. }
  21043. /**
  21044. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  21045. *
  21046. * @private
  21047. * @param {Object} object The object to query.
  21048. * @returns {Array} Returns the array of property names.
  21049. */
  21050. function baseKeysIn(object) {
  21051. if (!isObject(object)) {
  21052. return nativeKeysIn(object);
  21053. }
  21054. var isProto = isPrototype(object),
  21055. result = [];
  21056. for (var key in object) {
  21057. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  21058. result.push(key);
  21059. }
  21060. }
  21061. return result;
  21062. }
  21063. /**
  21064. * The base implementation of `_.lt` which doesn't coerce arguments.
  21065. *
  21066. * @private
  21067. * @param {*} value The value to compare.
  21068. * @param {*} other The other value to compare.
  21069. * @returns {boolean} Returns `true` if `value` is less than `other`,
  21070. * else `false`.
  21071. */
  21072. function baseLt(value, other) {
  21073. return value < other;
  21074. }
  21075. /**
  21076. * The base implementation of `_.map` without support for iteratee shorthands.
  21077. *
  21078. * @private
  21079. * @param {Array|Object} collection The collection to iterate over.
  21080. * @param {Function} iteratee The function invoked per iteration.
  21081. * @returns {Array} Returns the new mapped array.
  21082. */
  21083. function baseMap(collection, iteratee) {
  21084. var index = -1,
  21085. result = isArrayLike(collection) ? Array(collection.length) : [];
  21086. baseEach(collection, function(value, key, collection) {
  21087. result[++index] = iteratee(value, key, collection);
  21088. });
  21089. return result;
  21090. }
  21091. /**
  21092. * The base implementation of `_.matches` which doesn't clone `source`.
  21093. *
  21094. * @private
  21095. * @param {Object} source The object of property values to match.
  21096. * @returns {Function} Returns the new spec function.
  21097. */
  21098. function baseMatches(source) {
  21099. var matchData = getMatchData(source);
  21100. if (matchData.length == 1 && matchData[0][2]) {
  21101. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  21102. }
  21103. return function(object) {
  21104. return object === source || baseIsMatch(object, source, matchData);
  21105. };
  21106. }
  21107. /**
  21108. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  21109. *
  21110. * @private
  21111. * @param {string} path The path of the property to get.
  21112. * @param {*} srcValue The value to match.
  21113. * @returns {Function} Returns the new spec function.
  21114. */
  21115. function baseMatchesProperty(path, srcValue) {
  21116. if (isKey(path) && isStrictComparable(srcValue)) {
  21117. return matchesStrictComparable(toKey(path), srcValue);
  21118. }
  21119. return function(object) {
  21120. var objValue = get(object, path);
  21121. return (objValue === undefined && objValue === srcValue)
  21122. ? hasIn(object, path)
  21123. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  21124. };
  21125. }
  21126. /**
  21127. * The base implementation of `_.merge` without support for multiple sources.
  21128. *
  21129. * @private
  21130. * @param {Object} object The destination object.
  21131. * @param {Object} source The source object.
  21132. * @param {number} srcIndex The index of `source`.
  21133. * @param {Function} [customizer] The function to customize merged values.
  21134. * @param {Object} [stack] Tracks traversed source values and their merged
  21135. * counterparts.
  21136. */
  21137. function baseMerge(object, source, srcIndex, customizer, stack) {
  21138. if (object === source) {
  21139. return;
  21140. }
  21141. baseFor(source, function(srcValue, key) {
  21142. stack || (stack = new Stack);
  21143. if (isObject(srcValue)) {
  21144. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21145. }
  21146. else {
  21147. var newValue = customizer
  21148. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21149. : undefined;
  21150. if (newValue === undefined) {
  21151. newValue = srcValue;
  21152. }
  21153. assignMergeValue(object, key, newValue);
  21154. }
  21155. }, keysIn);
  21156. }
  21157. /**
  21158. * A specialized version of `baseMerge` for arrays and objects which performs
  21159. * deep merges and tracks traversed objects enabling objects with circular
  21160. * references to be merged.
  21161. *
  21162. * @private
  21163. * @param {Object} object The destination object.
  21164. * @param {Object} source The source object.
  21165. * @param {string} key The key of the value to merge.
  21166. * @param {number} srcIndex The index of `source`.
  21167. * @param {Function} mergeFunc The function to merge values.
  21168. * @param {Function} [customizer] The function to customize assigned values.
  21169. * @param {Object} [stack] Tracks traversed source values and their merged
  21170. * counterparts.
  21171. */
  21172. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21173. var objValue = safeGet(object, key),
  21174. srcValue = safeGet(source, key),
  21175. stacked = stack.get(srcValue);
  21176. if (stacked) {
  21177. assignMergeValue(object, key, stacked);
  21178. return;
  21179. }
  21180. var newValue = customizer
  21181. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21182. : undefined;
  21183. var isCommon = newValue === undefined;
  21184. if (isCommon) {
  21185. var isArr = isArray(srcValue),
  21186. isBuff = !isArr && isBuffer(srcValue),
  21187. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21188. newValue = srcValue;
  21189. if (isArr || isBuff || isTyped) {
  21190. if (isArray(objValue)) {
  21191. newValue = objValue;
  21192. }
  21193. else if (isArrayLikeObject(objValue)) {
  21194. newValue = copyArray(objValue);
  21195. }
  21196. else if (isBuff) {
  21197. isCommon = false;
  21198. newValue = cloneBuffer(srcValue, true);
  21199. }
  21200. else if (isTyped) {
  21201. isCommon = false;
  21202. newValue = cloneTypedArray(srcValue, true);
  21203. }
  21204. else {
  21205. newValue = [];
  21206. }
  21207. }
  21208. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21209. newValue = objValue;
  21210. if (isArguments(objValue)) {
  21211. newValue = toPlainObject(objValue);
  21212. }
  21213. else if (!isObject(objValue) || isFunction(objValue)) {
  21214. newValue = initCloneObject(srcValue);
  21215. }
  21216. }
  21217. else {
  21218. isCommon = false;
  21219. }
  21220. }
  21221. if (isCommon) {
  21222. // Recursively merge objects and arrays (susceptible to call stack limits).
  21223. stack.set(srcValue, newValue);
  21224. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21225. stack['delete'](srcValue);
  21226. }
  21227. assignMergeValue(object, key, newValue);
  21228. }
  21229. /**
  21230. * The base implementation of `_.nth` which doesn't coerce arguments.
  21231. *
  21232. * @private
  21233. * @param {Array} array The array to query.
  21234. * @param {number} n The index of the element to return.
  21235. * @returns {*} Returns the nth element of `array`.
  21236. */
  21237. function baseNth(array, n) {
  21238. var length = array.length;
  21239. if (!length) {
  21240. return;
  21241. }
  21242. n += n < 0 ? length : 0;
  21243. return isIndex(n, length) ? array[n] : undefined;
  21244. }
  21245. /**
  21246. * The base implementation of `_.orderBy` without param guards.
  21247. *
  21248. * @private
  21249. * @param {Array|Object} collection The collection to iterate over.
  21250. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21251. * @param {string[]} orders The sort orders of `iteratees`.
  21252. * @returns {Array} Returns the new sorted array.
  21253. */
  21254. function baseOrderBy(collection, iteratees, orders) {
  21255. var index = -1;
  21256. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21257. var result = baseMap(collection, function(value, key, collection) {
  21258. var criteria = arrayMap(iteratees, function(iteratee) {
  21259. return iteratee(value);
  21260. });
  21261. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21262. });
  21263. return baseSortBy(result, function(object, other) {
  21264. return compareMultiple(object, other, orders);
  21265. });
  21266. }
  21267. /**
  21268. * The base implementation of `_.pick` without support for individual
  21269. * property identifiers.
  21270. *
  21271. * @private
  21272. * @param {Object} object The source object.
  21273. * @param {string[]} paths The property paths to pick.
  21274. * @returns {Object} Returns the new object.
  21275. */
  21276. function basePick(object, paths) {
  21277. return basePickBy(object, paths, function(value, path) {
  21278. return hasIn(object, path);
  21279. });
  21280. }
  21281. /**
  21282. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21283. *
  21284. * @private
  21285. * @param {Object} object The source object.
  21286. * @param {string[]} paths The property paths to pick.
  21287. * @param {Function} predicate The function invoked per property.
  21288. * @returns {Object} Returns the new object.
  21289. */
  21290. function basePickBy(object, paths, predicate) {
  21291. var index = -1,
  21292. length = paths.length,
  21293. result = {};
  21294. while (++index < length) {
  21295. var path = paths[index],
  21296. value = baseGet(object, path);
  21297. if (predicate(value, path)) {
  21298. baseSet(result, castPath(path, object), value);
  21299. }
  21300. }
  21301. return result;
  21302. }
  21303. /**
  21304. * A specialized version of `baseProperty` which supports deep paths.
  21305. *
  21306. * @private
  21307. * @param {Array|string} path The path of the property to get.
  21308. * @returns {Function} Returns the new accessor function.
  21309. */
  21310. function basePropertyDeep(path) {
  21311. return function(object) {
  21312. return baseGet(object, path);
  21313. };
  21314. }
  21315. /**
  21316. * The base implementation of `_.pullAllBy` without support for iteratee
  21317. * shorthands.
  21318. *
  21319. * @private
  21320. * @param {Array} array The array to modify.
  21321. * @param {Array} values The values to remove.
  21322. * @param {Function} [iteratee] The iteratee invoked per element.
  21323. * @param {Function} [comparator] The comparator invoked per element.
  21324. * @returns {Array} Returns `array`.
  21325. */
  21326. function basePullAll(array, values, iteratee, comparator) {
  21327. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21328. index = -1,
  21329. length = values.length,
  21330. seen = array;
  21331. if (array === values) {
  21332. values = copyArray(values);
  21333. }
  21334. if (iteratee) {
  21335. seen = arrayMap(array, baseUnary(iteratee));
  21336. }
  21337. while (++index < length) {
  21338. var fromIndex = 0,
  21339. value = values[index],
  21340. computed = iteratee ? iteratee(value) : value;
  21341. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21342. if (seen !== array) {
  21343. splice.call(seen, fromIndex, 1);
  21344. }
  21345. splice.call(array, fromIndex, 1);
  21346. }
  21347. }
  21348. return array;
  21349. }
  21350. /**
  21351. * The base implementation of `_.pullAt` without support for individual
  21352. * indexes or capturing the removed elements.
  21353. *
  21354. * @private
  21355. * @param {Array} array The array to modify.
  21356. * @param {number[]} indexes The indexes of elements to remove.
  21357. * @returns {Array} Returns `array`.
  21358. */
  21359. function basePullAt(array, indexes) {
  21360. var length = array ? indexes.length : 0,
  21361. lastIndex = length - 1;
  21362. while (length--) {
  21363. var index = indexes[length];
  21364. if (length == lastIndex || index !== previous) {
  21365. var previous = index;
  21366. if (isIndex(index)) {
  21367. splice.call(array, index, 1);
  21368. } else {
  21369. baseUnset(array, index);
  21370. }
  21371. }
  21372. }
  21373. return array;
  21374. }
  21375. /**
  21376. * The base implementation of `_.random` without support for returning
  21377. * floating-point numbers.
  21378. *
  21379. * @private
  21380. * @param {number} lower The lower bound.
  21381. * @param {number} upper The upper bound.
  21382. * @returns {number} Returns the random number.
  21383. */
  21384. function baseRandom(lower, upper) {
  21385. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21386. }
  21387. /**
  21388. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21389. * coerce arguments.
  21390. *
  21391. * @private
  21392. * @param {number} start The start of the range.
  21393. * @param {number} end The end of the range.
  21394. * @param {number} step The value to increment or decrement by.
  21395. * @param {boolean} [fromRight] Specify iterating from right to left.
  21396. * @returns {Array} Returns the range of numbers.
  21397. */
  21398. function baseRange(start, end, step, fromRight) {
  21399. var index = -1,
  21400. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21401. result = Array(length);
  21402. while (length--) {
  21403. result[fromRight ? length : ++index] = start;
  21404. start += step;
  21405. }
  21406. return result;
  21407. }
  21408. /**
  21409. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21410. *
  21411. * @private
  21412. * @param {string} string The string to repeat.
  21413. * @param {number} n The number of times to repeat the string.
  21414. * @returns {string} Returns the repeated string.
  21415. */
  21416. function baseRepeat(string, n) {
  21417. var result = '';
  21418. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21419. return result;
  21420. }
  21421. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21422. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21423. do {
  21424. if (n % 2) {
  21425. result += string;
  21426. }
  21427. n = nativeFloor(n / 2);
  21428. if (n) {
  21429. string += string;
  21430. }
  21431. } while (n);
  21432. return result;
  21433. }
  21434. /**
  21435. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21436. *
  21437. * @private
  21438. * @param {Function} func The function to apply a rest parameter to.
  21439. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21440. * @returns {Function} Returns the new function.
  21441. */
  21442. function baseRest(func, start) {
  21443. return setToString(overRest(func, start, identity), func + '');
  21444. }
  21445. /**
  21446. * The base implementation of `_.sample`.
  21447. *
  21448. * @private
  21449. * @param {Array|Object} collection The collection to sample.
  21450. * @returns {*} Returns the random element.
  21451. */
  21452. function baseSample(collection) {
  21453. return arraySample(values(collection));
  21454. }
  21455. /**
  21456. * The base implementation of `_.sampleSize` without param guards.
  21457. *
  21458. * @private
  21459. * @param {Array|Object} collection The collection to sample.
  21460. * @param {number} n The number of elements to sample.
  21461. * @returns {Array} Returns the random elements.
  21462. */
  21463. function baseSampleSize(collection, n) {
  21464. var array = values(collection);
  21465. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21466. }
  21467. /**
  21468. * The base implementation of `_.set`.
  21469. *
  21470. * @private
  21471. * @param {Object} object The object to modify.
  21472. * @param {Array|string} path The path of the property to set.
  21473. * @param {*} value The value to set.
  21474. * @param {Function} [customizer] The function to customize path creation.
  21475. * @returns {Object} Returns `object`.
  21476. */
  21477. function baseSet(object, path, value, customizer) {
  21478. if (!isObject(object)) {
  21479. return object;
  21480. }
  21481. path = castPath(path, object);
  21482. var index = -1,
  21483. length = path.length,
  21484. lastIndex = length - 1,
  21485. nested = object;
  21486. while (nested != null && ++index < length) {
  21487. var key = toKey(path[index]),
  21488. newValue = value;
  21489. if (index != lastIndex) {
  21490. var objValue = nested[key];
  21491. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21492. if (newValue === undefined) {
  21493. newValue = isObject(objValue)
  21494. ? objValue
  21495. : (isIndex(path[index + 1]) ? [] : {});
  21496. }
  21497. }
  21498. assignValue(nested, key, newValue);
  21499. nested = nested[key];
  21500. }
  21501. return object;
  21502. }
  21503. /**
  21504. * The base implementation of `setData` without support for hot loop shorting.
  21505. *
  21506. * @private
  21507. * @param {Function} func The function to associate metadata with.
  21508. * @param {*} data The metadata.
  21509. * @returns {Function} Returns `func`.
  21510. */
  21511. var baseSetData = !metaMap ? identity : function(func, data) {
  21512. metaMap.set(func, data);
  21513. return func;
  21514. };
  21515. /**
  21516. * The base implementation of `setToString` without support for hot loop shorting.
  21517. *
  21518. * @private
  21519. * @param {Function} func The function to modify.
  21520. * @param {Function} string The `toString` result.
  21521. * @returns {Function} Returns `func`.
  21522. */
  21523. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21524. return defineProperty(func, 'toString', {
  21525. 'configurable': true,
  21526. 'enumerable': false,
  21527. 'value': constant(string),
  21528. 'writable': true
  21529. });
  21530. };
  21531. /**
  21532. * The base implementation of `_.shuffle`.
  21533. *
  21534. * @private
  21535. * @param {Array|Object} collection The collection to shuffle.
  21536. * @returns {Array} Returns the new shuffled array.
  21537. */
  21538. function baseShuffle(collection) {
  21539. return shuffleSelf(values(collection));
  21540. }
  21541. /**
  21542. * The base implementation of `_.slice` without an iteratee call guard.
  21543. *
  21544. * @private
  21545. * @param {Array} array The array to slice.
  21546. * @param {number} [start=0] The start position.
  21547. * @param {number} [end=array.length] The end position.
  21548. * @returns {Array} Returns the slice of `array`.
  21549. */
  21550. function baseSlice(array, start, end) {
  21551. var index = -1,
  21552. length = array.length;
  21553. if (start < 0) {
  21554. start = -start > length ? 0 : (length + start);
  21555. }
  21556. end = end > length ? length : end;
  21557. if (end < 0) {
  21558. end += length;
  21559. }
  21560. length = start > end ? 0 : ((end - start) >>> 0);
  21561. start >>>= 0;
  21562. var result = Array(length);
  21563. while (++index < length) {
  21564. result[index] = array[index + start];
  21565. }
  21566. return result;
  21567. }
  21568. /**
  21569. * The base implementation of `_.some` without support for iteratee shorthands.
  21570. *
  21571. * @private
  21572. * @param {Array|Object} collection The collection to iterate over.
  21573. * @param {Function} predicate The function invoked per iteration.
  21574. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21575. * else `false`.
  21576. */
  21577. function baseSome(collection, predicate) {
  21578. var result;
  21579. baseEach(collection, function(value, index, collection) {
  21580. result = predicate(value, index, collection);
  21581. return !result;
  21582. });
  21583. return !!result;
  21584. }
  21585. /**
  21586. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21587. * performs a binary search of `array` to determine the index at which `value`
  21588. * should be inserted into `array` in order to maintain its sort order.
  21589. *
  21590. * @private
  21591. * @param {Array} array The sorted array to inspect.
  21592. * @param {*} value The value to evaluate.
  21593. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21594. * @returns {number} Returns the index at which `value` should be inserted
  21595. * into `array`.
  21596. */
  21597. function baseSortedIndex(array, value, retHighest) {
  21598. var low = 0,
  21599. high = array == null ? low : array.length;
  21600. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21601. while (low < high) {
  21602. var mid = (low + high) >>> 1,
  21603. computed = array[mid];
  21604. if (computed !== null && !isSymbol(computed) &&
  21605. (retHighest ? (computed <= value) : (computed < value))) {
  21606. low = mid + 1;
  21607. } else {
  21608. high = mid;
  21609. }
  21610. }
  21611. return high;
  21612. }
  21613. return baseSortedIndexBy(array, value, identity, retHighest);
  21614. }
  21615. /**
  21616. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21617. * which invokes `iteratee` for `value` and each element of `array` to compute
  21618. * their sort ranking. The iteratee is invoked with one argument; (value).
  21619. *
  21620. * @private
  21621. * @param {Array} array The sorted array to inspect.
  21622. * @param {*} value The value to evaluate.
  21623. * @param {Function} iteratee The iteratee invoked per element.
  21624. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21625. * @returns {number} Returns the index at which `value` should be inserted
  21626. * into `array`.
  21627. */
  21628. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21629. value = iteratee(value);
  21630. var low = 0,
  21631. high = array == null ? 0 : array.length,
  21632. valIsNaN = value !== value,
  21633. valIsNull = value === null,
  21634. valIsSymbol = isSymbol(value),
  21635. valIsUndefined = value === undefined;
  21636. while (low < high) {
  21637. var mid = nativeFloor((low + high) / 2),
  21638. computed = iteratee(array[mid]),
  21639. othIsDefined = computed !== undefined,
  21640. othIsNull = computed === null,
  21641. othIsReflexive = computed === computed,
  21642. othIsSymbol = isSymbol(computed);
  21643. if (valIsNaN) {
  21644. var setLow = retHighest || othIsReflexive;
  21645. } else if (valIsUndefined) {
  21646. setLow = othIsReflexive && (retHighest || othIsDefined);
  21647. } else if (valIsNull) {
  21648. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21649. } else if (valIsSymbol) {
  21650. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21651. } else if (othIsNull || othIsSymbol) {
  21652. setLow = false;
  21653. } else {
  21654. setLow = retHighest ? (computed <= value) : (computed < value);
  21655. }
  21656. if (setLow) {
  21657. low = mid + 1;
  21658. } else {
  21659. high = mid;
  21660. }
  21661. }
  21662. return nativeMin(high, MAX_ARRAY_INDEX);
  21663. }
  21664. /**
  21665. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21666. * support for iteratee shorthands.
  21667. *
  21668. * @private
  21669. * @param {Array} array The array to inspect.
  21670. * @param {Function} [iteratee] The iteratee invoked per element.
  21671. * @returns {Array} Returns the new duplicate free array.
  21672. */
  21673. function baseSortedUniq(array, iteratee) {
  21674. var index = -1,
  21675. length = array.length,
  21676. resIndex = 0,
  21677. result = [];
  21678. while (++index < length) {
  21679. var value = array[index],
  21680. computed = iteratee ? iteratee(value) : value;
  21681. if (!index || !eq(computed, seen)) {
  21682. var seen = computed;
  21683. result[resIndex++] = value === 0 ? 0 : value;
  21684. }
  21685. }
  21686. return result;
  21687. }
  21688. /**
  21689. * The base implementation of `_.toNumber` which doesn't ensure correct
  21690. * conversions of binary, hexadecimal, or octal string values.
  21691. *
  21692. * @private
  21693. * @param {*} value The value to process.
  21694. * @returns {number} Returns the number.
  21695. */
  21696. function baseToNumber(value) {
  21697. if (typeof value == 'number') {
  21698. return value;
  21699. }
  21700. if (isSymbol(value)) {
  21701. return NAN;
  21702. }
  21703. return +value;
  21704. }
  21705. /**
  21706. * The base implementation of `_.toString` which doesn't convert nullish
  21707. * values to empty strings.
  21708. *
  21709. * @private
  21710. * @param {*} value The value to process.
  21711. * @returns {string} Returns the string.
  21712. */
  21713. function baseToString(value) {
  21714. // Exit early for strings to avoid a performance hit in some environments.
  21715. if (typeof value == 'string') {
  21716. return value;
  21717. }
  21718. if (isArray(value)) {
  21719. // Recursively convert values (susceptible to call stack limits).
  21720. return arrayMap(value, baseToString) + '';
  21721. }
  21722. if (isSymbol(value)) {
  21723. return symbolToString ? symbolToString.call(value) : '';
  21724. }
  21725. var result = (value + '');
  21726. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21727. }
  21728. /**
  21729. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21730. *
  21731. * @private
  21732. * @param {Array} array The array to inspect.
  21733. * @param {Function} [iteratee] The iteratee invoked per element.
  21734. * @param {Function} [comparator] The comparator invoked per element.
  21735. * @returns {Array} Returns the new duplicate free array.
  21736. */
  21737. function baseUniq(array, iteratee, comparator) {
  21738. var index = -1,
  21739. includes = arrayIncludes,
  21740. length = array.length,
  21741. isCommon = true,
  21742. result = [],
  21743. seen = result;
  21744. if (comparator) {
  21745. isCommon = false;
  21746. includes = arrayIncludesWith;
  21747. }
  21748. else if (length >= LARGE_ARRAY_SIZE) {
  21749. var set = iteratee ? null : createSet(array);
  21750. if (set) {
  21751. return setToArray(set);
  21752. }
  21753. isCommon = false;
  21754. includes = cacheHas;
  21755. seen = new SetCache;
  21756. }
  21757. else {
  21758. seen = iteratee ? [] : result;
  21759. }
  21760. outer:
  21761. while (++index < length) {
  21762. var value = array[index],
  21763. computed = iteratee ? iteratee(value) : value;
  21764. value = (comparator || value !== 0) ? value : 0;
  21765. if (isCommon && computed === computed) {
  21766. var seenIndex = seen.length;
  21767. while (seenIndex--) {
  21768. if (seen[seenIndex] === computed) {
  21769. continue outer;
  21770. }
  21771. }
  21772. if (iteratee) {
  21773. seen.push(computed);
  21774. }
  21775. result.push(value);
  21776. }
  21777. else if (!includes(seen, computed, comparator)) {
  21778. if (seen !== result) {
  21779. seen.push(computed);
  21780. }
  21781. result.push(value);
  21782. }
  21783. }
  21784. return result;
  21785. }
  21786. /**
  21787. * The base implementation of `_.unset`.
  21788. *
  21789. * @private
  21790. * @param {Object} object The object to modify.
  21791. * @param {Array|string} path The property path to unset.
  21792. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21793. */
  21794. function baseUnset(object, path) {
  21795. path = castPath(path, object);
  21796. object = parent(object, path);
  21797. return object == null || delete object[toKey(last(path))];
  21798. }
  21799. /**
  21800. * The base implementation of `_.update`.
  21801. *
  21802. * @private
  21803. * @param {Object} object The object to modify.
  21804. * @param {Array|string} path The path of the property to update.
  21805. * @param {Function} updater The function to produce the updated value.
  21806. * @param {Function} [customizer] The function to customize path creation.
  21807. * @returns {Object} Returns `object`.
  21808. */
  21809. function baseUpdate(object, path, updater, customizer) {
  21810. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21811. }
  21812. /**
  21813. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21814. * without support for iteratee shorthands.
  21815. *
  21816. * @private
  21817. * @param {Array} array The array to query.
  21818. * @param {Function} predicate The function invoked per iteration.
  21819. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21820. * @param {boolean} [fromRight] Specify iterating from right to left.
  21821. * @returns {Array} Returns the slice of `array`.
  21822. */
  21823. function baseWhile(array, predicate, isDrop, fromRight) {
  21824. var length = array.length,
  21825. index = fromRight ? length : -1;
  21826. while ((fromRight ? index-- : ++index < length) &&
  21827. predicate(array[index], index, array)) {}
  21828. return isDrop
  21829. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21830. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21831. }
  21832. /**
  21833. * The base implementation of `wrapperValue` which returns the result of
  21834. * performing a sequence of actions on the unwrapped `value`, where each
  21835. * successive action is supplied the return value of the previous.
  21836. *
  21837. * @private
  21838. * @param {*} value The unwrapped value.
  21839. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21840. * @returns {*} Returns the resolved value.
  21841. */
  21842. function baseWrapperValue(value, actions) {
  21843. var result = value;
  21844. if (result instanceof LazyWrapper) {
  21845. result = result.value();
  21846. }
  21847. return arrayReduce(actions, function(result, action) {
  21848. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21849. }, result);
  21850. }
  21851. /**
  21852. * The base implementation of methods like `_.xor`, without support for
  21853. * iteratee shorthands, that accepts an array of arrays to inspect.
  21854. *
  21855. * @private
  21856. * @param {Array} arrays The arrays to inspect.
  21857. * @param {Function} [iteratee] The iteratee invoked per element.
  21858. * @param {Function} [comparator] The comparator invoked per element.
  21859. * @returns {Array} Returns the new array of values.
  21860. */
  21861. function baseXor(arrays, iteratee, comparator) {
  21862. var length = arrays.length;
  21863. if (length < 2) {
  21864. return length ? baseUniq(arrays[0]) : [];
  21865. }
  21866. var index = -1,
  21867. result = Array(length);
  21868. while (++index < length) {
  21869. var array = arrays[index],
  21870. othIndex = -1;
  21871. while (++othIndex < length) {
  21872. if (othIndex != index) {
  21873. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21874. }
  21875. }
  21876. }
  21877. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21878. }
  21879. /**
  21880. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21881. *
  21882. * @private
  21883. * @param {Array} props The property identifiers.
  21884. * @param {Array} values The property values.
  21885. * @param {Function} assignFunc The function to assign values.
  21886. * @returns {Object} Returns the new object.
  21887. */
  21888. function baseZipObject(props, values, assignFunc) {
  21889. var index = -1,
  21890. length = props.length,
  21891. valsLength = values.length,
  21892. result = {};
  21893. while (++index < length) {
  21894. var value = index < valsLength ? values[index] : undefined;
  21895. assignFunc(result, props[index], value);
  21896. }
  21897. return result;
  21898. }
  21899. /**
  21900. * Casts `value` to an empty array if it's not an array like object.
  21901. *
  21902. * @private
  21903. * @param {*} value The value to inspect.
  21904. * @returns {Array|Object} Returns the cast array-like object.
  21905. */
  21906. function castArrayLikeObject(value) {
  21907. return isArrayLikeObject(value) ? value : [];
  21908. }
  21909. /**
  21910. * Casts `value` to `identity` if it's not a function.
  21911. *
  21912. * @private
  21913. * @param {*} value The value to inspect.
  21914. * @returns {Function} Returns cast function.
  21915. */
  21916. function castFunction(value) {
  21917. return typeof value == 'function' ? value : identity;
  21918. }
  21919. /**
  21920. * Casts `value` to a path array if it's not one.
  21921. *
  21922. * @private
  21923. * @param {*} value The value to inspect.
  21924. * @param {Object} [object] The object to query keys on.
  21925. * @returns {Array} Returns the cast property path array.
  21926. */
  21927. function castPath(value, object) {
  21928. if (isArray(value)) {
  21929. return value;
  21930. }
  21931. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21932. }
  21933. /**
  21934. * A `baseRest` alias which can be replaced with `identity` by module
  21935. * replacement plugins.
  21936. *
  21937. * @private
  21938. * @type {Function}
  21939. * @param {Function} func The function to apply a rest parameter to.
  21940. * @returns {Function} Returns the new function.
  21941. */
  21942. var castRest = baseRest;
  21943. /**
  21944. * Casts `array` to a slice if it's needed.
  21945. *
  21946. * @private
  21947. * @param {Array} array The array to inspect.
  21948. * @param {number} start The start position.
  21949. * @param {number} [end=array.length] The end position.
  21950. * @returns {Array} Returns the cast slice.
  21951. */
  21952. function castSlice(array, start, end) {
  21953. var length = array.length;
  21954. end = end === undefined ? length : end;
  21955. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21956. }
  21957. /**
  21958. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21959. *
  21960. * @private
  21961. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21962. */
  21963. var clearTimeout = ctxClearTimeout || function(id) {
  21964. return root.clearTimeout(id);
  21965. };
  21966. /**
  21967. * Creates a clone of `buffer`.
  21968. *
  21969. * @private
  21970. * @param {Buffer} buffer The buffer to clone.
  21971. * @param {boolean} [isDeep] Specify a deep clone.
  21972. * @returns {Buffer} Returns the cloned buffer.
  21973. */
  21974. function cloneBuffer(buffer, isDeep) {
  21975. if (isDeep) {
  21976. return buffer.slice();
  21977. }
  21978. var length = buffer.length,
  21979. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21980. buffer.copy(result);
  21981. return result;
  21982. }
  21983. /**
  21984. * Creates a clone of `arrayBuffer`.
  21985. *
  21986. * @private
  21987. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21988. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21989. */
  21990. function cloneArrayBuffer(arrayBuffer) {
  21991. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21992. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21993. return result;
  21994. }
  21995. /**
  21996. * Creates a clone of `dataView`.
  21997. *
  21998. * @private
  21999. * @param {Object} dataView The data view to clone.
  22000. * @param {boolean} [isDeep] Specify a deep clone.
  22001. * @returns {Object} Returns the cloned data view.
  22002. */
  22003. function cloneDataView(dataView, isDeep) {
  22004. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  22005. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  22006. }
  22007. /**
  22008. * Creates a clone of `regexp`.
  22009. *
  22010. * @private
  22011. * @param {Object} regexp The regexp to clone.
  22012. * @returns {Object} Returns the cloned regexp.
  22013. */
  22014. function cloneRegExp(regexp) {
  22015. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  22016. result.lastIndex = regexp.lastIndex;
  22017. return result;
  22018. }
  22019. /**
  22020. * Creates a clone of the `symbol` object.
  22021. *
  22022. * @private
  22023. * @param {Object} symbol The symbol object to clone.
  22024. * @returns {Object} Returns the cloned symbol object.
  22025. */
  22026. function cloneSymbol(symbol) {
  22027. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  22028. }
  22029. /**
  22030. * Creates a clone of `typedArray`.
  22031. *
  22032. * @private
  22033. * @param {Object} typedArray The typed array to clone.
  22034. * @param {boolean} [isDeep] Specify a deep clone.
  22035. * @returns {Object} Returns the cloned typed array.
  22036. */
  22037. function cloneTypedArray(typedArray, isDeep) {
  22038. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  22039. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  22040. }
  22041. /**
  22042. * Compares values to sort them in ascending order.
  22043. *
  22044. * @private
  22045. * @param {*} value The value to compare.
  22046. * @param {*} other The other value to compare.
  22047. * @returns {number} Returns the sort order indicator for `value`.
  22048. */
  22049. function compareAscending(value, other) {
  22050. if (value !== other) {
  22051. var valIsDefined = value !== undefined,
  22052. valIsNull = value === null,
  22053. valIsReflexive = value === value,
  22054. valIsSymbol = isSymbol(value);
  22055. var othIsDefined = other !== undefined,
  22056. othIsNull = other === null,
  22057. othIsReflexive = other === other,
  22058. othIsSymbol = isSymbol(other);
  22059. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  22060. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  22061. (valIsNull && othIsDefined && othIsReflexive) ||
  22062. (!valIsDefined && othIsReflexive) ||
  22063. !valIsReflexive) {
  22064. return 1;
  22065. }
  22066. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  22067. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  22068. (othIsNull && valIsDefined && valIsReflexive) ||
  22069. (!othIsDefined && valIsReflexive) ||
  22070. !othIsReflexive) {
  22071. return -1;
  22072. }
  22073. }
  22074. return 0;
  22075. }
  22076. /**
  22077. * Used by `_.orderBy` to compare multiple properties of a value to another
  22078. * and stable sort them.
  22079. *
  22080. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  22081. * specify an order of "desc" for descending or "asc" for ascending sort order
  22082. * of corresponding values.
  22083. *
  22084. * @private
  22085. * @param {Object} object The object to compare.
  22086. * @param {Object} other The other object to compare.
  22087. * @param {boolean[]|string[]} orders The order to sort by for each property.
  22088. * @returns {number} Returns the sort order indicator for `object`.
  22089. */
  22090. function compareMultiple(object, other, orders) {
  22091. var index = -1,
  22092. objCriteria = object.criteria,
  22093. othCriteria = other.criteria,
  22094. length = objCriteria.length,
  22095. ordersLength = orders.length;
  22096. while (++index < length) {
  22097. var result = compareAscending(objCriteria[index], othCriteria[index]);
  22098. if (result) {
  22099. if (index >= ordersLength) {
  22100. return result;
  22101. }
  22102. var order = orders[index];
  22103. return result * (order == 'desc' ? -1 : 1);
  22104. }
  22105. }
  22106. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  22107. // that causes it, under certain circumstances, to provide the same value for
  22108. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  22109. // for more details.
  22110. //
  22111. // This also ensures a stable sort in V8 and other engines.
  22112. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  22113. return object.index - other.index;
  22114. }
  22115. /**
  22116. * Creates an array that is the composition of partially applied arguments,
  22117. * placeholders, and provided arguments into a single array of arguments.
  22118. *
  22119. * @private
  22120. * @param {Array} args The provided arguments.
  22121. * @param {Array} partials The arguments to prepend to those provided.
  22122. * @param {Array} holders The `partials` placeholder indexes.
  22123. * @params {boolean} [isCurried] Specify composing for a curried function.
  22124. * @returns {Array} Returns the new array of composed arguments.
  22125. */
  22126. function composeArgs(args, partials, holders, isCurried) {
  22127. var argsIndex = -1,
  22128. argsLength = args.length,
  22129. holdersLength = holders.length,
  22130. leftIndex = -1,
  22131. leftLength = partials.length,
  22132. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22133. result = Array(leftLength + rangeLength),
  22134. isUncurried = !isCurried;
  22135. while (++leftIndex < leftLength) {
  22136. result[leftIndex] = partials[leftIndex];
  22137. }
  22138. while (++argsIndex < holdersLength) {
  22139. if (isUncurried || argsIndex < argsLength) {
  22140. result[holders[argsIndex]] = args[argsIndex];
  22141. }
  22142. }
  22143. while (rangeLength--) {
  22144. result[leftIndex++] = args[argsIndex++];
  22145. }
  22146. return result;
  22147. }
  22148. /**
  22149. * This function is like `composeArgs` except that the arguments composition
  22150. * is tailored for `_.partialRight`.
  22151. *
  22152. * @private
  22153. * @param {Array} args The provided arguments.
  22154. * @param {Array} partials The arguments to append to those provided.
  22155. * @param {Array} holders The `partials` placeholder indexes.
  22156. * @params {boolean} [isCurried] Specify composing for a curried function.
  22157. * @returns {Array} Returns the new array of composed arguments.
  22158. */
  22159. function composeArgsRight(args, partials, holders, isCurried) {
  22160. var argsIndex = -1,
  22161. argsLength = args.length,
  22162. holdersIndex = -1,
  22163. holdersLength = holders.length,
  22164. rightIndex = -1,
  22165. rightLength = partials.length,
  22166. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22167. result = Array(rangeLength + rightLength),
  22168. isUncurried = !isCurried;
  22169. while (++argsIndex < rangeLength) {
  22170. result[argsIndex] = args[argsIndex];
  22171. }
  22172. var offset = argsIndex;
  22173. while (++rightIndex < rightLength) {
  22174. result[offset + rightIndex] = partials[rightIndex];
  22175. }
  22176. while (++holdersIndex < holdersLength) {
  22177. if (isUncurried || argsIndex < argsLength) {
  22178. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22179. }
  22180. }
  22181. return result;
  22182. }
  22183. /**
  22184. * Copies the values of `source` to `array`.
  22185. *
  22186. * @private
  22187. * @param {Array} source The array to copy values from.
  22188. * @param {Array} [array=[]] The array to copy values to.
  22189. * @returns {Array} Returns `array`.
  22190. */
  22191. function copyArray(source, array) {
  22192. var index = -1,
  22193. length = source.length;
  22194. array || (array = Array(length));
  22195. while (++index < length) {
  22196. array[index] = source[index];
  22197. }
  22198. return array;
  22199. }
  22200. /**
  22201. * Copies properties of `source` to `object`.
  22202. *
  22203. * @private
  22204. * @param {Object} source The object to copy properties from.
  22205. * @param {Array} props The property identifiers to copy.
  22206. * @param {Object} [object={}] The object to copy properties to.
  22207. * @param {Function} [customizer] The function to customize copied values.
  22208. * @returns {Object} Returns `object`.
  22209. */
  22210. function copyObject(source, props, object, customizer) {
  22211. var isNew = !object;
  22212. object || (object = {});
  22213. var index = -1,
  22214. length = props.length;
  22215. while (++index < length) {
  22216. var key = props[index];
  22217. var newValue = customizer
  22218. ? customizer(object[key], source[key], key, object, source)
  22219. : undefined;
  22220. if (newValue === undefined) {
  22221. newValue = source[key];
  22222. }
  22223. if (isNew) {
  22224. baseAssignValue(object, key, newValue);
  22225. } else {
  22226. assignValue(object, key, newValue);
  22227. }
  22228. }
  22229. return object;
  22230. }
  22231. /**
  22232. * Copies own symbols of `source` to `object`.
  22233. *
  22234. * @private
  22235. * @param {Object} source The object to copy symbols from.
  22236. * @param {Object} [object={}] The object to copy symbols to.
  22237. * @returns {Object} Returns `object`.
  22238. */
  22239. function copySymbols(source, object) {
  22240. return copyObject(source, getSymbols(source), object);
  22241. }
  22242. /**
  22243. * Copies own and inherited symbols of `source` to `object`.
  22244. *
  22245. * @private
  22246. * @param {Object} source The object to copy symbols from.
  22247. * @param {Object} [object={}] The object to copy symbols to.
  22248. * @returns {Object} Returns `object`.
  22249. */
  22250. function copySymbolsIn(source, object) {
  22251. return copyObject(source, getSymbolsIn(source), object);
  22252. }
  22253. /**
  22254. * Creates a function like `_.groupBy`.
  22255. *
  22256. * @private
  22257. * @param {Function} setter The function to set accumulator values.
  22258. * @param {Function} [initializer] The accumulator object initializer.
  22259. * @returns {Function} Returns the new aggregator function.
  22260. */
  22261. function createAggregator(setter, initializer) {
  22262. return function(collection, iteratee) {
  22263. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22264. accumulator = initializer ? initializer() : {};
  22265. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22266. };
  22267. }
  22268. /**
  22269. * Creates a function like `_.assign`.
  22270. *
  22271. * @private
  22272. * @param {Function} assigner The function to assign values.
  22273. * @returns {Function} Returns the new assigner function.
  22274. */
  22275. function createAssigner(assigner) {
  22276. return baseRest(function(object, sources) {
  22277. var index = -1,
  22278. length = sources.length,
  22279. customizer = length > 1 ? sources[length - 1] : undefined,
  22280. guard = length > 2 ? sources[2] : undefined;
  22281. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22282. ? (length--, customizer)
  22283. : undefined;
  22284. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22285. customizer = length < 3 ? undefined : customizer;
  22286. length = 1;
  22287. }
  22288. object = Object(object);
  22289. while (++index < length) {
  22290. var source = sources[index];
  22291. if (source) {
  22292. assigner(object, source, index, customizer);
  22293. }
  22294. }
  22295. return object;
  22296. });
  22297. }
  22298. /**
  22299. * Creates a `baseEach` or `baseEachRight` function.
  22300. *
  22301. * @private
  22302. * @param {Function} eachFunc The function to iterate over a collection.
  22303. * @param {boolean} [fromRight] Specify iterating from right to left.
  22304. * @returns {Function} Returns the new base function.
  22305. */
  22306. function createBaseEach(eachFunc, fromRight) {
  22307. return function(collection, iteratee) {
  22308. if (collection == null) {
  22309. return collection;
  22310. }
  22311. if (!isArrayLike(collection)) {
  22312. return eachFunc(collection, iteratee);
  22313. }
  22314. var length = collection.length,
  22315. index = fromRight ? length : -1,
  22316. iterable = Object(collection);
  22317. while ((fromRight ? index-- : ++index < length)) {
  22318. if (iteratee(iterable[index], index, iterable) === false) {
  22319. break;
  22320. }
  22321. }
  22322. return collection;
  22323. };
  22324. }
  22325. /**
  22326. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22327. *
  22328. * @private
  22329. * @param {boolean} [fromRight] Specify iterating from right to left.
  22330. * @returns {Function} Returns the new base function.
  22331. */
  22332. function createBaseFor(fromRight) {
  22333. return function(object, iteratee, keysFunc) {
  22334. var index = -1,
  22335. iterable = Object(object),
  22336. props = keysFunc(object),
  22337. length = props.length;
  22338. while (length--) {
  22339. var key = props[fromRight ? length : ++index];
  22340. if (iteratee(iterable[key], key, iterable) === false) {
  22341. break;
  22342. }
  22343. }
  22344. return object;
  22345. };
  22346. }
  22347. /**
  22348. * Creates a function that wraps `func` to invoke it with the optional `this`
  22349. * binding of `thisArg`.
  22350. *
  22351. * @private
  22352. * @param {Function} func The function to wrap.
  22353. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22354. * @param {*} [thisArg] The `this` binding of `func`.
  22355. * @returns {Function} Returns the new wrapped function.
  22356. */
  22357. function createBind(func, bitmask, thisArg) {
  22358. var isBind = bitmask & WRAP_BIND_FLAG,
  22359. Ctor = createCtor(func);
  22360. function wrapper() {
  22361. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22362. return fn.apply(isBind ? thisArg : this, arguments);
  22363. }
  22364. return wrapper;
  22365. }
  22366. /**
  22367. * Creates a function like `_.lowerFirst`.
  22368. *
  22369. * @private
  22370. * @param {string} methodName The name of the `String` case method to use.
  22371. * @returns {Function} Returns the new case function.
  22372. */
  22373. function createCaseFirst(methodName) {
  22374. return function(string) {
  22375. string = toString(string);
  22376. var strSymbols = hasUnicode(string)
  22377. ? stringToArray(string)
  22378. : undefined;
  22379. var chr = strSymbols
  22380. ? strSymbols[0]
  22381. : string.charAt(0);
  22382. var trailing = strSymbols
  22383. ? castSlice(strSymbols, 1).join('')
  22384. : string.slice(1);
  22385. return chr[methodName]() + trailing;
  22386. };
  22387. }
  22388. /**
  22389. * Creates a function like `_.camelCase`.
  22390. *
  22391. * @private
  22392. * @param {Function} callback The function to combine each word.
  22393. * @returns {Function} Returns the new compounder function.
  22394. */
  22395. function createCompounder(callback) {
  22396. return function(string) {
  22397. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22398. };
  22399. }
  22400. /**
  22401. * Creates a function that produces an instance of `Ctor` regardless of
  22402. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22403. *
  22404. * @private
  22405. * @param {Function} Ctor The constructor to wrap.
  22406. * @returns {Function} Returns the new wrapped function.
  22407. */
  22408. function createCtor(Ctor) {
  22409. return function() {
  22410. // Use a `switch` statement to work with class constructors. See
  22411. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22412. // for more details.
  22413. var args = arguments;
  22414. switch (args.length) {
  22415. case 0: return new Ctor;
  22416. case 1: return new Ctor(args[0]);
  22417. case 2: return new Ctor(args[0], args[1]);
  22418. case 3: return new Ctor(args[0], args[1], args[2]);
  22419. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22420. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22421. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22422. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22423. }
  22424. var thisBinding = baseCreate(Ctor.prototype),
  22425. result = Ctor.apply(thisBinding, args);
  22426. // Mimic the constructor's `return` behavior.
  22427. // See https://es5.github.io/#x13.2.2 for more details.
  22428. return isObject(result) ? result : thisBinding;
  22429. };
  22430. }
  22431. /**
  22432. * Creates a function that wraps `func` to enable currying.
  22433. *
  22434. * @private
  22435. * @param {Function} func The function to wrap.
  22436. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22437. * @param {number} arity The arity of `func`.
  22438. * @returns {Function} Returns the new wrapped function.
  22439. */
  22440. function createCurry(func, bitmask, arity) {
  22441. var Ctor = createCtor(func);
  22442. function wrapper() {
  22443. var length = arguments.length,
  22444. args = Array(length),
  22445. index = length,
  22446. placeholder = getHolder(wrapper);
  22447. while (index--) {
  22448. args[index] = arguments[index];
  22449. }
  22450. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22451. ? []
  22452. : replaceHolders(args, placeholder);
  22453. length -= holders.length;
  22454. if (length < arity) {
  22455. return createRecurry(
  22456. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22457. args, holders, undefined, undefined, arity - length);
  22458. }
  22459. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22460. return apply(fn, this, args);
  22461. }
  22462. return wrapper;
  22463. }
  22464. /**
  22465. * Creates a `_.find` or `_.findLast` function.
  22466. *
  22467. * @private
  22468. * @param {Function} findIndexFunc The function to find the collection index.
  22469. * @returns {Function} Returns the new find function.
  22470. */
  22471. function createFind(findIndexFunc) {
  22472. return function(collection, predicate, fromIndex) {
  22473. var iterable = Object(collection);
  22474. if (!isArrayLike(collection)) {
  22475. var iteratee = getIteratee(predicate, 3);
  22476. collection = keys(collection);
  22477. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22478. }
  22479. var index = findIndexFunc(collection, predicate, fromIndex);
  22480. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22481. };
  22482. }
  22483. /**
  22484. * Creates a `_.flow` or `_.flowRight` function.
  22485. *
  22486. * @private
  22487. * @param {boolean} [fromRight] Specify iterating from right to left.
  22488. * @returns {Function} Returns the new flow function.
  22489. */
  22490. function createFlow(fromRight) {
  22491. return flatRest(function(funcs) {
  22492. var length = funcs.length,
  22493. index = length,
  22494. prereq = LodashWrapper.prototype.thru;
  22495. if (fromRight) {
  22496. funcs.reverse();
  22497. }
  22498. while (index--) {
  22499. var func = funcs[index];
  22500. if (typeof func != 'function') {
  22501. throw new TypeError(FUNC_ERROR_TEXT);
  22502. }
  22503. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22504. var wrapper = new LodashWrapper([], true);
  22505. }
  22506. }
  22507. index = wrapper ? index : length;
  22508. while (++index < length) {
  22509. func = funcs[index];
  22510. var funcName = getFuncName(func),
  22511. data = funcName == 'wrapper' ? getData(func) : undefined;
  22512. if (data && isLaziable(data[0]) &&
  22513. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22514. !data[4].length && data[9] == 1
  22515. ) {
  22516. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22517. } else {
  22518. wrapper = (func.length == 1 && isLaziable(func))
  22519. ? wrapper[funcName]()
  22520. : wrapper.thru(func);
  22521. }
  22522. }
  22523. return function() {
  22524. var args = arguments,
  22525. value = args[0];
  22526. if (wrapper && args.length == 1 && isArray(value)) {
  22527. return wrapper.plant(value).value();
  22528. }
  22529. var index = 0,
  22530. result = length ? funcs[index].apply(this, args) : value;
  22531. while (++index < length) {
  22532. result = funcs[index].call(this, result);
  22533. }
  22534. return result;
  22535. };
  22536. });
  22537. }
  22538. /**
  22539. * Creates a function that wraps `func` to invoke it with optional `this`
  22540. * binding of `thisArg`, partial application, and currying.
  22541. *
  22542. * @private
  22543. * @param {Function|string} func The function or method name to wrap.
  22544. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22545. * @param {*} [thisArg] The `this` binding of `func`.
  22546. * @param {Array} [partials] The arguments to prepend to those provided to
  22547. * the new function.
  22548. * @param {Array} [holders] The `partials` placeholder indexes.
  22549. * @param {Array} [partialsRight] The arguments to append to those provided
  22550. * to the new function.
  22551. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22552. * @param {Array} [argPos] The argument positions of the new function.
  22553. * @param {number} [ary] The arity cap of `func`.
  22554. * @param {number} [arity] The arity of `func`.
  22555. * @returns {Function} Returns the new wrapped function.
  22556. */
  22557. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22558. var isAry = bitmask & WRAP_ARY_FLAG,
  22559. isBind = bitmask & WRAP_BIND_FLAG,
  22560. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22561. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22562. isFlip = bitmask & WRAP_FLIP_FLAG,
  22563. Ctor = isBindKey ? undefined : createCtor(func);
  22564. function wrapper() {
  22565. var length = arguments.length,
  22566. args = Array(length),
  22567. index = length;
  22568. while (index--) {
  22569. args[index] = arguments[index];
  22570. }
  22571. if (isCurried) {
  22572. var placeholder = getHolder(wrapper),
  22573. holdersCount = countHolders(args, placeholder);
  22574. }
  22575. if (partials) {
  22576. args = composeArgs(args, partials, holders, isCurried);
  22577. }
  22578. if (partialsRight) {
  22579. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22580. }
  22581. length -= holdersCount;
  22582. if (isCurried && length < arity) {
  22583. var newHolders = replaceHolders(args, placeholder);
  22584. return createRecurry(
  22585. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22586. args, newHolders, argPos, ary, arity - length
  22587. );
  22588. }
  22589. var thisBinding = isBind ? thisArg : this,
  22590. fn = isBindKey ? thisBinding[func] : func;
  22591. length = args.length;
  22592. if (argPos) {
  22593. args = reorder(args, argPos);
  22594. } else if (isFlip && length > 1) {
  22595. args.reverse();
  22596. }
  22597. if (isAry && ary < length) {
  22598. args.length = ary;
  22599. }
  22600. if (this && this !== root && this instanceof wrapper) {
  22601. fn = Ctor || createCtor(fn);
  22602. }
  22603. return fn.apply(thisBinding, args);
  22604. }
  22605. return wrapper;
  22606. }
  22607. /**
  22608. * Creates a function like `_.invertBy`.
  22609. *
  22610. * @private
  22611. * @param {Function} setter The function to set accumulator values.
  22612. * @param {Function} toIteratee The function to resolve iteratees.
  22613. * @returns {Function} Returns the new inverter function.
  22614. */
  22615. function createInverter(setter, toIteratee) {
  22616. return function(object, iteratee) {
  22617. return baseInverter(object, setter, toIteratee(iteratee), {});
  22618. };
  22619. }
  22620. /**
  22621. * Creates a function that performs a mathematical operation on two values.
  22622. *
  22623. * @private
  22624. * @param {Function} operator The function to perform the operation.
  22625. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22626. * @returns {Function} Returns the new mathematical operation function.
  22627. */
  22628. function createMathOperation(operator, defaultValue) {
  22629. return function(value, other) {
  22630. var result;
  22631. if (value === undefined && other === undefined) {
  22632. return defaultValue;
  22633. }
  22634. if (value !== undefined) {
  22635. result = value;
  22636. }
  22637. if (other !== undefined) {
  22638. if (result === undefined) {
  22639. return other;
  22640. }
  22641. if (typeof value == 'string' || typeof other == 'string') {
  22642. value = baseToString(value);
  22643. other = baseToString(other);
  22644. } else {
  22645. value = baseToNumber(value);
  22646. other = baseToNumber(other);
  22647. }
  22648. result = operator(value, other);
  22649. }
  22650. return result;
  22651. };
  22652. }
  22653. /**
  22654. * Creates a function like `_.over`.
  22655. *
  22656. * @private
  22657. * @param {Function} arrayFunc The function to iterate over iteratees.
  22658. * @returns {Function} Returns the new over function.
  22659. */
  22660. function createOver(arrayFunc) {
  22661. return flatRest(function(iteratees) {
  22662. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22663. return baseRest(function(args) {
  22664. var thisArg = this;
  22665. return arrayFunc(iteratees, function(iteratee) {
  22666. return apply(iteratee, thisArg, args);
  22667. });
  22668. });
  22669. });
  22670. }
  22671. /**
  22672. * Creates the padding for `string` based on `length`. The `chars` string
  22673. * is truncated if the number of characters exceeds `length`.
  22674. *
  22675. * @private
  22676. * @param {number} length The padding length.
  22677. * @param {string} [chars=' '] The string used as padding.
  22678. * @returns {string} Returns the padding for `string`.
  22679. */
  22680. function createPadding(length, chars) {
  22681. chars = chars === undefined ? ' ' : baseToString(chars);
  22682. var charsLength = chars.length;
  22683. if (charsLength < 2) {
  22684. return charsLength ? baseRepeat(chars, length) : chars;
  22685. }
  22686. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22687. return hasUnicode(chars)
  22688. ? castSlice(stringToArray(result), 0, length).join('')
  22689. : result.slice(0, length);
  22690. }
  22691. /**
  22692. * Creates a function that wraps `func` to invoke it with the `this` binding
  22693. * of `thisArg` and `partials` prepended to the arguments it receives.
  22694. *
  22695. * @private
  22696. * @param {Function} func The function to wrap.
  22697. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22698. * @param {*} thisArg The `this` binding of `func`.
  22699. * @param {Array} partials The arguments to prepend to those provided to
  22700. * the new function.
  22701. * @returns {Function} Returns the new wrapped function.
  22702. */
  22703. function createPartial(func, bitmask, thisArg, partials) {
  22704. var isBind = bitmask & WRAP_BIND_FLAG,
  22705. Ctor = createCtor(func);
  22706. function wrapper() {
  22707. var argsIndex = -1,
  22708. argsLength = arguments.length,
  22709. leftIndex = -1,
  22710. leftLength = partials.length,
  22711. args = Array(leftLength + argsLength),
  22712. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22713. while (++leftIndex < leftLength) {
  22714. args[leftIndex] = partials[leftIndex];
  22715. }
  22716. while (argsLength--) {
  22717. args[leftIndex++] = arguments[++argsIndex];
  22718. }
  22719. return apply(fn, isBind ? thisArg : this, args);
  22720. }
  22721. return wrapper;
  22722. }
  22723. /**
  22724. * Creates a `_.range` or `_.rangeRight` function.
  22725. *
  22726. * @private
  22727. * @param {boolean} [fromRight] Specify iterating from right to left.
  22728. * @returns {Function} Returns the new range function.
  22729. */
  22730. function createRange(fromRight) {
  22731. return function(start, end, step) {
  22732. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22733. end = step = undefined;
  22734. }
  22735. // Ensure the sign of `-0` is preserved.
  22736. start = toFinite(start);
  22737. if (end === undefined) {
  22738. end = start;
  22739. start = 0;
  22740. } else {
  22741. end = toFinite(end);
  22742. }
  22743. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22744. return baseRange(start, end, step, fromRight);
  22745. };
  22746. }
  22747. /**
  22748. * Creates a function that performs a relational operation on two values.
  22749. *
  22750. * @private
  22751. * @param {Function} operator The function to perform the operation.
  22752. * @returns {Function} Returns the new relational operation function.
  22753. */
  22754. function createRelationalOperation(operator) {
  22755. return function(value, other) {
  22756. if (!(typeof value == 'string' && typeof other == 'string')) {
  22757. value = toNumber(value);
  22758. other = toNumber(other);
  22759. }
  22760. return operator(value, other);
  22761. };
  22762. }
  22763. /**
  22764. * Creates a function that wraps `func` to continue currying.
  22765. *
  22766. * @private
  22767. * @param {Function} func The function to wrap.
  22768. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22769. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22770. * @param {*} placeholder The placeholder value.
  22771. * @param {*} [thisArg] The `this` binding of `func`.
  22772. * @param {Array} [partials] The arguments to prepend to those provided to
  22773. * the new function.
  22774. * @param {Array} [holders] The `partials` placeholder indexes.
  22775. * @param {Array} [argPos] The argument positions of the new function.
  22776. * @param {number} [ary] The arity cap of `func`.
  22777. * @param {number} [arity] The arity of `func`.
  22778. * @returns {Function} Returns the new wrapped function.
  22779. */
  22780. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22781. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22782. newHolders = isCurry ? holders : undefined,
  22783. newHoldersRight = isCurry ? undefined : holders,
  22784. newPartials = isCurry ? partials : undefined,
  22785. newPartialsRight = isCurry ? undefined : partials;
  22786. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22787. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22788. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22789. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22790. }
  22791. var newData = [
  22792. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22793. newHoldersRight, argPos, ary, arity
  22794. ];
  22795. var result = wrapFunc.apply(undefined, newData);
  22796. if (isLaziable(func)) {
  22797. setData(result, newData);
  22798. }
  22799. result.placeholder = placeholder;
  22800. return setWrapToString(result, func, bitmask);
  22801. }
  22802. /**
  22803. * Creates a function like `_.round`.
  22804. *
  22805. * @private
  22806. * @param {string} methodName The name of the `Math` method to use when rounding.
  22807. * @returns {Function} Returns the new round function.
  22808. */
  22809. function createRound(methodName) {
  22810. var func = Math[methodName];
  22811. return function(number, precision) {
  22812. number = toNumber(number);
  22813. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22814. if (precision && nativeIsFinite(number)) {
  22815. // Shift with exponential notation to avoid floating-point issues.
  22816. // See [MDN](https://mdn.io/round#Examples) for more details.
  22817. var pair = (toString(number) + 'e').split('e'),
  22818. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22819. pair = (toString(value) + 'e').split('e');
  22820. return +(pair[0] + 'e' + (+pair[1] - precision));
  22821. }
  22822. return func(number);
  22823. };
  22824. }
  22825. /**
  22826. * Creates a set object of `values`.
  22827. *
  22828. * @private
  22829. * @param {Array} values The values to add to the set.
  22830. * @returns {Object} Returns the new set.
  22831. */
  22832. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22833. return new Set(values);
  22834. };
  22835. /**
  22836. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22837. *
  22838. * @private
  22839. * @param {Function} keysFunc The function to get the keys of a given object.
  22840. * @returns {Function} Returns the new pairs function.
  22841. */
  22842. function createToPairs(keysFunc) {
  22843. return function(object) {
  22844. var tag = getTag(object);
  22845. if (tag == mapTag) {
  22846. return mapToArray(object);
  22847. }
  22848. if (tag == setTag) {
  22849. return setToPairs(object);
  22850. }
  22851. return baseToPairs(object, keysFunc(object));
  22852. };
  22853. }
  22854. /**
  22855. * Creates a function that either curries or invokes `func` with optional
  22856. * `this` binding and partially applied arguments.
  22857. *
  22858. * @private
  22859. * @param {Function|string} func The function or method name to wrap.
  22860. * @param {number} bitmask The bitmask flags.
  22861. * 1 - `_.bind`
  22862. * 2 - `_.bindKey`
  22863. * 4 - `_.curry` or `_.curryRight` of a bound function
  22864. * 8 - `_.curry`
  22865. * 16 - `_.curryRight`
  22866. * 32 - `_.partial`
  22867. * 64 - `_.partialRight`
  22868. * 128 - `_.rearg`
  22869. * 256 - `_.ary`
  22870. * 512 - `_.flip`
  22871. * @param {*} [thisArg] The `this` binding of `func`.
  22872. * @param {Array} [partials] The arguments to be partially applied.
  22873. * @param {Array} [holders] The `partials` placeholder indexes.
  22874. * @param {Array} [argPos] The argument positions of the new function.
  22875. * @param {number} [ary] The arity cap of `func`.
  22876. * @param {number} [arity] The arity of `func`.
  22877. * @returns {Function} Returns the new wrapped function.
  22878. */
  22879. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22880. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22881. if (!isBindKey && typeof func != 'function') {
  22882. throw new TypeError(FUNC_ERROR_TEXT);
  22883. }
  22884. var length = partials ? partials.length : 0;
  22885. if (!length) {
  22886. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22887. partials = holders = undefined;
  22888. }
  22889. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22890. arity = arity === undefined ? arity : toInteger(arity);
  22891. length -= holders ? holders.length : 0;
  22892. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22893. var partialsRight = partials,
  22894. holdersRight = holders;
  22895. partials = holders = undefined;
  22896. }
  22897. var data = isBindKey ? undefined : getData(func);
  22898. var newData = [
  22899. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22900. argPos, ary, arity
  22901. ];
  22902. if (data) {
  22903. mergeData(newData, data);
  22904. }
  22905. func = newData[0];
  22906. bitmask = newData[1];
  22907. thisArg = newData[2];
  22908. partials = newData[3];
  22909. holders = newData[4];
  22910. arity = newData[9] = newData[9] === undefined
  22911. ? (isBindKey ? 0 : func.length)
  22912. : nativeMax(newData[9] - length, 0);
  22913. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22914. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22915. }
  22916. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22917. var result = createBind(func, bitmask, thisArg);
  22918. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22919. result = createCurry(func, bitmask, arity);
  22920. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22921. result = createPartial(func, bitmask, thisArg, partials);
  22922. } else {
  22923. result = createHybrid.apply(undefined, newData);
  22924. }
  22925. var setter = data ? baseSetData : setData;
  22926. return setWrapToString(setter(result, newData), func, bitmask);
  22927. }
  22928. /**
  22929. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22930. * of source objects to the destination object for all destination properties
  22931. * that resolve to `undefined`.
  22932. *
  22933. * @private
  22934. * @param {*} objValue The destination value.
  22935. * @param {*} srcValue The source value.
  22936. * @param {string} key The key of the property to assign.
  22937. * @param {Object} object The parent object of `objValue`.
  22938. * @returns {*} Returns the value to assign.
  22939. */
  22940. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22941. if (objValue === undefined ||
  22942. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22943. return srcValue;
  22944. }
  22945. return objValue;
  22946. }
  22947. /**
  22948. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22949. * objects into destination objects that are passed thru.
  22950. *
  22951. * @private
  22952. * @param {*} objValue The destination value.
  22953. * @param {*} srcValue The source value.
  22954. * @param {string} key The key of the property to merge.
  22955. * @param {Object} object The parent object of `objValue`.
  22956. * @param {Object} source The parent object of `srcValue`.
  22957. * @param {Object} [stack] Tracks traversed source values and their merged
  22958. * counterparts.
  22959. * @returns {*} Returns the value to assign.
  22960. */
  22961. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22962. if (isObject(objValue) && isObject(srcValue)) {
  22963. // Recursively merge objects and arrays (susceptible to call stack limits).
  22964. stack.set(srcValue, objValue);
  22965. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22966. stack['delete'](srcValue);
  22967. }
  22968. return objValue;
  22969. }
  22970. /**
  22971. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22972. * objects.
  22973. *
  22974. * @private
  22975. * @param {*} value The value to inspect.
  22976. * @param {string} key The key of the property to inspect.
  22977. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22978. */
  22979. function customOmitClone(value) {
  22980. return isPlainObject(value) ? undefined : value;
  22981. }
  22982. /**
  22983. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22984. * partial deep comparisons.
  22985. *
  22986. * @private
  22987. * @param {Array} array The array to compare.
  22988. * @param {Array} other The other array to compare.
  22989. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22990. * @param {Function} customizer The function to customize comparisons.
  22991. * @param {Function} equalFunc The function to determine equivalents of values.
  22992. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22993. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22994. */
  22995. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22996. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22997. arrLength = array.length,
  22998. othLength = other.length;
  22999. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  23000. return false;
  23001. }
  23002. // Assume cyclic values are equal.
  23003. var stacked = stack.get(array);
  23004. if (stacked && stack.get(other)) {
  23005. return stacked == other;
  23006. }
  23007. var index = -1,
  23008. result = true,
  23009. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  23010. stack.set(array, other);
  23011. stack.set(other, array);
  23012. // Ignore non-index properties.
  23013. while (++index < arrLength) {
  23014. var arrValue = array[index],
  23015. othValue = other[index];
  23016. if (customizer) {
  23017. var compared = isPartial
  23018. ? customizer(othValue, arrValue, index, other, array, stack)
  23019. : customizer(arrValue, othValue, index, array, other, stack);
  23020. }
  23021. if (compared !== undefined) {
  23022. if (compared) {
  23023. continue;
  23024. }
  23025. result = false;
  23026. break;
  23027. }
  23028. // Recursively compare arrays (susceptible to call stack limits).
  23029. if (seen) {
  23030. if (!arraySome(other, function(othValue, othIndex) {
  23031. if (!cacheHas(seen, othIndex) &&
  23032. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  23033. return seen.push(othIndex);
  23034. }
  23035. })) {
  23036. result = false;
  23037. break;
  23038. }
  23039. } else if (!(
  23040. arrValue === othValue ||
  23041. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  23042. )) {
  23043. result = false;
  23044. break;
  23045. }
  23046. }
  23047. stack['delete'](array);
  23048. stack['delete'](other);
  23049. return result;
  23050. }
  23051. /**
  23052. * A specialized version of `baseIsEqualDeep` for comparing objects of
  23053. * the same `toStringTag`.
  23054. *
  23055. * **Note:** This function only supports comparing values with tags of
  23056. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  23057. *
  23058. * @private
  23059. * @param {Object} object The object to compare.
  23060. * @param {Object} other The other object to compare.
  23061. * @param {string} tag The `toStringTag` of the objects to compare.
  23062. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23063. * @param {Function} customizer The function to customize comparisons.
  23064. * @param {Function} equalFunc The function to determine equivalents of values.
  23065. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23066. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23067. */
  23068. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  23069. switch (tag) {
  23070. case dataViewTag:
  23071. if ((object.byteLength != other.byteLength) ||
  23072. (object.byteOffset != other.byteOffset)) {
  23073. return false;
  23074. }
  23075. object = object.buffer;
  23076. other = other.buffer;
  23077. case arrayBufferTag:
  23078. if ((object.byteLength != other.byteLength) ||
  23079. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  23080. return false;
  23081. }
  23082. return true;
  23083. case boolTag:
  23084. case dateTag:
  23085. case numberTag:
  23086. // Coerce booleans to `1` or `0` and dates to milliseconds.
  23087. // Invalid dates are coerced to `NaN`.
  23088. return eq(+object, +other);
  23089. case errorTag:
  23090. return object.name == other.name && object.message == other.message;
  23091. case regexpTag:
  23092. case stringTag:
  23093. // Coerce regexes to strings and treat strings, primitives and objects,
  23094. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  23095. // for more details.
  23096. return object == (other + '');
  23097. case mapTag:
  23098. var convert = mapToArray;
  23099. case setTag:
  23100. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  23101. convert || (convert = setToArray);
  23102. if (object.size != other.size && !isPartial) {
  23103. return false;
  23104. }
  23105. // Assume cyclic values are equal.
  23106. var stacked = stack.get(object);
  23107. if (stacked) {
  23108. return stacked == other;
  23109. }
  23110. bitmask |= COMPARE_UNORDERED_FLAG;
  23111. // Recursively compare objects (susceptible to call stack limits).
  23112. stack.set(object, other);
  23113. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  23114. stack['delete'](object);
  23115. return result;
  23116. case symbolTag:
  23117. if (symbolValueOf) {
  23118. return symbolValueOf.call(object) == symbolValueOf.call(other);
  23119. }
  23120. }
  23121. return false;
  23122. }
  23123. /**
  23124. * A specialized version of `baseIsEqualDeep` for objects with support for
  23125. * partial deep comparisons.
  23126. *
  23127. * @private
  23128. * @param {Object} object The object to compare.
  23129. * @param {Object} other The other object to compare.
  23130. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23131. * @param {Function} customizer The function to customize comparisons.
  23132. * @param {Function} equalFunc The function to determine equivalents of values.
  23133. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23134. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23135. */
  23136. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23137. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23138. objProps = getAllKeys(object),
  23139. objLength = objProps.length,
  23140. othProps = getAllKeys(other),
  23141. othLength = othProps.length;
  23142. if (objLength != othLength && !isPartial) {
  23143. return false;
  23144. }
  23145. var index = objLength;
  23146. while (index--) {
  23147. var key = objProps[index];
  23148. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23149. return false;
  23150. }
  23151. }
  23152. // Assume cyclic values are equal.
  23153. var stacked = stack.get(object);
  23154. if (stacked && stack.get(other)) {
  23155. return stacked == other;
  23156. }
  23157. var result = true;
  23158. stack.set(object, other);
  23159. stack.set(other, object);
  23160. var skipCtor = isPartial;
  23161. while (++index < objLength) {
  23162. key = objProps[index];
  23163. var objValue = object[key],
  23164. othValue = other[key];
  23165. if (customizer) {
  23166. var compared = isPartial
  23167. ? customizer(othValue, objValue, key, other, object, stack)
  23168. : customizer(objValue, othValue, key, object, other, stack);
  23169. }
  23170. // Recursively compare objects (susceptible to call stack limits).
  23171. if (!(compared === undefined
  23172. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23173. : compared
  23174. )) {
  23175. result = false;
  23176. break;
  23177. }
  23178. skipCtor || (skipCtor = key == 'constructor');
  23179. }
  23180. if (result && !skipCtor) {
  23181. var objCtor = object.constructor,
  23182. othCtor = other.constructor;
  23183. // Non `Object` object instances with different constructors are not equal.
  23184. if (objCtor != othCtor &&
  23185. ('constructor' in object && 'constructor' in other) &&
  23186. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23187. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23188. result = false;
  23189. }
  23190. }
  23191. stack['delete'](object);
  23192. stack['delete'](other);
  23193. return result;
  23194. }
  23195. /**
  23196. * A specialized version of `baseRest` which flattens the rest array.
  23197. *
  23198. * @private
  23199. * @param {Function} func The function to apply a rest parameter to.
  23200. * @returns {Function} Returns the new function.
  23201. */
  23202. function flatRest(func) {
  23203. return setToString(overRest(func, undefined, flatten), func + '');
  23204. }
  23205. /**
  23206. * Creates an array of own enumerable property names and symbols of `object`.
  23207. *
  23208. * @private
  23209. * @param {Object} object The object to query.
  23210. * @returns {Array} Returns the array of property names and symbols.
  23211. */
  23212. function getAllKeys(object) {
  23213. return baseGetAllKeys(object, keys, getSymbols);
  23214. }
  23215. /**
  23216. * Creates an array of own and inherited enumerable property names and
  23217. * symbols of `object`.
  23218. *
  23219. * @private
  23220. * @param {Object} object The object to query.
  23221. * @returns {Array} Returns the array of property names and symbols.
  23222. */
  23223. function getAllKeysIn(object) {
  23224. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23225. }
  23226. /**
  23227. * Gets metadata for `func`.
  23228. *
  23229. * @private
  23230. * @param {Function} func The function to query.
  23231. * @returns {*} Returns the metadata for `func`.
  23232. */
  23233. var getData = !metaMap ? noop : function(func) {
  23234. return metaMap.get(func);
  23235. };
  23236. /**
  23237. * Gets the name of `func`.
  23238. *
  23239. * @private
  23240. * @param {Function} func The function to query.
  23241. * @returns {string} Returns the function name.
  23242. */
  23243. function getFuncName(func) {
  23244. var result = (func.name + ''),
  23245. array = realNames[result],
  23246. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23247. while (length--) {
  23248. var data = array[length],
  23249. otherFunc = data.func;
  23250. if (otherFunc == null || otherFunc == func) {
  23251. return data.name;
  23252. }
  23253. }
  23254. return result;
  23255. }
  23256. /**
  23257. * Gets the argument placeholder value for `func`.
  23258. *
  23259. * @private
  23260. * @param {Function} func The function to inspect.
  23261. * @returns {*} Returns the placeholder value.
  23262. */
  23263. function getHolder(func) {
  23264. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23265. return object.placeholder;
  23266. }
  23267. /**
  23268. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23269. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23270. * If arguments are provided, the chosen function is invoked with them and
  23271. * its result is returned.
  23272. *
  23273. * @private
  23274. * @param {*} [value] The value to convert to an iteratee.
  23275. * @param {number} [arity] The arity of the created iteratee.
  23276. * @returns {Function} Returns the chosen function or its result.
  23277. */
  23278. function getIteratee() {
  23279. var result = lodash.iteratee || iteratee;
  23280. result = result === iteratee ? baseIteratee : result;
  23281. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23282. }
  23283. /**
  23284. * Gets the data for `map`.
  23285. *
  23286. * @private
  23287. * @param {Object} map The map to query.
  23288. * @param {string} key The reference key.
  23289. * @returns {*} Returns the map data.
  23290. */
  23291. function getMapData(map, key) {
  23292. var data = map.__data__;
  23293. return isKeyable(key)
  23294. ? data[typeof key == 'string' ? 'string' : 'hash']
  23295. : data.map;
  23296. }
  23297. /**
  23298. * Gets the property names, values, and compare flags of `object`.
  23299. *
  23300. * @private
  23301. * @param {Object} object The object to query.
  23302. * @returns {Array} Returns the match data of `object`.
  23303. */
  23304. function getMatchData(object) {
  23305. var result = keys(object),
  23306. length = result.length;
  23307. while (length--) {
  23308. var key = result[length],
  23309. value = object[key];
  23310. result[length] = [key, value, isStrictComparable(value)];
  23311. }
  23312. return result;
  23313. }
  23314. /**
  23315. * Gets the native function at `key` of `object`.
  23316. *
  23317. * @private
  23318. * @param {Object} object The object to query.
  23319. * @param {string} key The key of the method to get.
  23320. * @returns {*} Returns the function if it's native, else `undefined`.
  23321. */
  23322. function getNative(object, key) {
  23323. var value = getValue(object, key);
  23324. return baseIsNative(value) ? value : undefined;
  23325. }
  23326. /**
  23327. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23328. *
  23329. * @private
  23330. * @param {*} value The value to query.
  23331. * @returns {string} Returns the raw `toStringTag`.
  23332. */
  23333. function getRawTag(value) {
  23334. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23335. tag = value[symToStringTag];
  23336. try {
  23337. value[symToStringTag] = undefined;
  23338. var unmasked = true;
  23339. } catch (e) {}
  23340. var result = nativeObjectToString.call(value);
  23341. if (unmasked) {
  23342. if (isOwn) {
  23343. value[symToStringTag] = tag;
  23344. } else {
  23345. delete value[symToStringTag];
  23346. }
  23347. }
  23348. return result;
  23349. }
  23350. /**
  23351. * Creates an array of the own enumerable symbols of `object`.
  23352. *
  23353. * @private
  23354. * @param {Object} object The object to query.
  23355. * @returns {Array} Returns the array of symbols.
  23356. */
  23357. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23358. if (object == null) {
  23359. return [];
  23360. }
  23361. object = Object(object);
  23362. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23363. return propertyIsEnumerable.call(object, symbol);
  23364. });
  23365. };
  23366. /**
  23367. * Creates an array of the own and inherited enumerable symbols of `object`.
  23368. *
  23369. * @private
  23370. * @param {Object} object The object to query.
  23371. * @returns {Array} Returns the array of symbols.
  23372. */
  23373. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23374. var result = [];
  23375. while (object) {
  23376. arrayPush(result, getSymbols(object));
  23377. object = getPrototype(object);
  23378. }
  23379. return result;
  23380. };
  23381. /**
  23382. * Gets the `toStringTag` of `value`.
  23383. *
  23384. * @private
  23385. * @param {*} value The value to query.
  23386. * @returns {string} Returns the `toStringTag`.
  23387. */
  23388. var getTag = baseGetTag;
  23389. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23390. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23391. (Map && getTag(new Map) != mapTag) ||
  23392. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23393. (Set && getTag(new Set) != setTag) ||
  23394. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23395. getTag = function(value) {
  23396. var result = baseGetTag(value),
  23397. Ctor = result == objectTag ? value.constructor : undefined,
  23398. ctorString = Ctor ? toSource(Ctor) : '';
  23399. if (ctorString) {
  23400. switch (ctorString) {
  23401. case dataViewCtorString: return dataViewTag;
  23402. case mapCtorString: return mapTag;
  23403. case promiseCtorString: return promiseTag;
  23404. case setCtorString: return setTag;
  23405. case weakMapCtorString: return weakMapTag;
  23406. }
  23407. }
  23408. return result;
  23409. };
  23410. }
  23411. /**
  23412. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23413. *
  23414. * @private
  23415. * @param {number} start The start of the view.
  23416. * @param {number} end The end of the view.
  23417. * @param {Array} transforms The transformations to apply to the view.
  23418. * @returns {Object} Returns an object containing the `start` and `end`
  23419. * positions of the view.
  23420. */
  23421. function getView(start, end, transforms) {
  23422. var index = -1,
  23423. length = transforms.length;
  23424. while (++index < length) {
  23425. var data = transforms[index],
  23426. size = data.size;
  23427. switch (data.type) {
  23428. case 'drop': start += size; break;
  23429. case 'dropRight': end -= size; break;
  23430. case 'take': end = nativeMin(end, start + size); break;
  23431. case 'takeRight': start = nativeMax(start, end - size); break;
  23432. }
  23433. }
  23434. return { 'start': start, 'end': end };
  23435. }
  23436. /**
  23437. * Extracts wrapper details from the `source` body comment.
  23438. *
  23439. * @private
  23440. * @param {string} source The source to inspect.
  23441. * @returns {Array} Returns the wrapper details.
  23442. */
  23443. function getWrapDetails(source) {
  23444. var match = source.match(reWrapDetails);
  23445. return match ? match[1].split(reSplitDetails) : [];
  23446. }
  23447. /**
  23448. * Checks if `path` exists on `object`.
  23449. *
  23450. * @private
  23451. * @param {Object} object The object to query.
  23452. * @param {Array|string} path The path to check.
  23453. * @param {Function} hasFunc The function to check properties.
  23454. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23455. */
  23456. function hasPath(object, path, hasFunc) {
  23457. path = castPath(path, object);
  23458. var index = -1,
  23459. length = path.length,
  23460. result = false;
  23461. while (++index < length) {
  23462. var key = toKey(path[index]);
  23463. if (!(result = object != null && hasFunc(object, key))) {
  23464. break;
  23465. }
  23466. object = object[key];
  23467. }
  23468. if (result || ++index != length) {
  23469. return result;
  23470. }
  23471. length = object == null ? 0 : object.length;
  23472. return !!length && isLength(length) && isIndex(key, length) &&
  23473. (isArray(object) || isArguments(object));
  23474. }
  23475. /**
  23476. * Initializes an array clone.
  23477. *
  23478. * @private
  23479. * @param {Array} array The array to clone.
  23480. * @returns {Array} Returns the initialized clone.
  23481. */
  23482. function initCloneArray(array) {
  23483. var length = array.length,
  23484. result = new array.constructor(length);
  23485. // Add properties assigned by `RegExp#exec`.
  23486. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23487. result.index = array.index;
  23488. result.input = array.input;
  23489. }
  23490. return result;
  23491. }
  23492. /**
  23493. * Initializes an object clone.
  23494. *
  23495. * @private
  23496. * @param {Object} object The object to clone.
  23497. * @returns {Object} Returns the initialized clone.
  23498. */
  23499. function initCloneObject(object) {
  23500. return (typeof object.constructor == 'function' && !isPrototype(object))
  23501. ? baseCreate(getPrototype(object))
  23502. : {};
  23503. }
  23504. /**
  23505. * Initializes an object clone based on its `toStringTag`.
  23506. *
  23507. * **Note:** This function only supports cloning values with tags of
  23508. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23509. *
  23510. * @private
  23511. * @param {Object} object The object to clone.
  23512. * @param {string} tag The `toStringTag` of the object to clone.
  23513. * @param {boolean} [isDeep] Specify a deep clone.
  23514. * @returns {Object} Returns the initialized clone.
  23515. */
  23516. function initCloneByTag(object, tag, isDeep) {
  23517. var Ctor = object.constructor;
  23518. switch (tag) {
  23519. case arrayBufferTag:
  23520. return cloneArrayBuffer(object);
  23521. case boolTag:
  23522. case dateTag:
  23523. return new Ctor(+object);
  23524. case dataViewTag:
  23525. return cloneDataView(object, isDeep);
  23526. case float32Tag: case float64Tag:
  23527. case int8Tag: case int16Tag: case int32Tag:
  23528. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23529. return cloneTypedArray(object, isDeep);
  23530. case mapTag:
  23531. return new Ctor;
  23532. case numberTag:
  23533. case stringTag:
  23534. return new Ctor(object);
  23535. case regexpTag:
  23536. return cloneRegExp(object);
  23537. case setTag:
  23538. return new Ctor;
  23539. case symbolTag:
  23540. return cloneSymbol(object);
  23541. }
  23542. }
  23543. /**
  23544. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23545. *
  23546. * @private
  23547. * @param {string} source The source to modify.
  23548. * @returns {Array} details The details to insert.
  23549. * @returns {string} Returns the modified source.
  23550. */
  23551. function insertWrapDetails(source, details) {
  23552. var length = details.length;
  23553. if (!length) {
  23554. return source;
  23555. }
  23556. var lastIndex = length - 1;
  23557. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23558. details = details.join(length > 2 ? ', ' : ' ');
  23559. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23560. }
  23561. /**
  23562. * Checks if `value` is a flattenable `arguments` object or array.
  23563. *
  23564. * @private
  23565. * @param {*} value The value to check.
  23566. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23567. */
  23568. function isFlattenable(value) {
  23569. return isArray(value) || isArguments(value) ||
  23570. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23571. }
  23572. /**
  23573. * Checks if `value` is a valid array-like index.
  23574. *
  23575. * @private
  23576. * @param {*} value The value to check.
  23577. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23578. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23579. */
  23580. function isIndex(value, length) {
  23581. var type = typeof value;
  23582. length = length == null ? MAX_SAFE_INTEGER : length;
  23583. return !!length &&
  23584. (type == 'number' ||
  23585. (type != 'symbol' && reIsUint.test(value))) &&
  23586. (value > -1 && value % 1 == 0 && value < length);
  23587. }
  23588. /**
  23589. * Checks if the given arguments are from an iteratee call.
  23590. *
  23591. * @private
  23592. * @param {*} value The potential iteratee value argument.
  23593. * @param {*} index The potential iteratee index or key argument.
  23594. * @param {*} object The potential iteratee object argument.
  23595. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23596. * else `false`.
  23597. */
  23598. function isIterateeCall(value, index, object) {
  23599. if (!isObject(object)) {
  23600. return false;
  23601. }
  23602. var type = typeof index;
  23603. if (type == 'number'
  23604. ? (isArrayLike(object) && isIndex(index, object.length))
  23605. : (type == 'string' && index in object)
  23606. ) {
  23607. return eq(object[index], value);
  23608. }
  23609. return false;
  23610. }
  23611. /**
  23612. * Checks if `value` is a property name and not a property path.
  23613. *
  23614. * @private
  23615. * @param {*} value The value to check.
  23616. * @param {Object} [object] The object to query keys on.
  23617. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23618. */
  23619. function isKey(value, object) {
  23620. if (isArray(value)) {
  23621. return false;
  23622. }
  23623. var type = typeof value;
  23624. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23625. value == null || isSymbol(value)) {
  23626. return true;
  23627. }
  23628. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23629. (object != null && value in Object(object));
  23630. }
  23631. /**
  23632. * Checks if `value` is suitable for use as unique object key.
  23633. *
  23634. * @private
  23635. * @param {*} value The value to check.
  23636. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23637. */
  23638. function isKeyable(value) {
  23639. var type = typeof value;
  23640. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23641. ? (value !== '__proto__')
  23642. : (value === null);
  23643. }
  23644. /**
  23645. * Checks if `func` has a lazy counterpart.
  23646. *
  23647. * @private
  23648. * @param {Function} func The function to check.
  23649. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23650. * else `false`.
  23651. */
  23652. function isLaziable(func) {
  23653. var funcName = getFuncName(func),
  23654. other = lodash[funcName];
  23655. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23656. return false;
  23657. }
  23658. if (func === other) {
  23659. return true;
  23660. }
  23661. var data = getData(other);
  23662. return !!data && func === data[0];
  23663. }
  23664. /**
  23665. * Checks if `func` has its source masked.
  23666. *
  23667. * @private
  23668. * @param {Function} func The function to check.
  23669. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23670. */
  23671. function isMasked(func) {
  23672. return !!maskSrcKey && (maskSrcKey in func);
  23673. }
  23674. /**
  23675. * Checks if `func` is capable of being masked.
  23676. *
  23677. * @private
  23678. * @param {*} value The value to check.
  23679. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23680. */
  23681. var isMaskable = coreJsData ? isFunction : stubFalse;
  23682. /**
  23683. * Checks if `value` is likely a prototype object.
  23684. *
  23685. * @private
  23686. * @param {*} value The value to check.
  23687. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23688. */
  23689. function isPrototype(value) {
  23690. var Ctor = value && value.constructor,
  23691. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23692. return value === proto;
  23693. }
  23694. /**
  23695. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23696. *
  23697. * @private
  23698. * @param {*} value The value to check.
  23699. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23700. * equality comparisons, else `false`.
  23701. */
  23702. function isStrictComparable(value) {
  23703. return value === value && !isObject(value);
  23704. }
  23705. /**
  23706. * A specialized version of `matchesProperty` for source values suitable
  23707. * for strict equality comparisons, i.e. `===`.
  23708. *
  23709. * @private
  23710. * @param {string} key The key of the property to get.
  23711. * @param {*} srcValue The value to match.
  23712. * @returns {Function} Returns the new spec function.
  23713. */
  23714. function matchesStrictComparable(key, srcValue) {
  23715. return function(object) {
  23716. if (object == null) {
  23717. return false;
  23718. }
  23719. return object[key] === srcValue &&
  23720. (srcValue !== undefined || (key in Object(object)));
  23721. };
  23722. }
  23723. /**
  23724. * A specialized version of `_.memoize` which clears the memoized function's
  23725. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23726. *
  23727. * @private
  23728. * @param {Function} func The function to have its output memoized.
  23729. * @returns {Function} Returns the new memoized function.
  23730. */
  23731. function memoizeCapped(func) {
  23732. var result = memoize(func, function(key) {
  23733. if (cache.size === MAX_MEMOIZE_SIZE) {
  23734. cache.clear();
  23735. }
  23736. return key;
  23737. });
  23738. var cache = result.cache;
  23739. return result;
  23740. }
  23741. /**
  23742. * Merges the function metadata of `source` into `data`.
  23743. *
  23744. * Merging metadata reduces the number of wrappers used to invoke a function.
  23745. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23746. * may be applied regardless of execution order. Methods like `_.ary` and
  23747. * `_.rearg` modify function arguments, making the order in which they are
  23748. * executed important, preventing the merging of metadata. However, we make
  23749. * an exception for a safe combined case where curried functions have `_.ary`
  23750. * and or `_.rearg` applied.
  23751. *
  23752. * @private
  23753. * @param {Array} data The destination metadata.
  23754. * @param {Array} source The source metadata.
  23755. * @returns {Array} Returns `data`.
  23756. */
  23757. function mergeData(data, source) {
  23758. var bitmask = data[1],
  23759. srcBitmask = source[1],
  23760. newBitmask = bitmask | srcBitmask,
  23761. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23762. var isCombo =
  23763. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23764. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23765. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23766. // Exit early if metadata can't be merged.
  23767. if (!(isCommon || isCombo)) {
  23768. return data;
  23769. }
  23770. // Use source `thisArg` if available.
  23771. if (srcBitmask & WRAP_BIND_FLAG) {
  23772. data[2] = source[2];
  23773. // Set when currying a bound function.
  23774. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23775. }
  23776. // Compose partial arguments.
  23777. var value = source[3];
  23778. if (value) {
  23779. var partials = data[3];
  23780. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23781. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23782. }
  23783. // Compose partial right arguments.
  23784. value = source[5];
  23785. if (value) {
  23786. partials = data[5];
  23787. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23788. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23789. }
  23790. // Use source `argPos` if available.
  23791. value = source[7];
  23792. if (value) {
  23793. data[7] = value;
  23794. }
  23795. // Use source `ary` if it's smaller.
  23796. if (srcBitmask & WRAP_ARY_FLAG) {
  23797. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23798. }
  23799. // Use source `arity` if one is not provided.
  23800. if (data[9] == null) {
  23801. data[9] = source[9];
  23802. }
  23803. // Use source `func` and merge bitmasks.
  23804. data[0] = source[0];
  23805. data[1] = newBitmask;
  23806. return data;
  23807. }
  23808. /**
  23809. * This function is like
  23810. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23811. * except that it includes inherited enumerable properties.
  23812. *
  23813. * @private
  23814. * @param {Object} object The object to query.
  23815. * @returns {Array} Returns the array of property names.
  23816. */
  23817. function nativeKeysIn(object) {
  23818. var result = [];
  23819. if (object != null) {
  23820. for (var key in Object(object)) {
  23821. result.push(key);
  23822. }
  23823. }
  23824. return result;
  23825. }
  23826. /**
  23827. * Converts `value` to a string using `Object.prototype.toString`.
  23828. *
  23829. * @private
  23830. * @param {*} value The value to convert.
  23831. * @returns {string} Returns the converted string.
  23832. */
  23833. function objectToString(value) {
  23834. return nativeObjectToString.call(value);
  23835. }
  23836. /**
  23837. * A specialized version of `baseRest` which transforms the rest array.
  23838. *
  23839. * @private
  23840. * @param {Function} func The function to apply a rest parameter to.
  23841. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23842. * @param {Function} transform The rest array transform.
  23843. * @returns {Function} Returns the new function.
  23844. */
  23845. function overRest(func, start, transform) {
  23846. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23847. return function() {
  23848. var args = arguments,
  23849. index = -1,
  23850. length = nativeMax(args.length - start, 0),
  23851. array = Array(length);
  23852. while (++index < length) {
  23853. array[index] = args[start + index];
  23854. }
  23855. index = -1;
  23856. var otherArgs = Array(start + 1);
  23857. while (++index < start) {
  23858. otherArgs[index] = args[index];
  23859. }
  23860. otherArgs[start] = transform(array);
  23861. return apply(func, this, otherArgs);
  23862. };
  23863. }
  23864. /**
  23865. * Gets the parent value at `path` of `object`.
  23866. *
  23867. * @private
  23868. * @param {Object} object The object to query.
  23869. * @param {Array} path The path to get the parent value of.
  23870. * @returns {*} Returns the parent value.
  23871. */
  23872. function parent(object, path) {
  23873. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23874. }
  23875. /**
  23876. * Reorder `array` according to the specified indexes where the element at
  23877. * the first index is assigned as the first element, the element at
  23878. * the second index is assigned as the second element, and so on.
  23879. *
  23880. * @private
  23881. * @param {Array} array The array to reorder.
  23882. * @param {Array} indexes The arranged array indexes.
  23883. * @returns {Array} Returns `array`.
  23884. */
  23885. function reorder(array, indexes) {
  23886. var arrLength = array.length,
  23887. length = nativeMin(indexes.length, arrLength),
  23888. oldArray = copyArray(array);
  23889. while (length--) {
  23890. var index = indexes[length];
  23891. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23892. }
  23893. return array;
  23894. }
  23895. /**
  23896. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23897. *
  23898. * @private
  23899. * @param {Object} object The object to query.
  23900. * @param {string} key The key of the property to get.
  23901. * @returns {*} Returns the property value.
  23902. */
  23903. function safeGet(object, key) {
  23904. if (key === 'constructor' && typeof object[key] === 'function') {
  23905. return;
  23906. }
  23907. if (key == '__proto__') {
  23908. return;
  23909. }
  23910. return object[key];
  23911. }
  23912. /**
  23913. * Sets metadata for `func`.
  23914. *
  23915. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23916. * period of time, it will trip its breaker and transition to an identity
  23917. * function to avoid garbage collection pauses in V8. See
  23918. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23919. * for more details.
  23920. *
  23921. * @private
  23922. * @param {Function} func The function to associate metadata with.
  23923. * @param {*} data The metadata.
  23924. * @returns {Function} Returns `func`.
  23925. */
  23926. var setData = shortOut(baseSetData);
  23927. /**
  23928. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23929. *
  23930. * @private
  23931. * @param {Function} func The function to delay.
  23932. * @param {number} wait The number of milliseconds to delay invocation.
  23933. * @returns {number|Object} Returns the timer id or timeout object.
  23934. */
  23935. var setTimeout = ctxSetTimeout || function(func, wait) {
  23936. return root.setTimeout(func, wait);
  23937. };
  23938. /**
  23939. * Sets the `toString` method of `func` to return `string`.
  23940. *
  23941. * @private
  23942. * @param {Function} func The function to modify.
  23943. * @param {Function} string The `toString` result.
  23944. * @returns {Function} Returns `func`.
  23945. */
  23946. var setToString = shortOut(baseSetToString);
  23947. /**
  23948. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23949. * with wrapper details in a comment at the top of the source body.
  23950. *
  23951. * @private
  23952. * @param {Function} wrapper The function to modify.
  23953. * @param {Function} reference The reference function.
  23954. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23955. * @returns {Function} Returns `wrapper`.
  23956. */
  23957. function setWrapToString(wrapper, reference, bitmask) {
  23958. var source = (reference + '');
  23959. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23960. }
  23961. /**
  23962. * Creates a function that'll short out and invoke `identity` instead
  23963. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23964. * milliseconds.
  23965. *
  23966. * @private
  23967. * @param {Function} func The function to restrict.
  23968. * @returns {Function} Returns the new shortable function.
  23969. */
  23970. function shortOut(func) {
  23971. var count = 0,
  23972. lastCalled = 0;
  23973. return function() {
  23974. var stamp = nativeNow(),
  23975. remaining = HOT_SPAN - (stamp - lastCalled);
  23976. lastCalled = stamp;
  23977. if (remaining > 0) {
  23978. if (++count >= HOT_COUNT) {
  23979. return arguments[0];
  23980. }
  23981. } else {
  23982. count = 0;
  23983. }
  23984. return func.apply(undefined, arguments);
  23985. };
  23986. }
  23987. /**
  23988. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23989. *
  23990. * @private
  23991. * @param {Array} array The array to shuffle.
  23992. * @param {number} [size=array.length] The size of `array`.
  23993. * @returns {Array} Returns `array`.
  23994. */
  23995. function shuffleSelf(array, size) {
  23996. var index = -1,
  23997. length = array.length,
  23998. lastIndex = length - 1;
  23999. size = size === undefined ? length : size;
  24000. while (++index < size) {
  24001. var rand = baseRandom(index, lastIndex),
  24002. value = array[rand];
  24003. array[rand] = array[index];
  24004. array[index] = value;
  24005. }
  24006. array.length = size;
  24007. return array;
  24008. }
  24009. /**
  24010. * Converts `string` to a property path array.
  24011. *
  24012. * @private
  24013. * @param {string} string The string to convert.
  24014. * @returns {Array} Returns the property path array.
  24015. */
  24016. var stringToPath = memoizeCapped(function(string) {
  24017. var result = [];
  24018. if (string.charCodeAt(0) === 46 /* . */) {
  24019. result.push('');
  24020. }
  24021. string.replace(rePropName, function(match, number, quote, subString) {
  24022. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  24023. });
  24024. return result;
  24025. });
  24026. /**
  24027. * Converts `value` to a string key if it's not a string or symbol.
  24028. *
  24029. * @private
  24030. * @param {*} value The value to inspect.
  24031. * @returns {string|symbol} Returns the key.
  24032. */
  24033. function toKey(value) {
  24034. if (typeof value == 'string' || isSymbol(value)) {
  24035. return value;
  24036. }
  24037. var result = (value + '');
  24038. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  24039. }
  24040. /**
  24041. * Converts `func` to its source code.
  24042. *
  24043. * @private
  24044. * @param {Function} func The function to convert.
  24045. * @returns {string} Returns the source code.
  24046. */
  24047. function toSource(func) {
  24048. if (func != null) {
  24049. try {
  24050. return funcToString.call(func);
  24051. } catch (e) {}
  24052. try {
  24053. return (func + '');
  24054. } catch (e) {}
  24055. }
  24056. return '';
  24057. }
  24058. /**
  24059. * Updates wrapper `details` based on `bitmask` flags.
  24060. *
  24061. * @private
  24062. * @returns {Array} details The details to modify.
  24063. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  24064. * @returns {Array} Returns `details`.
  24065. */
  24066. function updateWrapDetails(details, bitmask) {
  24067. arrayEach(wrapFlags, function(pair) {
  24068. var value = '_.' + pair[0];
  24069. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  24070. details.push(value);
  24071. }
  24072. });
  24073. return details.sort();
  24074. }
  24075. /**
  24076. * Creates a clone of `wrapper`.
  24077. *
  24078. * @private
  24079. * @param {Object} wrapper The wrapper to clone.
  24080. * @returns {Object} Returns the cloned wrapper.
  24081. */
  24082. function wrapperClone(wrapper) {
  24083. if (wrapper instanceof LazyWrapper) {
  24084. return wrapper.clone();
  24085. }
  24086. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  24087. result.__actions__ = copyArray(wrapper.__actions__);
  24088. result.__index__ = wrapper.__index__;
  24089. result.__values__ = wrapper.__values__;
  24090. return result;
  24091. }
  24092. /*------------------------------------------------------------------------*/
  24093. /**
  24094. * Creates an array of elements split into groups the length of `size`.
  24095. * If `array` can't be split evenly, the final chunk will be the remaining
  24096. * elements.
  24097. *
  24098. * @static
  24099. * @memberOf _
  24100. * @since 3.0.0
  24101. * @category Array
  24102. * @param {Array} array The array to process.
  24103. * @param {number} [size=1] The length of each chunk
  24104. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24105. * @returns {Array} Returns the new array of chunks.
  24106. * @example
  24107. *
  24108. * _.chunk(['a', 'b', 'c', 'd'], 2);
  24109. * // => [['a', 'b'], ['c', 'd']]
  24110. *
  24111. * _.chunk(['a', 'b', 'c', 'd'], 3);
  24112. * // => [['a', 'b', 'c'], ['d']]
  24113. */
  24114. function chunk(array, size, guard) {
  24115. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  24116. size = 1;
  24117. } else {
  24118. size = nativeMax(toInteger(size), 0);
  24119. }
  24120. var length = array == null ? 0 : array.length;
  24121. if (!length || size < 1) {
  24122. return [];
  24123. }
  24124. var index = 0,
  24125. resIndex = 0,
  24126. result = Array(nativeCeil(length / size));
  24127. while (index < length) {
  24128. result[resIndex++] = baseSlice(array, index, (index += size));
  24129. }
  24130. return result;
  24131. }
  24132. /**
  24133. * Creates an array with all falsey values removed. The values `false`, `null`,
  24134. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24135. *
  24136. * @static
  24137. * @memberOf _
  24138. * @since 0.1.0
  24139. * @category Array
  24140. * @param {Array} array The array to compact.
  24141. * @returns {Array} Returns the new array of filtered values.
  24142. * @example
  24143. *
  24144. * _.compact([0, 1, false, 2, '', 3]);
  24145. * // => [1, 2, 3]
  24146. */
  24147. function compact(array) {
  24148. var index = -1,
  24149. length = array == null ? 0 : array.length,
  24150. resIndex = 0,
  24151. result = [];
  24152. while (++index < length) {
  24153. var value = array[index];
  24154. if (value) {
  24155. result[resIndex++] = value;
  24156. }
  24157. }
  24158. return result;
  24159. }
  24160. /**
  24161. * Creates a new array concatenating `array` with any additional arrays
  24162. * and/or values.
  24163. *
  24164. * @static
  24165. * @memberOf _
  24166. * @since 4.0.0
  24167. * @category Array
  24168. * @param {Array} array The array to concatenate.
  24169. * @param {...*} [values] The values to concatenate.
  24170. * @returns {Array} Returns the new concatenated array.
  24171. * @example
  24172. *
  24173. * var array = [1];
  24174. * var other = _.concat(array, 2, [3], [[4]]);
  24175. *
  24176. * console.log(other);
  24177. * // => [1, 2, 3, [4]]
  24178. *
  24179. * console.log(array);
  24180. * // => [1]
  24181. */
  24182. function concat() {
  24183. var length = arguments.length;
  24184. if (!length) {
  24185. return [];
  24186. }
  24187. var args = Array(length - 1),
  24188. array = arguments[0],
  24189. index = length;
  24190. while (index--) {
  24191. args[index - 1] = arguments[index];
  24192. }
  24193. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24194. }
  24195. /**
  24196. * Creates an array of `array` values not included in the other given arrays
  24197. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24198. * for equality comparisons. The order and references of result values are
  24199. * determined by the first array.
  24200. *
  24201. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24202. *
  24203. * @static
  24204. * @memberOf _
  24205. * @since 0.1.0
  24206. * @category Array
  24207. * @param {Array} array The array to inspect.
  24208. * @param {...Array} [values] The values to exclude.
  24209. * @returns {Array} Returns the new array of filtered values.
  24210. * @see _.without, _.xor
  24211. * @example
  24212. *
  24213. * _.difference([2, 1], [2, 3]);
  24214. * // => [1]
  24215. */
  24216. var difference = baseRest(function(array, values) {
  24217. return isArrayLikeObject(array)
  24218. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24219. : [];
  24220. });
  24221. /**
  24222. * This method is like `_.difference` except that it accepts `iteratee` which
  24223. * is invoked for each element of `array` and `values` to generate the criterion
  24224. * by which they're compared. The order and references of result values are
  24225. * determined by the first array. The iteratee is invoked with one argument:
  24226. * (value).
  24227. *
  24228. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24229. *
  24230. * @static
  24231. * @memberOf _
  24232. * @since 4.0.0
  24233. * @category Array
  24234. * @param {Array} array The array to inspect.
  24235. * @param {...Array} [values] The values to exclude.
  24236. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24237. * @returns {Array} Returns the new array of filtered values.
  24238. * @example
  24239. *
  24240. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24241. * // => [1.2]
  24242. *
  24243. * // The `_.property` iteratee shorthand.
  24244. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24245. * // => [{ 'x': 2 }]
  24246. */
  24247. var differenceBy = baseRest(function(array, values) {
  24248. var iteratee = last(values);
  24249. if (isArrayLikeObject(iteratee)) {
  24250. iteratee = undefined;
  24251. }
  24252. return isArrayLikeObject(array)
  24253. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24254. : [];
  24255. });
  24256. /**
  24257. * This method is like `_.difference` except that it accepts `comparator`
  24258. * which is invoked to compare elements of `array` to `values`. The order and
  24259. * references of result values are determined by the first array. The comparator
  24260. * is invoked with two arguments: (arrVal, othVal).
  24261. *
  24262. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24263. *
  24264. * @static
  24265. * @memberOf _
  24266. * @since 4.0.0
  24267. * @category Array
  24268. * @param {Array} array The array to inspect.
  24269. * @param {...Array} [values] The values to exclude.
  24270. * @param {Function} [comparator] The comparator invoked per element.
  24271. * @returns {Array} Returns the new array of filtered values.
  24272. * @example
  24273. *
  24274. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24275. *
  24276. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24277. * // => [{ 'x': 2, 'y': 1 }]
  24278. */
  24279. var differenceWith = baseRest(function(array, values) {
  24280. var comparator = last(values);
  24281. if (isArrayLikeObject(comparator)) {
  24282. comparator = undefined;
  24283. }
  24284. return isArrayLikeObject(array)
  24285. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24286. : [];
  24287. });
  24288. /**
  24289. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24290. *
  24291. * @static
  24292. * @memberOf _
  24293. * @since 0.5.0
  24294. * @category Array
  24295. * @param {Array} array The array to query.
  24296. * @param {number} [n=1] The number of elements to drop.
  24297. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24298. * @returns {Array} Returns the slice of `array`.
  24299. * @example
  24300. *
  24301. * _.drop([1, 2, 3]);
  24302. * // => [2, 3]
  24303. *
  24304. * _.drop([1, 2, 3], 2);
  24305. * // => [3]
  24306. *
  24307. * _.drop([1, 2, 3], 5);
  24308. * // => []
  24309. *
  24310. * _.drop([1, 2, 3], 0);
  24311. * // => [1, 2, 3]
  24312. */
  24313. function drop(array, n, guard) {
  24314. var length = array == null ? 0 : array.length;
  24315. if (!length) {
  24316. return [];
  24317. }
  24318. n = (guard || n === undefined) ? 1 : toInteger(n);
  24319. return baseSlice(array, n < 0 ? 0 : n, length);
  24320. }
  24321. /**
  24322. * Creates a slice of `array` with `n` elements dropped from the end.
  24323. *
  24324. * @static
  24325. * @memberOf _
  24326. * @since 3.0.0
  24327. * @category Array
  24328. * @param {Array} array The array to query.
  24329. * @param {number} [n=1] The number of elements to drop.
  24330. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24331. * @returns {Array} Returns the slice of `array`.
  24332. * @example
  24333. *
  24334. * _.dropRight([1, 2, 3]);
  24335. * // => [1, 2]
  24336. *
  24337. * _.dropRight([1, 2, 3], 2);
  24338. * // => [1]
  24339. *
  24340. * _.dropRight([1, 2, 3], 5);
  24341. * // => []
  24342. *
  24343. * _.dropRight([1, 2, 3], 0);
  24344. * // => [1, 2, 3]
  24345. */
  24346. function dropRight(array, n, guard) {
  24347. var length = array == null ? 0 : array.length;
  24348. if (!length) {
  24349. return [];
  24350. }
  24351. n = (guard || n === undefined) ? 1 : toInteger(n);
  24352. n = length - n;
  24353. return baseSlice(array, 0, n < 0 ? 0 : n);
  24354. }
  24355. /**
  24356. * Creates a slice of `array` excluding elements dropped from the end.
  24357. * Elements are dropped until `predicate` returns falsey. The predicate is
  24358. * invoked with three arguments: (value, index, array).
  24359. *
  24360. * @static
  24361. * @memberOf _
  24362. * @since 3.0.0
  24363. * @category Array
  24364. * @param {Array} array The array to query.
  24365. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24366. * @returns {Array} Returns the slice of `array`.
  24367. * @example
  24368. *
  24369. * var users = [
  24370. * { 'user': 'barney', 'active': true },
  24371. * { 'user': 'fred', 'active': false },
  24372. * { 'user': 'pebbles', 'active': false }
  24373. * ];
  24374. *
  24375. * _.dropRightWhile(users, function(o) { return !o.active; });
  24376. * // => objects for ['barney']
  24377. *
  24378. * // The `_.matches` iteratee shorthand.
  24379. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24380. * // => objects for ['barney', 'fred']
  24381. *
  24382. * // The `_.matchesProperty` iteratee shorthand.
  24383. * _.dropRightWhile(users, ['active', false]);
  24384. * // => objects for ['barney']
  24385. *
  24386. * // The `_.property` iteratee shorthand.
  24387. * _.dropRightWhile(users, 'active');
  24388. * // => objects for ['barney', 'fred', 'pebbles']
  24389. */
  24390. function dropRightWhile(array, predicate) {
  24391. return (array && array.length)
  24392. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24393. : [];
  24394. }
  24395. /**
  24396. * Creates a slice of `array` excluding elements dropped from the beginning.
  24397. * Elements are dropped until `predicate` returns falsey. The predicate is
  24398. * invoked with three arguments: (value, index, array).
  24399. *
  24400. * @static
  24401. * @memberOf _
  24402. * @since 3.0.0
  24403. * @category Array
  24404. * @param {Array} array The array to query.
  24405. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24406. * @returns {Array} Returns the slice of `array`.
  24407. * @example
  24408. *
  24409. * var users = [
  24410. * { 'user': 'barney', 'active': false },
  24411. * { 'user': 'fred', 'active': false },
  24412. * { 'user': 'pebbles', 'active': true }
  24413. * ];
  24414. *
  24415. * _.dropWhile(users, function(o) { return !o.active; });
  24416. * // => objects for ['pebbles']
  24417. *
  24418. * // The `_.matches` iteratee shorthand.
  24419. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24420. * // => objects for ['fred', 'pebbles']
  24421. *
  24422. * // The `_.matchesProperty` iteratee shorthand.
  24423. * _.dropWhile(users, ['active', false]);
  24424. * // => objects for ['pebbles']
  24425. *
  24426. * // The `_.property` iteratee shorthand.
  24427. * _.dropWhile(users, 'active');
  24428. * // => objects for ['barney', 'fred', 'pebbles']
  24429. */
  24430. function dropWhile(array, predicate) {
  24431. return (array && array.length)
  24432. ? baseWhile(array, getIteratee(predicate, 3), true)
  24433. : [];
  24434. }
  24435. /**
  24436. * Fills elements of `array` with `value` from `start` up to, but not
  24437. * including, `end`.
  24438. *
  24439. * **Note:** This method mutates `array`.
  24440. *
  24441. * @static
  24442. * @memberOf _
  24443. * @since 3.2.0
  24444. * @category Array
  24445. * @param {Array} array The array to fill.
  24446. * @param {*} value The value to fill `array` with.
  24447. * @param {number} [start=0] The start position.
  24448. * @param {number} [end=array.length] The end position.
  24449. * @returns {Array} Returns `array`.
  24450. * @example
  24451. *
  24452. * var array = [1, 2, 3];
  24453. *
  24454. * _.fill(array, 'a');
  24455. * console.log(array);
  24456. * // => ['a', 'a', 'a']
  24457. *
  24458. * _.fill(Array(3), 2);
  24459. * // => [2, 2, 2]
  24460. *
  24461. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24462. * // => [4, '*', '*', 10]
  24463. */
  24464. function fill(array, value, start, end) {
  24465. var length = array == null ? 0 : array.length;
  24466. if (!length) {
  24467. return [];
  24468. }
  24469. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24470. start = 0;
  24471. end = length;
  24472. }
  24473. return baseFill(array, value, start, end);
  24474. }
  24475. /**
  24476. * This method is like `_.find` except that it returns the index of the first
  24477. * element `predicate` returns truthy for instead of the element itself.
  24478. *
  24479. * @static
  24480. * @memberOf _
  24481. * @since 1.1.0
  24482. * @category Array
  24483. * @param {Array} array The array to inspect.
  24484. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24485. * @param {number} [fromIndex=0] The index to search from.
  24486. * @returns {number} Returns the index of the found element, else `-1`.
  24487. * @example
  24488. *
  24489. * var users = [
  24490. * { 'user': 'barney', 'active': false },
  24491. * { 'user': 'fred', 'active': false },
  24492. * { 'user': 'pebbles', 'active': true }
  24493. * ];
  24494. *
  24495. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24496. * // => 0
  24497. *
  24498. * // The `_.matches` iteratee shorthand.
  24499. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24500. * // => 1
  24501. *
  24502. * // The `_.matchesProperty` iteratee shorthand.
  24503. * _.findIndex(users, ['active', false]);
  24504. * // => 0
  24505. *
  24506. * // The `_.property` iteratee shorthand.
  24507. * _.findIndex(users, 'active');
  24508. * // => 2
  24509. */
  24510. function findIndex(array, predicate, fromIndex) {
  24511. var length = array == null ? 0 : array.length;
  24512. if (!length) {
  24513. return -1;
  24514. }
  24515. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24516. if (index < 0) {
  24517. index = nativeMax(length + index, 0);
  24518. }
  24519. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24520. }
  24521. /**
  24522. * This method is like `_.findIndex` except that it iterates over elements
  24523. * of `collection` from right to left.
  24524. *
  24525. * @static
  24526. * @memberOf _
  24527. * @since 2.0.0
  24528. * @category Array
  24529. * @param {Array} array The array to inspect.
  24530. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24531. * @param {number} [fromIndex=array.length-1] The index to search from.
  24532. * @returns {number} Returns the index of the found element, else `-1`.
  24533. * @example
  24534. *
  24535. * var users = [
  24536. * { 'user': 'barney', 'active': true },
  24537. * { 'user': 'fred', 'active': false },
  24538. * { 'user': 'pebbles', 'active': false }
  24539. * ];
  24540. *
  24541. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24542. * // => 2
  24543. *
  24544. * // The `_.matches` iteratee shorthand.
  24545. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24546. * // => 0
  24547. *
  24548. * // The `_.matchesProperty` iteratee shorthand.
  24549. * _.findLastIndex(users, ['active', false]);
  24550. * // => 2
  24551. *
  24552. * // The `_.property` iteratee shorthand.
  24553. * _.findLastIndex(users, 'active');
  24554. * // => 0
  24555. */
  24556. function findLastIndex(array, predicate, fromIndex) {
  24557. var length = array == null ? 0 : array.length;
  24558. if (!length) {
  24559. return -1;
  24560. }
  24561. var index = length - 1;
  24562. if (fromIndex !== undefined) {
  24563. index = toInteger(fromIndex);
  24564. index = fromIndex < 0
  24565. ? nativeMax(length + index, 0)
  24566. : nativeMin(index, length - 1);
  24567. }
  24568. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24569. }
  24570. /**
  24571. * Flattens `array` a single level deep.
  24572. *
  24573. * @static
  24574. * @memberOf _
  24575. * @since 0.1.0
  24576. * @category Array
  24577. * @param {Array} array The array to flatten.
  24578. * @returns {Array} Returns the new flattened array.
  24579. * @example
  24580. *
  24581. * _.flatten([1, [2, [3, [4]], 5]]);
  24582. * // => [1, 2, [3, [4]], 5]
  24583. */
  24584. function flatten(array) {
  24585. var length = array == null ? 0 : array.length;
  24586. return length ? baseFlatten(array, 1) : [];
  24587. }
  24588. /**
  24589. * Recursively flattens `array`.
  24590. *
  24591. * @static
  24592. * @memberOf _
  24593. * @since 3.0.0
  24594. * @category Array
  24595. * @param {Array} array The array to flatten.
  24596. * @returns {Array} Returns the new flattened array.
  24597. * @example
  24598. *
  24599. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24600. * // => [1, 2, 3, 4, 5]
  24601. */
  24602. function flattenDeep(array) {
  24603. var length = array == null ? 0 : array.length;
  24604. return length ? baseFlatten(array, INFINITY) : [];
  24605. }
  24606. /**
  24607. * Recursively flatten `array` up to `depth` times.
  24608. *
  24609. * @static
  24610. * @memberOf _
  24611. * @since 4.4.0
  24612. * @category Array
  24613. * @param {Array} array The array to flatten.
  24614. * @param {number} [depth=1] The maximum recursion depth.
  24615. * @returns {Array} Returns the new flattened array.
  24616. * @example
  24617. *
  24618. * var array = [1, [2, [3, [4]], 5]];
  24619. *
  24620. * _.flattenDepth(array, 1);
  24621. * // => [1, 2, [3, [4]], 5]
  24622. *
  24623. * _.flattenDepth(array, 2);
  24624. * // => [1, 2, 3, [4], 5]
  24625. */
  24626. function flattenDepth(array, depth) {
  24627. var length = array == null ? 0 : array.length;
  24628. if (!length) {
  24629. return [];
  24630. }
  24631. depth = depth === undefined ? 1 : toInteger(depth);
  24632. return baseFlatten(array, depth);
  24633. }
  24634. /**
  24635. * The inverse of `_.toPairs`; this method returns an object composed
  24636. * from key-value `pairs`.
  24637. *
  24638. * @static
  24639. * @memberOf _
  24640. * @since 4.0.0
  24641. * @category Array
  24642. * @param {Array} pairs The key-value pairs.
  24643. * @returns {Object} Returns the new object.
  24644. * @example
  24645. *
  24646. * _.fromPairs([['a', 1], ['b', 2]]);
  24647. * // => { 'a': 1, 'b': 2 }
  24648. */
  24649. function fromPairs(pairs) {
  24650. var index = -1,
  24651. length = pairs == null ? 0 : pairs.length,
  24652. result = {};
  24653. while (++index < length) {
  24654. var pair = pairs[index];
  24655. result[pair[0]] = pair[1];
  24656. }
  24657. return result;
  24658. }
  24659. /**
  24660. * Gets the first element of `array`.
  24661. *
  24662. * @static
  24663. * @memberOf _
  24664. * @since 0.1.0
  24665. * @alias first
  24666. * @category Array
  24667. * @param {Array} array The array to query.
  24668. * @returns {*} Returns the first element of `array`.
  24669. * @example
  24670. *
  24671. * _.head([1, 2, 3]);
  24672. * // => 1
  24673. *
  24674. * _.head([]);
  24675. * // => undefined
  24676. */
  24677. function head(array) {
  24678. return (array && array.length) ? array[0] : undefined;
  24679. }
  24680. /**
  24681. * Gets the index at which the first occurrence of `value` is found in `array`
  24682. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24683. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24684. * offset from the end of `array`.
  24685. *
  24686. * @static
  24687. * @memberOf _
  24688. * @since 0.1.0
  24689. * @category Array
  24690. * @param {Array} array The array to inspect.
  24691. * @param {*} value The value to search for.
  24692. * @param {number} [fromIndex=0] The index to search from.
  24693. * @returns {number} Returns the index of the matched value, else `-1`.
  24694. * @example
  24695. *
  24696. * _.indexOf([1, 2, 1, 2], 2);
  24697. * // => 1
  24698. *
  24699. * // Search from the `fromIndex`.
  24700. * _.indexOf([1, 2, 1, 2], 2, 2);
  24701. * // => 3
  24702. */
  24703. function indexOf(array, value, fromIndex) {
  24704. var length = array == null ? 0 : array.length;
  24705. if (!length) {
  24706. return -1;
  24707. }
  24708. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24709. if (index < 0) {
  24710. index = nativeMax(length + index, 0);
  24711. }
  24712. return baseIndexOf(array, value, index);
  24713. }
  24714. /**
  24715. * Gets all but the last element of `array`.
  24716. *
  24717. * @static
  24718. * @memberOf _
  24719. * @since 0.1.0
  24720. * @category Array
  24721. * @param {Array} array The array to query.
  24722. * @returns {Array} Returns the slice of `array`.
  24723. * @example
  24724. *
  24725. * _.initial([1, 2, 3]);
  24726. * // => [1, 2]
  24727. */
  24728. function initial(array) {
  24729. var length = array == null ? 0 : array.length;
  24730. return length ? baseSlice(array, 0, -1) : [];
  24731. }
  24732. /**
  24733. * Creates an array of unique values that are included in all given arrays
  24734. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24735. * for equality comparisons. The order and references of result values are
  24736. * determined by the first array.
  24737. *
  24738. * @static
  24739. * @memberOf _
  24740. * @since 0.1.0
  24741. * @category Array
  24742. * @param {...Array} [arrays] The arrays to inspect.
  24743. * @returns {Array} Returns the new array of intersecting values.
  24744. * @example
  24745. *
  24746. * _.intersection([2, 1], [2, 3]);
  24747. * // => [2]
  24748. */
  24749. var intersection = baseRest(function(arrays) {
  24750. var mapped = arrayMap(arrays, castArrayLikeObject);
  24751. return (mapped.length && mapped[0] === arrays[0])
  24752. ? baseIntersection(mapped)
  24753. : [];
  24754. });
  24755. /**
  24756. * This method is like `_.intersection` except that it accepts `iteratee`
  24757. * which is invoked for each element of each `arrays` to generate the criterion
  24758. * by which they're compared. The order and references of result values are
  24759. * determined by the first array. The iteratee is invoked with one argument:
  24760. * (value).
  24761. *
  24762. * @static
  24763. * @memberOf _
  24764. * @since 4.0.0
  24765. * @category Array
  24766. * @param {...Array} [arrays] The arrays to inspect.
  24767. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24768. * @returns {Array} Returns the new array of intersecting values.
  24769. * @example
  24770. *
  24771. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24772. * // => [2.1]
  24773. *
  24774. * // The `_.property` iteratee shorthand.
  24775. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24776. * // => [{ 'x': 1 }]
  24777. */
  24778. var intersectionBy = baseRest(function(arrays) {
  24779. var iteratee = last(arrays),
  24780. mapped = arrayMap(arrays, castArrayLikeObject);
  24781. if (iteratee === last(mapped)) {
  24782. iteratee = undefined;
  24783. } else {
  24784. mapped.pop();
  24785. }
  24786. return (mapped.length && mapped[0] === arrays[0])
  24787. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24788. : [];
  24789. });
  24790. /**
  24791. * This method is like `_.intersection` except that it accepts `comparator`
  24792. * which is invoked to compare elements of `arrays`. The order and references
  24793. * of result values are determined by the first array. The comparator is
  24794. * invoked with two arguments: (arrVal, othVal).
  24795. *
  24796. * @static
  24797. * @memberOf _
  24798. * @since 4.0.0
  24799. * @category Array
  24800. * @param {...Array} [arrays] The arrays to inspect.
  24801. * @param {Function} [comparator] The comparator invoked per element.
  24802. * @returns {Array} Returns the new array of intersecting values.
  24803. * @example
  24804. *
  24805. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24806. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24807. *
  24808. * _.intersectionWith(objects, others, _.isEqual);
  24809. * // => [{ 'x': 1, 'y': 2 }]
  24810. */
  24811. var intersectionWith = baseRest(function(arrays) {
  24812. var comparator = last(arrays),
  24813. mapped = arrayMap(arrays, castArrayLikeObject);
  24814. comparator = typeof comparator == 'function' ? comparator : undefined;
  24815. if (comparator) {
  24816. mapped.pop();
  24817. }
  24818. return (mapped.length && mapped[0] === arrays[0])
  24819. ? baseIntersection(mapped, undefined, comparator)
  24820. : [];
  24821. });
  24822. /**
  24823. * Converts all elements in `array` into a string separated by `separator`.
  24824. *
  24825. * @static
  24826. * @memberOf _
  24827. * @since 4.0.0
  24828. * @category Array
  24829. * @param {Array} array The array to convert.
  24830. * @param {string} [separator=','] The element separator.
  24831. * @returns {string} Returns the joined string.
  24832. * @example
  24833. *
  24834. * _.join(['a', 'b', 'c'], '~');
  24835. * // => 'a~b~c'
  24836. */
  24837. function join(array, separator) {
  24838. return array == null ? '' : nativeJoin.call(array, separator);
  24839. }
  24840. /**
  24841. * Gets the last element of `array`.
  24842. *
  24843. * @static
  24844. * @memberOf _
  24845. * @since 0.1.0
  24846. * @category Array
  24847. * @param {Array} array The array to query.
  24848. * @returns {*} Returns the last element of `array`.
  24849. * @example
  24850. *
  24851. * _.last([1, 2, 3]);
  24852. * // => 3
  24853. */
  24854. function last(array) {
  24855. var length = array == null ? 0 : array.length;
  24856. return length ? array[length - 1] : undefined;
  24857. }
  24858. /**
  24859. * This method is like `_.indexOf` except that it iterates over elements of
  24860. * `array` from right to left.
  24861. *
  24862. * @static
  24863. * @memberOf _
  24864. * @since 0.1.0
  24865. * @category Array
  24866. * @param {Array} array The array to inspect.
  24867. * @param {*} value The value to search for.
  24868. * @param {number} [fromIndex=array.length-1] The index to search from.
  24869. * @returns {number} Returns the index of the matched value, else `-1`.
  24870. * @example
  24871. *
  24872. * _.lastIndexOf([1, 2, 1, 2], 2);
  24873. * // => 3
  24874. *
  24875. * // Search from the `fromIndex`.
  24876. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24877. * // => 1
  24878. */
  24879. function lastIndexOf(array, value, fromIndex) {
  24880. var length = array == null ? 0 : array.length;
  24881. if (!length) {
  24882. return -1;
  24883. }
  24884. var index = length;
  24885. if (fromIndex !== undefined) {
  24886. index = toInteger(fromIndex);
  24887. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24888. }
  24889. return value === value
  24890. ? strictLastIndexOf(array, value, index)
  24891. : baseFindIndex(array, baseIsNaN, index, true);
  24892. }
  24893. /**
  24894. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24895. * element from the end is returned.
  24896. *
  24897. * @static
  24898. * @memberOf _
  24899. * @since 4.11.0
  24900. * @category Array
  24901. * @param {Array} array The array to query.
  24902. * @param {number} [n=0] The index of the element to return.
  24903. * @returns {*} Returns the nth element of `array`.
  24904. * @example
  24905. *
  24906. * var array = ['a', 'b', 'c', 'd'];
  24907. *
  24908. * _.nth(array, 1);
  24909. * // => 'b'
  24910. *
  24911. * _.nth(array, -2);
  24912. * // => 'c';
  24913. */
  24914. function nth(array, n) {
  24915. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24916. }
  24917. /**
  24918. * Removes all given values from `array` using
  24919. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24920. * for equality comparisons.
  24921. *
  24922. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24923. * to remove elements from an array by predicate.
  24924. *
  24925. * @static
  24926. * @memberOf _
  24927. * @since 2.0.0
  24928. * @category Array
  24929. * @param {Array} array The array to modify.
  24930. * @param {...*} [values] The values to remove.
  24931. * @returns {Array} Returns `array`.
  24932. * @example
  24933. *
  24934. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24935. *
  24936. * _.pull(array, 'a', 'c');
  24937. * console.log(array);
  24938. * // => ['b', 'b']
  24939. */
  24940. var pull = baseRest(pullAll);
  24941. /**
  24942. * This method is like `_.pull` except that it accepts an array of values to remove.
  24943. *
  24944. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24945. *
  24946. * @static
  24947. * @memberOf _
  24948. * @since 4.0.0
  24949. * @category Array
  24950. * @param {Array} array The array to modify.
  24951. * @param {Array} values The values to remove.
  24952. * @returns {Array} Returns `array`.
  24953. * @example
  24954. *
  24955. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24956. *
  24957. * _.pullAll(array, ['a', 'c']);
  24958. * console.log(array);
  24959. * // => ['b', 'b']
  24960. */
  24961. function pullAll(array, values) {
  24962. return (array && array.length && values && values.length)
  24963. ? basePullAll(array, values)
  24964. : array;
  24965. }
  24966. /**
  24967. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24968. * invoked for each element of `array` and `values` to generate the criterion
  24969. * by which they're compared. The iteratee is invoked with one argument: (value).
  24970. *
  24971. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24972. *
  24973. * @static
  24974. * @memberOf _
  24975. * @since 4.0.0
  24976. * @category Array
  24977. * @param {Array} array The array to modify.
  24978. * @param {Array} values The values to remove.
  24979. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24980. * @returns {Array} Returns `array`.
  24981. * @example
  24982. *
  24983. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24984. *
  24985. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24986. * console.log(array);
  24987. * // => [{ 'x': 2 }]
  24988. */
  24989. function pullAllBy(array, values, iteratee) {
  24990. return (array && array.length && values && values.length)
  24991. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24992. : array;
  24993. }
  24994. /**
  24995. * This method is like `_.pullAll` except that it accepts `comparator` which
  24996. * is invoked to compare elements of `array` to `values`. The comparator is
  24997. * invoked with two arguments: (arrVal, othVal).
  24998. *
  24999. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  25000. *
  25001. * @static
  25002. * @memberOf _
  25003. * @since 4.6.0
  25004. * @category Array
  25005. * @param {Array} array The array to modify.
  25006. * @param {Array} values The values to remove.
  25007. * @param {Function} [comparator] The comparator invoked per element.
  25008. * @returns {Array} Returns `array`.
  25009. * @example
  25010. *
  25011. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  25012. *
  25013. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  25014. * console.log(array);
  25015. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  25016. */
  25017. function pullAllWith(array, values, comparator) {
  25018. return (array && array.length && values && values.length)
  25019. ? basePullAll(array, values, undefined, comparator)
  25020. : array;
  25021. }
  25022. /**
  25023. * Removes elements from `array` corresponding to `indexes` and returns an
  25024. * array of removed elements.
  25025. *
  25026. * **Note:** Unlike `_.at`, this method mutates `array`.
  25027. *
  25028. * @static
  25029. * @memberOf _
  25030. * @since 3.0.0
  25031. * @category Array
  25032. * @param {Array} array The array to modify.
  25033. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  25034. * @returns {Array} Returns the new array of removed elements.
  25035. * @example
  25036. *
  25037. * var array = ['a', 'b', 'c', 'd'];
  25038. * var pulled = _.pullAt(array, [1, 3]);
  25039. *
  25040. * console.log(array);
  25041. * // => ['a', 'c']
  25042. *
  25043. * console.log(pulled);
  25044. * // => ['b', 'd']
  25045. */
  25046. var pullAt = flatRest(function(array, indexes) {
  25047. var length = array == null ? 0 : array.length,
  25048. result = baseAt(array, indexes);
  25049. basePullAt(array, arrayMap(indexes, function(index) {
  25050. return isIndex(index, length) ? +index : index;
  25051. }).sort(compareAscending));
  25052. return result;
  25053. });
  25054. /**
  25055. * Removes all elements from `array` that `predicate` returns truthy for
  25056. * and returns an array of the removed elements. The predicate is invoked
  25057. * with three arguments: (value, index, array).
  25058. *
  25059. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  25060. * to pull elements from an array by value.
  25061. *
  25062. * @static
  25063. * @memberOf _
  25064. * @since 2.0.0
  25065. * @category Array
  25066. * @param {Array} array The array to modify.
  25067. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25068. * @returns {Array} Returns the new array of removed elements.
  25069. * @example
  25070. *
  25071. * var array = [1, 2, 3, 4];
  25072. * var evens = _.remove(array, function(n) {
  25073. * return n % 2 == 0;
  25074. * });
  25075. *
  25076. * console.log(array);
  25077. * // => [1, 3]
  25078. *
  25079. * console.log(evens);
  25080. * // => [2, 4]
  25081. */
  25082. function remove(array, predicate) {
  25083. var result = [];
  25084. if (!(array && array.length)) {
  25085. return result;
  25086. }
  25087. var index = -1,
  25088. indexes = [],
  25089. length = array.length;
  25090. predicate = getIteratee(predicate, 3);
  25091. while (++index < length) {
  25092. var value = array[index];
  25093. if (predicate(value, index, array)) {
  25094. result.push(value);
  25095. indexes.push(index);
  25096. }
  25097. }
  25098. basePullAt(array, indexes);
  25099. return result;
  25100. }
  25101. /**
  25102. * Reverses `array` so that the first element becomes the last, the second
  25103. * element becomes the second to last, and so on.
  25104. *
  25105. * **Note:** This method mutates `array` and is based on
  25106. * [`Array#reverse`](https://mdn.io/Array/reverse).
  25107. *
  25108. * @static
  25109. * @memberOf _
  25110. * @since 4.0.0
  25111. * @category Array
  25112. * @param {Array} array The array to modify.
  25113. * @returns {Array} Returns `array`.
  25114. * @example
  25115. *
  25116. * var array = [1, 2, 3];
  25117. *
  25118. * _.reverse(array);
  25119. * // => [3, 2, 1]
  25120. *
  25121. * console.log(array);
  25122. * // => [3, 2, 1]
  25123. */
  25124. function reverse(array) {
  25125. return array == null ? array : nativeReverse.call(array);
  25126. }
  25127. /**
  25128. * Creates a slice of `array` from `start` up to, but not including, `end`.
  25129. *
  25130. * **Note:** This method is used instead of
  25131. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25132. * returned.
  25133. *
  25134. * @static
  25135. * @memberOf _
  25136. * @since 3.0.0
  25137. * @category Array
  25138. * @param {Array} array The array to slice.
  25139. * @param {number} [start=0] The start position.
  25140. * @param {number} [end=array.length] The end position.
  25141. * @returns {Array} Returns the slice of `array`.
  25142. */
  25143. function slice(array, start, end) {
  25144. var length = array == null ? 0 : array.length;
  25145. if (!length) {
  25146. return [];
  25147. }
  25148. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25149. start = 0;
  25150. end = length;
  25151. }
  25152. else {
  25153. start = start == null ? 0 : toInteger(start);
  25154. end = end === undefined ? length : toInteger(end);
  25155. }
  25156. return baseSlice(array, start, end);
  25157. }
  25158. /**
  25159. * Uses a binary search to determine the lowest index at which `value`
  25160. * should be inserted into `array` in order to maintain its sort order.
  25161. *
  25162. * @static
  25163. * @memberOf _
  25164. * @since 0.1.0
  25165. * @category Array
  25166. * @param {Array} array The sorted array to inspect.
  25167. * @param {*} value The value to evaluate.
  25168. * @returns {number} Returns the index at which `value` should be inserted
  25169. * into `array`.
  25170. * @example
  25171. *
  25172. * _.sortedIndex([30, 50], 40);
  25173. * // => 1
  25174. */
  25175. function sortedIndex(array, value) {
  25176. return baseSortedIndex(array, value);
  25177. }
  25178. /**
  25179. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25180. * which is invoked for `value` and each element of `array` to compute their
  25181. * sort ranking. The iteratee is invoked with one argument: (value).
  25182. *
  25183. * @static
  25184. * @memberOf _
  25185. * @since 4.0.0
  25186. * @category Array
  25187. * @param {Array} array The sorted array to inspect.
  25188. * @param {*} value The value to evaluate.
  25189. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25190. * @returns {number} Returns the index at which `value` should be inserted
  25191. * into `array`.
  25192. * @example
  25193. *
  25194. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25195. *
  25196. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25197. * // => 0
  25198. *
  25199. * // The `_.property` iteratee shorthand.
  25200. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25201. * // => 0
  25202. */
  25203. function sortedIndexBy(array, value, iteratee) {
  25204. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25205. }
  25206. /**
  25207. * This method is like `_.indexOf` except that it performs a binary
  25208. * search on a sorted `array`.
  25209. *
  25210. * @static
  25211. * @memberOf _
  25212. * @since 4.0.0
  25213. * @category Array
  25214. * @param {Array} array The array to inspect.
  25215. * @param {*} value The value to search for.
  25216. * @returns {number} Returns the index of the matched value, else `-1`.
  25217. * @example
  25218. *
  25219. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25220. * // => 1
  25221. */
  25222. function sortedIndexOf(array, value) {
  25223. var length = array == null ? 0 : array.length;
  25224. if (length) {
  25225. var index = baseSortedIndex(array, value);
  25226. if (index < length && eq(array[index], value)) {
  25227. return index;
  25228. }
  25229. }
  25230. return -1;
  25231. }
  25232. /**
  25233. * This method is like `_.sortedIndex` except that it returns the highest
  25234. * index at which `value` should be inserted into `array` in order to
  25235. * maintain its sort order.
  25236. *
  25237. * @static
  25238. * @memberOf _
  25239. * @since 3.0.0
  25240. * @category Array
  25241. * @param {Array} array The sorted array to inspect.
  25242. * @param {*} value The value to evaluate.
  25243. * @returns {number} Returns the index at which `value` should be inserted
  25244. * into `array`.
  25245. * @example
  25246. *
  25247. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25248. * // => 4
  25249. */
  25250. function sortedLastIndex(array, value) {
  25251. return baseSortedIndex(array, value, true);
  25252. }
  25253. /**
  25254. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25255. * which is invoked for `value` and each element of `array` to compute their
  25256. * sort ranking. The iteratee is invoked with one argument: (value).
  25257. *
  25258. * @static
  25259. * @memberOf _
  25260. * @since 4.0.0
  25261. * @category Array
  25262. * @param {Array} array The sorted array to inspect.
  25263. * @param {*} value The value to evaluate.
  25264. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25265. * @returns {number} Returns the index at which `value` should be inserted
  25266. * into `array`.
  25267. * @example
  25268. *
  25269. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25270. *
  25271. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25272. * // => 1
  25273. *
  25274. * // The `_.property` iteratee shorthand.
  25275. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25276. * // => 1
  25277. */
  25278. function sortedLastIndexBy(array, value, iteratee) {
  25279. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25280. }
  25281. /**
  25282. * This method is like `_.lastIndexOf` except that it performs a binary
  25283. * search on a sorted `array`.
  25284. *
  25285. * @static
  25286. * @memberOf _
  25287. * @since 4.0.0
  25288. * @category Array
  25289. * @param {Array} array The array to inspect.
  25290. * @param {*} value The value to search for.
  25291. * @returns {number} Returns the index of the matched value, else `-1`.
  25292. * @example
  25293. *
  25294. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25295. * // => 3
  25296. */
  25297. function sortedLastIndexOf(array, value) {
  25298. var length = array == null ? 0 : array.length;
  25299. if (length) {
  25300. var index = baseSortedIndex(array, value, true) - 1;
  25301. if (eq(array[index], value)) {
  25302. return index;
  25303. }
  25304. }
  25305. return -1;
  25306. }
  25307. /**
  25308. * This method is like `_.uniq` except that it's designed and optimized
  25309. * for sorted arrays.
  25310. *
  25311. * @static
  25312. * @memberOf _
  25313. * @since 4.0.0
  25314. * @category Array
  25315. * @param {Array} array The array to inspect.
  25316. * @returns {Array} Returns the new duplicate free array.
  25317. * @example
  25318. *
  25319. * _.sortedUniq([1, 1, 2]);
  25320. * // => [1, 2]
  25321. */
  25322. function sortedUniq(array) {
  25323. return (array && array.length)
  25324. ? baseSortedUniq(array)
  25325. : [];
  25326. }
  25327. /**
  25328. * This method is like `_.uniqBy` except that it's designed and optimized
  25329. * for sorted arrays.
  25330. *
  25331. * @static
  25332. * @memberOf _
  25333. * @since 4.0.0
  25334. * @category Array
  25335. * @param {Array} array The array to inspect.
  25336. * @param {Function} [iteratee] The iteratee invoked per element.
  25337. * @returns {Array} Returns the new duplicate free array.
  25338. * @example
  25339. *
  25340. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25341. * // => [1.1, 2.3]
  25342. */
  25343. function sortedUniqBy(array, iteratee) {
  25344. return (array && array.length)
  25345. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25346. : [];
  25347. }
  25348. /**
  25349. * Gets all but the first element of `array`.
  25350. *
  25351. * @static
  25352. * @memberOf _
  25353. * @since 4.0.0
  25354. * @category Array
  25355. * @param {Array} array The array to query.
  25356. * @returns {Array} Returns the slice of `array`.
  25357. * @example
  25358. *
  25359. * _.tail([1, 2, 3]);
  25360. * // => [2, 3]
  25361. */
  25362. function tail(array) {
  25363. var length = array == null ? 0 : array.length;
  25364. return length ? baseSlice(array, 1, length) : [];
  25365. }
  25366. /**
  25367. * Creates a slice of `array` with `n` elements taken from the beginning.
  25368. *
  25369. * @static
  25370. * @memberOf _
  25371. * @since 0.1.0
  25372. * @category Array
  25373. * @param {Array} array The array to query.
  25374. * @param {number} [n=1] The number of elements to take.
  25375. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25376. * @returns {Array} Returns the slice of `array`.
  25377. * @example
  25378. *
  25379. * _.take([1, 2, 3]);
  25380. * // => [1]
  25381. *
  25382. * _.take([1, 2, 3], 2);
  25383. * // => [1, 2]
  25384. *
  25385. * _.take([1, 2, 3], 5);
  25386. * // => [1, 2, 3]
  25387. *
  25388. * _.take([1, 2, 3], 0);
  25389. * // => []
  25390. */
  25391. function take(array, n, guard) {
  25392. if (!(array && array.length)) {
  25393. return [];
  25394. }
  25395. n = (guard || n === undefined) ? 1 : toInteger(n);
  25396. return baseSlice(array, 0, n < 0 ? 0 : n);
  25397. }
  25398. /**
  25399. * Creates a slice of `array` with `n` elements taken from the end.
  25400. *
  25401. * @static
  25402. * @memberOf _
  25403. * @since 3.0.0
  25404. * @category Array
  25405. * @param {Array} array The array to query.
  25406. * @param {number} [n=1] The number of elements to take.
  25407. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25408. * @returns {Array} Returns the slice of `array`.
  25409. * @example
  25410. *
  25411. * _.takeRight([1, 2, 3]);
  25412. * // => [3]
  25413. *
  25414. * _.takeRight([1, 2, 3], 2);
  25415. * // => [2, 3]
  25416. *
  25417. * _.takeRight([1, 2, 3], 5);
  25418. * // => [1, 2, 3]
  25419. *
  25420. * _.takeRight([1, 2, 3], 0);
  25421. * // => []
  25422. */
  25423. function takeRight(array, n, guard) {
  25424. var length = array == null ? 0 : array.length;
  25425. if (!length) {
  25426. return [];
  25427. }
  25428. n = (guard || n === undefined) ? 1 : toInteger(n);
  25429. n = length - n;
  25430. return baseSlice(array, n < 0 ? 0 : n, length);
  25431. }
  25432. /**
  25433. * Creates a slice of `array` with elements taken from the end. Elements are
  25434. * taken until `predicate` returns falsey. The predicate is invoked with
  25435. * three arguments: (value, index, array).
  25436. *
  25437. * @static
  25438. * @memberOf _
  25439. * @since 3.0.0
  25440. * @category Array
  25441. * @param {Array} array The array to query.
  25442. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25443. * @returns {Array} Returns the slice of `array`.
  25444. * @example
  25445. *
  25446. * var users = [
  25447. * { 'user': 'barney', 'active': true },
  25448. * { 'user': 'fred', 'active': false },
  25449. * { 'user': 'pebbles', 'active': false }
  25450. * ];
  25451. *
  25452. * _.takeRightWhile(users, function(o) { return !o.active; });
  25453. * // => objects for ['fred', 'pebbles']
  25454. *
  25455. * // The `_.matches` iteratee shorthand.
  25456. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25457. * // => objects for ['pebbles']
  25458. *
  25459. * // The `_.matchesProperty` iteratee shorthand.
  25460. * _.takeRightWhile(users, ['active', false]);
  25461. * // => objects for ['fred', 'pebbles']
  25462. *
  25463. * // The `_.property` iteratee shorthand.
  25464. * _.takeRightWhile(users, 'active');
  25465. * // => []
  25466. */
  25467. function takeRightWhile(array, predicate) {
  25468. return (array && array.length)
  25469. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25470. : [];
  25471. }
  25472. /**
  25473. * Creates a slice of `array` with elements taken from the beginning. Elements
  25474. * are taken until `predicate` returns falsey. The predicate is invoked with
  25475. * three arguments: (value, index, array).
  25476. *
  25477. * @static
  25478. * @memberOf _
  25479. * @since 3.0.0
  25480. * @category Array
  25481. * @param {Array} array The array to query.
  25482. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25483. * @returns {Array} Returns the slice of `array`.
  25484. * @example
  25485. *
  25486. * var users = [
  25487. * { 'user': 'barney', 'active': false },
  25488. * { 'user': 'fred', 'active': false },
  25489. * { 'user': 'pebbles', 'active': true }
  25490. * ];
  25491. *
  25492. * _.takeWhile(users, function(o) { return !o.active; });
  25493. * // => objects for ['barney', 'fred']
  25494. *
  25495. * // The `_.matches` iteratee shorthand.
  25496. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25497. * // => objects for ['barney']
  25498. *
  25499. * // The `_.matchesProperty` iteratee shorthand.
  25500. * _.takeWhile(users, ['active', false]);
  25501. * // => objects for ['barney', 'fred']
  25502. *
  25503. * // The `_.property` iteratee shorthand.
  25504. * _.takeWhile(users, 'active');
  25505. * // => []
  25506. */
  25507. function takeWhile(array, predicate) {
  25508. return (array && array.length)
  25509. ? baseWhile(array, getIteratee(predicate, 3))
  25510. : [];
  25511. }
  25512. /**
  25513. * Creates an array of unique values, in order, from all given arrays using
  25514. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25515. * for equality comparisons.
  25516. *
  25517. * @static
  25518. * @memberOf _
  25519. * @since 0.1.0
  25520. * @category Array
  25521. * @param {...Array} [arrays] The arrays to inspect.
  25522. * @returns {Array} Returns the new array of combined values.
  25523. * @example
  25524. *
  25525. * _.union([2], [1, 2]);
  25526. * // => [2, 1]
  25527. */
  25528. var union = baseRest(function(arrays) {
  25529. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25530. });
  25531. /**
  25532. * This method is like `_.union` except that it accepts `iteratee` which is
  25533. * invoked for each element of each `arrays` to generate the criterion by
  25534. * which uniqueness is computed. Result values are chosen from the first
  25535. * array in which the value occurs. The iteratee is invoked with one argument:
  25536. * (value).
  25537. *
  25538. * @static
  25539. * @memberOf _
  25540. * @since 4.0.0
  25541. * @category Array
  25542. * @param {...Array} [arrays] The arrays to inspect.
  25543. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25544. * @returns {Array} Returns the new array of combined values.
  25545. * @example
  25546. *
  25547. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25548. * // => [2.1, 1.2]
  25549. *
  25550. * // The `_.property` iteratee shorthand.
  25551. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25552. * // => [{ 'x': 1 }, { 'x': 2 }]
  25553. */
  25554. var unionBy = baseRest(function(arrays) {
  25555. var iteratee = last(arrays);
  25556. if (isArrayLikeObject(iteratee)) {
  25557. iteratee = undefined;
  25558. }
  25559. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25560. });
  25561. /**
  25562. * This method is like `_.union` except that it accepts `comparator` which
  25563. * is invoked to compare elements of `arrays`. Result values are chosen from
  25564. * the first array in which the value occurs. The comparator is invoked
  25565. * with two arguments: (arrVal, othVal).
  25566. *
  25567. * @static
  25568. * @memberOf _
  25569. * @since 4.0.0
  25570. * @category Array
  25571. * @param {...Array} [arrays] The arrays to inspect.
  25572. * @param {Function} [comparator] The comparator invoked per element.
  25573. * @returns {Array} Returns the new array of combined values.
  25574. * @example
  25575. *
  25576. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25577. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25578. *
  25579. * _.unionWith(objects, others, _.isEqual);
  25580. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25581. */
  25582. var unionWith = baseRest(function(arrays) {
  25583. var comparator = last(arrays);
  25584. comparator = typeof comparator == 'function' ? comparator : undefined;
  25585. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25586. });
  25587. /**
  25588. * Creates a duplicate-free version of an array, using
  25589. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25590. * for equality comparisons, in which only the first occurrence of each element
  25591. * is kept. The order of result values is determined by the order they occur
  25592. * in the array.
  25593. *
  25594. * @static
  25595. * @memberOf _
  25596. * @since 0.1.0
  25597. * @category Array
  25598. * @param {Array} array The array to inspect.
  25599. * @returns {Array} Returns the new duplicate free array.
  25600. * @example
  25601. *
  25602. * _.uniq([2, 1, 2]);
  25603. * // => [2, 1]
  25604. */
  25605. function uniq(array) {
  25606. return (array && array.length) ? baseUniq(array) : [];
  25607. }
  25608. /**
  25609. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25610. * invoked for each element in `array` to generate the criterion by which
  25611. * uniqueness is computed. The order of result values is determined by the
  25612. * order they occur in the array. The iteratee is invoked with one argument:
  25613. * (value).
  25614. *
  25615. * @static
  25616. * @memberOf _
  25617. * @since 4.0.0
  25618. * @category Array
  25619. * @param {Array} array The array to inspect.
  25620. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25621. * @returns {Array} Returns the new duplicate free array.
  25622. * @example
  25623. *
  25624. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25625. * // => [2.1, 1.2]
  25626. *
  25627. * // The `_.property` iteratee shorthand.
  25628. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25629. * // => [{ 'x': 1 }, { 'x': 2 }]
  25630. */
  25631. function uniqBy(array, iteratee) {
  25632. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25633. }
  25634. /**
  25635. * This method is like `_.uniq` except that it accepts `comparator` which
  25636. * is invoked to compare elements of `array`. The order of result values is
  25637. * determined by the order they occur in the array.The comparator is invoked
  25638. * with two arguments: (arrVal, othVal).
  25639. *
  25640. * @static
  25641. * @memberOf _
  25642. * @since 4.0.0
  25643. * @category Array
  25644. * @param {Array} array The array to inspect.
  25645. * @param {Function} [comparator] The comparator invoked per element.
  25646. * @returns {Array} Returns the new duplicate free array.
  25647. * @example
  25648. *
  25649. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25650. *
  25651. * _.uniqWith(objects, _.isEqual);
  25652. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25653. */
  25654. function uniqWith(array, comparator) {
  25655. comparator = typeof comparator == 'function' ? comparator : undefined;
  25656. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25657. }
  25658. /**
  25659. * This method is like `_.zip` except that it accepts an array of grouped
  25660. * elements and creates an array regrouping the elements to their pre-zip
  25661. * configuration.
  25662. *
  25663. * @static
  25664. * @memberOf _
  25665. * @since 1.2.0
  25666. * @category Array
  25667. * @param {Array} array The array of grouped elements to process.
  25668. * @returns {Array} Returns the new array of regrouped elements.
  25669. * @example
  25670. *
  25671. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25672. * // => [['a', 1, true], ['b', 2, false]]
  25673. *
  25674. * _.unzip(zipped);
  25675. * // => [['a', 'b'], [1, 2], [true, false]]
  25676. */
  25677. function unzip(array) {
  25678. if (!(array && array.length)) {
  25679. return [];
  25680. }
  25681. var length = 0;
  25682. array = arrayFilter(array, function(group) {
  25683. if (isArrayLikeObject(group)) {
  25684. length = nativeMax(group.length, length);
  25685. return true;
  25686. }
  25687. });
  25688. return baseTimes(length, function(index) {
  25689. return arrayMap(array, baseProperty(index));
  25690. });
  25691. }
  25692. /**
  25693. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25694. * how regrouped values should be combined. The iteratee is invoked with the
  25695. * elements of each group: (...group).
  25696. *
  25697. * @static
  25698. * @memberOf _
  25699. * @since 3.8.0
  25700. * @category Array
  25701. * @param {Array} array The array of grouped elements to process.
  25702. * @param {Function} [iteratee=_.identity] The function to combine
  25703. * regrouped values.
  25704. * @returns {Array} Returns the new array of regrouped elements.
  25705. * @example
  25706. *
  25707. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25708. * // => [[1, 10, 100], [2, 20, 200]]
  25709. *
  25710. * _.unzipWith(zipped, _.add);
  25711. * // => [3, 30, 300]
  25712. */
  25713. function unzipWith(array, iteratee) {
  25714. if (!(array && array.length)) {
  25715. return [];
  25716. }
  25717. var result = unzip(array);
  25718. if (iteratee == null) {
  25719. return result;
  25720. }
  25721. return arrayMap(result, function(group) {
  25722. return apply(iteratee, undefined, group);
  25723. });
  25724. }
  25725. /**
  25726. * Creates an array excluding all given values using
  25727. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25728. * for equality comparisons.
  25729. *
  25730. * **Note:** Unlike `_.pull`, this method returns a new array.
  25731. *
  25732. * @static
  25733. * @memberOf _
  25734. * @since 0.1.0
  25735. * @category Array
  25736. * @param {Array} array The array to inspect.
  25737. * @param {...*} [values] The values to exclude.
  25738. * @returns {Array} Returns the new array of filtered values.
  25739. * @see _.difference, _.xor
  25740. * @example
  25741. *
  25742. * _.without([2, 1, 2, 3], 1, 2);
  25743. * // => [3]
  25744. */
  25745. var without = baseRest(function(array, values) {
  25746. return isArrayLikeObject(array)
  25747. ? baseDifference(array, values)
  25748. : [];
  25749. });
  25750. /**
  25751. * Creates an array of unique values that is the
  25752. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25753. * of the given arrays. The order of result values is determined by the order
  25754. * they occur in the arrays.
  25755. *
  25756. * @static
  25757. * @memberOf _
  25758. * @since 2.4.0
  25759. * @category Array
  25760. * @param {...Array} [arrays] The arrays to inspect.
  25761. * @returns {Array} Returns the new array of filtered values.
  25762. * @see _.difference, _.without
  25763. * @example
  25764. *
  25765. * _.xor([2, 1], [2, 3]);
  25766. * // => [1, 3]
  25767. */
  25768. var xor = baseRest(function(arrays) {
  25769. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25770. });
  25771. /**
  25772. * This method is like `_.xor` except that it accepts `iteratee` which is
  25773. * invoked for each element of each `arrays` to generate the criterion by
  25774. * which by which they're compared. The order of result values is determined
  25775. * by the order they occur in the arrays. The iteratee is invoked with one
  25776. * argument: (value).
  25777. *
  25778. * @static
  25779. * @memberOf _
  25780. * @since 4.0.0
  25781. * @category Array
  25782. * @param {...Array} [arrays] The arrays to inspect.
  25783. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25784. * @returns {Array} Returns the new array of filtered values.
  25785. * @example
  25786. *
  25787. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25788. * // => [1.2, 3.4]
  25789. *
  25790. * // The `_.property` iteratee shorthand.
  25791. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25792. * // => [{ 'x': 2 }]
  25793. */
  25794. var xorBy = baseRest(function(arrays) {
  25795. var iteratee = last(arrays);
  25796. if (isArrayLikeObject(iteratee)) {
  25797. iteratee = undefined;
  25798. }
  25799. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25800. });
  25801. /**
  25802. * This method is like `_.xor` except that it accepts `comparator` which is
  25803. * invoked to compare elements of `arrays`. The order of result values is
  25804. * determined by the order they occur in the arrays. The comparator is invoked
  25805. * with two arguments: (arrVal, othVal).
  25806. *
  25807. * @static
  25808. * @memberOf _
  25809. * @since 4.0.0
  25810. * @category Array
  25811. * @param {...Array} [arrays] The arrays to inspect.
  25812. * @param {Function} [comparator] The comparator invoked per element.
  25813. * @returns {Array} Returns the new array of filtered values.
  25814. * @example
  25815. *
  25816. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25817. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25818. *
  25819. * _.xorWith(objects, others, _.isEqual);
  25820. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25821. */
  25822. var xorWith = baseRest(function(arrays) {
  25823. var comparator = last(arrays);
  25824. comparator = typeof comparator == 'function' ? comparator : undefined;
  25825. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25826. });
  25827. /**
  25828. * Creates an array of grouped elements, the first of which contains the
  25829. * first elements of the given arrays, the second of which contains the
  25830. * second elements of the given arrays, and so on.
  25831. *
  25832. * @static
  25833. * @memberOf _
  25834. * @since 0.1.0
  25835. * @category Array
  25836. * @param {...Array} [arrays] The arrays to process.
  25837. * @returns {Array} Returns the new array of grouped elements.
  25838. * @example
  25839. *
  25840. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25841. * // => [['a', 1, true], ['b', 2, false]]
  25842. */
  25843. var zip = baseRest(unzip);
  25844. /**
  25845. * This method is like `_.fromPairs` except that it accepts two arrays,
  25846. * one of property identifiers and one of corresponding values.
  25847. *
  25848. * @static
  25849. * @memberOf _
  25850. * @since 0.4.0
  25851. * @category Array
  25852. * @param {Array} [props=[]] The property identifiers.
  25853. * @param {Array} [values=[]] The property values.
  25854. * @returns {Object} Returns the new object.
  25855. * @example
  25856. *
  25857. * _.zipObject(['a', 'b'], [1, 2]);
  25858. * // => { 'a': 1, 'b': 2 }
  25859. */
  25860. function zipObject(props, values) {
  25861. return baseZipObject(props || [], values || [], assignValue);
  25862. }
  25863. /**
  25864. * This method is like `_.zipObject` except that it supports property paths.
  25865. *
  25866. * @static
  25867. * @memberOf _
  25868. * @since 4.1.0
  25869. * @category Array
  25870. * @param {Array} [props=[]] The property identifiers.
  25871. * @param {Array} [values=[]] The property values.
  25872. * @returns {Object} Returns the new object.
  25873. * @example
  25874. *
  25875. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25876. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25877. */
  25878. function zipObjectDeep(props, values) {
  25879. return baseZipObject(props || [], values || [], baseSet);
  25880. }
  25881. /**
  25882. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25883. * how grouped values should be combined. The iteratee is invoked with the
  25884. * elements of each group: (...group).
  25885. *
  25886. * @static
  25887. * @memberOf _
  25888. * @since 3.8.0
  25889. * @category Array
  25890. * @param {...Array} [arrays] The arrays to process.
  25891. * @param {Function} [iteratee=_.identity] The function to combine
  25892. * grouped values.
  25893. * @returns {Array} Returns the new array of grouped elements.
  25894. * @example
  25895. *
  25896. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25897. * return a + b + c;
  25898. * });
  25899. * // => [111, 222]
  25900. */
  25901. var zipWith = baseRest(function(arrays) {
  25902. var length = arrays.length,
  25903. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25904. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25905. return unzipWith(arrays, iteratee);
  25906. });
  25907. /*------------------------------------------------------------------------*/
  25908. /**
  25909. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25910. * chain sequences enabled. The result of such sequences must be unwrapped
  25911. * with `_#value`.
  25912. *
  25913. * @static
  25914. * @memberOf _
  25915. * @since 1.3.0
  25916. * @category Seq
  25917. * @param {*} value The value to wrap.
  25918. * @returns {Object} Returns the new `lodash` wrapper instance.
  25919. * @example
  25920. *
  25921. * var users = [
  25922. * { 'user': 'barney', 'age': 36 },
  25923. * { 'user': 'fred', 'age': 40 },
  25924. * { 'user': 'pebbles', 'age': 1 }
  25925. * ];
  25926. *
  25927. * var youngest = _
  25928. * .chain(users)
  25929. * .sortBy('age')
  25930. * .map(function(o) {
  25931. * return o.user + ' is ' + o.age;
  25932. * })
  25933. * .head()
  25934. * .value();
  25935. * // => 'pebbles is 1'
  25936. */
  25937. function chain(value) {
  25938. var result = lodash(value);
  25939. result.__chain__ = true;
  25940. return result;
  25941. }
  25942. /**
  25943. * This method invokes `interceptor` and returns `value`. The interceptor
  25944. * is invoked with one argument; (value). The purpose of this method is to
  25945. * "tap into" a method chain sequence in order to modify intermediate results.
  25946. *
  25947. * @static
  25948. * @memberOf _
  25949. * @since 0.1.0
  25950. * @category Seq
  25951. * @param {*} value The value to provide to `interceptor`.
  25952. * @param {Function} interceptor The function to invoke.
  25953. * @returns {*} Returns `value`.
  25954. * @example
  25955. *
  25956. * _([1, 2, 3])
  25957. * .tap(function(array) {
  25958. * // Mutate input array.
  25959. * array.pop();
  25960. * })
  25961. * .reverse()
  25962. * .value();
  25963. * // => [2, 1]
  25964. */
  25965. function tap(value, interceptor) {
  25966. interceptor(value);
  25967. return value;
  25968. }
  25969. /**
  25970. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25971. * The purpose of this method is to "pass thru" values replacing intermediate
  25972. * results in a method chain sequence.
  25973. *
  25974. * @static
  25975. * @memberOf _
  25976. * @since 3.0.0
  25977. * @category Seq
  25978. * @param {*} value The value to provide to `interceptor`.
  25979. * @param {Function} interceptor The function to invoke.
  25980. * @returns {*} Returns the result of `interceptor`.
  25981. * @example
  25982. *
  25983. * _(' abc ')
  25984. * .chain()
  25985. * .trim()
  25986. * .thru(function(value) {
  25987. * return [value];
  25988. * })
  25989. * .value();
  25990. * // => ['abc']
  25991. */
  25992. function thru(value, interceptor) {
  25993. return interceptor(value);
  25994. }
  25995. /**
  25996. * This method is the wrapper version of `_.at`.
  25997. *
  25998. * @name at
  25999. * @memberOf _
  26000. * @since 1.0.0
  26001. * @category Seq
  26002. * @param {...(string|string[])} [paths] The property paths to pick.
  26003. * @returns {Object} Returns the new `lodash` wrapper instance.
  26004. * @example
  26005. *
  26006. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  26007. *
  26008. * _(object).at(['a[0].b.c', 'a[1]']).value();
  26009. * // => [3, 4]
  26010. */
  26011. var wrapperAt = flatRest(function(paths) {
  26012. var length = paths.length,
  26013. start = length ? paths[0] : 0,
  26014. value = this.__wrapped__,
  26015. interceptor = function(object) { return baseAt(object, paths); };
  26016. if (length > 1 || this.__actions__.length ||
  26017. !(value instanceof LazyWrapper) || !isIndex(start)) {
  26018. return this.thru(interceptor);
  26019. }
  26020. value = value.slice(start, +start + (length ? 1 : 0));
  26021. value.__actions__.push({
  26022. 'func': thru,
  26023. 'args': [interceptor],
  26024. 'thisArg': undefined
  26025. });
  26026. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  26027. if (length && !array.length) {
  26028. array.push(undefined);
  26029. }
  26030. return array;
  26031. });
  26032. });
  26033. /**
  26034. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  26035. *
  26036. * @name chain
  26037. * @memberOf _
  26038. * @since 0.1.0
  26039. * @category Seq
  26040. * @returns {Object} Returns the new `lodash` wrapper instance.
  26041. * @example
  26042. *
  26043. * var users = [
  26044. * { 'user': 'barney', 'age': 36 },
  26045. * { 'user': 'fred', 'age': 40 }
  26046. * ];
  26047. *
  26048. * // A sequence without explicit chaining.
  26049. * _(users).head();
  26050. * // => { 'user': 'barney', 'age': 36 }
  26051. *
  26052. * // A sequence with explicit chaining.
  26053. * _(users)
  26054. * .chain()
  26055. * .head()
  26056. * .pick('user')
  26057. * .value();
  26058. * // => { 'user': 'barney' }
  26059. */
  26060. function wrapperChain() {
  26061. return chain(this);
  26062. }
  26063. /**
  26064. * Executes the chain sequence and returns the wrapped result.
  26065. *
  26066. * @name commit
  26067. * @memberOf _
  26068. * @since 3.2.0
  26069. * @category Seq
  26070. * @returns {Object} Returns the new `lodash` wrapper instance.
  26071. * @example
  26072. *
  26073. * var array = [1, 2];
  26074. * var wrapped = _(array).push(3);
  26075. *
  26076. * console.log(array);
  26077. * // => [1, 2]
  26078. *
  26079. * wrapped = wrapped.commit();
  26080. * console.log(array);
  26081. * // => [1, 2, 3]
  26082. *
  26083. * wrapped.last();
  26084. * // => 3
  26085. *
  26086. * console.log(array);
  26087. * // => [1, 2, 3]
  26088. */
  26089. function wrapperCommit() {
  26090. return new LodashWrapper(this.value(), this.__chain__);
  26091. }
  26092. /**
  26093. * Gets the next value on a wrapped object following the
  26094. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  26095. *
  26096. * @name next
  26097. * @memberOf _
  26098. * @since 4.0.0
  26099. * @category Seq
  26100. * @returns {Object} Returns the next iterator value.
  26101. * @example
  26102. *
  26103. * var wrapped = _([1, 2]);
  26104. *
  26105. * wrapped.next();
  26106. * // => { 'done': false, 'value': 1 }
  26107. *
  26108. * wrapped.next();
  26109. * // => { 'done': false, 'value': 2 }
  26110. *
  26111. * wrapped.next();
  26112. * // => { 'done': true, 'value': undefined }
  26113. */
  26114. function wrapperNext() {
  26115. if (this.__values__ === undefined) {
  26116. this.__values__ = toArray(this.value());
  26117. }
  26118. var done = this.__index__ >= this.__values__.length,
  26119. value = done ? undefined : this.__values__[this.__index__++];
  26120. return { 'done': done, 'value': value };
  26121. }
  26122. /**
  26123. * Enables the wrapper to be iterable.
  26124. *
  26125. * @name Symbol.iterator
  26126. * @memberOf _
  26127. * @since 4.0.0
  26128. * @category Seq
  26129. * @returns {Object} Returns the wrapper object.
  26130. * @example
  26131. *
  26132. * var wrapped = _([1, 2]);
  26133. *
  26134. * wrapped[Symbol.iterator]() === wrapped;
  26135. * // => true
  26136. *
  26137. * Array.from(wrapped);
  26138. * // => [1, 2]
  26139. */
  26140. function wrapperToIterator() {
  26141. return this;
  26142. }
  26143. /**
  26144. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26145. *
  26146. * @name plant
  26147. * @memberOf _
  26148. * @since 3.2.0
  26149. * @category Seq
  26150. * @param {*} value The value to plant.
  26151. * @returns {Object} Returns the new `lodash` wrapper instance.
  26152. * @example
  26153. *
  26154. * function square(n) {
  26155. * return n * n;
  26156. * }
  26157. *
  26158. * var wrapped = _([1, 2]).map(square);
  26159. * var other = wrapped.plant([3, 4]);
  26160. *
  26161. * other.value();
  26162. * // => [9, 16]
  26163. *
  26164. * wrapped.value();
  26165. * // => [1, 4]
  26166. */
  26167. function wrapperPlant(value) {
  26168. var result,
  26169. parent = this;
  26170. while (parent instanceof baseLodash) {
  26171. var clone = wrapperClone(parent);
  26172. clone.__index__ = 0;
  26173. clone.__values__ = undefined;
  26174. if (result) {
  26175. previous.__wrapped__ = clone;
  26176. } else {
  26177. result = clone;
  26178. }
  26179. var previous = clone;
  26180. parent = parent.__wrapped__;
  26181. }
  26182. previous.__wrapped__ = value;
  26183. return result;
  26184. }
  26185. /**
  26186. * This method is the wrapper version of `_.reverse`.
  26187. *
  26188. * **Note:** This method mutates the wrapped array.
  26189. *
  26190. * @name reverse
  26191. * @memberOf _
  26192. * @since 0.1.0
  26193. * @category Seq
  26194. * @returns {Object} Returns the new `lodash` wrapper instance.
  26195. * @example
  26196. *
  26197. * var array = [1, 2, 3];
  26198. *
  26199. * _(array).reverse().value()
  26200. * // => [3, 2, 1]
  26201. *
  26202. * console.log(array);
  26203. * // => [3, 2, 1]
  26204. */
  26205. function wrapperReverse() {
  26206. var value = this.__wrapped__;
  26207. if (value instanceof LazyWrapper) {
  26208. var wrapped = value;
  26209. if (this.__actions__.length) {
  26210. wrapped = new LazyWrapper(this);
  26211. }
  26212. wrapped = wrapped.reverse();
  26213. wrapped.__actions__.push({
  26214. 'func': thru,
  26215. 'args': [reverse],
  26216. 'thisArg': undefined
  26217. });
  26218. return new LodashWrapper(wrapped, this.__chain__);
  26219. }
  26220. return this.thru(reverse);
  26221. }
  26222. /**
  26223. * Executes the chain sequence to resolve the unwrapped value.
  26224. *
  26225. * @name value
  26226. * @memberOf _
  26227. * @since 0.1.0
  26228. * @alias toJSON, valueOf
  26229. * @category Seq
  26230. * @returns {*} Returns the resolved unwrapped value.
  26231. * @example
  26232. *
  26233. * _([1, 2, 3]).value();
  26234. * // => [1, 2, 3]
  26235. */
  26236. function wrapperValue() {
  26237. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26238. }
  26239. /*------------------------------------------------------------------------*/
  26240. /**
  26241. * Creates an object composed of keys generated from the results of running
  26242. * each element of `collection` thru `iteratee`. The corresponding value of
  26243. * each key is the number of times the key was returned by `iteratee`. The
  26244. * iteratee is invoked with one argument: (value).
  26245. *
  26246. * @static
  26247. * @memberOf _
  26248. * @since 0.5.0
  26249. * @category Collection
  26250. * @param {Array|Object} collection The collection to iterate over.
  26251. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26252. * @returns {Object} Returns the composed aggregate object.
  26253. * @example
  26254. *
  26255. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26256. * // => { '4': 1, '6': 2 }
  26257. *
  26258. * // The `_.property` iteratee shorthand.
  26259. * _.countBy(['one', 'two', 'three'], 'length');
  26260. * // => { '3': 2, '5': 1 }
  26261. */
  26262. var countBy = createAggregator(function(result, value, key) {
  26263. if (hasOwnProperty.call(result, key)) {
  26264. ++result[key];
  26265. } else {
  26266. baseAssignValue(result, key, 1);
  26267. }
  26268. });
  26269. /**
  26270. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26271. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26272. * invoked with three arguments: (value, index|key, collection).
  26273. *
  26274. * **Note:** This method returns `true` for
  26275. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26276. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26277. * elements of empty collections.
  26278. *
  26279. * @static
  26280. * @memberOf _
  26281. * @since 0.1.0
  26282. * @category Collection
  26283. * @param {Array|Object} collection The collection to iterate over.
  26284. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26285. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26286. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26287. * else `false`.
  26288. * @example
  26289. *
  26290. * _.every([true, 1, null, 'yes'], Boolean);
  26291. * // => false
  26292. *
  26293. * var users = [
  26294. * { 'user': 'barney', 'age': 36, 'active': false },
  26295. * { 'user': 'fred', 'age': 40, 'active': false }
  26296. * ];
  26297. *
  26298. * // The `_.matches` iteratee shorthand.
  26299. * _.every(users, { 'user': 'barney', 'active': false });
  26300. * // => false
  26301. *
  26302. * // The `_.matchesProperty` iteratee shorthand.
  26303. * _.every(users, ['active', false]);
  26304. * // => true
  26305. *
  26306. * // The `_.property` iteratee shorthand.
  26307. * _.every(users, 'active');
  26308. * // => false
  26309. */
  26310. function every(collection, predicate, guard) {
  26311. var func = isArray(collection) ? arrayEvery : baseEvery;
  26312. if (guard && isIterateeCall(collection, predicate, guard)) {
  26313. predicate = undefined;
  26314. }
  26315. return func(collection, getIteratee(predicate, 3));
  26316. }
  26317. /**
  26318. * Iterates over elements of `collection`, returning an array of all elements
  26319. * `predicate` returns truthy for. The predicate is invoked with three
  26320. * arguments: (value, index|key, collection).
  26321. *
  26322. * **Note:** Unlike `_.remove`, this method returns a new array.
  26323. *
  26324. * @static
  26325. * @memberOf _
  26326. * @since 0.1.0
  26327. * @category Collection
  26328. * @param {Array|Object} collection The collection to iterate over.
  26329. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26330. * @returns {Array} Returns the new filtered array.
  26331. * @see _.reject
  26332. * @example
  26333. *
  26334. * var users = [
  26335. * { 'user': 'barney', 'age': 36, 'active': true },
  26336. * { 'user': 'fred', 'age': 40, 'active': false }
  26337. * ];
  26338. *
  26339. * _.filter(users, function(o) { return !o.active; });
  26340. * // => objects for ['fred']
  26341. *
  26342. * // The `_.matches` iteratee shorthand.
  26343. * _.filter(users, { 'age': 36, 'active': true });
  26344. * // => objects for ['barney']
  26345. *
  26346. * // The `_.matchesProperty` iteratee shorthand.
  26347. * _.filter(users, ['active', false]);
  26348. * // => objects for ['fred']
  26349. *
  26350. * // The `_.property` iteratee shorthand.
  26351. * _.filter(users, 'active');
  26352. * // => objects for ['barney']
  26353. */
  26354. function filter(collection, predicate) {
  26355. var func = isArray(collection) ? arrayFilter : baseFilter;
  26356. return func(collection, getIteratee(predicate, 3));
  26357. }
  26358. /**
  26359. * Iterates over elements of `collection`, returning the first element
  26360. * `predicate` returns truthy for. The predicate is invoked with three
  26361. * arguments: (value, index|key, collection).
  26362. *
  26363. * @static
  26364. * @memberOf _
  26365. * @since 0.1.0
  26366. * @category Collection
  26367. * @param {Array|Object} collection The collection to inspect.
  26368. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26369. * @param {number} [fromIndex=0] The index to search from.
  26370. * @returns {*} Returns the matched element, else `undefined`.
  26371. * @example
  26372. *
  26373. * var users = [
  26374. * { 'user': 'barney', 'age': 36, 'active': true },
  26375. * { 'user': 'fred', 'age': 40, 'active': false },
  26376. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26377. * ];
  26378. *
  26379. * _.find(users, function(o) { return o.age < 40; });
  26380. * // => object for 'barney'
  26381. *
  26382. * // The `_.matches` iteratee shorthand.
  26383. * _.find(users, { 'age': 1, 'active': true });
  26384. * // => object for 'pebbles'
  26385. *
  26386. * // The `_.matchesProperty` iteratee shorthand.
  26387. * _.find(users, ['active', false]);
  26388. * // => object for 'fred'
  26389. *
  26390. * // The `_.property` iteratee shorthand.
  26391. * _.find(users, 'active');
  26392. * // => object for 'barney'
  26393. */
  26394. var find = createFind(findIndex);
  26395. /**
  26396. * This method is like `_.find` except that it iterates over elements of
  26397. * `collection` from right to left.
  26398. *
  26399. * @static
  26400. * @memberOf _
  26401. * @since 2.0.0
  26402. * @category Collection
  26403. * @param {Array|Object} collection The collection to inspect.
  26404. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26405. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26406. * @returns {*} Returns the matched element, else `undefined`.
  26407. * @example
  26408. *
  26409. * _.findLast([1, 2, 3, 4], function(n) {
  26410. * return n % 2 == 1;
  26411. * });
  26412. * // => 3
  26413. */
  26414. var findLast = createFind(findLastIndex);
  26415. /**
  26416. * Creates a flattened array of values by running each element in `collection`
  26417. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26418. * with three arguments: (value, index|key, collection).
  26419. *
  26420. * @static
  26421. * @memberOf _
  26422. * @since 4.0.0
  26423. * @category Collection
  26424. * @param {Array|Object} collection The collection to iterate over.
  26425. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26426. * @returns {Array} Returns the new flattened array.
  26427. * @example
  26428. *
  26429. * function duplicate(n) {
  26430. * return [n, n];
  26431. * }
  26432. *
  26433. * _.flatMap([1, 2], duplicate);
  26434. * // => [1, 1, 2, 2]
  26435. */
  26436. function flatMap(collection, iteratee) {
  26437. return baseFlatten(map(collection, iteratee), 1);
  26438. }
  26439. /**
  26440. * This method is like `_.flatMap` except that it recursively flattens the
  26441. * mapped results.
  26442. *
  26443. * @static
  26444. * @memberOf _
  26445. * @since 4.7.0
  26446. * @category Collection
  26447. * @param {Array|Object} collection The collection to iterate over.
  26448. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26449. * @returns {Array} Returns the new flattened array.
  26450. * @example
  26451. *
  26452. * function duplicate(n) {
  26453. * return [[[n, n]]];
  26454. * }
  26455. *
  26456. * _.flatMapDeep([1, 2], duplicate);
  26457. * // => [1, 1, 2, 2]
  26458. */
  26459. function flatMapDeep(collection, iteratee) {
  26460. return baseFlatten(map(collection, iteratee), INFINITY);
  26461. }
  26462. /**
  26463. * This method is like `_.flatMap` except that it recursively flattens the
  26464. * mapped results up to `depth` times.
  26465. *
  26466. * @static
  26467. * @memberOf _
  26468. * @since 4.7.0
  26469. * @category Collection
  26470. * @param {Array|Object} collection The collection to iterate over.
  26471. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26472. * @param {number} [depth=1] The maximum recursion depth.
  26473. * @returns {Array} Returns the new flattened array.
  26474. * @example
  26475. *
  26476. * function duplicate(n) {
  26477. * return [[[n, n]]];
  26478. * }
  26479. *
  26480. * _.flatMapDepth([1, 2], duplicate, 2);
  26481. * // => [[1, 1], [2, 2]]
  26482. */
  26483. function flatMapDepth(collection, iteratee, depth) {
  26484. depth = depth === undefined ? 1 : toInteger(depth);
  26485. return baseFlatten(map(collection, iteratee), depth);
  26486. }
  26487. /**
  26488. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26489. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26490. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26491. *
  26492. * **Note:** As with other "Collections" methods, objects with a "length"
  26493. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26494. * or `_.forOwn` for object iteration.
  26495. *
  26496. * @static
  26497. * @memberOf _
  26498. * @since 0.1.0
  26499. * @alias each
  26500. * @category Collection
  26501. * @param {Array|Object} collection The collection to iterate over.
  26502. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26503. * @returns {Array|Object} Returns `collection`.
  26504. * @see _.forEachRight
  26505. * @example
  26506. *
  26507. * _.forEach([1, 2], function(value) {
  26508. * console.log(value);
  26509. * });
  26510. * // => Logs `1` then `2`.
  26511. *
  26512. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26513. * console.log(key);
  26514. * });
  26515. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26516. */
  26517. function forEach(collection, iteratee) {
  26518. var func = isArray(collection) ? arrayEach : baseEach;
  26519. return func(collection, getIteratee(iteratee, 3));
  26520. }
  26521. /**
  26522. * This method is like `_.forEach` except that it iterates over elements of
  26523. * `collection` from right to left.
  26524. *
  26525. * @static
  26526. * @memberOf _
  26527. * @since 2.0.0
  26528. * @alias eachRight
  26529. * @category Collection
  26530. * @param {Array|Object} collection The collection to iterate over.
  26531. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26532. * @returns {Array|Object} Returns `collection`.
  26533. * @see _.forEach
  26534. * @example
  26535. *
  26536. * _.forEachRight([1, 2], function(value) {
  26537. * console.log(value);
  26538. * });
  26539. * // => Logs `2` then `1`.
  26540. */
  26541. function forEachRight(collection, iteratee) {
  26542. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26543. return func(collection, getIteratee(iteratee, 3));
  26544. }
  26545. /**
  26546. * Creates an object composed of keys generated from the results of running
  26547. * each element of `collection` thru `iteratee`. The order of grouped values
  26548. * is determined by the order they occur in `collection`. The corresponding
  26549. * value of each key is an array of elements responsible for generating the
  26550. * key. The iteratee is invoked with one argument: (value).
  26551. *
  26552. * @static
  26553. * @memberOf _
  26554. * @since 0.1.0
  26555. * @category Collection
  26556. * @param {Array|Object} collection The collection to iterate over.
  26557. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26558. * @returns {Object} Returns the composed aggregate object.
  26559. * @example
  26560. *
  26561. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26562. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26563. *
  26564. * // The `_.property` iteratee shorthand.
  26565. * _.groupBy(['one', 'two', 'three'], 'length');
  26566. * // => { '3': ['one', 'two'], '5': ['three'] }
  26567. */
  26568. var groupBy = createAggregator(function(result, value, key) {
  26569. if (hasOwnProperty.call(result, key)) {
  26570. result[key].push(value);
  26571. } else {
  26572. baseAssignValue(result, key, [value]);
  26573. }
  26574. });
  26575. /**
  26576. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26577. * checked for a substring of `value`, otherwise
  26578. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26579. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26580. * the offset from the end of `collection`.
  26581. *
  26582. * @static
  26583. * @memberOf _
  26584. * @since 0.1.0
  26585. * @category Collection
  26586. * @param {Array|Object|string} collection The collection to inspect.
  26587. * @param {*} value The value to search for.
  26588. * @param {number} [fromIndex=0] The index to search from.
  26589. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26590. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26591. * @example
  26592. *
  26593. * _.includes([1, 2, 3], 1);
  26594. * // => true
  26595. *
  26596. * _.includes([1, 2, 3], 1, 2);
  26597. * // => false
  26598. *
  26599. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26600. * // => true
  26601. *
  26602. * _.includes('abcd', 'bc');
  26603. * // => true
  26604. */
  26605. function includes(collection, value, fromIndex, guard) {
  26606. collection = isArrayLike(collection) ? collection : values(collection);
  26607. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26608. var length = collection.length;
  26609. if (fromIndex < 0) {
  26610. fromIndex = nativeMax(length + fromIndex, 0);
  26611. }
  26612. return isString(collection)
  26613. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26614. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26615. }
  26616. /**
  26617. * Invokes the method at `path` of each element in `collection`, returning
  26618. * an array of the results of each invoked method. Any additional arguments
  26619. * are provided to each invoked method. If `path` is a function, it's invoked
  26620. * for, and `this` bound to, each element in `collection`.
  26621. *
  26622. * @static
  26623. * @memberOf _
  26624. * @since 4.0.0
  26625. * @category Collection
  26626. * @param {Array|Object} collection The collection to iterate over.
  26627. * @param {Array|Function|string} path The path of the method to invoke or
  26628. * the function invoked per iteration.
  26629. * @param {...*} [args] The arguments to invoke each method with.
  26630. * @returns {Array} Returns the array of results.
  26631. * @example
  26632. *
  26633. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26634. * // => [[1, 5, 7], [1, 2, 3]]
  26635. *
  26636. * _.invokeMap([123, 456], String.prototype.split, '');
  26637. * // => [['1', '2', '3'], ['4', '5', '6']]
  26638. */
  26639. var invokeMap = baseRest(function(collection, path, args) {
  26640. var index = -1,
  26641. isFunc = typeof path == 'function',
  26642. result = isArrayLike(collection) ? Array(collection.length) : [];
  26643. baseEach(collection, function(value) {
  26644. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26645. });
  26646. return result;
  26647. });
  26648. /**
  26649. * Creates an object composed of keys generated from the results of running
  26650. * each element of `collection` thru `iteratee`. The corresponding value of
  26651. * each key is the last element responsible for generating the key. The
  26652. * iteratee is invoked with one argument: (value).
  26653. *
  26654. * @static
  26655. * @memberOf _
  26656. * @since 4.0.0
  26657. * @category Collection
  26658. * @param {Array|Object} collection The collection to iterate over.
  26659. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26660. * @returns {Object} Returns the composed aggregate object.
  26661. * @example
  26662. *
  26663. * var array = [
  26664. * { 'dir': 'left', 'code': 97 },
  26665. * { 'dir': 'right', 'code': 100 }
  26666. * ];
  26667. *
  26668. * _.keyBy(array, function(o) {
  26669. * return String.fromCharCode(o.code);
  26670. * });
  26671. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26672. *
  26673. * _.keyBy(array, 'dir');
  26674. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26675. */
  26676. var keyBy = createAggregator(function(result, value, key) {
  26677. baseAssignValue(result, key, value);
  26678. });
  26679. /**
  26680. * Creates an array of values by running each element in `collection` thru
  26681. * `iteratee`. The iteratee is invoked with three arguments:
  26682. * (value, index|key, collection).
  26683. *
  26684. * Many lodash methods are guarded to work as iteratees for methods like
  26685. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26686. *
  26687. * The guarded methods are:
  26688. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26689. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26690. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26691. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26692. *
  26693. * @static
  26694. * @memberOf _
  26695. * @since 0.1.0
  26696. * @category Collection
  26697. * @param {Array|Object} collection The collection to iterate over.
  26698. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26699. * @returns {Array} Returns the new mapped array.
  26700. * @example
  26701. *
  26702. * function square(n) {
  26703. * return n * n;
  26704. * }
  26705. *
  26706. * _.map([4, 8], square);
  26707. * // => [16, 64]
  26708. *
  26709. * _.map({ 'a': 4, 'b': 8 }, square);
  26710. * // => [16, 64] (iteration order is not guaranteed)
  26711. *
  26712. * var users = [
  26713. * { 'user': 'barney' },
  26714. * { 'user': 'fred' }
  26715. * ];
  26716. *
  26717. * // The `_.property` iteratee shorthand.
  26718. * _.map(users, 'user');
  26719. * // => ['barney', 'fred']
  26720. */
  26721. function map(collection, iteratee) {
  26722. var func = isArray(collection) ? arrayMap : baseMap;
  26723. return func(collection, getIteratee(iteratee, 3));
  26724. }
  26725. /**
  26726. * This method is like `_.sortBy` except that it allows specifying the sort
  26727. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26728. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26729. * descending or "asc" for ascending sort order of corresponding values.
  26730. *
  26731. * @static
  26732. * @memberOf _
  26733. * @since 4.0.0
  26734. * @category Collection
  26735. * @param {Array|Object} collection The collection to iterate over.
  26736. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26737. * The iteratees to sort by.
  26738. * @param {string[]} [orders] The sort orders of `iteratees`.
  26739. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26740. * @returns {Array} Returns the new sorted array.
  26741. * @example
  26742. *
  26743. * var users = [
  26744. * { 'user': 'fred', 'age': 48 },
  26745. * { 'user': 'barney', 'age': 34 },
  26746. * { 'user': 'fred', 'age': 40 },
  26747. * { 'user': 'barney', 'age': 36 }
  26748. * ];
  26749. *
  26750. * // Sort by `user` in ascending order and by `age` in descending order.
  26751. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26752. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26753. */
  26754. function orderBy(collection, iteratees, orders, guard) {
  26755. if (collection == null) {
  26756. return [];
  26757. }
  26758. if (!isArray(iteratees)) {
  26759. iteratees = iteratees == null ? [] : [iteratees];
  26760. }
  26761. orders = guard ? undefined : orders;
  26762. if (!isArray(orders)) {
  26763. orders = orders == null ? [] : [orders];
  26764. }
  26765. return baseOrderBy(collection, iteratees, orders);
  26766. }
  26767. /**
  26768. * Creates an array of elements split into two groups, the first of which
  26769. * contains elements `predicate` returns truthy for, the second of which
  26770. * contains elements `predicate` returns falsey for. The predicate is
  26771. * invoked with one argument: (value).
  26772. *
  26773. * @static
  26774. * @memberOf _
  26775. * @since 3.0.0
  26776. * @category Collection
  26777. * @param {Array|Object} collection The collection to iterate over.
  26778. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26779. * @returns {Array} Returns the array of grouped elements.
  26780. * @example
  26781. *
  26782. * var users = [
  26783. * { 'user': 'barney', 'age': 36, 'active': false },
  26784. * { 'user': 'fred', 'age': 40, 'active': true },
  26785. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26786. * ];
  26787. *
  26788. * _.partition(users, function(o) { return o.active; });
  26789. * // => objects for [['fred'], ['barney', 'pebbles']]
  26790. *
  26791. * // The `_.matches` iteratee shorthand.
  26792. * _.partition(users, { 'age': 1, 'active': false });
  26793. * // => objects for [['pebbles'], ['barney', 'fred']]
  26794. *
  26795. * // The `_.matchesProperty` iteratee shorthand.
  26796. * _.partition(users, ['active', false]);
  26797. * // => objects for [['barney', 'pebbles'], ['fred']]
  26798. *
  26799. * // The `_.property` iteratee shorthand.
  26800. * _.partition(users, 'active');
  26801. * // => objects for [['fred'], ['barney', 'pebbles']]
  26802. */
  26803. var partition = createAggregator(function(result, value, key) {
  26804. result[key ? 0 : 1].push(value);
  26805. }, function() { return [[], []]; });
  26806. /**
  26807. * Reduces `collection` to a value which is the accumulated result of running
  26808. * each element in `collection` thru `iteratee`, where each successive
  26809. * invocation is supplied the return value of the previous. If `accumulator`
  26810. * is not given, the first element of `collection` is used as the initial
  26811. * value. The iteratee is invoked with four arguments:
  26812. * (accumulator, value, index|key, collection).
  26813. *
  26814. * Many lodash methods are guarded to work as iteratees for methods like
  26815. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26816. *
  26817. * The guarded methods are:
  26818. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26819. * and `sortBy`
  26820. *
  26821. * @static
  26822. * @memberOf _
  26823. * @since 0.1.0
  26824. * @category Collection
  26825. * @param {Array|Object} collection The collection to iterate over.
  26826. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26827. * @param {*} [accumulator] The initial value.
  26828. * @returns {*} Returns the accumulated value.
  26829. * @see _.reduceRight
  26830. * @example
  26831. *
  26832. * _.reduce([1, 2], function(sum, n) {
  26833. * return sum + n;
  26834. * }, 0);
  26835. * // => 3
  26836. *
  26837. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26838. * (result[value] || (result[value] = [])).push(key);
  26839. * return result;
  26840. * }, {});
  26841. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26842. */
  26843. function reduce(collection, iteratee, accumulator) {
  26844. var func = isArray(collection) ? arrayReduce : baseReduce,
  26845. initAccum = arguments.length < 3;
  26846. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26847. }
  26848. /**
  26849. * This method is like `_.reduce` except that it iterates over elements of
  26850. * `collection` from right to left.
  26851. *
  26852. * @static
  26853. * @memberOf _
  26854. * @since 0.1.0
  26855. * @category Collection
  26856. * @param {Array|Object} collection The collection to iterate over.
  26857. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26858. * @param {*} [accumulator] The initial value.
  26859. * @returns {*} Returns the accumulated value.
  26860. * @see _.reduce
  26861. * @example
  26862. *
  26863. * var array = [[0, 1], [2, 3], [4, 5]];
  26864. *
  26865. * _.reduceRight(array, function(flattened, other) {
  26866. * return flattened.concat(other);
  26867. * }, []);
  26868. * // => [4, 5, 2, 3, 0, 1]
  26869. */
  26870. function reduceRight(collection, iteratee, accumulator) {
  26871. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26872. initAccum = arguments.length < 3;
  26873. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26874. }
  26875. /**
  26876. * The opposite of `_.filter`; this method returns the elements of `collection`
  26877. * that `predicate` does **not** return truthy for.
  26878. *
  26879. * @static
  26880. * @memberOf _
  26881. * @since 0.1.0
  26882. * @category Collection
  26883. * @param {Array|Object} collection The collection to iterate over.
  26884. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26885. * @returns {Array} Returns the new filtered array.
  26886. * @see _.filter
  26887. * @example
  26888. *
  26889. * var users = [
  26890. * { 'user': 'barney', 'age': 36, 'active': false },
  26891. * { 'user': 'fred', 'age': 40, 'active': true }
  26892. * ];
  26893. *
  26894. * _.reject(users, function(o) { return !o.active; });
  26895. * // => objects for ['fred']
  26896. *
  26897. * // The `_.matches` iteratee shorthand.
  26898. * _.reject(users, { 'age': 40, 'active': true });
  26899. * // => objects for ['barney']
  26900. *
  26901. * // The `_.matchesProperty` iteratee shorthand.
  26902. * _.reject(users, ['active', false]);
  26903. * // => objects for ['fred']
  26904. *
  26905. * // The `_.property` iteratee shorthand.
  26906. * _.reject(users, 'active');
  26907. * // => objects for ['barney']
  26908. */
  26909. function reject(collection, predicate) {
  26910. var func = isArray(collection) ? arrayFilter : baseFilter;
  26911. return func(collection, negate(getIteratee(predicate, 3)));
  26912. }
  26913. /**
  26914. * Gets a random element from `collection`.
  26915. *
  26916. * @static
  26917. * @memberOf _
  26918. * @since 2.0.0
  26919. * @category Collection
  26920. * @param {Array|Object} collection The collection to sample.
  26921. * @returns {*} Returns the random element.
  26922. * @example
  26923. *
  26924. * _.sample([1, 2, 3, 4]);
  26925. * // => 2
  26926. */
  26927. function sample(collection) {
  26928. var func = isArray(collection) ? arraySample : baseSample;
  26929. return func(collection);
  26930. }
  26931. /**
  26932. * Gets `n` random elements at unique keys from `collection` up to the
  26933. * size of `collection`.
  26934. *
  26935. * @static
  26936. * @memberOf _
  26937. * @since 4.0.0
  26938. * @category Collection
  26939. * @param {Array|Object} collection The collection to sample.
  26940. * @param {number} [n=1] The number of elements to sample.
  26941. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26942. * @returns {Array} Returns the random elements.
  26943. * @example
  26944. *
  26945. * _.sampleSize([1, 2, 3], 2);
  26946. * // => [3, 1]
  26947. *
  26948. * _.sampleSize([1, 2, 3], 4);
  26949. * // => [2, 3, 1]
  26950. */
  26951. function sampleSize(collection, n, guard) {
  26952. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26953. n = 1;
  26954. } else {
  26955. n = toInteger(n);
  26956. }
  26957. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26958. return func(collection, n);
  26959. }
  26960. /**
  26961. * Creates an array of shuffled values, using a version of the
  26962. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26963. *
  26964. * @static
  26965. * @memberOf _
  26966. * @since 0.1.0
  26967. * @category Collection
  26968. * @param {Array|Object} collection The collection to shuffle.
  26969. * @returns {Array} Returns the new shuffled array.
  26970. * @example
  26971. *
  26972. * _.shuffle([1, 2, 3, 4]);
  26973. * // => [4, 1, 3, 2]
  26974. */
  26975. function shuffle(collection) {
  26976. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26977. return func(collection);
  26978. }
  26979. /**
  26980. * Gets the size of `collection` by returning its length for array-like
  26981. * values or the number of own enumerable string keyed properties for objects.
  26982. *
  26983. * @static
  26984. * @memberOf _
  26985. * @since 0.1.0
  26986. * @category Collection
  26987. * @param {Array|Object|string} collection The collection to inspect.
  26988. * @returns {number} Returns the collection size.
  26989. * @example
  26990. *
  26991. * _.size([1, 2, 3]);
  26992. * // => 3
  26993. *
  26994. * _.size({ 'a': 1, 'b': 2 });
  26995. * // => 2
  26996. *
  26997. * _.size('pebbles');
  26998. * // => 7
  26999. */
  27000. function size(collection) {
  27001. if (collection == null) {
  27002. return 0;
  27003. }
  27004. if (isArrayLike(collection)) {
  27005. return isString(collection) ? stringSize(collection) : collection.length;
  27006. }
  27007. var tag = getTag(collection);
  27008. if (tag == mapTag || tag == setTag) {
  27009. return collection.size;
  27010. }
  27011. return baseKeys(collection).length;
  27012. }
  27013. /**
  27014. * Checks if `predicate` returns truthy for **any** element of `collection`.
  27015. * Iteration is stopped once `predicate` returns truthy. The predicate is
  27016. * invoked with three arguments: (value, index|key, collection).
  27017. *
  27018. * @static
  27019. * @memberOf _
  27020. * @since 0.1.0
  27021. * @category Collection
  27022. * @param {Array|Object} collection The collection to iterate over.
  27023. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27024. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27025. * @returns {boolean} Returns `true` if any element passes the predicate check,
  27026. * else `false`.
  27027. * @example
  27028. *
  27029. * _.some([null, 0, 'yes', false], Boolean);
  27030. * // => true
  27031. *
  27032. * var users = [
  27033. * { 'user': 'barney', 'active': true },
  27034. * { 'user': 'fred', 'active': false }
  27035. * ];
  27036. *
  27037. * // The `_.matches` iteratee shorthand.
  27038. * _.some(users, { 'user': 'barney', 'active': false });
  27039. * // => false
  27040. *
  27041. * // The `_.matchesProperty` iteratee shorthand.
  27042. * _.some(users, ['active', false]);
  27043. * // => true
  27044. *
  27045. * // The `_.property` iteratee shorthand.
  27046. * _.some(users, 'active');
  27047. * // => true
  27048. */
  27049. function some(collection, predicate, guard) {
  27050. var func = isArray(collection) ? arraySome : baseSome;
  27051. if (guard && isIterateeCall(collection, predicate, guard)) {
  27052. predicate = undefined;
  27053. }
  27054. return func(collection, getIteratee(predicate, 3));
  27055. }
  27056. /**
  27057. * Creates an array of elements, sorted in ascending order by the results of
  27058. * running each element in a collection thru each iteratee. This method
  27059. * performs a stable sort, that is, it preserves the original sort order of
  27060. * equal elements. The iteratees are invoked with one argument: (value).
  27061. *
  27062. * @static
  27063. * @memberOf _
  27064. * @since 0.1.0
  27065. * @category Collection
  27066. * @param {Array|Object} collection The collection to iterate over.
  27067. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  27068. * The iteratees to sort by.
  27069. * @returns {Array} Returns the new sorted array.
  27070. * @example
  27071. *
  27072. * var users = [
  27073. * { 'user': 'fred', 'age': 48 },
  27074. * { 'user': 'barney', 'age': 36 },
  27075. * { 'user': 'fred', 'age': 40 },
  27076. * { 'user': 'barney', 'age': 34 }
  27077. * ];
  27078. *
  27079. * _.sortBy(users, [function(o) { return o.user; }]);
  27080. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  27081. *
  27082. * _.sortBy(users, ['user', 'age']);
  27083. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  27084. */
  27085. var sortBy = baseRest(function(collection, iteratees) {
  27086. if (collection == null) {
  27087. return [];
  27088. }
  27089. var length = iteratees.length;
  27090. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  27091. iteratees = [];
  27092. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  27093. iteratees = [iteratees[0]];
  27094. }
  27095. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  27096. });
  27097. /*------------------------------------------------------------------------*/
  27098. /**
  27099. * Gets the timestamp of the number of milliseconds that have elapsed since
  27100. * the Unix epoch (1 January 1970 00:00:00 UTC).
  27101. *
  27102. * @static
  27103. * @memberOf _
  27104. * @since 2.4.0
  27105. * @category Date
  27106. * @returns {number} Returns the timestamp.
  27107. * @example
  27108. *
  27109. * _.defer(function(stamp) {
  27110. * console.log(_.now() - stamp);
  27111. * }, _.now());
  27112. * // => Logs the number of milliseconds it took for the deferred invocation.
  27113. */
  27114. var now = ctxNow || function() {
  27115. return root.Date.now();
  27116. };
  27117. /*------------------------------------------------------------------------*/
  27118. /**
  27119. * The opposite of `_.before`; this method creates a function that invokes
  27120. * `func` once it's called `n` or more times.
  27121. *
  27122. * @static
  27123. * @memberOf _
  27124. * @since 0.1.0
  27125. * @category Function
  27126. * @param {number} n The number of calls before `func` is invoked.
  27127. * @param {Function} func The function to restrict.
  27128. * @returns {Function} Returns the new restricted function.
  27129. * @example
  27130. *
  27131. * var saves = ['profile', 'settings'];
  27132. *
  27133. * var done = _.after(saves.length, function() {
  27134. * console.log('done saving!');
  27135. * });
  27136. *
  27137. * _.forEach(saves, function(type) {
  27138. * asyncSave({ 'type': type, 'complete': done });
  27139. * });
  27140. * // => Logs 'done saving!' after the two async saves have completed.
  27141. */
  27142. function after(n, func) {
  27143. if (typeof func != 'function') {
  27144. throw new TypeError(FUNC_ERROR_TEXT);
  27145. }
  27146. n = toInteger(n);
  27147. return function() {
  27148. if (--n < 1) {
  27149. return func.apply(this, arguments);
  27150. }
  27151. };
  27152. }
  27153. /**
  27154. * Creates a function that invokes `func`, with up to `n` arguments,
  27155. * ignoring any additional arguments.
  27156. *
  27157. * @static
  27158. * @memberOf _
  27159. * @since 3.0.0
  27160. * @category Function
  27161. * @param {Function} func The function to cap arguments for.
  27162. * @param {number} [n=func.length] The arity cap.
  27163. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27164. * @returns {Function} Returns the new capped function.
  27165. * @example
  27166. *
  27167. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27168. * // => [6, 8, 10]
  27169. */
  27170. function ary(func, n, guard) {
  27171. n = guard ? undefined : n;
  27172. n = (func && n == null) ? func.length : n;
  27173. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27174. }
  27175. /**
  27176. * Creates a function that invokes `func`, with the `this` binding and arguments
  27177. * of the created function, while it's called less than `n` times. Subsequent
  27178. * calls to the created function return the result of the last `func` invocation.
  27179. *
  27180. * @static
  27181. * @memberOf _
  27182. * @since 3.0.0
  27183. * @category Function
  27184. * @param {number} n The number of calls at which `func` is no longer invoked.
  27185. * @param {Function} func The function to restrict.
  27186. * @returns {Function} Returns the new restricted function.
  27187. * @example
  27188. *
  27189. * jQuery(element).on('click', _.before(5, addContactToList));
  27190. * // => Allows adding up to 4 contacts to the list.
  27191. */
  27192. function before(n, func) {
  27193. var result;
  27194. if (typeof func != 'function') {
  27195. throw new TypeError(FUNC_ERROR_TEXT);
  27196. }
  27197. n = toInteger(n);
  27198. return function() {
  27199. if (--n > 0) {
  27200. result = func.apply(this, arguments);
  27201. }
  27202. if (n <= 1) {
  27203. func = undefined;
  27204. }
  27205. return result;
  27206. };
  27207. }
  27208. /**
  27209. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27210. * and `partials` prepended to the arguments it receives.
  27211. *
  27212. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27213. * may be used as a placeholder for partially applied arguments.
  27214. *
  27215. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27216. * property of bound functions.
  27217. *
  27218. * @static
  27219. * @memberOf _
  27220. * @since 0.1.0
  27221. * @category Function
  27222. * @param {Function} func The function to bind.
  27223. * @param {*} thisArg The `this` binding of `func`.
  27224. * @param {...*} [partials] The arguments to be partially applied.
  27225. * @returns {Function} Returns the new bound function.
  27226. * @example
  27227. *
  27228. * function greet(greeting, punctuation) {
  27229. * return greeting + ' ' + this.user + punctuation;
  27230. * }
  27231. *
  27232. * var object = { 'user': 'fred' };
  27233. *
  27234. * var bound = _.bind(greet, object, 'hi');
  27235. * bound('!');
  27236. * // => 'hi fred!'
  27237. *
  27238. * // Bound with placeholders.
  27239. * var bound = _.bind(greet, object, _, '!');
  27240. * bound('hi');
  27241. * // => 'hi fred!'
  27242. */
  27243. var bind = baseRest(function(func, thisArg, partials) {
  27244. var bitmask = WRAP_BIND_FLAG;
  27245. if (partials.length) {
  27246. var holders = replaceHolders(partials, getHolder(bind));
  27247. bitmask |= WRAP_PARTIAL_FLAG;
  27248. }
  27249. return createWrap(func, bitmask, thisArg, partials, holders);
  27250. });
  27251. /**
  27252. * Creates a function that invokes the method at `object[key]` with `partials`
  27253. * prepended to the arguments it receives.
  27254. *
  27255. * This method differs from `_.bind` by allowing bound functions to reference
  27256. * methods that may be redefined or don't yet exist. See
  27257. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27258. * for more details.
  27259. *
  27260. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27261. * builds, may be used as a placeholder for partially applied arguments.
  27262. *
  27263. * @static
  27264. * @memberOf _
  27265. * @since 0.10.0
  27266. * @category Function
  27267. * @param {Object} object The object to invoke the method on.
  27268. * @param {string} key The key of the method.
  27269. * @param {...*} [partials] The arguments to be partially applied.
  27270. * @returns {Function} Returns the new bound function.
  27271. * @example
  27272. *
  27273. * var object = {
  27274. * 'user': 'fred',
  27275. * 'greet': function(greeting, punctuation) {
  27276. * return greeting + ' ' + this.user + punctuation;
  27277. * }
  27278. * };
  27279. *
  27280. * var bound = _.bindKey(object, 'greet', 'hi');
  27281. * bound('!');
  27282. * // => 'hi fred!'
  27283. *
  27284. * object.greet = function(greeting, punctuation) {
  27285. * return greeting + 'ya ' + this.user + punctuation;
  27286. * };
  27287. *
  27288. * bound('!');
  27289. * // => 'hiya fred!'
  27290. *
  27291. * // Bound with placeholders.
  27292. * var bound = _.bindKey(object, 'greet', _, '!');
  27293. * bound('hi');
  27294. * // => 'hiya fred!'
  27295. */
  27296. var bindKey = baseRest(function(object, key, partials) {
  27297. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27298. if (partials.length) {
  27299. var holders = replaceHolders(partials, getHolder(bindKey));
  27300. bitmask |= WRAP_PARTIAL_FLAG;
  27301. }
  27302. return createWrap(key, bitmask, object, partials, holders);
  27303. });
  27304. /**
  27305. * Creates a function that accepts arguments of `func` and either invokes
  27306. * `func` returning its result, if at least `arity` number of arguments have
  27307. * been provided, or returns a function that accepts the remaining `func`
  27308. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27309. * is not sufficient.
  27310. *
  27311. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27312. * may be used as a placeholder for provided arguments.
  27313. *
  27314. * **Note:** This method doesn't set the "length" property of curried functions.
  27315. *
  27316. * @static
  27317. * @memberOf _
  27318. * @since 2.0.0
  27319. * @category Function
  27320. * @param {Function} func The function to curry.
  27321. * @param {number} [arity=func.length] The arity of `func`.
  27322. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27323. * @returns {Function} Returns the new curried function.
  27324. * @example
  27325. *
  27326. * var abc = function(a, b, c) {
  27327. * return [a, b, c];
  27328. * };
  27329. *
  27330. * var curried = _.curry(abc);
  27331. *
  27332. * curried(1)(2)(3);
  27333. * // => [1, 2, 3]
  27334. *
  27335. * curried(1, 2)(3);
  27336. * // => [1, 2, 3]
  27337. *
  27338. * curried(1, 2, 3);
  27339. * // => [1, 2, 3]
  27340. *
  27341. * // Curried with placeholders.
  27342. * curried(1)(_, 3)(2);
  27343. * // => [1, 2, 3]
  27344. */
  27345. function curry(func, arity, guard) {
  27346. arity = guard ? undefined : arity;
  27347. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27348. result.placeholder = curry.placeholder;
  27349. return result;
  27350. }
  27351. /**
  27352. * This method is like `_.curry` except that arguments are applied to `func`
  27353. * in the manner of `_.partialRight` instead of `_.partial`.
  27354. *
  27355. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27356. * builds, may be used as a placeholder for provided arguments.
  27357. *
  27358. * **Note:** This method doesn't set the "length" property of curried functions.
  27359. *
  27360. * @static
  27361. * @memberOf _
  27362. * @since 3.0.0
  27363. * @category Function
  27364. * @param {Function} func The function to curry.
  27365. * @param {number} [arity=func.length] The arity of `func`.
  27366. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27367. * @returns {Function} Returns the new curried function.
  27368. * @example
  27369. *
  27370. * var abc = function(a, b, c) {
  27371. * return [a, b, c];
  27372. * };
  27373. *
  27374. * var curried = _.curryRight(abc);
  27375. *
  27376. * curried(3)(2)(1);
  27377. * // => [1, 2, 3]
  27378. *
  27379. * curried(2, 3)(1);
  27380. * // => [1, 2, 3]
  27381. *
  27382. * curried(1, 2, 3);
  27383. * // => [1, 2, 3]
  27384. *
  27385. * // Curried with placeholders.
  27386. * curried(3)(1, _)(2);
  27387. * // => [1, 2, 3]
  27388. */
  27389. function curryRight(func, arity, guard) {
  27390. arity = guard ? undefined : arity;
  27391. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27392. result.placeholder = curryRight.placeholder;
  27393. return result;
  27394. }
  27395. /**
  27396. * Creates a debounced function that delays invoking `func` until after `wait`
  27397. * milliseconds have elapsed since the last time the debounced function was
  27398. * invoked. The debounced function comes with a `cancel` method to cancel
  27399. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27400. * Provide `options` to indicate whether `func` should be invoked on the
  27401. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27402. * with the last arguments provided to the debounced function. Subsequent
  27403. * calls to the debounced function return the result of the last `func`
  27404. * invocation.
  27405. *
  27406. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27407. * invoked on the trailing edge of the timeout only if the debounced function
  27408. * is invoked more than once during the `wait` timeout.
  27409. *
  27410. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27411. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27412. *
  27413. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27414. * for details over the differences between `_.debounce` and `_.throttle`.
  27415. *
  27416. * @static
  27417. * @memberOf _
  27418. * @since 0.1.0
  27419. * @category Function
  27420. * @param {Function} func The function to debounce.
  27421. * @param {number} [wait=0] The number of milliseconds to delay.
  27422. * @param {Object} [options={}] The options object.
  27423. * @param {boolean} [options.leading=false]
  27424. * Specify invoking on the leading edge of the timeout.
  27425. * @param {number} [options.maxWait]
  27426. * The maximum time `func` is allowed to be delayed before it's invoked.
  27427. * @param {boolean} [options.trailing=true]
  27428. * Specify invoking on the trailing edge of the timeout.
  27429. * @returns {Function} Returns the new debounced function.
  27430. * @example
  27431. *
  27432. * // Avoid costly calculations while the window size is in flux.
  27433. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27434. *
  27435. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27436. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27437. * 'leading': true,
  27438. * 'trailing': false
  27439. * }));
  27440. *
  27441. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27442. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27443. * var source = new EventSource('/stream');
  27444. * jQuery(source).on('message', debounced);
  27445. *
  27446. * // Cancel the trailing debounced invocation.
  27447. * jQuery(window).on('popstate', debounced.cancel);
  27448. */
  27449. function debounce(func, wait, options) {
  27450. var lastArgs,
  27451. lastThis,
  27452. maxWait,
  27453. result,
  27454. timerId,
  27455. lastCallTime,
  27456. lastInvokeTime = 0,
  27457. leading = false,
  27458. maxing = false,
  27459. trailing = true;
  27460. if (typeof func != 'function') {
  27461. throw new TypeError(FUNC_ERROR_TEXT);
  27462. }
  27463. wait = toNumber(wait) || 0;
  27464. if (isObject(options)) {
  27465. leading = !!options.leading;
  27466. maxing = 'maxWait' in options;
  27467. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27468. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27469. }
  27470. function invokeFunc(time) {
  27471. var args = lastArgs,
  27472. thisArg = lastThis;
  27473. lastArgs = lastThis = undefined;
  27474. lastInvokeTime = time;
  27475. result = func.apply(thisArg, args);
  27476. return result;
  27477. }
  27478. function leadingEdge(time) {
  27479. // Reset any `maxWait` timer.
  27480. lastInvokeTime = time;
  27481. // Start the timer for the trailing edge.
  27482. timerId = setTimeout(timerExpired, wait);
  27483. // Invoke the leading edge.
  27484. return leading ? invokeFunc(time) : result;
  27485. }
  27486. function remainingWait(time) {
  27487. var timeSinceLastCall = time - lastCallTime,
  27488. timeSinceLastInvoke = time - lastInvokeTime,
  27489. timeWaiting = wait - timeSinceLastCall;
  27490. return maxing
  27491. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27492. : timeWaiting;
  27493. }
  27494. function shouldInvoke(time) {
  27495. var timeSinceLastCall = time - lastCallTime,
  27496. timeSinceLastInvoke = time - lastInvokeTime;
  27497. // Either this is the first call, activity has stopped and we're at the
  27498. // trailing edge, the system time has gone backwards and we're treating
  27499. // it as the trailing edge, or we've hit the `maxWait` limit.
  27500. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27501. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27502. }
  27503. function timerExpired() {
  27504. var time = now();
  27505. if (shouldInvoke(time)) {
  27506. return trailingEdge(time);
  27507. }
  27508. // Restart the timer.
  27509. timerId = setTimeout(timerExpired, remainingWait(time));
  27510. }
  27511. function trailingEdge(time) {
  27512. timerId = undefined;
  27513. // Only invoke if we have `lastArgs` which means `func` has been
  27514. // debounced at least once.
  27515. if (trailing && lastArgs) {
  27516. return invokeFunc(time);
  27517. }
  27518. lastArgs = lastThis = undefined;
  27519. return result;
  27520. }
  27521. function cancel() {
  27522. if (timerId !== undefined) {
  27523. clearTimeout(timerId);
  27524. }
  27525. lastInvokeTime = 0;
  27526. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27527. }
  27528. function flush() {
  27529. return timerId === undefined ? result : trailingEdge(now());
  27530. }
  27531. function debounced() {
  27532. var time = now(),
  27533. isInvoking = shouldInvoke(time);
  27534. lastArgs = arguments;
  27535. lastThis = this;
  27536. lastCallTime = time;
  27537. if (isInvoking) {
  27538. if (timerId === undefined) {
  27539. return leadingEdge(lastCallTime);
  27540. }
  27541. if (maxing) {
  27542. // Handle invocations in a tight loop.
  27543. clearTimeout(timerId);
  27544. timerId = setTimeout(timerExpired, wait);
  27545. return invokeFunc(lastCallTime);
  27546. }
  27547. }
  27548. if (timerId === undefined) {
  27549. timerId = setTimeout(timerExpired, wait);
  27550. }
  27551. return result;
  27552. }
  27553. debounced.cancel = cancel;
  27554. debounced.flush = flush;
  27555. return debounced;
  27556. }
  27557. /**
  27558. * Defers invoking the `func` until the current call stack has cleared. Any
  27559. * additional arguments are provided to `func` when it's invoked.
  27560. *
  27561. * @static
  27562. * @memberOf _
  27563. * @since 0.1.0
  27564. * @category Function
  27565. * @param {Function} func The function to defer.
  27566. * @param {...*} [args] The arguments to invoke `func` with.
  27567. * @returns {number} Returns the timer id.
  27568. * @example
  27569. *
  27570. * _.defer(function(text) {
  27571. * console.log(text);
  27572. * }, 'deferred');
  27573. * // => Logs 'deferred' after one millisecond.
  27574. */
  27575. var defer = baseRest(function(func, args) {
  27576. return baseDelay(func, 1, args);
  27577. });
  27578. /**
  27579. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27580. * provided to `func` when it's invoked.
  27581. *
  27582. * @static
  27583. * @memberOf _
  27584. * @since 0.1.0
  27585. * @category Function
  27586. * @param {Function} func The function to delay.
  27587. * @param {number} wait The number of milliseconds to delay invocation.
  27588. * @param {...*} [args] The arguments to invoke `func` with.
  27589. * @returns {number} Returns the timer id.
  27590. * @example
  27591. *
  27592. * _.delay(function(text) {
  27593. * console.log(text);
  27594. * }, 1000, 'later');
  27595. * // => Logs 'later' after one second.
  27596. */
  27597. var delay = baseRest(function(func, wait, args) {
  27598. return baseDelay(func, toNumber(wait) || 0, args);
  27599. });
  27600. /**
  27601. * Creates a function that invokes `func` with arguments reversed.
  27602. *
  27603. * @static
  27604. * @memberOf _
  27605. * @since 4.0.0
  27606. * @category Function
  27607. * @param {Function} func The function to flip arguments for.
  27608. * @returns {Function} Returns the new flipped function.
  27609. * @example
  27610. *
  27611. * var flipped = _.flip(function() {
  27612. * return _.toArray(arguments);
  27613. * });
  27614. *
  27615. * flipped('a', 'b', 'c', 'd');
  27616. * // => ['d', 'c', 'b', 'a']
  27617. */
  27618. function flip(func) {
  27619. return createWrap(func, WRAP_FLIP_FLAG);
  27620. }
  27621. /**
  27622. * Creates a function that memoizes the result of `func`. If `resolver` is
  27623. * provided, it determines the cache key for storing the result based on the
  27624. * arguments provided to the memoized function. By default, the first argument
  27625. * provided to the memoized function is used as the map cache key. The `func`
  27626. * is invoked with the `this` binding of the memoized function.
  27627. *
  27628. * **Note:** The cache is exposed as the `cache` property on the memoized
  27629. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27630. * constructor with one whose instances implement the
  27631. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27632. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27633. *
  27634. * @static
  27635. * @memberOf _
  27636. * @since 0.1.0
  27637. * @category Function
  27638. * @param {Function} func The function to have its output memoized.
  27639. * @param {Function} [resolver] The function to resolve the cache key.
  27640. * @returns {Function} Returns the new memoized function.
  27641. * @example
  27642. *
  27643. * var object = { 'a': 1, 'b': 2 };
  27644. * var other = { 'c': 3, 'd': 4 };
  27645. *
  27646. * var values = _.memoize(_.values);
  27647. * values(object);
  27648. * // => [1, 2]
  27649. *
  27650. * values(other);
  27651. * // => [3, 4]
  27652. *
  27653. * object.a = 2;
  27654. * values(object);
  27655. * // => [1, 2]
  27656. *
  27657. * // Modify the result cache.
  27658. * values.cache.set(object, ['a', 'b']);
  27659. * values(object);
  27660. * // => ['a', 'b']
  27661. *
  27662. * // Replace `_.memoize.Cache`.
  27663. * _.memoize.Cache = WeakMap;
  27664. */
  27665. function memoize(func, resolver) {
  27666. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27667. throw new TypeError(FUNC_ERROR_TEXT);
  27668. }
  27669. var memoized = function() {
  27670. var args = arguments,
  27671. key = resolver ? resolver.apply(this, args) : args[0],
  27672. cache = memoized.cache;
  27673. if (cache.has(key)) {
  27674. return cache.get(key);
  27675. }
  27676. var result = func.apply(this, args);
  27677. memoized.cache = cache.set(key, result) || cache;
  27678. return result;
  27679. };
  27680. memoized.cache = new (memoize.Cache || MapCache);
  27681. return memoized;
  27682. }
  27683. // Expose `MapCache`.
  27684. memoize.Cache = MapCache;
  27685. /**
  27686. * Creates a function that negates the result of the predicate `func`. The
  27687. * `func` predicate is invoked with the `this` binding and arguments of the
  27688. * created function.
  27689. *
  27690. * @static
  27691. * @memberOf _
  27692. * @since 3.0.0
  27693. * @category Function
  27694. * @param {Function} predicate The predicate to negate.
  27695. * @returns {Function} Returns the new negated function.
  27696. * @example
  27697. *
  27698. * function isEven(n) {
  27699. * return n % 2 == 0;
  27700. * }
  27701. *
  27702. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27703. * // => [1, 3, 5]
  27704. */
  27705. function negate(predicate) {
  27706. if (typeof predicate != 'function') {
  27707. throw new TypeError(FUNC_ERROR_TEXT);
  27708. }
  27709. return function() {
  27710. var args = arguments;
  27711. switch (args.length) {
  27712. case 0: return !predicate.call(this);
  27713. case 1: return !predicate.call(this, args[0]);
  27714. case 2: return !predicate.call(this, args[0], args[1]);
  27715. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27716. }
  27717. return !predicate.apply(this, args);
  27718. };
  27719. }
  27720. /**
  27721. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27722. * to the function return the value of the first invocation. The `func` is
  27723. * invoked with the `this` binding and arguments of the created function.
  27724. *
  27725. * @static
  27726. * @memberOf _
  27727. * @since 0.1.0
  27728. * @category Function
  27729. * @param {Function} func The function to restrict.
  27730. * @returns {Function} Returns the new restricted function.
  27731. * @example
  27732. *
  27733. * var initialize = _.once(createApplication);
  27734. * initialize();
  27735. * initialize();
  27736. * // => `createApplication` is invoked once
  27737. */
  27738. function once(func) {
  27739. return before(2, func);
  27740. }
  27741. /**
  27742. * Creates a function that invokes `func` with its arguments transformed.
  27743. *
  27744. * @static
  27745. * @since 4.0.0
  27746. * @memberOf _
  27747. * @category Function
  27748. * @param {Function} func The function to wrap.
  27749. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27750. * The argument transforms.
  27751. * @returns {Function} Returns the new function.
  27752. * @example
  27753. *
  27754. * function doubled(n) {
  27755. * return n * 2;
  27756. * }
  27757. *
  27758. * function square(n) {
  27759. * return n * n;
  27760. * }
  27761. *
  27762. * var func = _.overArgs(function(x, y) {
  27763. * return [x, y];
  27764. * }, [square, doubled]);
  27765. *
  27766. * func(9, 3);
  27767. * // => [81, 6]
  27768. *
  27769. * func(10, 5);
  27770. * // => [100, 10]
  27771. */
  27772. var overArgs = castRest(function(func, transforms) {
  27773. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27774. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27775. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27776. var funcsLength = transforms.length;
  27777. return baseRest(function(args) {
  27778. var index = -1,
  27779. length = nativeMin(args.length, funcsLength);
  27780. while (++index < length) {
  27781. args[index] = transforms[index].call(this, args[index]);
  27782. }
  27783. return apply(func, this, args);
  27784. });
  27785. });
  27786. /**
  27787. * Creates a function that invokes `func` with `partials` prepended to the
  27788. * arguments it receives. This method is like `_.bind` except it does **not**
  27789. * alter the `this` binding.
  27790. *
  27791. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27792. * builds, may be used as a placeholder for partially applied arguments.
  27793. *
  27794. * **Note:** This method doesn't set the "length" property of partially
  27795. * applied functions.
  27796. *
  27797. * @static
  27798. * @memberOf _
  27799. * @since 0.2.0
  27800. * @category Function
  27801. * @param {Function} func The function to partially apply arguments to.
  27802. * @param {...*} [partials] The arguments to be partially applied.
  27803. * @returns {Function} Returns the new partially applied function.
  27804. * @example
  27805. *
  27806. * function greet(greeting, name) {
  27807. * return greeting + ' ' + name;
  27808. * }
  27809. *
  27810. * var sayHelloTo = _.partial(greet, 'hello');
  27811. * sayHelloTo('fred');
  27812. * // => 'hello fred'
  27813. *
  27814. * // Partially applied with placeholders.
  27815. * var greetFred = _.partial(greet, _, 'fred');
  27816. * greetFred('hi');
  27817. * // => 'hi fred'
  27818. */
  27819. var partial = baseRest(function(func, partials) {
  27820. var holders = replaceHolders(partials, getHolder(partial));
  27821. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27822. });
  27823. /**
  27824. * This method is like `_.partial` except that partially applied arguments
  27825. * are appended to the arguments it receives.
  27826. *
  27827. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27828. * builds, may be used as a placeholder for partially applied arguments.
  27829. *
  27830. * **Note:** This method doesn't set the "length" property of partially
  27831. * applied functions.
  27832. *
  27833. * @static
  27834. * @memberOf _
  27835. * @since 1.0.0
  27836. * @category Function
  27837. * @param {Function} func The function to partially apply arguments to.
  27838. * @param {...*} [partials] The arguments to be partially applied.
  27839. * @returns {Function} Returns the new partially applied function.
  27840. * @example
  27841. *
  27842. * function greet(greeting, name) {
  27843. * return greeting + ' ' + name;
  27844. * }
  27845. *
  27846. * var greetFred = _.partialRight(greet, 'fred');
  27847. * greetFred('hi');
  27848. * // => 'hi fred'
  27849. *
  27850. * // Partially applied with placeholders.
  27851. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27852. * sayHelloTo('fred');
  27853. * // => 'hello fred'
  27854. */
  27855. var partialRight = baseRest(function(func, partials) {
  27856. var holders = replaceHolders(partials, getHolder(partialRight));
  27857. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27858. });
  27859. /**
  27860. * Creates a function that invokes `func` with arguments arranged according
  27861. * to the specified `indexes` where the argument value at the first index is
  27862. * provided as the first argument, the argument value at the second index is
  27863. * provided as the second argument, and so on.
  27864. *
  27865. * @static
  27866. * @memberOf _
  27867. * @since 3.0.0
  27868. * @category Function
  27869. * @param {Function} func The function to rearrange arguments for.
  27870. * @param {...(number|number[])} indexes The arranged argument indexes.
  27871. * @returns {Function} Returns the new function.
  27872. * @example
  27873. *
  27874. * var rearged = _.rearg(function(a, b, c) {
  27875. * return [a, b, c];
  27876. * }, [2, 0, 1]);
  27877. *
  27878. * rearged('b', 'c', 'a')
  27879. * // => ['a', 'b', 'c']
  27880. */
  27881. var rearg = flatRest(function(func, indexes) {
  27882. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27883. });
  27884. /**
  27885. * Creates a function that invokes `func` with the `this` binding of the
  27886. * created function and arguments from `start` and beyond provided as
  27887. * an array.
  27888. *
  27889. * **Note:** This method is based on the
  27890. * [rest parameter](https://mdn.io/rest_parameters).
  27891. *
  27892. * @static
  27893. * @memberOf _
  27894. * @since 4.0.0
  27895. * @category Function
  27896. * @param {Function} func The function to apply a rest parameter to.
  27897. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27898. * @returns {Function} Returns the new function.
  27899. * @example
  27900. *
  27901. * var say = _.rest(function(what, names) {
  27902. * return what + ' ' + _.initial(names).join(', ') +
  27903. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27904. * });
  27905. *
  27906. * say('hello', 'fred', 'barney', 'pebbles');
  27907. * // => 'hello fred, barney, & pebbles'
  27908. */
  27909. function rest(func, start) {
  27910. if (typeof func != 'function') {
  27911. throw new TypeError(FUNC_ERROR_TEXT);
  27912. }
  27913. start = start === undefined ? start : toInteger(start);
  27914. return baseRest(func, start);
  27915. }
  27916. /**
  27917. * Creates a function that invokes `func` with the `this` binding of the
  27918. * create function and an array of arguments much like
  27919. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27920. *
  27921. * **Note:** This method is based on the
  27922. * [spread operator](https://mdn.io/spread_operator).
  27923. *
  27924. * @static
  27925. * @memberOf _
  27926. * @since 3.2.0
  27927. * @category Function
  27928. * @param {Function} func The function to spread arguments over.
  27929. * @param {number} [start=0] The start position of the spread.
  27930. * @returns {Function} Returns the new function.
  27931. * @example
  27932. *
  27933. * var say = _.spread(function(who, what) {
  27934. * return who + ' says ' + what;
  27935. * });
  27936. *
  27937. * say(['fred', 'hello']);
  27938. * // => 'fred says hello'
  27939. *
  27940. * var numbers = Promise.all([
  27941. * Promise.resolve(40),
  27942. * Promise.resolve(36)
  27943. * ]);
  27944. *
  27945. * numbers.then(_.spread(function(x, y) {
  27946. * return x + y;
  27947. * }));
  27948. * // => a Promise of 76
  27949. */
  27950. function spread(func, start) {
  27951. if (typeof func != 'function') {
  27952. throw new TypeError(FUNC_ERROR_TEXT);
  27953. }
  27954. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27955. return baseRest(function(args) {
  27956. var array = args[start],
  27957. otherArgs = castSlice(args, 0, start);
  27958. if (array) {
  27959. arrayPush(otherArgs, array);
  27960. }
  27961. return apply(func, this, otherArgs);
  27962. });
  27963. }
  27964. /**
  27965. * Creates a throttled function that only invokes `func` at most once per
  27966. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27967. * method to cancel delayed `func` invocations and a `flush` method to
  27968. * immediately invoke them. Provide `options` to indicate whether `func`
  27969. * should be invoked on the leading and/or trailing edge of the `wait`
  27970. * timeout. The `func` is invoked with the last arguments provided to the
  27971. * throttled function. Subsequent calls to the throttled function return the
  27972. * result of the last `func` invocation.
  27973. *
  27974. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27975. * invoked on the trailing edge of the timeout only if the throttled function
  27976. * is invoked more than once during the `wait` timeout.
  27977. *
  27978. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27979. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27980. *
  27981. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27982. * for details over the differences between `_.throttle` and `_.debounce`.
  27983. *
  27984. * @static
  27985. * @memberOf _
  27986. * @since 0.1.0
  27987. * @category Function
  27988. * @param {Function} func The function to throttle.
  27989. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27990. * @param {Object} [options={}] The options object.
  27991. * @param {boolean} [options.leading=true]
  27992. * Specify invoking on the leading edge of the timeout.
  27993. * @param {boolean} [options.trailing=true]
  27994. * Specify invoking on the trailing edge of the timeout.
  27995. * @returns {Function} Returns the new throttled function.
  27996. * @example
  27997. *
  27998. * // Avoid excessively updating the position while scrolling.
  27999. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  28000. *
  28001. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  28002. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  28003. * jQuery(element).on('click', throttled);
  28004. *
  28005. * // Cancel the trailing throttled invocation.
  28006. * jQuery(window).on('popstate', throttled.cancel);
  28007. */
  28008. function throttle(func, wait, options) {
  28009. var leading = true,
  28010. trailing = true;
  28011. if (typeof func != 'function') {
  28012. throw new TypeError(FUNC_ERROR_TEXT);
  28013. }
  28014. if (isObject(options)) {
  28015. leading = 'leading' in options ? !!options.leading : leading;
  28016. trailing = 'trailing' in options ? !!options.trailing : trailing;
  28017. }
  28018. return debounce(func, wait, {
  28019. 'leading': leading,
  28020. 'maxWait': wait,
  28021. 'trailing': trailing
  28022. });
  28023. }
  28024. /**
  28025. * Creates a function that accepts up to one argument, ignoring any
  28026. * additional arguments.
  28027. *
  28028. * @static
  28029. * @memberOf _
  28030. * @since 4.0.0
  28031. * @category Function
  28032. * @param {Function} func The function to cap arguments for.
  28033. * @returns {Function} Returns the new capped function.
  28034. * @example
  28035. *
  28036. * _.map(['6', '8', '10'], _.unary(parseInt));
  28037. * // => [6, 8, 10]
  28038. */
  28039. function unary(func) {
  28040. return ary(func, 1);
  28041. }
  28042. /**
  28043. * Creates a function that provides `value` to `wrapper` as its first
  28044. * argument. Any additional arguments provided to the function are appended
  28045. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  28046. * binding of the created function.
  28047. *
  28048. * @static
  28049. * @memberOf _
  28050. * @since 0.1.0
  28051. * @category Function
  28052. * @param {*} value The value to wrap.
  28053. * @param {Function} [wrapper=identity] The wrapper function.
  28054. * @returns {Function} Returns the new function.
  28055. * @example
  28056. *
  28057. * var p = _.wrap(_.escape, function(func, text) {
  28058. * return '<p>' + func(text) + '</p>';
  28059. * });
  28060. *
  28061. * p('fred, barney, & pebbles');
  28062. * // => '<p>fred, barney, &amp; pebbles</p>'
  28063. */
  28064. function wrap(value, wrapper) {
  28065. return partial(castFunction(wrapper), value);
  28066. }
  28067. /*------------------------------------------------------------------------*/
  28068. /**
  28069. * Casts `value` as an array if it's not one.
  28070. *
  28071. * @static
  28072. * @memberOf _
  28073. * @since 4.4.0
  28074. * @category Lang
  28075. * @param {*} value The value to inspect.
  28076. * @returns {Array} Returns the cast array.
  28077. * @example
  28078. *
  28079. * _.castArray(1);
  28080. * // => [1]
  28081. *
  28082. * _.castArray({ 'a': 1 });
  28083. * // => [{ 'a': 1 }]
  28084. *
  28085. * _.castArray('abc');
  28086. * // => ['abc']
  28087. *
  28088. * _.castArray(null);
  28089. * // => [null]
  28090. *
  28091. * _.castArray(undefined);
  28092. * // => [undefined]
  28093. *
  28094. * _.castArray();
  28095. * // => []
  28096. *
  28097. * var array = [1, 2, 3];
  28098. * console.log(_.castArray(array) === array);
  28099. * // => true
  28100. */
  28101. function castArray() {
  28102. if (!arguments.length) {
  28103. return [];
  28104. }
  28105. var value = arguments[0];
  28106. return isArray(value) ? value : [value];
  28107. }
  28108. /**
  28109. * Creates a shallow clone of `value`.
  28110. *
  28111. * **Note:** This method is loosely based on the
  28112. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  28113. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  28114. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  28115. * arrays. The own enumerable properties of `arguments` objects are cloned
  28116. * as plain objects. An empty object is returned for uncloneable values such
  28117. * as error objects, functions, DOM nodes, and WeakMaps.
  28118. *
  28119. * @static
  28120. * @memberOf _
  28121. * @since 0.1.0
  28122. * @category Lang
  28123. * @param {*} value The value to clone.
  28124. * @returns {*} Returns the cloned value.
  28125. * @see _.cloneDeep
  28126. * @example
  28127. *
  28128. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28129. *
  28130. * var shallow = _.clone(objects);
  28131. * console.log(shallow[0] === objects[0]);
  28132. * // => true
  28133. */
  28134. function clone(value) {
  28135. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28136. }
  28137. /**
  28138. * This method is like `_.clone` except that it accepts `customizer` which
  28139. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28140. * cloning is handled by the method instead. The `customizer` is invoked with
  28141. * up to four arguments; (value [, index|key, object, stack]).
  28142. *
  28143. * @static
  28144. * @memberOf _
  28145. * @since 4.0.0
  28146. * @category Lang
  28147. * @param {*} value The value to clone.
  28148. * @param {Function} [customizer] The function to customize cloning.
  28149. * @returns {*} Returns the cloned value.
  28150. * @see _.cloneDeepWith
  28151. * @example
  28152. *
  28153. * function customizer(value) {
  28154. * if (_.isElement(value)) {
  28155. * return value.cloneNode(false);
  28156. * }
  28157. * }
  28158. *
  28159. * var el = _.cloneWith(document.body, customizer);
  28160. *
  28161. * console.log(el === document.body);
  28162. * // => false
  28163. * console.log(el.nodeName);
  28164. * // => 'BODY'
  28165. * console.log(el.childNodes.length);
  28166. * // => 0
  28167. */
  28168. function cloneWith(value, customizer) {
  28169. customizer = typeof customizer == 'function' ? customizer : undefined;
  28170. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28171. }
  28172. /**
  28173. * This method is like `_.clone` except that it recursively clones `value`.
  28174. *
  28175. * @static
  28176. * @memberOf _
  28177. * @since 1.0.0
  28178. * @category Lang
  28179. * @param {*} value The value to recursively clone.
  28180. * @returns {*} Returns the deep cloned value.
  28181. * @see _.clone
  28182. * @example
  28183. *
  28184. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28185. *
  28186. * var deep = _.cloneDeep(objects);
  28187. * console.log(deep[0] === objects[0]);
  28188. * // => false
  28189. */
  28190. function cloneDeep(value) {
  28191. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28192. }
  28193. /**
  28194. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28195. *
  28196. * @static
  28197. * @memberOf _
  28198. * @since 4.0.0
  28199. * @category Lang
  28200. * @param {*} value The value to recursively clone.
  28201. * @param {Function} [customizer] The function to customize cloning.
  28202. * @returns {*} Returns the deep cloned value.
  28203. * @see _.cloneWith
  28204. * @example
  28205. *
  28206. * function customizer(value) {
  28207. * if (_.isElement(value)) {
  28208. * return value.cloneNode(true);
  28209. * }
  28210. * }
  28211. *
  28212. * var el = _.cloneDeepWith(document.body, customizer);
  28213. *
  28214. * console.log(el === document.body);
  28215. * // => false
  28216. * console.log(el.nodeName);
  28217. * // => 'BODY'
  28218. * console.log(el.childNodes.length);
  28219. * // => 20
  28220. */
  28221. function cloneDeepWith(value, customizer) {
  28222. customizer = typeof customizer == 'function' ? customizer : undefined;
  28223. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28224. }
  28225. /**
  28226. * Checks if `object` conforms to `source` by invoking the predicate
  28227. * properties of `source` with the corresponding property values of `object`.
  28228. *
  28229. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28230. * partially applied.
  28231. *
  28232. * @static
  28233. * @memberOf _
  28234. * @since 4.14.0
  28235. * @category Lang
  28236. * @param {Object} object The object to inspect.
  28237. * @param {Object} source The object of property predicates to conform to.
  28238. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28239. * @example
  28240. *
  28241. * var object = { 'a': 1, 'b': 2 };
  28242. *
  28243. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28244. * // => true
  28245. *
  28246. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28247. * // => false
  28248. */
  28249. function conformsTo(object, source) {
  28250. return source == null || baseConformsTo(object, source, keys(source));
  28251. }
  28252. /**
  28253. * Performs a
  28254. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28255. * comparison between two values to determine if they are equivalent.
  28256. *
  28257. * @static
  28258. * @memberOf _
  28259. * @since 4.0.0
  28260. * @category Lang
  28261. * @param {*} value The value to compare.
  28262. * @param {*} other The other value to compare.
  28263. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28264. * @example
  28265. *
  28266. * var object = { 'a': 1 };
  28267. * var other = { 'a': 1 };
  28268. *
  28269. * _.eq(object, object);
  28270. * // => true
  28271. *
  28272. * _.eq(object, other);
  28273. * // => false
  28274. *
  28275. * _.eq('a', 'a');
  28276. * // => true
  28277. *
  28278. * _.eq('a', Object('a'));
  28279. * // => false
  28280. *
  28281. * _.eq(NaN, NaN);
  28282. * // => true
  28283. */
  28284. function eq(value, other) {
  28285. return value === other || (value !== value && other !== other);
  28286. }
  28287. /**
  28288. * Checks if `value` is greater than `other`.
  28289. *
  28290. * @static
  28291. * @memberOf _
  28292. * @since 3.9.0
  28293. * @category Lang
  28294. * @param {*} value The value to compare.
  28295. * @param {*} other The other value to compare.
  28296. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28297. * else `false`.
  28298. * @see _.lt
  28299. * @example
  28300. *
  28301. * _.gt(3, 1);
  28302. * // => true
  28303. *
  28304. * _.gt(3, 3);
  28305. * // => false
  28306. *
  28307. * _.gt(1, 3);
  28308. * // => false
  28309. */
  28310. var gt = createRelationalOperation(baseGt);
  28311. /**
  28312. * Checks if `value` is greater than or equal to `other`.
  28313. *
  28314. * @static
  28315. * @memberOf _
  28316. * @since 3.9.0
  28317. * @category Lang
  28318. * @param {*} value The value to compare.
  28319. * @param {*} other The other value to compare.
  28320. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28321. * `other`, else `false`.
  28322. * @see _.lte
  28323. * @example
  28324. *
  28325. * _.gte(3, 1);
  28326. * // => true
  28327. *
  28328. * _.gte(3, 3);
  28329. * // => true
  28330. *
  28331. * _.gte(1, 3);
  28332. * // => false
  28333. */
  28334. var gte = createRelationalOperation(function(value, other) {
  28335. return value >= other;
  28336. });
  28337. /**
  28338. * Checks if `value` is likely an `arguments` object.
  28339. *
  28340. * @static
  28341. * @memberOf _
  28342. * @since 0.1.0
  28343. * @category Lang
  28344. * @param {*} value The value to check.
  28345. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28346. * else `false`.
  28347. * @example
  28348. *
  28349. * _.isArguments(function() { return arguments; }());
  28350. * // => true
  28351. *
  28352. * _.isArguments([1, 2, 3]);
  28353. * // => false
  28354. */
  28355. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28356. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28357. !propertyIsEnumerable.call(value, 'callee');
  28358. };
  28359. /**
  28360. * Checks if `value` is classified as an `Array` object.
  28361. *
  28362. * @static
  28363. * @memberOf _
  28364. * @since 0.1.0
  28365. * @category Lang
  28366. * @param {*} value The value to check.
  28367. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28368. * @example
  28369. *
  28370. * _.isArray([1, 2, 3]);
  28371. * // => true
  28372. *
  28373. * _.isArray(document.body.children);
  28374. * // => false
  28375. *
  28376. * _.isArray('abc');
  28377. * // => false
  28378. *
  28379. * _.isArray(_.noop);
  28380. * // => false
  28381. */
  28382. var isArray = Array.isArray;
  28383. /**
  28384. * Checks if `value` is classified as an `ArrayBuffer` object.
  28385. *
  28386. * @static
  28387. * @memberOf _
  28388. * @since 4.3.0
  28389. * @category Lang
  28390. * @param {*} value The value to check.
  28391. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28392. * @example
  28393. *
  28394. * _.isArrayBuffer(new ArrayBuffer(2));
  28395. * // => true
  28396. *
  28397. * _.isArrayBuffer(new Array(2));
  28398. * // => false
  28399. */
  28400. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28401. /**
  28402. * Checks if `value` is array-like. A value is considered array-like if it's
  28403. * not a function and has a `value.length` that's an integer greater than or
  28404. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28405. *
  28406. * @static
  28407. * @memberOf _
  28408. * @since 4.0.0
  28409. * @category Lang
  28410. * @param {*} value The value to check.
  28411. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28412. * @example
  28413. *
  28414. * _.isArrayLike([1, 2, 3]);
  28415. * // => true
  28416. *
  28417. * _.isArrayLike(document.body.children);
  28418. * // => true
  28419. *
  28420. * _.isArrayLike('abc');
  28421. * // => true
  28422. *
  28423. * _.isArrayLike(_.noop);
  28424. * // => false
  28425. */
  28426. function isArrayLike(value) {
  28427. return value != null && isLength(value.length) && !isFunction(value);
  28428. }
  28429. /**
  28430. * This method is like `_.isArrayLike` except that it also checks if `value`
  28431. * is an object.
  28432. *
  28433. * @static
  28434. * @memberOf _
  28435. * @since 4.0.0
  28436. * @category Lang
  28437. * @param {*} value The value to check.
  28438. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28439. * else `false`.
  28440. * @example
  28441. *
  28442. * _.isArrayLikeObject([1, 2, 3]);
  28443. * // => true
  28444. *
  28445. * _.isArrayLikeObject(document.body.children);
  28446. * // => true
  28447. *
  28448. * _.isArrayLikeObject('abc');
  28449. * // => false
  28450. *
  28451. * _.isArrayLikeObject(_.noop);
  28452. * // => false
  28453. */
  28454. function isArrayLikeObject(value) {
  28455. return isObjectLike(value) && isArrayLike(value);
  28456. }
  28457. /**
  28458. * Checks if `value` is classified as a boolean primitive or object.
  28459. *
  28460. * @static
  28461. * @memberOf _
  28462. * @since 0.1.0
  28463. * @category Lang
  28464. * @param {*} value The value to check.
  28465. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28466. * @example
  28467. *
  28468. * _.isBoolean(false);
  28469. * // => true
  28470. *
  28471. * _.isBoolean(null);
  28472. * // => false
  28473. */
  28474. function isBoolean(value) {
  28475. return value === true || value === false ||
  28476. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28477. }
  28478. /**
  28479. * Checks if `value` is a buffer.
  28480. *
  28481. * @static
  28482. * @memberOf _
  28483. * @since 4.3.0
  28484. * @category Lang
  28485. * @param {*} value The value to check.
  28486. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28487. * @example
  28488. *
  28489. * _.isBuffer(new Buffer(2));
  28490. * // => true
  28491. *
  28492. * _.isBuffer(new Uint8Array(2));
  28493. * // => false
  28494. */
  28495. var isBuffer = nativeIsBuffer || stubFalse;
  28496. /**
  28497. * Checks if `value` is classified as a `Date` object.
  28498. *
  28499. * @static
  28500. * @memberOf _
  28501. * @since 0.1.0
  28502. * @category Lang
  28503. * @param {*} value The value to check.
  28504. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28505. * @example
  28506. *
  28507. * _.isDate(new Date);
  28508. * // => true
  28509. *
  28510. * _.isDate('Mon April 23 2012');
  28511. * // => false
  28512. */
  28513. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28514. /**
  28515. * Checks if `value` is likely a DOM element.
  28516. *
  28517. * @static
  28518. * @memberOf _
  28519. * @since 0.1.0
  28520. * @category Lang
  28521. * @param {*} value The value to check.
  28522. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28523. * @example
  28524. *
  28525. * _.isElement(document.body);
  28526. * // => true
  28527. *
  28528. * _.isElement('<body>');
  28529. * // => false
  28530. */
  28531. function isElement(value) {
  28532. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28533. }
  28534. /**
  28535. * Checks if `value` is an empty object, collection, map, or set.
  28536. *
  28537. * Objects are considered empty if they have no own enumerable string keyed
  28538. * properties.
  28539. *
  28540. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28541. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28542. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28543. *
  28544. * @static
  28545. * @memberOf _
  28546. * @since 0.1.0
  28547. * @category Lang
  28548. * @param {*} value The value to check.
  28549. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28550. * @example
  28551. *
  28552. * _.isEmpty(null);
  28553. * // => true
  28554. *
  28555. * _.isEmpty(true);
  28556. * // => true
  28557. *
  28558. * _.isEmpty(1);
  28559. * // => true
  28560. *
  28561. * _.isEmpty([1, 2, 3]);
  28562. * // => false
  28563. *
  28564. * _.isEmpty({ 'a': 1 });
  28565. * // => false
  28566. */
  28567. function isEmpty(value) {
  28568. if (value == null) {
  28569. return true;
  28570. }
  28571. if (isArrayLike(value) &&
  28572. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28573. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28574. return !value.length;
  28575. }
  28576. var tag = getTag(value);
  28577. if (tag == mapTag || tag == setTag) {
  28578. return !value.size;
  28579. }
  28580. if (isPrototype(value)) {
  28581. return !baseKeys(value).length;
  28582. }
  28583. for (var key in value) {
  28584. if (hasOwnProperty.call(value, key)) {
  28585. return false;
  28586. }
  28587. }
  28588. return true;
  28589. }
  28590. /**
  28591. * Performs a deep comparison between two values to determine if they are
  28592. * equivalent.
  28593. *
  28594. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28595. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28596. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28597. * by their own, not inherited, enumerable properties. Functions and DOM
  28598. * nodes are compared by strict equality, i.e. `===`.
  28599. *
  28600. * @static
  28601. * @memberOf _
  28602. * @since 0.1.0
  28603. * @category Lang
  28604. * @param {*} value The value to compare.
  28605. * @param {*} other The other value to compare.
  28606. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28607. * @example
  28608. *
  28609. * var object = { 'a': 1 };
  28610. * var other = { 'a': 1 };
  28611. *
  28612. * _.isEqual(object, other);
  28613. * // => true
  28614. *
  28615. * object === other;
  28616. * // => false
  28617. */
  28618. function isEqual(value, other) {
  28619. return baseIsEqual(value, other);
  28620. }
  28621. /**
  28622. * This method is like `_.isEqual` except that it accepts `customizer` which
  28623. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28624. * are handled by the method instead. The `customizer` is invoked with up to
  28625. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28626. *
  28627. * @static
  28628. * @memberOf _
  28629. * @since 4.0.0
  28630. * @category Lang
  28631. * @param {*} value The value to compare.
  28632. * @param {*} other The other value to compare.
  28633. * @param {Function} [customizer] The function to customize comparisons.
  28634. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28635. * @example
  28636. *
  28637. * function isGreeting(value) {
  28638. * return /^h(?:i|ello)$/.test(value);
  28639. * }
  28640. *
  28641. * function customizer(objValue, othValue) {
  28642. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28643. * return true;
  28644. * }
  28645. * }
  28646. *
  28647. * var array = ['hello', 'goodbye'];
  28648. * var other = ['hi', 'goodbye'];
  28649. *
  28650. * _.isEqualWith(array, other, customizer);
  28651. * // => true
  28652. */
  28653. function isEqualWith(value, other, customizer) {
  28654. customizer = typeof customizer == 'function' ? customizer : undefined;
  28655. var result = customizer ? customizer(value, other) : undefined;
  28656. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28657. }
  28658. /**
  28659. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28660. * `SyntaxError`, `TypeError`, or `URIError` object.
  28661. *
  28662. * @static
  28663. * @memberOf _
  28664. * @since 3.0.0
  28665. * @category Lang
  28666. * @param {*} value The value to check.
  28667. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28668. * @example
  28669. *
  28670. * _.isError(new Error);
  28671. * // => true
  28672. *
  28673. * _.isError(Error);
  28674. * // => false
  28675. */
  28676. function isError(value) {
  28677. if (!isObjectLike(value)) {
  28678. return false;
  28679. }
  28680. var tag = baseGetTag(value);
  28681. return tag == errorTag || tag == domExcTag ||
  28682. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28683. }
  28684. /**
  28685. * Checks if `value` is a finite primitive number.
  28686. *
  28687. * **Note:** This method is based on
  28688. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28689. *
  28690. * @static
  28691. * @memberOf _
  28692. * @since 0.1.0
  28693. * @category Lang
  28694. * @param {*} value The value to check.
  28695. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28696. * @example
  28697. *
  28698. * _.isFinite(3);
  28699. * // => true
  28700. *
  28701. * _.isFinite(Number.MIN_VALUE);
  28702. * // => true
  28703. *
  28704. * _.isFinite(Infinity);
  28705. * // => false
  28706. *
  28707. * _.isFinite('3');
  28708. * // => false
  28709. */
  28710. function isFinite(value) {
  28711. return typeof value == 'number' && nativeIsFinite(value);
  28712. }
  28713. /**
  28714. * Checks if `value` is classified as a `Function` object.
  28715. *
  28716. * @static
  28717. * @memberOf _
  28718. * @since 0.1.0
  28719. * @category Lang
  28720. * @param {*} value The value to check.
  28721. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28722. * @example
  28723. *
  28724. * _.isFunction(_);
  28725. * // => true
  28726. *
  28727. * _.isFunction(/abc/);
  28728. * // => false
  28729. */
  28730. function isFunction(value) {
  28731. if (!isObject(value)) {
  28732. return false;
  28733. }
  28734. // The use of `Object#toString` avoids issues with the `typeof` operator
  28735. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28736. var tag = baseGetTag(value);
  28737. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28738. }
  28739. /**
  28740. * Checks if `value` is an integer.
  28741. *
  28742. * **Note:** This method is based on
  28743. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28744. *
  28745. * @static
  28746. * @memberOf _
  28747. * @since 4.0.0
  28748. * @category Lang
  28749. * @param {*} value The value to check.
  28750. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28751. * @example
  28752. *
  28753. * _.isInteger(3);
  28754. * // => true
  28755. *
  28756. * _.isInteger(Number.MIN_VALUE);
  28757. * // => false
  28758. *
  28759. * _.isInteger(Infinity);
  28760. * // => false
  28761. *
  28762. * _.isInteger('3');
  28763. * // => false
  28764. */
  28765. function isInteger(value) {
  28766. return typeof value == 'number' && value == toInteger(value);
  28767. }
  28768. /**
  28769. * Checks if `value` is a valid array-like length.
  28770. *
  28771. * **Note:** This method is loosely based on
  28772. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28773. *
  28774. * @static
  28775. * @memberOf _
  28776. * @since 4.0.0
  28777. * @category Lang
  28778. * @param {*} value The value to check.
  28779. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28780. * @example
  28781. *
  28782. * _.isLength(3);
  28783. * // => true
  28784. *
  28785. * _.isLength(Number.MIN_VALUE);
  28786. * // => false
  28787. *
  28788. * _.isLength(Infinity);
  28789. * // => false
  28790. *
  28791. * _.isLength('3');
  28792. * // => false
  28793. */
  28794. function isLength(value) {
  28795. return typeof value == 'number' &&
  28796. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28797. }
  28798. /**
  28799. * Checks if `value` is the
  28800. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28801. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28802. *
  28803. * @static
  28804. * @memberOf _
  28805. * @since 0.1.0
  28806. * @category Lang
  28807. * @param {*} value The value to check.
  28808. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28809. * @example
  28810. *
  28811. * _.isObject({});
  28812. * // => true
  28813. *
  28814. * _.isObject([1, 2, 3]);
  28815. * // => true
  28816. *
  28817. * _.isObject(_.noop);
  28818. * // => true
  28819. *
  28820. * _.isObject(null);
  28821. * // => false
  28822. */
  28823. function isObject(value) {
  28824. var type = typeof value;
  28825. return value != null && (type == 'object' || type == 'function');
  28826. }
  28827. /**
  28828. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28829. * and has a `typeof` result of "object".
  28830. *
  28831. * @static
  28832. * @memberOf _
  28833. * @since 4.0.0
  28834. * @category Lang
  28835. * @param {*} value The value to check.
  28836. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28837. * @example
  28838. *
  28839. * _.isObjectLike({});
  28840. * // => true
  28841. *
  28842. * _.isObjectLike([1, 2, 3]);
  28843. * // => true
  28844. *
  28845. * _.isObjectLike(_.noop);
  28846. * // => false
  28847. *
  28848. * _.isObjectLike(null);
  28849. * // => false
  28850. */
  28851. function isObjectLike(value) {
  28852. return value != null && typeof value == 'object';
  28853. }
  28854. /**
  28855. * Checks if `value` is classified as a `Map` object.
  28856. *
  28857. * @static
  28858. * @memberOf _
  28859. * @since 4.3.0
  28860. * @category Lang
  28861. * @param {*} value The value to check.
  28862. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28863. * @example
  28864. *
  28865. * _.isMap(new Map);
  28866. * // => true
  28867. *
  28868. * _.isMap(new WeakMap);
  28869. * // => false
  28870. */
  28871. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28872. /**
  28873. * Performs a partial deep comparison between `object` and `source` to
  28874. * determine if `object` contains equivalent property values.
  28875. *
  28876. * **Note:** This method is equivalent to `_.matches` when `source` is
  28877. * partially applied.
  28878. *
  28879. * Partial comparisons will match empty array and empty object `source`
  28880. * values against any array or object value, respectively. See `_.isEqual`
  28881. * for a list of supported value comparisons.
  28882. *
  28883. * @static
  28884. * @memberOf _
  28885. * @since 3.0.0
  28886. * @category Lang
  28887. * @param {Object} object The object to inspect.
  28888. * @param {Object} source The object of property values to match.
  28889. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28890. * @example
  28891. *
  28892. * var object = { 'a': 1, 'b': 2 };
  28893. *
  28894. * _.isMatch(object, { 'b': 2 });
  28895. * // => true
  28896. *
  28897. * _.isMatch(object, { 'b': 1 });
  28898. * // => false
  28899. */
  28900. function isMatch(object, source) {
  28901. return object === source || baseIsMatch(object, source, getMatchData(source));
  28902. }
  28903. /**
  28904. * This method is like `_.isMatch` except that it accepts `customizer` which
  28905. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28906. * are handled by the method instead. The `customizer` is invoked with five
  28907. * arguments: (objValue, srcValue, index|key, object, source).
  28908. *
  28909. * @static
  28910. * @memberOf _
  28911. * @since 4.0.0
  28912. * @category Lang
  28913. * @param {Object} object The object to inspect.
  28914. * @param {Object} source The object of property values to match.
  28915. * @param {Function} [customizer] The function to customize comparisons.
  28916. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28917. * @example
  28918. *
  28919. * function isGreeting(value) {
  28920. * return /^h(?:i|ello)$/.test(value);
  28921. * }
  28922. *
  28923. * function customizer(objValue, srcValue) {
  28924. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28925. * return true;
  28926. * }
  28927. * }
  28928. *
  28929. * var object = { 'greeting': 'hello' };
  28930. * var source = { 'greeting': 'hi' };
  28931. *
  28932. * _.isMatchWith(object, source, customizer);
  28933. * // => true
  28934. */
  28935. function isMatchWith(object, source, customizer) {
  28936. customizer = typeof customizer == 'function' ? customizer : undefined;
  28937. return baseIsMatch(object, source, getMatchData(source), customizer);
  28938. }
  28939. /**
  28940. * Checks if `value` is `NaN`.
  28941. *
  28942. * **Note:** This method is based on
  28943. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28944. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28945. * `undefined` and other non-number values.
  28946. *
  28947. * @static
  28948. * @memberOf _
  28949. * @since 0.1.0
  28950. * @category Lang
  28951. * @param {*} value The value to check.
  28952. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28953. * @example
  28954. *
  28955. * _.isNaN(NaN);
  28956. * // => true
  28957. *
  28958. * _.isNaN(new Number(NaN));
  28959. * // => true
  28960. *
  28961. * isNaN(undefined);
  28962. * // => true
  28963. *
  28964. * _.isNaN(undefined);
  28965. * // => false
  28966. */
  28967. function isNaN(value) {
  28968. // An `NaN` primitive is the only value that is not equal to itself.
  28969. // Perform the `toStringTag` check first to avoid errors with some
  28970. // ActiveX objects in IE.
  28971. return isNumber(value) && value != +value;
  28972. }
  28973. /**
  28974. * Checks if `value` is a pristine native function.
  28975. *
  28976. * **Note:** This method can't reliably detect native functions in the presence
  28977. * of the core-js package because core-js circumvents this kind of detection.
  28978. * Despite multiple requests, the core-js maintainer has made it clear: any
  28979. * attempt to fix the detection will be obstructed. As a result, we're left
  28980. * with little choice but to throw an error. Unfortunately, this also affects
  28981. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28982. * which rely on core-js.
  28983. *
  28984. * @static
  28985. * @memberOf _
  28986. * @since 3.0.0
  28987. * @category Lang
  28988. * @param {*} value The value to check.
  28989. * @returns {boolean} Returns `true` if `value` is a native function,
  28990. * else `false`.
  28991. * @example
  28992. *
  28993. * _.isNative(Array.prototype.push);
  28994. * // => true
  28995. *
  28996. * _.isNative(_);
  28997. * // => false
  28998. */
  28999. function isNative(value) {
  29000. if (isMaskable(value)) {
  29001. throw new Error(CORE_ERROR_TEXT);
  29002. }
  29003. return baseIsNative(value);
  29004. }
  29005. /**
  29006. * Checks if `value` is `null`.
  29007. *
  29008. * @static
  29009. * @memberOf _
  29010. * @since 0.1.0
  29011. * @category Lang
  29012. * @param {*} value The value to check.
  29013. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  29014. * @example
  29015. *
  29016. * _.isNull(null);
  29017. * // => true
  29018. *
  29019. * _.isNull(void 0);
  29020. * // => false
  29021. */
  29022. function isNull(value) {
  29023. return value === null;
  29024. }
  29025. /**
  29026. * Checks if `value` is `null` or `undefined`.
  29027. *
  29028. * @static
  29029. * @memberOf _
  29030. * @since 4.0.0
  29031. * @category Lang
  29032. * @param {*} value The value to check.
  29033. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  29034. * @example
  29035. *
  29036. * _.isNil(null);
  29037. * // => true
  29038. *
  29039. * _.isNil(void 0);
  29040. * // => true
  29041. *
  29042. * _.isNil(NaN);
  29043. * // => false
  29044. */
  29045. function isNil(value) {
  29046. return value == null;
  29047. }
  29048. /**
  29049. * Checks if `value` is classified as a `Number` primitive or object.
  29050. *
  29051. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  29052. * classified as numbers, use the `_.isFinite` method.
  29053. *
  29054. * @static
  29055. * @memberOf _
  29056. * @since 0.1.0
  29057. * @category Lang
  29058. * @param {*} value The value to check.
  29059. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  29060. * @example
  29061. *
  29062. * _.isNumber(3);
  29063. * // => true
  29064. *
  29065. * _.isNumber(Number.MIN_VALUE);
  29066. * // => true
  29067. *
  29068. * _.isNumber(Infinity);
  29069. * // => true
  29070. *
  29071. * _.isNumber('3');
  29072. * // => false
  29073. */
  29074. function isNumber(value) {
  29075. return typeof value == 'number' ||
  29076. (isObjectLike(value) && baseGetTag(value) == numberTag);
  29077. }
  29078. /**
  29079. * Checks if `value` is a plain object, that is, an object created by the
  29080. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  29081. *
  29082. * @static
  29083. * @memberOf _
  29084. * @since 0.8.0
  29085. * @category Lang
  29086. * @param {*} value The value to check.
  29087. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  29088. * @example
  29089. *
  29090. * function Foo() {
  29091. * this.a = 1;
  29092. * }
  29093. *
  29094. * _.isPlainObject(new Foo);
  29095. * // => false
  29096. *
  29097. * _.isPlainObject([1, 2, 3]);
  29098. * // => false
  29099. *
  29100. * _.isPlainObject({ 'x': 0, 'y': 0 });
  29101. * // => true
  29102. *
  29103. * _.isPlainObject(Object.create(null));
  29104. * // => true
  29105. */
  29106. function isPlainObject(value) {
  29107. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  29108. return false;
  29109. }
  29110. var proto = getPrototype(value);
  29111. if (proto === null) {
  29112. return true;
  29113. }
  29114. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  29115. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  29116. funcToString.call(Ctor) == objectCtorString;
  29117. }
  29118. /**
  29119. * Checks if `value` is classified as a `RegExp` object.
  29120. *
  29121. * @static
  29122. * @memberOf _
  29123. * @since 0.1.0
  29124. * @category Lang
  29125. * @param {*} value The value to check.
  29126. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  29127. * @example
  29128. *
  29129. * _.isRegExp(/abc/);
  29130. * // => true
  29131. *
  29132. * _.isRegExp('/abc/');
  29133. * // => false
  29134. */
  29135. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29136. /**
  29137. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29138. * double precision number which isn't the result of a rounded unsafe integer.
  29139. *
  29140. * **Note:** This method is based on
  29141. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29142. *
  29143. * @static
  29144. * @memberOf _
  29145. * @since 4.0.0
  29146. * @category Lang
  29147. * @param {*} value The value to check.
  29148. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29149. * @example
  29150. *
  29151. * _.isSafeInteger(3);
  29152. * // => true
  29153. *
  29154. * _.isSafeInteger(Number.MIN_VALUE);
  29155. * // => false
  29156. *
  29157. * _.isSafeInteger(Infinity);
  29158. * // => false
  29159. *
  29160. * _.isSafeInteger('3');
  29161. * // => false
  29162. */
  29163. function isSafeInteger(value) {
  29164. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29165. }
  29166. /**
  29167. * Checks if `value` is classified as a `Set` object.
  29168. *
  29169. * @static
  29170. * @memberOf _
  29171. * @since 4.3.0
  29172. * @category Lang
  29173. * @param {*} value The value to check.
  29174. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29175. * @example
  29176. *
  29177. * _.isSet(new Set);
  29178. * // => true
  29179. *
  29180. * _.isSet(new WeakSet);
  29181. * // => false
  29182. */
  29183. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29184. /**
  29185. * Checks if `value` is classified as a `String` primitive or object.
  29186. *
  29187. * @static
  29188. * @since 0.1.0
  29189. * @memberOf _
  29190. * @category Lang
  29191. * @param {*} value The value to check.
  29192. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29193. * @example
  29194. *
  29195. * _.isString('abc');
  29196. * // => true
  29197. *
  29198. * _.isString(1);
  29199. * // => false
  29200. */
  29201. function isString(value) {
  29202. return typeof value == 'string' ||
  29203. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29204. }
  29205. /**
  29206. * Checks if `value` is classified as a `Symbol` primitive or object.
  29207. *
  29208. * @static
  29209. * @memberOf _
  29210. * @since 4.0.0
  29211. * @category Lang
  29212. * @param {*} value The value to check.
  29213. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29214. * @example
  29215. *
  29216. * _.isSymbol(Symbol.iterator);
  29217. * // => true
  29218. *
  29219. * _.isSymbol('abc');
  29220. * // => false
  29221. */
  29222. function isSymbol(value) {
  29223. return typeof value == 'symbol' ||
  29224. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29225. }
  29226. /**
  29227. * Checks if `value` is classified as a typed array.
  29228. *
  29229. * @static
  29230. * @memberOf _
  29231. * @since 3.0.0
  29232. * @category Lang
  29233. * @param {*} value The value to check.
  29234. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29235. * @example
  29236. *
  29237. * _.isTypedArray(new Uint8Array);
  29238. * // => true
  29239. *
  29240. * _.isTypedArray([]);
  29241. * // => false
  29242. */
  29243. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29244. /**
  29245. * Checks if `value` is `undefined`.
  29246. *
  29247. * @static
  29248. * @since 0.1.0
  29249. * @memberOf _
  29250. * @category Lang
  29251. * @param {*} value The value to check.
  29252. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29253. * @example
  29254. *
  29255. * _.isUndefined(void 0);
  29256. * // => true
  29257. *
  29258. * _.isUndefined(null);
  29259. * // => false
  29260. */
  29261. function isUndefined(value) {
  29262. return value === undefined;
  29263. }
  29264. /**
  29265. * Checks if `value` is classified as a `WeakMap` object.
  29266. *
  29267. * @static
  29268. * @memberOf _
  29269. * @since 4.3.0
  29270. * @category Lang
  29271. * @param {*} value The value to check.
  29272. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29273. * @example
  29274. *
  29275. * _.isWeakMap(new WeakMap);
  29276. * // => true
  29277. *
  29278. * _.isWeakMap(new Map);
  29279. * // => false
  29280. */
  29281. function isWeakMap(value) {
  29282. return isObjectLike(value) && getTag(value) == weakMapTag;
  29283. }
  29284. /**
  29285. * Checks if `value` is classified as a `WeakSet` object.
  29286. *
  29287. * @static
  29288. * @memberOf _
  29289. * @since 4.3.0
  29290. * @category Lang
  29291. * @param {*} value The value to check.
  29292. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29293. * @example
  29294. *
  29295. * _.isWeakSet(new WeakSet);
  29296. * // => true
  29297. *
  29298. * _.isWeakSet(new Set);
  29299. * // => false
  29300. */
  29301. function isWeakSet(value) {
  29302. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29303. }
  29304. /**
  29305. * Checks if `value` is less than `other`.
  29306. *
  29307. * @static
  29308. * @memberOf _
  29309. * @since 3.9.0
  29310. * @category Lang
  29311. * @param {*} value The value to compare.
  29312. * @param {*} other The other value to compare.
  29313. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29314. * else `false`.
  29315. * @see _.gt
  29316. * @example
  29317. *
  29318. * _.lt(1, 3);
  29319. * // => true
  29320. *
  29321. * _.lt(3, 3);
  29322. * // => false
  29323. *
  29324. * _.lt(3, 1);
  29325. * // => false
  29326. */
  29327. var lt = createRelationalOperation(baseLt);
  29328. /**
  29329. * Checks if `value` is less than or equal to `other`.
  29330. *
  29331. * @static
  29332. * @memberOf _
  29333. * @since 3.9.0
  29334. * @category Lang
  29335. * @param {*} value The value to compare.
  29336. * @param {*} other The other value to compare.
  29337. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29338. * `other`, else `false`.
  29339. * @see _.gte
  29340. * @example
  29341. *
  29342. * _.lte(1, 3);
  29343. * // => true
  29344. *
  29345. * _.lte(3, 3);
  29346. * // => true
  29347. *
  29348. * _.lte(3, 1);
  29349. * // => false
  29350. */
  29351. var lte = createRelationalOperation(function(value, other) {
  29352. return value <= other;
  29353. });
  29354. /**
  29355. * Converts `value` to an array.
  29356. *
  29357. * @static
  29358. * @since 0.1.0
  29359. * @memberOf _
  29360. * @category Lang
  29361. * @param {*} value The value to convert.
  29362. * @returns {Array} Returns the converted array.
  29363. * @example
  29364. *
  29365. * _.toArray({ 'a': 1, 'b': 2 });
  29366. * // => [1, 2]
  29367. *
  29368. * _.toArray('abc');
  29369. * // => ['a', 'b', 'c']
  29370. *
  29371. * _.toArray(1);
  29372. * // => []
  29373. *
  29374. * _.toArray(null);
  29375. * // => []
  29376. */
  29377. function toArray(value) {
  29378. if (!value) {
  29379. return [];
  29380. }
  29381. if (isArrayLike(value)) {
  29382. return isString(value) ? stringToArray(value) : copyArray(value);
  29383. }
  29384. if (symIterator && value[symIterator]) {
  29385. return iteratorToArray(value[symIterator]());
  29386. }
  29387. var tag = getTag(value),
  29388. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29389. return func(value);
  29390. }
  29391. /**
  29392. * Converts `value` to a finite number.
  29393. *
  29394. * @static
  29395. * @memberOf _
  29396. * @since 4.12.0
  29397. * @category Lang
  29398. * @param {*} value The value to convert.
  29399. * @returns {number} Returns the converted number.
  29400. * @example
  29401. *
  29402. * _.toFinite(3.2);
  29403. * // => 3.2
  29404. *
  29405. * _.toFinite(Number.MIN_VALUE);
  29406. * // => 5e-324
  29407. *
  29408. * _.toFinite(Infinity);
  29409. * // => 1.7976931348623157e+308
  29410. *
  29411. * _.toFinite('3.2');
  29412. * // => 3.2
  29413. */
  29414. function toFinite(value) {
  29415. if (!value) {
  29416. return value === 0 ? value : 0;
  29417. }
  29418. value = toNumber(value);
  29419. if (value === INFINITY || value === -INFINITY) {
  29420. var sign = (value < 0 ? -1 : 1);
  29421. return sign * MAX_INTEGER;
  29422. }
  29423. return value === value ? value : 0;
  29424. }
  29425. /**
  29426. * Converts `value` to an integer.
  29427. *
  29428. * **Note:** This method is loosely based on
  29429. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29430. *
  29431. * @static
  29432. * @memberOf _
  29433. * @since 4.0.0
  29434. * @category Lang
  29435. * @param {*} value The value to convert.
  29436. * @returns {number} Returns the converted integer.
  29437. * @example
  29438. *
  29439. * _.toInteger(3.2);
  29440. * // => 3
  29441. *
  29442. * _.toInteger(Number.MIN_VALUE);
  29443. * // => 0
  29444. *
  29445. * _.toInteger(Infinity);
  29446. * // => 1.7976931348623157e+308
  29447. *
  29448. * _.toInteger('3.2');
  29449. * // => 3
  29450. */
  29451. function toInteger(value) {
  29452. var result = toFinite(value),
  29453. remainder = result % 1;
  29454. return result === result ? (remainder ? result - remainder : result) : 0;
  29455. }
  29456. /**
  29457. * Converts `value` to an integer suitable for use as the length of an
  29458. * array-like object.
  29459. *
  29460. * **Note:** This method is based on
  29461. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29462. *
  29463. * @static
  29464. * @memberOf _
  29465. * @since 4.0.0
  29466. * @category Lang
  29467. * @param {*} value The value to convert.
  29468. * @returns {number} Returns the converted integer.
  29469. * @example
  29470. *
  29471. * _.toLength(3.2);
  29472. * // => 3
  29473. *
  29474. * _.toLength(Number.MIN_VALUE);
  29475. * // => 0
  29476. *
  29477. * _.toLength(Infinity);
  29478. * // => 4294967295
  29479. *
  29480. * _.toLength('3.2');
  29481. * // => 3
  29482. */
  29483. function toLength(value) {
  29484. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29485. }
  29486. /**
  29487. * Converts `value` to a number.
  29488. *
  29489. * @static
  29490. * @memberOf _
  29491. * @since 4.0.0
  29492. * @category Lang
  29493. * @param {*} value The value to process.
  29494. * @returns {number} Returns the number.
  29495. * @example
  29496. *
  29497. * _.toNumber(3.2);
  29498. * // => 3.2
  29499. *
  29500. * _.toNumber(Number.MIN_VALUE);
  29501. * // => 5e-324
  29502. *
  29503. * _.toNumber(Infinity);
  29504. * // => Infinity
  29505. *
  29506. * _.toNumber('3.2');
  29507. * // => 3.2
  29508. */
  29509. function toNumber(value) {
  29510. if (typeof value == 'number') {
  29511. return value;
  29512. }
  29513. if (isSymbol(value)) {
  29514. return NAN;
  29515. }
  29516. if (isObject(value)) {
  29517. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29518. value = isObject(other) ? (other + '') : other;
  29519. }
  29520. if (typeof value != 'string') {
  29521. return value === 0 ? value : +value;
  29522. }
  29523. value = value.replace(reTrim, '');
  29524. var isBinary = reIsBinary.test(value);
  29525. return (isBinary || reIsOctal.test(value))
  29526. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29527. : (reIsBadHex.test(value) ? NAN : +value);
  29528. }
  29529. /**
  29530. * Converts `value` to a plain object flattening inherited enumerable string
  29531. * keyed properties of `value` to own properties of the plain object.
  29532. *
  29533. * @static
  29534. * @memberOf _
  29535. * @since 3.0.0
  29536. * @category Lang
  29537. * @param {*} value The value to convert.
  29538. * @returns {Object} Returns the converted plain object.
  29539. * @example
  29540. *
  29541. * function Foo() {
  29542. * this.b = 2;
  29543. * }
  29544. *
  29545. * Foo.prototype.c = 3;
  29546. *
  29547. * _.assign({ 'a': 1 }, new Foo);
  29548. * // => { 'a': 1, 'b': 2 }
  29549. *
  29550. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29551. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29552. */
  29553. function toPlainObject(value) {
  29554. return copyObject(value, keysIn(value));
  29555. }
  29556. /**
  29557. * Converts `value` to a safe integer. A safe integer can be compared and
  29558. * represented correctly.
  29559. *
  29560. * @static
  29561. * @memberOf _
  29562. * @since 4.0.0
  29563. * @category Lang
  29564. * @param {*} value The value to convert.
  29565. * @returns {number} Returns the converted integer.
  29566. * @example
  29567. *
  29568. * _.toSafeInteger(3.2);
  29569. * // => 3
  29570. *
  29571. * _.toSafeInteger(Number.MIN_VALUE);
  29572. * // => 0
  29573. *
  29574. * _.toSafeInteger(Infinity);
  29575. * // => 9007199254740991
  29576. *
  29577. * _.toSafeInteger('3.2');
  29578. * // => 3
  29579. */
  29580. function toSafeInteger(value) {
  29581. return value
  29582. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29583. : (value === 0 ? value : 0);
  29584. }
  29585. /**
  29586. * Converts `value` to a string. An empty string is returned for `null`
  29587. * and `undefined` values. The sign of `-0` is preserved.
  29588. *
  29589. * @static
  29590. * @memberOf _
  29591. * @since 4.0.0
  29592. * @category Lang
  29593. * @param {*} value The value to convert.
  29594. * @returns {string} Returns the converted string.
  29595. * @example
  29596. *
  29597. * _.toString(null);
  29598. * // => ''
  29599. *
  29600. * _.toString(-0);
  29601. * // => '-0'
  29602. *
  29603. * _.toString([1, 2, 3]);
  29604. * // => '1,2,3'
  29605. */
  29606. function toString(value) {
  29607. return value == null ? '' : baseToString(value);
  29608. }
  29609. /*------------------------------------------------------------------------*/
  29610. /**
  29611. * Assigns own enumerable string keyed properties of source objects to the
  29612. * destination object. Source objects are applied from left to right.
  29613. * Subsequent sources overwrite property assignments of previous sources.
  29614. *
  29615. * **Note:** This method mutates `object` and is loosely based on
  29616. * [`Object.assign`](https://mdn.io/Object/assign).
  29617. *
  29618. * @static
  29619. * @memberOf _
  29620. * @since 0.10.0
  29621. * @category Object
  29622. * @param {Object} object The destination object.
  29623. * @param {...Object} [sources] The source objects.
  29624. * @returns {Object} Returns `object`.
  29625. * @see _.assignIn
  29626. * @example
  29627. *
  29628. * function Foo() {
  29629. * this.a = 1;
  29630. * }
  29631. *
  29632. * function Bar() {
  29633. * this.c = 3;
  29634. * }
  29635. *
  29636. * Foo.prototype.b = 2;
  29637. * Bar.prototype.d = 4;
  29638. *
  29639. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29640. * // => { 'a': 1, 'c': 3 }
  29641. */
  29642. var assign = createAssigner(function(object, source) {
  29643. if (isPrototype(source) || isArrayLike(source)) {
  29644. copyObject(source, keys(source), object);
  29645. return;
  29646. }
  29647. for (var key in source) {
  29648. if (hasOwnProperty.call(source, key)) {
  29649. assignValue(object, key, source[key]);
  29650. }
  29651. }
  29652. });
  29653. /**
  29654. * This method is like `_.assign` except that it iterates over own and
  29655. * inherited source properties.
  29656. *
  29657. * **Note:** This method mutates `object`.
  29658. *
  29659. * @static
  29660. * @memberOf _
  29661. * @since 4.0.0
  29662. * @alias extend
  29663. * @category Object
  29664. * @param {Object} object The destination object.
  29665. * @param {...Object} [sources] The source objects.
  29666. * @returns {Object} Returns `object`.
  29667. * @see _.assign
  29668. * @example
  29669. *
  29670. * function Foo() {
  29671. * this.a = 1;
  29672. * }
  29673. *
  29674. * function Bar() {
  29675. * this.c = 3;
  29676. * }
  29677. *
  29678. * Foo.prototype.b = 2;
  29679. * Bar.prototype.d = 4;
  29680. *
  29681. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29682. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29683. */
  29684. var assignIn = createAssigner(function(object, source) {
  29685. copyObject(source, keysIn(source), object);
  29686. });
  29687. /**
  29688. * This method is like `_.assignIn` except that it accepts `customizer`
  29689. * which is invoked to produce the assigned values. If `customizer` returns
  29690. * `undefined`, assignment is handled by the method instead. The `customizer`
  29691. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29692. *
  29693. * **Note:** This method mutates `object`.
  29694. *
  29695. * @static
  29696. * @memberOf _
  29697. * @since 4.0.0
  29698. * @alias extendWith
  29699. * @category Object
  29700. * @param {Object} object The destination object.
  29701. * @param {...Object} sources The source objects.
  29702. * @param {Function} [customizer] The function to customize assigned values.
  29703. * @returns {Object} Returns `object`.
  29704. * @see _.assignWith
  29705. * @example
  29706. *
  29707. * function customizer(objValue, srcValue) {
  29708. * return _.isUndefined(objValue) ? srcValue : objValue;
  29709. * }
  29710. *
  29711. * var defaults = _.partialRight(_.assignInWith, customizer);
  29712. *
  29713. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29714. * // => { 'a': 1, 'b': 2 }
  29715. */
  29716. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29717. copyObject(source, keysIn(source), object, customizer);
  29718. });
  29719. /**
  29720. * This method is like `_.assign` except that it accepts `customizer`
  29721. * which is invoked to produce the assigned values. If `customizer` returns
  29722. * `undefined`, assignment is handled by the method instead. The `customizer`
  29723. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29724. *
  29725. * **Note:** This method mutates `object`.
  29726. *
  29727. * @static
  29728. * @memberOf _
  29729. * @since 4.0.0
  29730. * @category Object
  29731. * @param {Object} object The destination object.
  29732. * @param {...Object} sources The source objects.
  29733. * @param {Function} [customizer] The function to customize assigned values.
  29734. * @returns {Object} Returns `object`.
  29735. * @see _.assignInWith
  29736. * @example
  29737. *
  29738. * function customizer(objValue, srcValue) {
  29739. * return _.isUndefined(objValue) ? srcValue : objValue;
  29740. * }
  29741. *
  29742. * var defaults = _.partialRight(_.assignWith, customizer);
  29743. *
  29744. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29745. * // => { 'a': 1, 'b': 2 }
  29746. */
  29747. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29748. copyObject(source, keys(source), object, customizer);
  29749. });
  29750. /**
  29751. * Creates an array of values corresponding to `paths` of `object`.
  29752. *
  29753. * @static
  29754. * @memberOf _
  29755. * @since 1.0.0
  29756. * @category Object
  29757. * @param {Object} object The object to iterate over.
  29758. * @param {...(string|string[])} [paths] The property paths to pick.
  29759. * @returns {Array} Returns the picked values.
  29760. * @example
  29761. *
  29762. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29763. *
  29764. * _.at(object, ['a[0].b.c', 'a[1]']);
  29765. * // => [3, 4]
  29766. */
  29767. var at = flatRest(baseAt);
  29768. /**
  29769. * Creates an object that inherits from the `prototype` object. If a
  29770. * `properties` object is given, its own enumerable string keyed properties
  29771. * are assigned to the created object.
  29772. *
  29773. * @static
  29774. * @memberOf _
  29775. * @since 2.3.0
  29776. * @category Object
  29777. * @param {Object} prototype The object to inherit from.
  29778. * @param {Object} [properties] The properties to assign to the object.
  29779. * @returns {Object} Returns the new object.
  29780. * @example
  29781. *
  29782. * function Shape() {
  29783. * this.x = 0;
  29784. * this.y = 0;
  29785. * }
  29786. *
  29787. * function Circle() {
  29788. * Shape.call(this);
  29789. * }
  29790. *
  29791. * Circle.prototype = _.create(Shape.prototype, {
  29792. * 'constructor': Circle
  29793. * });
  29794. *
  29795. * var circle = new Circle;
  29796. * circle instanceof Circle;
  29797. * // => true
  29798. *
  29799. * circle instanceof Shape;
  29800. * // => true
  29801. */
  29802. function create(prototype, properties) {
  29803. var result = baseCreate(prototype);
  29804. return properties == null ? result : baseAssign(result, properties);
  29805. }
  29806. /**
  29807. * Assigns own and inherited enumerable string keyed properties of source
  29808. * objects to the destination object for all destination properties that
  29809. * resolve to `undefined`. Source objects are applied from left to right.
  29810. * Once a property is set, additional values of the same property are ignored.
  29811. *
  29812. * **Note:** This method mutates `object`.
  29813. *
  29814. * @static
  29815. * @since 0.1.0
  29816. * @memberOf _
  29817. * @category Object
  29818. * @param {Object} object The destination object.
  29819. * @param {...Object} [sources] The source objects.
  29820. * @returns {Object} Returns `object`.
  29821. * @see _.defaultsDeep
  29822. * @example
  29823. *
  29824. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29825. * // => { 'a': 1, 'b': 2 }
  29826. */
  29827. var defaults = baseRest(function(object, sources) {
  29828. object = Object(object);
  29829. var index = -1;
  29830. var length = sources.length;
  29831. var guard = length > 2 ? sources[2] : undefined;
  29832. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29833. length = 1;
  29834. }
  29835. while (++index < length) {
  29836. var source = sources[index];
  29837. var props = keysIn(source);
  29838. var propsIndex = -1;
  29839. var propsLength = props.length;
  29840. while (++propsIndex < propsLength) {
  29841. var key = props[propsIndex];
  29842. var value = object[key];
  29843. if (value === undefined ||
  29844. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29845. object[key] = source[key];
  29846. }
  29847. }
  29848. }
  29849. return object;
  29850. });
  29851. /**
  29852. * This method is like `_.defaults` except that it recursively assigns
  29853. * default properties.
  29854. *
  29855. * **Note:** This method mutates `object`.
  29856. *
  29857. * @static
  29858. * @memberOf _
  29859. * @since 3.10.0
  29860. * @category Object
  29861. * @param {Object} object The destination object.
  29862. * @param {...Object} [sources] The source objects.
  29863. * @returns {Object} Returns `object`.
  29864. * @see _.defaults
  29865. * @example
  29866. *
  29867. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29868. * // => { 'a': { 'b': 2, 'c': 3 } }
  29869. */
  29870. var defaultsDeep = baseRest(function(args) {
  29871. args.push(undefined, customDefaultsMerge);
  29872. return apply(mergeWith, undefined, args);
  29873. });
  29874. /**
  29875. * This method is like `_.find` except that it returns the key of the first
  29876. * element `predicate` returns truthy for instead of the element itself.
  29877. *
  29878. * @static
  29879. * @memberOf _
  29880. * @since 1.1.0
  29881. * @category Object
  29882. * @param {Object} object The object to inspect.
  29883. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29884. * @returns {string|undefined} Returns the key of the matched element,
  29885. * else `undefined`.
  29886. * @example
  29887. *
  29888. * var users = {
  29889. * 'barney': { 'age': 36, 'active': true },
  29890. * 'fred': { 'age': 40, 'active': false },
  29891. * 'pebbles': { 'age': 1, 'active': true }
  29892. * };
  29893. *
  29894. * _.findKey(users, function(o) { return o.age < 40; });
  29895. * // => 'barney' (iteration order is not guaranteed)
  29896. *
  29897. * // The `_.matches` iteratee shorthand.
  29898. * _.findKey(users, { 'age': 1, 'active': true });
  29899. * // => 'pebbles'
  29900. *
  29901. * // The `_.matchesProperty` iteratee shorthand.
  29902. * _.findKey(users, ['active', false]);
  29903. * // => 'fred'
  29904. *
  29905. * // The `_.property` iteratee shorthand.
  29906. * _.findKey(users, 'active');
  29907. * // => 'barney'
  29908. */
  29909. function findKey(object, predicate) {
  29910. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29911. }
  29912. /**
  29913. * This method is like `_.findKey` except that it iterates over elements of
  29914. * a collection in the opposite order.
  29915. *
  29916. * @static
  29917. * @memberOf _
  29918. * @since 2.0.0
  29919. * @category Object
  29920. * @param {Object} object The object to inspect.
  29921. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29922. * @returns {string|undefined} Returns the key of the matched element,
  29923. * else `undefined`.
  29924. * @example
  29925. *
  29926. * var users = {
  29927. * 'barney': { 'age': 36, 'active': true },
  29928. * 'fred': { 'age': 40, 'active': false },
  29929. * 'pebbles': { 'age': 1, 'active': true }
  29930. * };
  29931. *
  29932. * _.findLastKey(users, function(o) { return o.age < 40; });
  29933. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29934. *
  29935. * // The `_.matches` iteratee shorthand.
  29936. * _.findLastKey(users, { 'age': 36, 'active': true });
  29937. * // => 'barney'
  29938. *
  29939. * // The `_.matchesProperty` iteratee shorthand.
  29940. * _.findLastKey(users, ['active', false]);
  29941. * // => 'fred'
  29942. *
  29943. * // The `_.property` iteratee shorthand.
  29944. * _.findLastKey(users, 'active');
  29945. * // => 'pebbles'
  29946. */
  29947. function findLastKey(object, predicate) {
  29948. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29949. }
  29950. /**
  29951. * Iterates over own and inherited enumerable string keyed properties of an
  29952. * object and invokes `iteratee` for each property. The iteratee is invoked
  29953. * with three arguments: (value, key, object). Iteratee functions may exit
  29954. * iteration early by explicitly returning `false`.
  29955. *
  29956. * @static
  29957. * @memberOf _
  29958. * @since 0.3.0
  29959. * @category Object
  29960. * @param {Object} object The object to iterate over.
  29961. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29962. * @returns {Object} Returns `object`.
  29963. * @see _.forInRight
  29964. * @example
  29965. *
  29966. * function Foo() {
  29967. * this.a = 1;
  29968. * this.b = 2;
  29969. * }
  29970. *
  29971. * Foo.prototype.c = 3;
  29972. *
  29973. * _.forIn(new Foo, function(value, key) {
  29974. * console.log(key);
  29975. * });
  29976. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29977. */
  29978. function forIn(object, iteratee) {
  29979. return object == null
  29980. ? object
  29981. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29982. }
  29983. /**
  29984. * This method is like `_.forIn` except that it iterates over properties of
  29985. * `object` in the opposite order.
  29986. *
  29987. * @static
  29988. * @memberOf _
  29989. * @since 2.0.0
  29990. * @category Object
  29991. * @param {Object} object The object to iterate over.
  29992. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29993. * @returns {Object} Returns `object`.
  29994. * @see _.forIn
  29995. * @example
  29996. *
  29997. * function Foo() {
  29998. * this.a = 1;
  29999. * this.b = 2;
  30000. * }
  30001. *
  30002. * Foo.prototype.c = 3;
  30003. *
  30004. * _.forInRight(new Foo, function(value, key) {
  30005. * console.log(key);
  30006. * });
  30007. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  30008. */
  30009. function forInRight(object, iteratee) {
  30010. return object == null
  30011. ? object
  30012. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  30013. }
  30014. /**
  30015. * Iterates over own enumerable string keyed properties of an object and
  30016. * invokes `iteratee` for each property. The iteratee is invoked with three
  30017. * arguments: (value, key, object). Iteratee functions may exit iteration
  30018. * early by explicitly returning `false`.
  30019. *
  30020. * @static
  30021. * @memberOf _
  30022. * @since 0.3.0
  30023. * @category Object
  30024. * @param {Object} object The object to iterate over.
  30025. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30026. * @returns {Object} Returns `object`.
  30027. * @see _.forOwnRight
  30028. * @example
  30029. *
  30030. * function Foo() {
  30031. * this.a = 1;
  30032. * this.b = 2;
  30033. * }
  30034. *
  30035. * Foo.prototype.c = 3;
  30036. *
  30037. * _.forOwn(new Foo, function(value, key) {
  30038. * console.log(key);
  30039. * });
  30040. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  30041. */
  30042. function forOwn(object, iteratee) {
  30043. return object && baseForOwn(object, getIteratee(iteratee, 3));
  30044. }
  30045. /**
  30046. * This method is like `_.forOwn` except that it iterates over properties of
  30047. * `object` in the opposite order.
  30048. *
  30049. * @static
  30050. * @memberOf _
  30051. * @since 2.0.0
  30052. * @category Object
  30053. * @param {Object} object The object to iterate over.
  30054. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30055. * @returns {Object} Returns `object`.
  30056. * @see _.forOwn
  30057. * @example
  30058. *
  30059. * function Foo() {
  30060. * this.a = 1;
  30061. * this.b = 2;
  30062. * }
  30063. *
  30064. * Foo.prototype.c = 3;
  30065. *
  30066. * _.forOwnRight(new Foo, function(value, key) {
  30067. * console.log(key);
  30068. * });
  30069. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  30070. */
  30071. function forOwnRight(object, iteratee) {
  30072. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  30073. }
  30074. /**
  30075. * Creates an array of function property names from own enumerable properties
  30076. * of `object`.
  30077. *
  30078. * @static
  30079. * @since 0.1.0
  30080. * @memberOf _
  30081. * @category Object
  30082. * @param {Object} object The object to inspect.
  30083. * @returns {Array} Returns the function names.
  30084. * @see _.functionsIn
  30085. * @example
  30086. *
  30087. * function Foo() {
  30088. * this.a = _.constant('a');
  30089. * this.b = _.constant('b');
  30090. * }
  30091. *
  30092. * Foo.prototype.c = _.constant('c');
  30093. *
  30094. * _.functions(new Foo);
  30095. * // => ['a', 'b']
  30096. */
  30097. function functions(object) {
  30098. return object == null ? [] : baseFunctions(object, keys(object));
  30099. }
  30100. /**
  30101. * Creates an array of function property names from own and inherited
  30102. * enumerable properties of `object`.
  30103. *
  30104. * @static
  30105. * @memberOf _
  30106. * @since 4.0.0
  30107. * @category Object
  30108. * @param {Object} object The object to inspect.
  30109. * @returns {Array} Returns the function names.
  30110. * @see _.functions
  30111. * @example
  30112. *
  30113. * function Foo() {
  30114. * this.a = _.constant('a');
  30115. * this.b = _.constant('b');
  30116. * }
  30117. *
  30118. * Foo.prototype.c = _.constant('c');
  30119. *
  30120. * _.functionsIn(new Foo);
  30121. * // => ['a', 'b', 'c']
  30122. */
  30123. function functionsIn(object) {
  30124. return object == null ? [] : baseFunctions(object, keysIn(object));
  30125. }
  30126. /**
  30127. * Gets the value at `path` of `object`. If the resolved value is
  30128. * `undefined`, the `defaultValue` is returned in its place.
  30129. *
  30130. * @static
  30131. * @memberOf _
  30132. * @since 3.7.0
  30133. * @category Object
  30134. * @param {Object} object The object to query.
  30135. * @param {Array|string} path The path of the property to get.
  30136. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30137. * @returns {*} Returns the resolved value.
  30138. * @example
  30139. *
  30140. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30141. *
  30142. * _.get(object, 'a[0].b.c');
  30143. * // => 3
  30144. *
  30145. * _.get(object, ['a', '0', 'b', 'c']);
  30146. * // => 3
  30147. *
  30148. * _.get(object, 'a.b.c', 'default');
  30149. * // => 'default'
  30150. */
  30151. function get(object, path, defaultValue) {
  30152. var result = object == null ? undefined : baseGet(object, path);
  30153. return result === undefined ? defaultValue : result;
  30154. }
  30155. /**
  30156. * Checks if `path` is a direct property of `object`.
  30157. *
  30158. * @static
  30159. * @since 0.1.0
  30160. * @memberOf _
  30161. * @category Object
  30162. * @param {Object} object The object to query.
  30163. * @param {Array|string} path The path to check.
  30164. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30165. * @example
  30166. *
  30167. * var object = { 'a': { 'b': 2 } };
  30168. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30169. *
  30170. * _.has(object, 'a');
  30171. * // => true
  30172. *
  30173. * _.has(object, 'a.b');
  30174. * // => true
  30175. *
  30176. * _.has(object, ['a', 'b']);
  30177. * // => true
  30178. *
  30179. * _.has(other, 'a');
  30180. * // => false
  30181. */
  30182. function has(object, path) {
  30183. return object != null && hasPath(object, path, baseHas);
  30184. }
  30185. /**
  30186. * Checks if `path` is a direct or inherited property of `object`.
  30187. *
  30188. * @static
  30189. * @memberOf _
  30190. * @since 4.0.0
  30191. * @category Object
  30192. * @param {Object} object The object to query.
  30193. * @param {Array|string} path The path to check.
  30194. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30195. * @example
  30196. *
  30197. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30198. *
  30199. * _.hasIn(object, 'a');
  30200. * // => true
  30201. *
  30202. * _.hasIn(object, 'a.b');
  30203. * // => true
  30204. *
  30205. * _.hasIn(object, ['a', 'b']);
  30206. * // => true
  30207. *
  30208. * _.hasIn(object, 'b');
  30209. * // => false
  30210. */
  30211. function hasIn(object, path) {
  30212. return object != null && hasPath(object, path, baseHasIn);
  30213. }
  30214. /**
  30215. * Creates an object composed of the inverted keys and values of `object`.
  30216. * If `object` contains duplicate values, subsequent values overwrite
  30217. * property assignments of previous values.
  30218. *
  30219. * @static
  30220. * @memberOf _
  30221. * @since 0.7.0
  30222. * @category Object
  30223. * @param {Object} object The object to invert.
  30224. * @returns {Object} Returns the new inverted object.
  30225. * @example
  30226. *
  30227. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30228. *
  30229. * _.invert(object);
  30230. * // => { '1': 'c', '2': 'b' }
  30231. */
  30232. var invert = createInverter(function(result, value, key) {
  30233. if (value != null &&
  30234. typeof value.toString != 'function') {
  30235. value = nativeObjectToString.call(value);
  30236. }
  30237. result[value] = key;
  30238. }, constant(identity));
  30239. /**
  30240. * This method is like `_.invert` except that the inverted object is generated
  30241. * from the results of running each element of `object` thru `iteratee`. The
  30242. * corresponding inverted value of each inverted key is an array of keys
  30243. * responsible for generating the inverted value. The iteratee is invoked
  30244. * with one argument: (value).
  30245. *
  30246. * @static
  30247. * @memberOf _
  30248. * @since 4.1.0
  30249. * @category Object
  30250. * @param {Object} object The object to invert.
  30251. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30252. * @returns {Object} Returns the new inverted object.
  30253. * @example
  30254. *
  30255. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30256. *
  30257. * _.invertBy(object);
  30258. * // => { '1': ['a', 'c'], '2': ['b'] }
  30259. *
  30260. * _.invertBy(object, function(value) {
  30261. * return 'group' + value;
  30262. * });
  30263. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30264. */
  30265. var invertBy = createInverter(function(result, value, key) {
  30266. if (value != null &&
  30267. typeof value.toString != 'function') {
  30268. value = nativeObjectToString.call(value);
  30269. }
  30270. if (hasOwnProperty.call(result, value)) {
  30271. result[value].push(key);
  30272. } else {
  30273. result[value] = [key];
  30274. }
  30275. }, getIteratee);
  30276. /**
  30277. * Invokes the method at `path` of `object`.
  30278. *
  30279. * @static
  30280. * @memberOf _
  30281. * @since 4.0.0
  30282. * @category Object
  30283. * @param {Object} object The object to query.
  30284. * @param {Array|string} path The path of the method to invoke.
  30285. * @param {...*} [args] The arguments to invoke the method with.
  30286. * @returns {*} Returns the result of the invoked method.
  30287. * @example
  30288. *
  30289. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30290. *
  30291. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30292. * // => [2, 3]
  30293. */
  30294. var invoke = baseRest(baseInvoke);
  30295. /**
  30296. * Creates an array of the own enumerable property names of `object`.
  30297. *
  30298. * **Note:** Non-object values are coerced to objects. See the
  30299. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30300. * for more details.
  30301. *
  30302. * @static
  30303. * @since 0.1.0
  30304. * @memberOf _
  30305. * @category Object
  30306. * @param {Object} object The object to query.
  30307. * @returns {Array} Returns the array of property names.
  30308. * @example
  30309. *
  30310. * function Foo() {
  30311. * this.a = 1;
  30312. * this.b = 2;
  30313. * }
  30314. *
  30315. * Foo.prototype.c = 3;
  30316. *
  30317. * _.keys(new Foo);
  30318. * // => ['a', 'b'] (iteration order is not guaranteed)
  30319. *
  30320. * _.keys('hi');
  30321. * // => ['0', '1']
  30322. */
  30323. function keys(object) {
  30324. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30325. }
  30326. /**
  30327. * Creates an array of the own and inherited enumerable property names of `object`.
  30328. *
  30329. * **Note:** Non-object values are coerced to objects.
  30330. *
  30331. * @static
  30332. * @memberOf _
  30333. * @since 3.0.0
  30334. * @category Object
  30335. * @param {Object} object The object to query.
  30336. * @returns {Array} Returns the array of property names.
  30337. * @example
  30338. *
  30339. * function Foo() {
  30340. * this.a = 1;
  30341. * this.b = 2;
  30342. * }
  30343. *
  30344. * Foo.prototype.c = 3;
  30345. *
  30346. * _.keysIn(new Foo);
  30347. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30348. */
  30349. function keysIn(object) {
  30350. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30351. }
  30352. /**
  30353. * The opposite of `_.mapValues`; this method creates an object with the
  30354. * same values as `object` and keys generated by running each own enumerable
  30355. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30356. * with three arguments: (value, key, object).
  30357. *
  30358. * @static
  30359. * @memberOf _
  30360. * @since 3.8.0
  30361. * @category Object
  30362. * @param {Object} object The object to iterate over.
  30363. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30364. * @returns {Object} Returns the new mapped object.
  30365. * @see _.mapValues
  30366. * @example
  30367. *
  30368. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30369. * return key + value;
  30370. * });
  30371. * // => { 'a1': 1, 'b2': 2 }
  30372. */
  30373. function mapKeys(object, iteratee) {
  30374. var result = {};
  30375. iteratee = getIteratee(iteratee, 3);
  30376. baseForOwn(object, function(value, key, object) {
  30377. baseAssignValue(result, iteratee(value, key, object), value);
  30378. });
  30379. return result;
  30380. }
  30381. /**
  30382. * Creates an object with the same keys as `object` and values generated
  30383. * by running each own enumerable string keyed property of `object` thru
  30384. * `iteratee`. The iteratee is invoked with three arguments:
  30385. * (value, key, object).
  30386. *
  30387. * @static
  30388. * @memberOf _
  30389. * @since 2.4.0
  30390. * @category Object
  30391. * @param {Object} object The object to iterate over.
  30392. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30393. * @returns {Object} Returns the new mapped object.
  30394. * @see _.mapKeys
  30395. * @example
  30396. *
  30397. * var users = {
  30398. * 'fred': { 'user': 'fred', 'age': 40 },
  30399. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30400. * };
  30401. *
  30402. * _.mapValues(users, function(o) { return o.age; });
  30403. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30404. *
  30405. * // The `_.property` iteratee shorthand.
  30406. * _.mapValues(users, 'age');
  30407. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30408. */
  30409. function mapValues(object, iteratee) {
  30410. var result = {};
  30411. iteratee = getIteratee(iteratee, 3);
  30412. baseForOwn(object, function(value, key, object) {
  30413. baseAssignValue(result, key, iteratee(value, key, object));
  30414. });
  30415. return result;
  30416. }
  30417. /**
  30418. * This method is like `_.assign` except that it recursively merges own and
  30419. * inherited enumerable string keyed properties of source objects into the
  30420. * destination object. Source properties that resolve to `undefined` are
  30421. * skipped if a destination value exists. Array and plain object properties
  30422. * are merged recursively. Other objects and value types are overridden by
  30423. * assignment. Source objects are applied from left to right. Subsequent
  30424. * sources overwrite property assignments of previous sources.
  30425. *
  30426. * **Note:** This method mutates `object`.
  30427. *
  30428. * @static
  30429. * @memberOf _
  30430. * @since 0.5.0
  30431. * @category Object
  30432. * @param {Object} object The destination object.
  30433. * @param {...Object} [sources] The source objects.
  30434. * @returns {Object} Returns `object`.
  30435. * @example
  30436. *
  30437. * var object = {
  30438. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30439. * };
  30440. *
  30441. * var other = {
  30442. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30443. * };
  30444. *
  30445. * _.merge(object, other);
  30446. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30447. */
  30448. var merge = createAssigner(function(object, source, srcIndex) {
  30449. baseMerge(object, source, srcIndex);
  30450. });
  30451. /**
  30452. * This method is like `_.merge` except that it accepts `customizer` which
  30453. * is invoked to produce the merged values of the destination and source
  30454. * properties. If `customizer` returns `undefined`, merging is handled by the
  30455. * method instead. The `customizer` is invoked with six arguments:
  30456. * (objValue, srcValue, key, object, source, stack).
  30457. *
  30458. * **Note:** This method mutates `object`.
  30459. *
  30460. * @static
  30461. * @memberOf _
  30462. * @since 4.0.0
  30463. * @category Object
  30464. * @param {Object} object The destination object.
  30465. * @param {...Object} sources The source objects.
  30466. * @param {Function} customizer The function to customize assigned values.
  30467. * @returns {Object} Returns `object`.
  30468. * @example
  30469. *
  30470. * function customizer(objValue, srcValue) {
  30471. * if (_.isArray(objValue)) {
  30472. * return objValue.concat(srcValue);
  30473. * }
  30474. * }
  30475. *
  30476. * var object = { 'a': [1], 'b': [2] };
  30477. * var other = { 'a': [3], 'b': [4] };
  30478. *
  30479. * _.mergeWith(object, other, customizer);
  30480. * // => { 'a': [1, 3], 'b': [2, 4] }
  30481. */
  30482. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30483. baseMerge(object, source, srcIndex, customizer);
  30484. });
  30485. /**
  30486. * The opposite of `_.pick`; this method creates an object composed of the
  30487. * own and inherited enumerable property paths of `object` that are not omitted.
  30488. *
  30489. * **Note:** This method is considerably slower than `_.pick`.
  30490. *
  30491. * @static
  30492. * @since 0.1.0
  30493. * @memberOf _
  30494. * @category Object
  30495. * @param {Object} object The source object.
  30496. * @param {...(string|string[])} [paths] The property paths to omit.
  30497. * @returns {Object} Returns the new object.
  30498. * @example
  30499. *
  30500. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30501. *
  30502. * _.omit(object, ['a', 'c']);
  30503. * // => { 'b': '2' }
  30504. */
  30505. var omit = flatRest(function(object, paths) {
  30506. var result = {};
  30507. if (object == null) {
  30508. return result;
  30509. }
  30510. var isDeep = false;
  30511. paths = arrayMap(paths, function(path) {
  30512. path = castPath(path, object);
  30513. isDeep || (isDeep = path.length > 1);
  30514. return path;
  30515. });
  30516. copyObject(object, getAllKeysIn(object), result);
  30517. if (isDeep) {
  30518. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30519. }
  30520. var length = paths.length;
  30521. while (length--) {
  30522. baseUnset(result, paths[length]);
  30523. }
  30524. return result;
  30525. });
  30526. /**
  30527. * The opposite of `_.pickBy`; this method creates an object composed of
  30528. * the own and inherited enumerable string keyed properties of `object` that
  30529. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30530. * arguments: (value, key).
  30531. *
  30532. * @static
  30533. * @memberOf _
  30534. * @since 4.0.0
  30535. * @category Object
  30536. * @param {Object} object The source object.
  30537. * @param {Function} [predicate=_.identity] The function invoked per property.
  30538. * @returns {Object} Returns the new object.
  30539. * @example
  30540. *
  30541. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30542. *
  30543. * _.omitBy(object, _.isNumber);
  30544. * // => { 'b': '2' }
  30545. */
  30546. function omitBy(object, predicate) {
  30547. return pickBy(object, negate(getIteratee(predicate)));
  30548. }
  30549. /**
  30550. * Creates an object composed of the picked `object` properties.
  30551. *
  30552. * @static
  30553. * @since 0.1.0
  30554. * @memberOf _
  30555. * @category Object
  30556. * @param {Object} object The source object.
  30557. * @param {...(string|string[])} [paths] The property paths to pick.
  30558. * @returns {Object} Returns the new object.
  30559. * @example
  30560. *
  30561. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30562. *
  30563. * _.pick(object, ['a', 'c']);
  30564. * // => { 'a': 1, 'c': 3 }
  30565. */
  30566. var pick = flatRest(function(object, paths) {
  30567. return object == null ? {} : basePick(object, paths);
  30568. });
  30569. /**
  30570. * Creates an object composed of the `object` properties `predicate` returns
  30571. * truthy for. The predicate is invoked with two arguments: (value, key).
  30572. *
  30573. * @static
  30574. * @memberOf _
  30575. * @since 4.0.0
  30576. * @category Object
  30577. * @param {Object} object The source object.
  30578. * @param {Function} [predicate=_.identity] The function invoked per property.
  30579. * @returns {Object} Returns the new object.
  30580. * @example
  30581. *
  30582. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30583. *
  30584. * _.pickBy(object, _.isNumber);
  30585. * // => { 'a': 1, 'c': 3 }
  30586. */
  30587. function pickBy(object, predicate) {
  30588. if (object == null) {
  30589. return {};
  30590. }
  30591. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30592. return [prop];
  30593. });
  30594. predicate = getIteratee(predicate);
  30595. return basePickBy(object, props, function(value, path) {
  30596. return predicate(value, path[0]);
  30597. });
  30598. }
  30599. /**
  30600. * This method is like `_.get` except that if the resolved value is a
  30601. * function it's invoked with the `this` binding of its parent object and
  30602. * its result is returned.
  30603. *
  30604. * @static
  30605. * @since 0.1.0
  30606. * @memberOf _
  30607. * @category Object
  30608. * @param {Object} object The object to query.
  30609. * @param {Array|string} path The path of the property to resolve.
  30610. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30611. * @returns {*} Returns the resolved value.
  30612. * @example
  30613. *
  30614. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30615. *
  30616. * _.result(object, 'a[0].b.c1');
  30617. * // => 3
  30618. *
  30619. * _.result(object, 'a[0].b.c2');
  30620. * // => 4
  30621. *
  30622. * _.result(object, 'a[0].b.c3', 'default');
  30623. * // => 'default'
  30624. *
  30625. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30626. * // => 'default'
  30627. */
  30628. function result(object, path, defaultValue) {
  30629. path = castPath(path, object);
  30630. var index = -1,
  30631. length = path.length;
  30632. // Ensure the loop is entered when path is empty.
  30633. if (!length) {
  30634. length = 1;
  30635. object = undefined;
  30636. }
  30637. while (++index < length) {
  30638. var value = object == null ? undefined : object[toKey(path[index])];
  30639. if (value === undefined) {
  30640. index = length;
  30641. value = defaultValue;
  30642. }
  30643. object = isFunction(value) ? value.call(object) : value;
  30644. }
  30645. return object;
  30646. }
  30647. /**
  30648. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30649. * it's created. Arrays are created for missing index properties while objects
  30650. * are created for all other missing properties. Use `_.setWith` to customize
  30651. * `path` creation.
  30652. *
  30653. * **Note:** This method mutates `object`.
  30654. *
  30655. * @static
  30656. * @memberOf _
  30657. * @since 3.7.0
  30658. * @category Object
  30659. * @param {Object} object The object to modify.
  30660. * @param {Array|string} path The path of the property to set.
  30661. * @param {*} value The value to set.
  30662. * @returns {Object} Returns `object`.
  30663. * @example
  30664. *
  30665. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30666. *
  30667. * _.set(object, 'a[0].b.c', 4);
  30668. * console.log(object.a[0].b.c);
  30669. * // => 4
  30670. *
  30671. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30672. * console.log(object.x[0].y.z);
  30673. * // => 5
  30674. */
  30675. function set(object, path, value) {
  30676. return object == null ? object : baseSet(object, path, value);
  30677. }
  30678. /**
  30679. * This method is like `_.set` except that it accepts `customizer` which is
  30680. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30681. * path creation is handled by the method instead. The `customizer` is invoked
  30682. * with three arguments: (nsValue, key, nsObject).
  30683. *
  30684. * **Note:** This method mutates `object`.
  30685. *
  30686. * @static
  30687. * @memberOf _
  30688. * @since 4.0.0
  30689. * @category Object
  30690. * @param {Object} object The object to modify.
  30691. * @param {Array|string} path The path of the property to set.
  30692. * @param {*} value The value to set.
  30693. * @param {Function} [customizer] The function to customize assigned values.
  30694. * @returns {Object} Returns `object`.
  30695. * @example
  30696. *
  30697. * var object = {};
  30698. *
  30699. * _.setWith(object, '[0][1]', 'a', Object);
  30700. * // => { '0': { '1': 'a' } }
  30701. */
  30702. function setWith(object, path, value, customizer) {
  30703. customizer = typeof customizer == 'function' ? customizer : undefined;
  30704. return object == null ? object : baseSet(object, path, value, customizer);
  30705. }
  30706. /**
  30707. * Creates an array of own enumerable string keyed-value pairs for `object`
  30708. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30709. * entries are returned.
  30710. *
  30711. * @static
  30712. * @memberOf _
  30713. * @since 4.0.0
  30714. * @alias entries
  30715. * @category Object
  30716. * @param {Object} object The object to query.
  30717. * @returns {Array} Returns the key-value pairs.
  30718. * @example
  30719. *
  30720. * function Foo() {
  30721. * this.a = 1;
  30722. * this.b = 2;
  30723. * }
  30724. *
  30725. * Foo.prototype.c = 3;
  30726. *
  30727. * _.toPairs(new Foo);
  30728. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30729. */
  30730. var toPairs = createToPairs(keys);
  30731. /**
  30732. * Creates an array of own and inherited enumerable string keyed-value pairs
  30733. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30734. * or set, its entries are returned.
  30735. *
  30736. * @static
  30737. * @memberOf _
  30738. * @since 4.0.0
  30739. * @alias entriesIn
  30740. * @category Object
  30741. * @param {Object} object The object to query.
  30742. * @returns {Array} Returns the key-value pairs.
  30743. * @example
  30744. *
  30745. * function Foo() {
  30746. * this.a = 1;
  30747. * this.b = 2;
  30748. * }
  30749. *
  30750. * Foo.prototype.c = 3;
  30751. *
  30752. * _.toPairsIn(new Foo);
  30753. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30754. */
  30755. var toPairsIn = createToPairs(keysIn);
  30756. /**
  30757. * An alternative to `_.reduce`; this method transforms `object` to a new
  30758. * `accumulator` object which is the result of running each of its own
  30759. * enumerable string keyed properties thru `iteratee`, with each invocation
  30760. * potentially mutating the `accumulator` object. If `accumulator` is not
  30761. * provided, a new object with the same `[[Prototype]]` will be used. The
  30762. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30763. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30764. *
  30765. * @static
  30766. * @memberOf _
  30767. * @since 1.3.0
  30768. * @category Object
  30769. * @param {Object} object The object to iterate over.
  30770. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30771. * @param {*} [accumulator] The custom accumulator value.
  30772. * @returns {*} Returns the accumulated value.
  30773. * @example
  30774. *
  30775. * _.transform([2, 3, 4], function(result, n) {
  30776. * result.push(n *= n);
  30777. * return n % 2 == 0;
  30778. * }, []);
  30779. * // => [4, 9]
  30780. *
  30781. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30782. * (result[value] || (result[value] = [])).push(key);
  30783. * }, {});
  30784. * // => { '1': ['a', 'c'], '2': ['b'] }
  30785. */
  30786. function transform(object, iteratee, accumulator) {
  30787. var isArr = isArray(object),
  30788. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30789. iteratee = getIteratee(iteratee, 4);
  30790. if (accumulator == null) {
  30791. var Ctor = object && object.constructor;
  30792. if (isArrLike) {
  30793. accumulator = isArr ? new Ctor : [];
  30794. }
  30795. else if (isObject(object)) {
  30796. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30797. }
  30798. else {
  30799. accumulator = {};
  30800. }
  30801. }
  30802. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30803. return iteratee(accumulator, value, index, object);
  30804. });
  30805. return accumulator;
  30806. }
  30807. /**
  30808. * Removes the property at `path` of `object`.
  30809. *
  30810. * **Note:** This method mutates `object`.
  30811. *
  30812. * @static
  30813. * @memberOf _
  30814. * @since 4.0.0
  30815. * @category Object
  30816. * @param {Object} object The object to modify.
  30817. * @param {Array|string} path The path of the property to unset.
  30818. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30819. * @example
  30820. *
  30821. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30822. * _.unset(object, 'a[0].b.c');
  30823. * // => true
  30824. *
  30825. * console.log(object);
  30826. * // => { 'a': [{ 'b': {} }] };
  30827. *
  30828. * _.unset(object, ['a', '0', 'b', 'c']);
  30829. * // => true
  30830. *
  30831. * console.log(object);
  30832. * // => { 'a': [{ 'b': {} }] };
  30833. */
  30834. function unset(object, path) {
  30835. return object == null ? true : baseUnset(object, path);
  30836. }
  30837. /**
  30838. * This method is like `_.set` except that accepts `updater` to produce the
  30839. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30840. * is invoked with one argument: (value).
  30841. *
  30842. * **Note:** This method mutates `object`.
  30843. *
  30844. * @static
  30845. * @memberOf _
  30846. * @since 4.6.0
  30847. * @category Object
  30848. * @param {Object} object The object to modify.
  30849. * @param {Array|string} path The path of the property to set.
  30850. * @param {Function} updater The function to produce the updated value.
  30851. * @returns {Object} Returns `object`.
  30852. * @example
  30853. *
  30854. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30855. *
  30856. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30857. * console.log(object.a[0].b.c);
  30858. * // => 9
  30859. *
  30860. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30861. * console.log(object.x[0].y.z);
  30862. * // => 0
  30863. */
  30864. function update(object, path, updater) {
  30865. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30866. }
  30867. /**
  30868. * This method is like `_.update` except that it accepts `customizer` which is
  30869. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30870. * path creation is handled by the method instead. The `customizer` is invoked
  30871. * with three arguments: (nsValue, key, nsObject).
  30872. *
  30873. * **Note:** This method mutates `object`.
  30874. *
  30875. * @static
  30876. * @memberOf _
  30877. * @since 4.6.0
  30878. * @category Object
  30879. * @param {Object} object The object to modify.
  30880. * @param {Array|string} path The path of the property to set.
  30881. * @param {Function} updater The function to produce the updated value.
  30882. * @param {Function} [customizer] The function to customize assigned values.
  30883. * @returns {Object} Returns `object`.
  30884. * @example
  30885. *
  30886. * var object = {};
  30887. *
  30888. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30889. * // => { '0': { '1': 'a' } }
  30890. */
  30891. function updateWith(object, path, updater, customizer) {
  30892. customizer = typeof customizer == 'function' ? customizer : undefined;
  30893. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30894. }
  30895. /**
  30896. * Creates an array of the own enumerable string keyed property values of `object`.
  30897. *
  30898. * **Note:** Non-object values are coerced to objects.
  30899. *
  30900. * @static
  30901. * @since 0.1.0
  30902. * @memberOf _
  30903. * @category Object
  30904. * @param {Object} object The object to query.
  30905. * @returns {Array} Returns the array of property values.
  30906. * @example
  30907. *
  30908. * function Foo() {
  30909. * this.a = 1;
  30910. * this.b = 2;
  30911. * }
  30912. *
  30913. * Foo.prototype.c = 3;
  30914. *
  30915. * _.values(new Foo);
  30916. * // => [1, 2] (iteration order is not guaranteed)
  30917. *
  30918. * _.values('hi');
  30919. * // => ['h', 'i']
  30920. */
  30921. function values(object) {
  30922. return object == null ? [] : baseValues(object, keys(object));
  30923. }
  30924. /**
  30925. * Creates an array of the own and inherited enumerable string keyed property
  30926. * values of `object`.
  30927. *
  30928. * **Note:** Non-object values are coerced to objects.
  30929. *
  30930. * @static
  30931. * @memberOf _
  30932. * @since 3.0.0
  30933. * @category Object
  30934. * @param {Object} object The object to query.
  30935. * @returns {Array} Returns the array of property values.
  30936. * @example
  30937. *
  30938. * function Foo() {
  30939. * this.a = 1;
  30940. * this.b = 2;
  30941. * }
  30942. *
  30943. * Foo.prototype.c = 3;
  30944. *
  30945. * _.valuesIn(new Foo);
  30946. * // => [1, 2, 3] (iteration order is not guaranteed)
  30947. */
  30948. function valuesIn(object) {
  30949. return object == null ? [] : baseValues(object, keysIn(object));
  30950. }
  30951. /*------------------------------------------------------------------------*/
  30952. /**
  30953. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30954. *
  30955. * @static
  30956. * @memberOf _
  30957. * @since 4.0.0
  30958. * @category Number
  30959. * @param {number} number The number to clamp.
  30960. * @param {number} [lower] The lower bound.
  30961. * @param {number} upper The upper bound.
  30962. * @returns {number} Returns the clamped number.
  30963. * @example
  30964. *
  30965. * _.clamp(-10, -5, 5);
  30966. * // => -5
  30967. *
  30968. * _.clamp(10, -5, 5);
  30969. * // => 5
  30970. */
  30971. function clamp(number, lower, upper) {
  30972. if (upper === undefined) {
  30973. upper = lower;
  30974. lower = undefined;
  30975. }
  30976. if (upper !== undefined) {
  30977. upper = toNumber(upper);
  30978. upper = upper === upper ? upper : 0;
  30979. }
  30980. if (lower !== undefined) {
  30981. lower = toNumber(lower);
  30982. lower = lower === lower ? lower : 0;
  30983. }
  30984. return baseClamp(toNumber(number), lower, upper);
  30985. }
  30986. /**
  30987. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30988. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30989. * If `start` is greater than `end` the params are swapped to support
  30990. * negative ranges.
  30991. *
  30992. * @static
  30993. * @memberOf _
  30994. * @since 3.3.0
  30995. * @category Number
  30996. * @param {number} number The number to check.
  30997. * @param {number} [start=0] The start of the range.
  30998. * @param {number} end The end of the range.
  30999. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  31000. * @see _.range, _.rangeRight
  31001. * @example
  31002. *
  31003. * _.inRange(3, 2, 4);
  31004. * // => true
  31005. *
  31006. * _.inRange(4, 8);
  31007. * // => true
  31008. *
  31009. * _.inRange(4, 2);
  31010. * // => false
  31011. *
  31012. * _.inRange(2, 2);
  31013. * // => false
  31014. *
  31015. * _.inRange(1.2, 2);
  31016. * // => true
  31017. *
  31018. * _.inRange(5.2, 4);
  31019. * // => false
  31020. *
  31021. * _.inRange(-3, -2, -6);
  31022. * // => true
  31023. */
  31024. function inRange(number, start, end) {
  31025. start = toFinite(start);
  31026. if (end === undefined) {
  31027. end = start;
  31028. start = 0;
  31029. } else {
  31030. end = toFinite(end);
  31031. }
  31032. number = toNumber(number);
  31033. return baseInRange(number, start, end);
  31034. }
  31035. /**
  31036. * Produces a random number between the inclusive `lower` and `upper` bounds.
  31037. * If only one argument is provided a number between `0` and the given number
  31038. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  31039. * floats, a floating-point number is returned instead of an integer.
  31040. *
  31041. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31042. * floating-point values which can produce unexpected results.
  31043. *
  31044. * @static
  31045. * @memberOf _
  31046. * @since 0.7.0
  31047. * @category Number
  31048. * @param {number} [lower=0] The lower bound.
  31049. * @param {number} [upper=1] The upper bound.
  31050. * @param {boolean} [floating] Specify returning a floating-point number.
  31051. * @returns {number} Returns the random number.
  31052. * @example
  31053. *
  31054. * _.random(0, 5);
  31055. * // => an integer between 0 and 5
  31056. *
  31057. * _.random(5);
  31058. * // => also an integer between 0 and 5
  31059. *
  31060. * _.random(5, true);
  31061. * // => a floating-point number between 0 and 5
  31062. *
  31063. * _.random(1.2, 5.2);
  31064. * // => a floating-point number between 1.2 and 5.2
  31065. */
  31066. function random(lower, upper, floating) {
  31067. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  31068. upper = floating = undefined;
  31069. }
  31070. if (floating === undefined) {
  31071. if (typeof upper == 'boolean') {
  31072. floating = upper;
  31073. upper = undefined;
  31074. }
  31075. else if (typeof lower == 'boolean') {
  31076. floating = lower;
  31077. lower = undefined;
  31078. }
  31079. }
  31080. if (lower === undefined && upper === undefined) {
  31081. lower = 0;
  31082. upper = 1;
  31083. }
  31084. else {
  31085. lower = toFinite(lower);
  31086. if (upper === undefined) {
  31087. upper = lower;
  31088. lower = 0;
  31089. } else {
  31090. upper = toFinite(upper);
  31091. }
  31092. }
  31093. if (lower > upper) {
  31094. var temp = lower;
  31095. lower = upper;
  31096. upper = temp;
  31097. }
  31098. if (floating || lower % 1 || upper % 1) {
  31099. var rand = nativeRandom();
  31100. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  31101. }
  31102. return baseRandom(lower, upper);
  31103. }
  31104. /*------------------------------------------------------------------------*/
  31105. /**
  31106. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  31107. *
  31108. * @static
  31109. * @memberOf _
  31110. * @since 3.0.0
  31111. * @category String
  31112. * @param {string} [string=''] The string to convert.
  31113. * @returns {string} Returns the camel cased string.
  31114. * @example
  31115. *
  31116. * _.camelCase('Foo Bar');
  31117. * // => 'fooBar'
  31118. *
  31119. * _.camelCase('--foo-bar--');
  31120. * // => 'fooBar'
  31121. *
  31122. * _.camelCase('__FOO_BAR__');
  31123. * // => 'fooBar'
  31124. */
  31125. var camelCase = createCompounder(function(result, word, index) {
  31126. word = word.toLowerCase();
  31127. return result + (index ? capitalize(word) : word);
  31128. });
  31129. /**
  31130. * Converts the first character of `string` to upper case and the remaining
  31131. * to lower case.
  31132. *
  31133. * @static
  31134. * @memberOf _
  31135. * @since 3.0.0
  31136. * @category String
  31137. * @param {string} [string=''] The string to capitalize.
  31138. * @returns {string} Returns the capitalized string.
  31139. * @example
  31140. *
  31141. * _.capitalize('FRED');
  31142. * // => 'Fred'
  31143. */
  31144. function capitalize(string) {
  31145. return upperFirst(toString(string).toLowerCase());
  31146. }
  31147. /**
  31148. * Deburrs `string` by converting
  31149. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31150. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31151. * letters to basic Latin letters and removing
  31152. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31153. *
  31154. * @static
  31155. * @memberOf _
  31156. * @since 3.0.0
  31157. * @category String
  31158. * @param {string} [string=''] The string to deburr.
  31159. * @returns {string} Returns the deburred string.
  31160. * @example
  31161. *
  31162. * _.deburr('déjà vu');
  31163. * // => 'deja vu'
  31164. */
  31165. function deburr(string) {
  31166. string = toString(string);
  31167. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31168. }
  31169. /**
  31170. * Checks if `string` ends with the given target string.
  31171. *
  31172. * @static
  31173. * @memberOf _
  31174. * @since 3.0.0
  31175. * @category String
  31176. * @param {string} [string=''] The string to inspect.
  31177. * @param {string} [target] The string to search for.
  31178. * @param {number} [position=string.length] The position to search up to.
  31179. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31180. * else `false`.
  31181. * @example
  31182. *
  31183. * _.endsWith('abc', 'c');
  31184. * // => true
  31185. *
  31186. * _.endsWith('abc', 'b');
  31187. * // => false
  31188. *
  31189. * _.endsWith('abc', 'b', 2);
  31190. * // => true
  31191. */
  31192. function endsWith(string, target, position) {
  31193. string = toString(string);
  31194. target = baseToString(target);
  31195. var length = string.length;
  31196. position = position === undefined
  31197. ? length
  31198. : baseClamp(toInteger(position), 0, length);
  31199. var end = position;
  31200. position -= target.length;
  31201. return position >= 0 && string.slice(position, end) == target;
  31202. }
  31203. /**
  31204. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31205. * corresponding HTML entities.
  31206. *
  31207. * **Note:** No other characters are escaped. To escape additional
  31208. * characters use a third-party library like [_he_](https://mths.be/he).
  31209. *
  31210. * Though the ">" character is escaped for symmetry, characters like
  31211. * ">" and "/" don't need escaping in HTML and have no special meaning
  31212. * unless they're part of a tag or unquoted attribute value. See
  31213. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31214. * (under "semi-related fun fact") for more details.
  31215. *
  31216. * When working with HTML you should always
  31217. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31218. * XSS vectors.
  31219. *
  31220. * @static
  31221. * @since 0.1.0
  31222. * @memberOf _
  31223. * @category String
  31224. * @param {string} [string=''] The string to escape.
  31225. * @returns {string} Returns the escaped string.
  31226. * @example
  31227. *
  31228. * _.escape('fred, barney, & pebbles');
  31229. * // => 'fred, barney, &amp; pebbles'
  31230. */
  31231. function escape(string) {
  31232. string = toString(string);
  31233. return (string && reHasUnescapedHtml.test(string))
  31234. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31235. : string;
  31236. }
  31237. /**
  31238. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31239. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31240. *
  31241. * @static
  31242. * @memberOf _
  31243. * @since 3.0.0
  31244. * @category String
  31245. * @param {string} [string=''] The string to escape.
  31246. * @returns {string} Returns the escaped string.
  31247. * @example
  31248. *
  31249. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31250. * // => '\[lodash\]\(https://lodash\.com/\)'
  31251. */
  31252. function escapeRegExp(string) {
  31253. string = toString(string);
  31254. return (string && reHasRegExpChar.test(string))
  31255. ? string.replace(reRegExpChar, '\\$&')
  31256. : string;
  31257. }
  31258. /**
  31259. * Converts `string` to
  31260. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31261. *
  31262. * @static
  31263. * @memberOf _
  31264. * @since 3.0.0
  31265. * @category String
  31266. * @param {string} [string=''] The string to convert.
  31267. * @returns {string} Returns the kebab cased string.
  31268. * @example
  31269. *
  31270. * _.kebabCase('Foo Bar');
  31271. * // => 'foo-bar'
  31272. *
  31273. * _.kebabCase('fooBar');
  31274. * // => 'foo-bar'
  31275. *
  31276. * _.kebabCase('__FOO_BAR__');
  31277. * // => 'foo-bar'
  31278. */
  31279. var kebabCase = createCompounder(function(result, word, index) {
  31280. return result + (index ? '-' : '') + word.toLowerCase();
  31281. });
  31282. /**
  31283. * Converts `string`, as space separated words, to lower case.
  31284. *
  31285. * @static
  31286. * @memberOf _
  31287. * @since 4.0.0
  31288. * @category String
  31289. * @param {string} [string=''] The string to convert.
  31290. * @returns {string} Returns the lower cased string.
  31291. * @example
  31292. *
  31293. * _.lowerCase('--Foo-Bar--');
  31294. * // => 'foo bar'
  31295. *
  31296. * _.lowerCase('fooBar');
  31297. * // => 'foo bar'
  31298. *
  31299. * _.lowerCase('__FOO_BAR__');
  31300. * // => 'foo bar'
  31301. */
  31302. var lowerCase = createCompounder(function(result, word, index) {
  31303. return result + (index ? ' ' : '') + word.toLowerCase();
  31304. });
  31305. /**
  31306. * Converts the first character of `string` to lower case.
  31307. *
  31308. * @static
  31309. * @memberOf _
  31310. * @since 4.0.0
  31311. * @category String
  31312. * @param {string} [string=''] The string to convert.
  31313. * @returns {string} Returns the converted string.
  31314. * @example
  31315. *
  31316. * _.lowerFirst('Fred');
  31317. * // => 'fred'
  31318. *
  31319. * _.lowerFirst('FRED');
  31320. * // => 'fRED'
  31321. */
  31322. var lowerFirst = createCaseFirst('toLowerCase');
  31323. /**
  31324. * Pads `string` on the left and right sides if it's shorter than `length`.
  31325. * Padding characters are truncated if they can't be evenly divided by `length`.
  31326. *
  31327. * @static
  31328. * @memberOf _
  31329. * @since 3.0.0
  31330. * @category String
  31331. * @param {string} [string=''] The string to pad.
  31332. * @param {number} [length=0] The padding length.
  31333. * @param {string} [chars=' '] The string used as padding.
  31334. * @returns {string} Returns the padded string.
  31335. * @example
  31336. *
  31337. * _.pad('abc', 8);
  31338. * // => ' abc '
  31339. *
  31340. * _.pad('abc', 8, '_-');
  31341. * // => '_-abc_-_'
  31342. *
  31343. * _.pad('abc', 3);
  31344. * // => 'abc'
  31345. */
  31346. function pad(string, length, chars) {
  31347. string = toString(string);
  31348. length = toInteger(length);
  31349. var strLength = length ? stringSize(string) : 0;
  31350. if (!length || strLength >= length) {
  31351. return string;
  31352. }
  31353. var mid = (length - strLength) / 2;
  31354. return (
  31355. createPadding(nativeFloor(mid), chars) +
  31356. string +
  31357. createPadding(nativeCeil(mid), chars)
  31358. );
  31359. }
  31360. /**
  31361. * Pads `string` on the right side if it's shorter than `length`. Padding
  31362. * characters are truncated if they exceed `length`.
  31363. *
  31364. * @static
  31365. * @memberOf _
  31366. * @since 4.0.0
  31367. * @category String
  31368. * @param {string} [string=''] The string to pad.
  31369. * @param {number} [length=0] The padding length.
  31370. * @param {string} [chars=' '] The string used as padding.
  31371. * @returns {string} Returns the padded string.
  31372. * @example
  31373. *
  31374. * _.padEnd('abc', 6);
  31375. * // => 'abc '
  31376. *
  31377. * _.padEnd('abc', 6, '_-');
  31378. * // => 'abc_-_'
  31379. *
  31380. * _.padEnd('abc', 3);
  31381. * // => 'abc'
  31382. */
  31383. function padEnd(string, length, chars) {
  31384. string = toString(string);
  31385. length = toInteger(length);
  31386. var strLength = length ? stringSize(string) : 0;
  31387. return (length && strLength < length)
  31388. ? (string + createPadding(length - strLength, chars))
  31389. : string;
  31390. }
  31391. /**
  31392. * Pads `string` on the left side if it's shorter than `length`. Padding
  31393. * characters are truncated if they exceed `length`.
  31394. *
  31395. * @static
  31396. * @memberOf _
  31397. * @since 4.0.0
  31398. * @category String
  31399. * @param {string} [string=''] The string to pad.
  31400. * @param {number} [length=0] The padding length.
  31401. * @param {string} [chars=' '] The string used as padding.
  31402. * @returns {string} Returns the padded string.
  31403. * @example
  31404. *
  31405. * _.padStart('abc', 6);
  31406. * // => ' abc'
  31407. *
  31408. * _.padStart('abc', 6, '_-');
  31409. * // => '_-_abc'
  31410. *
  31411. * _.padStart('abc', 3);
  31412. * // => 'abc'
  31413. */
  31414. function padStart(string, length, chars) {
  31415. string = toString(string);
  31416. length = toInteger(length);
  31417. var strLength = length ? stringSize(string) : 0;
  31418. return (length && strLength < length)
  31419. ? (createPadding(length - strLength, chars) + string)
  31420. : string;
  31421. }
  31422. /**
  31423. * Converts `string` to an integer of the specified radix. If `radix` is
  31424. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31425. * hexadecimal, in which case a `radix` of `16` is used.
  31426. *
  31427. * **Note:** This method aligns with the
  31428. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31429. *
  31430. * @static
  31431. * @memberOf _
  31432. * @since 1.1.0
  31433. * @category String
  31434. * @param {string} string The string to convert.
  31435. * @param {number} [radix=10] The radix to interpret `value` by.
  31436. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31437. * @returns {number} Returns the converted integer.
  31438. * @example
  31439. *
  31440. * _.parseInt('08');
  31441. * // => 8
  31442. *
  31443. * _.map(['6', '08', '10'], _.parseInt);
  31444. * // => [6, 8, 10]
  31445. */
  31446. function parseInt(string, radix, guard) {
  31447. if (guard || radix == null) {
  31448. radix = 0;
  31449. } else if (radix) {
  31450. radix = +radix;
  31451. }
  31452. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31453. }
  31454. /**
  31455. * Repeats the given string `n` times.
  31456. *
  31457. * @static
  31458. * @memberOf _
  31459. * @since 3.0.0
  31460. * @category String
  31461. * @param {string} [string=''] The string to repeat.
  31462. * @param {number} [n=1] The number of times to repeat the string.
  31463. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31464. * @returns {string} Returns the repeated string.
  31465. * @example
  31466. *
  31467. * _.repeat('*', 3);
  31468. * // => '***'
  31469. *
  31470. * _.repeat('abc', 2);
  31471. * // => 'abcabc'
  31472. *
  31473. * _.repeat('abc', 0);
  31474. * // => ''
  31475. */
  31476. function repeat(string, n, guard) {
  31477. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31478. n = 1;
  31479. } else {
  31480. n = toInteger(n);
  31481. }
  31482. return baseRepeat(toString(string), n);
  31483. }
  31484. /**
  31485. * Replaces matches for `pattern` in `string` with `replacement`.
  31486. *
  31487. * **Note:** This method is based on
  31488. * [`String#replace`](https://mdn.io/String/replace).
  31489. *
  31490. * @static
  31491. * @memberOf _
  31492. * @since 4.0.0
  31493. * @category String
  31494. * @param {string} [string=''] The string to modify.
  31495. * @param {RegExp|string} pattern The pattern to replace.
  31496. * @param {Function|string} replacement The match replacement.
  31497. * @returns {string} Returns the modified string.
  31498. * @example
  31499. *
  31500. * _.replace('Hi Fred', 'Fred', 'Barney');
  31501. * // => 'Hi Barney'
  31502. */
  31503. function replace() {
  31504. var args = arguments,
  31505. string = toString(args[0]);
  31506. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31507. }
  31508. /**
  31509. * Converts `string` to
  31510. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31511. *
  31512. * @static
  31513. * @memberOf _
  31514. * @since 3.0.0
  31515. * @category String
  31516. * @param {string} [string=''] The string to convert.
  31517. * @returns {string} Returns the snake cased string.
  31518. * @example
  31519. *
  31520. * _.snakeCase('Foo Bar');
  31521. * // => 'foo_bar'
  31522. *
  31523. * _.snakeCase('fooBar');
  31524. * // => 'foo_bar'
  31525. *
  31526. * _.snakeCase('--FOO-BAR--');
  31527. * // => 'foo_bar'
  31528. */
  31529. var snakeCase = createCompounder(function(result, word, index) {
  31530. return result + (index ? '_' : '') + word.toLowerCase();
  31531. });
  31532. /**
  31533. * Splits `string` by `separator`.
  31534. *
  31535. * **Note:** This method is based on
  31536. * [`String#split`](https://mdn.io/String/split).
  31537. *
  31538. * @static
  31539. * @memberOf _
  31540. * @since 4.0.0
  31541. * @category String
  31542. * @param {string} [string=''] The string to split.
  31543. * @param {RegExp|string} separator The separator pattern to split by.
  31544. * @param {number} [limit] The length to truncate results to.
  31545. * @returns {Array} Returns the string segments.
  31546. * @example
  31547. *
  31548. * _.split('a-b-c', '-', 2);
  31549. * // => ['a', 'b']
  31550. */
  31551. function split(string, separator, limit) {
  31552. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31553. separator = limit = undefined;
  31554. }
  31555. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31556. if (!limit) {
  31557. return [];
  31558. }
  31559. string = toString(string);
  31560. if (string && (
  31561. typeof separator == 'string' ||
  31562. (separator != null && !isRegExp(separator))
  31563. )) {
  31564. separator = baseToString(separator);
  31565. if (!separator && hasUnicode(string)) {
  31566. return castSlice(stringToArray(string), 0, limit);
  31567. }
  31568. }
  31569. return string.split(separator, limit);
  31570. }
  31571. /**
  31572. * Converts `string` to
  31573. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31574. *
  31575. * @static
  31576. * @memberOf _
  31577. * @since 3.1.0
  31578. * @category String
  31579. * @param {string} [string=''] The string to convert.
  31580. * @returns {string} Returns the start cased string.
  31581. * @example
  31582. *
  31583. * _.startCase('--foo-bar--');
  31584. * // => 'Foo Bar'
  31585. *
  31586. * _.startCase('fooBar');
  31587. * // => 'Foo Bar'
  31588. *
  31589. * _.startCase('__FOO_BAR__');
  31590. * // => 'FOO BAR'
  31591. */
  31592. var startCase = createCompounder(function(result, word, index) {
  31593. return result + (index ? ' ' : '') + upperFirst(word);
  31594. });
  31595. /**
  31596. * Checks if `string` starts with the given target string.
  31597. *
  31598. * @static
  31599. * @memberOf _
  31600. * @since 3.0.0
  31601. * @category String
  31602. * @param {string} [string=''] The string to inspect.
  31603. * @param {string} [target] The string to search for.
  31604. * @param {number} [position=0] The position to search from.
  31605. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31606. * else `false`.
  31607. * @example
  31608. *
  31609. * _.startsWith('abc', 'a');
  31610. * // => true
  31611. *
  31612. * _.startsWith('abc', 'b');
  31613. * // => false
  31614. *
  31615. * _.startsWith('abc', 'b', 1);
  31616. * // => true
  31617. */
  31618. function startsWith(string, target, position) {
  31619. string = toString(string);
  31620. position = position == null
  31621. ? 0
  31622. : baseClamp(toInteger(position), 0, string.length);
  31623. target = baseToString(target);
  31624. return string.slice(position, position + target.length) == target;
  31625. }
  31626. /**
  31627. * Creates a compiled template function that can interpolate data properties
  31628. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31629. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31630. * properties may be accessed as free variables in the template. If a setting
  31631. * object is given, it takes precedence over `_.templateSettings` values.
  31632. *
  31633. * **Note:** In the development build `_.template` utilizes
  31634. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31635. * for easier debugging.
  31636. *
  31637. * For more information on precompiling templates see
  31638. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31639. *
  31640. * For more information on Chrome extension sandboxes see
  31641. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31642. *
  31643. * @static
  31644. * @since 0.1.0
  31645. * @memberOf _
  31646. * @category String
  31647. * @param {string} [string=''] The template string.
  31648. * @param {Object} [options={}] The options object.
  31649. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31650. * The HTML "escape" delimiter.
  31651. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31652. * The "evaluate" delimiter.
  31653. * @param {Object} [options.imports=_.templateSettings.imports]
  31654. * An object to import into the template as free variables.
  31655. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31656. * The "interpolate" delimiter.
  31657. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31658. * The sourceURL of the compiled template.
  31659. * @param {string} [options.variable='obj']
  31660. * The data object variable name.
  31661. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31662. * @returns {Function} Returns the compiled template function.
  31663. * @example
  31664. *
  31665. * // Use the "interpolate" delimiter to create a compiled template.
  31666. * var compiled = _.template('hello <%= user %>!');
  31667. * compiled({ 'user': 'fred' });
  31668. * // => 'hello fred!'
  31669. *
  31670. * // Use the HTML "escape" delimiter to escape data property values.
  31671. * var compiled = _.template('<b><%- value %></b>');
  31672. * compiled({ 'value': '<script>' });
  31673. * // => '<b>&lt;script&gt;</b>'
  31674. *
  31675. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31676. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31677. * compiled({ 'users': ['fred', 'barney'] });
  31678. * // => '<li>fred</li><li>barney</li>'
  31679. *
  31680. * // Use the internal `print` function in "evaluate" delimiters.
  31681. * var compiled = _.template('<% print("hello " + user); %>!');
  31682. * compiled({ 'user': 'barney' });
  31683. * // => 'hello barney!'
  31684. *
  31685. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31686. * // Disable support by replacing the "interpolate" delimiter.
  31687. * var compiled = _.template('hello ${ user }!');
  31688. * compiled({ 'user': 'pebbles' });
  31689. * // => 'hello pebbles!'
  31690. *
  31691. * // Use backslashes to treat delimiters as plain text.
  31692. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31693. * compiled({ 'value': 'ignored' });
  31694. * // => '<%- value %>'
  31695. *
  31696. * // Use the `imports` option to import `jQuery` as `jq`.
  31697. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31698. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31699. * compiled({ 'users': ['fred', 'barney'] });
  31700. * // => '<li>fred</li><li>barney</li>'
  31701. *
  31702. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31703. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31704. * compiled(data);
  31705. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31706. *
  31707. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31708. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31709. * compiled.source;
  31710. * // => function(data) {
  31711. * // var __t, __p = '';
  31712. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31713. * // return __p;
  31714. * // }
  31715. *
  31716. * // Use custom template delimiters.
  31717. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31718. * var compiled = _.template('hello {{ user }}!');
  31719. * compiled({ 'user': 'mustache' });
  31720. * // => 'hello mustache!'
  31721. *
  31722. * // Use the `source` property to inline compiled templates for meaningful
  31723. * // line numbers in error messages and stack traces.
  31724. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31725. * var JST = {\
  31726. * "main": ' + _.template(mainText).source + '\
  31727. * };\
  31728. * ');
  31729. */
  31730. function template(string, options, guard) {
  31731. // Based on John Resig's `tmpl` implementation
  31732. // (http://ejohn.org/blog/javascript-micro-templating/)
  31733. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31734. var settings = lodash.templateSettings;
  31735. if (guard && isIterateeCall(string, options, guard)) {
  31736. options = undefined;
  31737. }
  31738. string = toString(string);
  31739. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31740. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31741. importsKeys = keys(imports),
  31742. importsValues = baseValues(imports, importsKeys);
  31743. var isEscaping,
  31744. isEvaluating,
  31745. index = 0,
  31746. interpolate = options.interpolate || reNoMatch,
  31747. source = "__p += '";
  31748. // Compile the regexp to match each delimiter.
  31749. var reDelimiters = RegExp(
  31750. (options.escape || reNoMatch).source + '|' +
  31751. interpolate.source + '|' +
  31752. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31753. (options.evaluate || reNoMatch).source + '|$'
  31754. , 'g');
  31755. // Use a sourceURL for easier debugging.
  31756. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31757. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31758. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31759. var sourceURL = '//# sourceURL=' +
  31760. (hasOwnProperty.call(options, 'sourceURL')
  31761. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31762. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31763. ) + '\n';
  31764. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31765. interpolateValue || (interpolateValue = esTemplateValue);
  31766. // Escape characters that can't be included in string literals.
  31767. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31768. // Replace delimiters with snippets.
  31769. if (escapeValue) {
  31770. isEscaping = true;
  31771. source += "' +\n__e(" + escapeValue + ") +\n'";
  31772. }
  31773. if (evaluateValue) {
  31774. isEvaluating = true;
  31775. source += "';\n" + evaluateValue + ";\n__p += '";
  31776. }
  31777. if (interpolateValue) {
  31778. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31779. }
  31780. index = offset + match.length;
  31781. // The JS engine embedded in Adobe products needs `match` returned in
  31782. // order to produce the correct `offset` value.
  31783. return match;
  31784. });
  31785. source += "';\n";
  31786. // If `variable` is not specified wrap a with-statement around the generated
  31787. // code to add the data object to the top of the scope chain.
  31788. // Like with sourceURL, we take care to not check the option's prototype,
  31789. // as this configuration is a code injection vector.
  31790. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31791. if (!variable) {
  31792. source = 'with (obj) {\n' + source + '\n}\n';
  31793. }
  31794. // Cleanup code by stripping empty strings.
  31795. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31796. .replace(reEmptyStringMiddle, '$1')
  31797. .replace(reEmptyStringTrailing, '$1;');
  31798. // Frame code as the function body.
  31799. source = 'function(' + (variable || 'obj') + ') {\n' +
  31800. (variable
  31801. ? ''
  31802. : 'obj || (obj = {});\n'
  31803. ) +
  31804. "var __t, __p = ''" +
  31805. (isEscaping
  31806. ? ', __e = _.escape'
  31807. : ''
  31808. ) +
  31809. (isEvaluating
  31810. ? ', __j = Array.prototype.join;\n' +
  31811. "function print() { __p += __j.call(arguments, '') }\n"
  31812. : ';\n'
  31813. ) +
  31814. source +
  31815. 'return __p\n}';
  31816. var result = attempt(function() {
  31817. return Function(importsKeys, sourceURL + 'return ' + source)
  31818. .apply(undefined, importsValues);
  31819. });
  31820. // Provide the compiled function's source by its `toString` method or
  31821. // the `source` property as a convenience for inlining compiled templates.
  31822. result.source = source;
  31823. if (isError(result)) {
  31824. throw result;
  31825. }
  31826. return result;
  31827. }
  31828. /**
  31829. * Converts `string`, as a whole, to lower case just like
  31830. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31831. *
  31832. * @static
  31833. * @memberOf _
  31834. * @since 4.0.0
  31835. * @category String
  31836. * @param {string} [string=''] The string to convert.
  31837. * @returns {string} Returns the lower cased string.
  31838. * @example
  31839. *
  31840. * _.toLower('--Foo-Bar--');
  31841. * // => '--foo-bar--'
  31842. *
  31843. * _.toLower('fooBar');
  31844. * // => 'foobar'
  31845. *
  31846. * _.toLower('__FOO_BAR__');
  31847. * // => '__foo_bar__'
  31848. */
  31849. function toLower(value) {
  31850. return toString(value).toLowerCase();
  31851. }
  31852. /**
  31853. * Converts `string`, as a whole, to upper case just like
  31854. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31855. *
  31856. * @static
  31857. * @memberOf _
  31858. * @since 4.0.0
  31859. * @category String
  31860. * @param {string} [string=''] The string to convert.
  31861. * @returns {string} Returns the upper cased string.
  31862. * @example
  31863. *
  31864. * _.toUpper('--foo-bar--');
  31865. * // => '--FOO-BAR--'
  31866. *
  31867. * _.toUpper('fooBar');
  31868. * // => 'FOOBAR'
  31869. *
  31870. * _.toUpper('__foo_bar__');
  31871. * // => '__FOO_BAR__'
  31872. */
  31873. function toUpper(value) {
  31874. return toString(value).toUpperCase();
  31875. }
  31876. /**
  31877. * Removes leading and trailing whitespace or specified characters from `string`.
  31878. *
  31879. * @static
  31880. * @memberOf _
  31881. * @since 3.0.0
  31882. * @category String
  31883. * @param {string} [string=''] The string to trim.
  31884. * @param {string} [chars=whitespace] The characters to trim.
  31885. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31886. * @returns {string} Returns the trimmed string.
  31887. * @example
  31888. *
  31889. * _.trim(' abc ');
  31890. * // => 'abc'
  31891. *
  31892. * _.trim('-_-abc-_-', '_-');
  31893. * // => 'abc'
  31894. *
  31895. * _.map([' foo ', ' bar '], _.trim);
  31896. * // => ['foo', 'bar']
  31897. */
  31898. function trim(string, chars, guard) {
  31899. string = toString(string);
  31900. if (string && (guard || chars === undefined)) {
  31901. return string.replace(reTrim, '');
  31902. }
  31903. if (!string || !(chars = baseToString(chars))) {
  31904. return string;
  31905. }
  31906. var strSymbols = stringToArray(string),
  31907. chrSymbols = stringToArray(chars),
  31908. start = charsStartIndex(strSymbols, chrSymbols),
  31909. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31910. return castSlice(strSymbols, start, end).join('');
  31911. }
  31912. /**
  31913. * Removes trailing whitespace or specified characters from `string`.
  31914. *
  31915. * @static
  31916. * @memberOf _
  31917. * @since 4.0.0
  31918. * @category String
  31919. * @param {string} [string=''] The string to trim.
  31920. * @param {string} [chars=whitespace] The characters to trim.
  31921. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31922. * @returns {string} Returns the trimmed string.
  31923. * @example
  31924. *
  31925. * _.trimEnd(' abc ');
  31926. * // => ' abc'
  31927. *
  31928. * _.trimEnd('-_-abc-_-', '_-');
  31929. * // => '-_-abc'
  31930. */
  31931. function trimEnd(string, chars, guard) {
  31932. string = toString(string);
  31933. if (string && (guard || chars === undefined)) {
  31934. return string.replace(reTrimEnd, '');
  31935. }
  31936. if (!string || !(chars = baseToString(chars))) {
  31937. return string;
  31938. }
  31939. var strSymbols = stringToArray(string),
  31940. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31941. return castSlice(strSymbols, 0, end).join('');
  31942. }
  31943. /**
  31944. * Removes leading whitespace or specified characters from `string`.
  31945. *
  31946. * @static
  31947. * @memberOf _
  31948. * @since 4.0.0
  31949. * @category String
  31950. * @param {string} [string=''] The string to trim.
  31951. * @param {string} [chars=whitespace] The characters to trim.
  31952. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31953. * @returns {string} Returns the trimmed string.
  31954. * @example
  31955. *
  31956. * _.trimStart(' abc ');
  31957. * // => 'abc '
  31958. *
  31959. * _.trimStart('-_-abc-_-', '_-');
  31960. * // => 'abc-_-'
  31961. */
  31962. function trimStart(string, chars, guard) {
  31963. string = toString(string);
  31964. if (string && (guard || chars === undefined)) {
  31965. return string.replace(reTrimStart, '');
  31966. }
  31967. if (!string || !(chars = baseToString(chars))) {
  31968. return string;
  31969. }
  31970. var strSymbols = stringToArray(string),
  31971. start = charsStartIndex(strSymbols, stringToArray(chars));
  31972. return castSlice(strSymbols, start).join('');
  31973. }
  31974. /**
  31975. * Truncates `string` if it's longer than the given maximum string length.
  31976. * The last characters of the truncated string are replaced with the omission
  31977. * string which defaults to "...".
  31978. *
  31979. * @static
  31980. * @memberOf _
  31981. * @since 4.0.0
  31982. * @category String
  31983. * @param {string} [string=''] The string to truncate.
  31984. * @param {Object} [options={}] The options object.
  31985. * @param {number} [options.length=30] The maximum string length.
  31986. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31987. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31988. * @returns {string} Returns the truncated string.
  31989. * @example
  31990. *
  31991. * _.truncate('hi-diddly-ho there, neighborino');
  31992. * // => 'hi-diddly-ho there, neighbo...'
  31993. *
  31994. * _.truncate('hi-diddly-ho there, neighborino', {
  31995. * 'length': 24,
  31996. * 'separator': ' '
  31997. * });
  31998. * // => 'hi-diddly-ho there,...'
  31999. *
  32000. * _.truncate('hi-diddly-ho there, neighborino', {
  32001. * 'length': 24,
  32002. * 'separator': /,? +/
  32003. * });
  32004. * // => 'hi-diddly-ho there...'
  32005. *
  32006. * _.truncate('hi-diddly-ho there, neighborino', {
  32007. * 'omission': ' [...]'
  32008. * });
  32009. * // => 'hi-diddly-ho there, neig [...]'
  32010. */
  32011. function truncate(string, options) {
  32012. var length = DEFAULT_TRUNC_LENGTH,
  32013. omission = DEFAULT_TRUNC_OMISSION;
  32014. if (isObject(options)) {
  32015. var separator = 'separator' in options ? options.separator : separator;
  32016. length = 'length' in options ? toInteger(options.length) : length;
  32017. omission = 'omission' in options ? baseToString(options.omission) : omission;
  32018. }
  32019. string = toString(string);
  32020. var strLength = string.length;
  32021. if (hasUnicode(string)) {
  32022. var strSymbols = stringToArray(string);
  32023. strLength = strSymbols.length;
  32024. }
  32025. if (length >= strLength) {
  32026. return string;
  32027. }
  32028. var end = length - stringSize(omission);
  32029. if (end < 1) {
  32030. return omission;
  32031. }
  32032. var result = strSymbols
  32033. ? castSlice(strSymbols, 0, end).join('')
  32034. : string.slice(0, end);
  32035. if (separator === undefined) {
  32036. return result + omission;
  32037. }
  32038. if (strSymbols) {
  32039. end += (result.length - end);
  32040. }
  32041. if (isRegExp(separator)) {
  32042. if (string.slice(end).search(separator)) {
  32043. var match,
  32044. substring = result;
  32045. if (!separator.global) {
  32046. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  32047. }
  32048. separator.lastIndex = 0;
  32049. while ((match = separator.exec(substring))) {
  32050. var newEnd = match.index;
  32051. }
  32052. result = result.slice(0, newEnd === undefined ? end : newEnd);
  32053. }
  32054. } else if (string.indexOf(baseToString(separator), end) != end) {
  32055. var index = result.lastIndexOf(separator);
  32056. if (index > -1) {
  32057. result = result.slice(0, index);
  32058. }
  32059. }
  32060. return result + omission;
  32061. }
  32062. /**
  32063. * The inverse of `_.escape`; this method converts the HTML entities
  32064. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  32065. * their corresponding characters.
  32066. *
  32067. * **Note:** No other HTML entities are unescaped. To unescape additional
  32068. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  32069. *
  32070. * @static
  32071. * @memberOf _
  32072. * @since 0.6.0
  32073. * @category String
  32074. * @param {string} [string=''] The string to unescape.
  32075. * @returns {string} Returns the unescaped string.
  32076. * @example
  32077. *
  32078. * _.unescape('fred, barney, &amp; pebbles');
  32079. * // => 'fred, barney, & pebbles'
  32080. */
  32081. function unescape(string) {
  32082. string = toString(string);
  32083. return (string && reHasEscapedHtml.test(string))
  32084. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  32085. : string;
  32086. }
  32087. /**
  32088. * Converts `string`, as space separated words, to upper case.
  32089. *
  32090. * @static
  32091. * @memberOf _
  32092. * @since 4.0.0
  32093. * @category String
  32094. * @param {string} [string=''] The string to convert.
  32095. * @returns {string} Returns the upper cased string.
  32096. * @example
  32097. *
  32098. * _.upperCase('--foo-bar');
  32099. * // => 'FOO BAR'
  32100. *
  32101. * _.upperCase('fooBar');
  32102. * // => 'FOO BAR'
  32103. *
  32104. * _.upperCase('__foo_bar__');
  32105. * // => 'FOO BAR'
  32106. */
  32107. var upperCase = createCompounder(function(result, word, index) {
  32108. return result + (index ? ' ' : '') + word.toUpperCase();
  32109. });
  32110. /**
  32111. * Converts the first character of `string` to upper case.
  32112. *
  32113. * @static
  32114. * @memberOf _
  32115. * @since 4.0.0
  32116. * @category String
  32117. * @param {string} [string=''] The string to convert.
  32118. * @returns {string} Returns the converted string.
  32119. * @example
  32120. *
  32121. * _.upperFirst('fred');
  32122. * // => 'Fred'
  32123. *
  32124. * _.upperFirst('FRED');
  32125. * // => 'FRED'
  32126. */
  32127. var upperFirst = createCaseFirst('toUpperCase');
  32128. /**
  32129. * Splits `string` into an array of its words.
  32130. *
  32131. * @static
  32132. * @memberOf _
  32133. * @since 3.0.0
  32134. * @category String
  32135. * @param {string} [string=''] The string to inspect.
  32136. * @param {RegExp|string} [pattern] The pattern to match words.
  32137. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32138. * @returns {Array} Returns the words of `string`.
  32139. * @example
  32140. *
  32141. * _.words('fred, barney, & pebbles');
  32142. * // => ['fred', 'barney', 'pebbles']
  32143. *
  32144. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32145. * // => ['fred', 'barney', '&', 'pebbles']
  32146. */
  32147. function words(string, pattern, guard) {
  32148. string = toString(string);
  32149. pattern = guard ? undefined : pattern;
  32150. if (pattern === undefined) {
  32151. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32152. }
  32153. return string.match(pattern) || [];
  32154. }
  32155. /*------------------------------------------------------------------------*/
  32156. /**
  32157. * Attempts to invoke `func`, returning either the result or the caught error
  32158. * object. Any additional arguments are provided to `func` when it's invoked.
  32159. *
  32160. * @static
  32161. * @memberOf _
  32162. * @since 3.0.0
  32163. * @category Util
  32164. * @param {Function} func The function to attempt.
  32165. * @param {...*} [args] The arguments to invoke `func` with.
  32166. * @returns {*} Returns the `func` result or error object.
  32167. * @example
  32168. *
  32169. * // Avoid throwing errors for invalid selectors.
  32170. * var elements = _.attempt(function(selector) {
  32171. * return document.querySelectorAll(selector);
  32172. * }, '>_>');
  32173. *
  32174. * if (_.isError(elements)) {
  32175. * elements = [];
  32176. * }
  32177. */
  32178. var attempt = baseRest(function(func, args) {
  32179. try {
  32180. return apply(func, undefined, args);
  32181. } catch (e) {
  32182. return isError(e) ? e : new Error(e);
  32183. }
  32184. });
  32185. /**
  32186. * Binds methods of an object to the object itself, overwriting the existing
  32187. * method.
  32188. *
  32189. * **Note:** This method doesn't set the "length" property of bound functions.
  32190. *
  32191. * @static
  32192. * @since 0.1.0
  32193. * @memberOf _
  32194. * @category Util
  32195. * @param {Object} object The object to bind and assign the bound methods to.
  32196. * @param {...(string|string[])} methodNames The object method names to bind.
  32197. * @returns {Object} Returns `object`.
  32198. * @example
  32199. *
  32200. * var view = {
  32201. * 'label': 'docs',
  32202. * 'click': function() {
  32203. * console.log('clicked ' + this.label);
  32204. * }
  32205. * };
  32206. *
  32207. * _.bindAll(view, ['click']);
  32208. * jQuery(element).on('click', view.click);
  32209. * // => Logs 'clicked docs' when clicked.
  32210. */
  32211. var bindAll = flatRest(function(object, methodNames) {
  32212. arrayEach(methodNames, function(key) {
  32213. key = toKey(key);
  32214. baseAssignValue(object, key, bind(object[key], object));
  32215. });
  32216. return object;
  32217. });
  32218. /**
  32219. * Creates a function that iterates over `pairs` and invokes the corresponding
  32220. * function of the first predicate to return truthy. The predicate-function
  32221. * pairs are invoked with the `this` binding and arguments of the created
  32222. * function.
  32223. *
  32224. * @static
  32225. * @memberOf _
  32226. * @since 4.0.0
  32227. * @category Util
  32228. * @param {Array} pairs The predicate-function pairs.
  32229. * @returns {Function} Returns the new composite function.
  32230. * @example
  32231. *
  32232. * var func = _.cond([
  32233. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32234. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32235. * [_.stubTrue, _.constant('no match')]
  32236. * ]);
  32237. *
  32238. * func({ 'a': 1, 'b': 2 });
  32239. * // => 'matches A'
  32240. *
  32241. * func({ 'a': 0, 'b': 1 });
  32242. * // => 'matches B'
  32243. *
  32244. * func({ 'a': '1', 'b': '2' });
  32245. * // => 'no match'
  32246. */
  32247. function cond(pairs) {
  32248. var length = pairs == null ? 0 : pairs.length,
  32249. toIteratee = getIteratee();
  32250. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32251. if (typeof pair[1] != 'function') {
  32252. throw new TypeError(FUNC_ERROR_TEXT);
  32253. }
  32254. return [toIteratee(pair[0]), pair[1]];
  32255. });
  32256. return baseRest(function(args) {
  32257. var index = -1;
  32258. while (++index < length) {
  32259. var pair = pairs[index];
  32260. if (apply(pair[0], this, args)) {
  32261. return apply(pair[1], this, args);
  32262. }
  32263. }
  32264. });
  32265. }
  32266. /**
  32267. * Creates a function that invokes the predicate properties of `source` with
  32268. * the corresponding property values of a given object, returning `true` if
  32269. * all predicates return truthy, else `false`.
  32270. *
  32271. * **Note:** The created function is equivalent to `_.conformsTo` with
  32272. * `source` partially applied.
  32273. *
  32274. * @static
  32275. * @memberOf _
  32276. * @since 4.0.0
  32277. * @category Util
  32278. * @param {Object} source The object of property predicates to conform to.
  32279. * @returns {Function} Returns the new spec function.
  32280. * @example
  32281. *
  32282. * var objects = [
  32283. * { 'a': 2, 'b': 1 },
  32284. * { 'a': 1, 'b': 2 }
  32285. * ];
  32286. *
  32287. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32288. * // => [{ 'a': 1, 'b': 2 }]
  32289. */
  32290. function conforms(source) {
  32291. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32292. }
  32293. /**
  32294. * Creates a function that returns `value`.
  32295. *
  32296. * @static
  32297. * @memberOf _
  32298. * @since 2.4.0
  32299. * @category Util
  32300. * @param {*} value The value to return from the new function.
  32301. * @returns {Function} Returns the new constant function.
  32302. * @example
  32303. *
  32304. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32305. *
  32306. * console.log(objects);
  32307. * // => [{ 'a': 1 }, { 'a': 1 }]
  32308. *
  32309. * console.log(objects[0] === objects[1]);
  32310. * // => true
  32311. */
  32312. function constant(value) {
  32313. return function() {
  32314. return value;
  32315. };
  32316. }
  32317. /**
  32318. * Checks `value` to determine whether a default value should be returned in
  32319. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32320. * or `undefined`.
  32321. *
  32322. * @static
  32323. * @memberOf _
  32324. * @since 4.14.0
  32325. * @category Util
  32326. * @param {*} value The value to check.
  32327. * @param {*} defaultValue The default value.
  32328. * @returns {*} Returns the resolved value.
  32329. * @example
  32330. *
  32331. * _.defaultTo(1, 10);
  32332. * // => 1
  32333. *
  32334. * _.defaultTo(undefined, 10);
  32335. * // => 10
  32336. */
  32337. function defaultTo(value, defaultValue) {
  32338. return (value == null || value !== value) ? defaultValue : value;
  32339. }
  32340. /**
  32341. * Creates a function that returns the result of invoking the given functions
  32342. * with the `this` binding of the created function, where each successive
  32343. * invocation is supplied the return value of the previous.
  32344. *
  32345. * @static
  32346. * @memberOf _
  32347. * @since 3.0.0
  32348. * @category Util
  32349. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32350. * @returns {Function} Returns the new composite function.
  32351. * @see _.flowRight
  32352. * @example
  32353. *
  32354. * function square(n) {
  32355. * return n * n;
  32356. * }
  32357. *
  32358. * var addSquare = _.flow([_.add, square]);
  32359. * addSquare(1, 2);
  32360. * // => 9
  32361. */
  32362. var flow = createFlow();
  32363. /**
  32364. * This method is like `_.flow` except that it creates a function that
  32365. * invokes the given functions from right to left.
  32366. *
  32367. * @static
  32368. * @since 3.0.0
  32369. * @memberOf _
  32370. * @category Util
  32371. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32372. * @returns {Function} Returns the new composite function.
  32373. * @see _.flow
  32374. * @example
  32375. *
  32376. * function square(n) {
  32377. * return n * n;
  32378. * }
  32379. *
  32380. * var addSquare = _.flowRight([square, _.add]);
  32381. * addSquare(1, 2);
  32382. * // => 9
  32383. */
  32384. var flowRight = createFlow(true);
  32385. /**
  32386. * This method returns the first argument it receives.
  32387. *
  32388. * @static
  32389. * @since 0.1.0
  32390. * @memberOf _
  32391. * @category Util
  32392. * @param {*} value Any value.
  32393. * @returns {*} Returns `value`.
  32394. * @example
  32395. *
  32396. * var object = { 'a': 1 };
  32397. *
  32398. * console.log(_.identity(object) === object);
  32399. * // => true
  32400. */
  32401. function identity(value) {
  32402. return value;
  32403. }
  32404. /**
  32405. * Creates a function that invokes `func` with the arguments of the created
  32406. * function. If `func` is a property name, the created function returns the
  32407. * property value for a given element. If `func` is an array or object, the
  32408. * created function returns `true` for elements that contain the equivalent
  32409. * source properties, otherwise it returns `false`.
  32410. *
  32411. * @static
  32412. * @since 4.0.0
  32413. * @memberOf _
  32414. * @category Util
  32415. * @param {*} [func=_.identity] The value to convert to a callback.
  32416. * @returns {Function} Returns the callback.
  32417. * @example
  32418. *
  32419. * var users = [
  32420. * { 'user': 'barney', 'age': 36, 'active': true },
  32421. * { 'user': 'fred', 'age': 40, 'active': false }
  32422. * ];
  32423. *
  32424. * // The `_.matches` iteratee shorthand.
  32425. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32426. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32427. *
  32428. * // The `_.matchesProperty` iteratee shorthand.
  32429. * _.filter(users, _.iteratee(['user', 'fred']));
  32430. * // => [{ 'user': 'fred', 'age': 40 }]
  32431. *
  32432. * // The `_.property` iteratee shorthand.
  32433. * _.map(users, _.iteratee('user'));
  32434. * // => ['barney', 'fred']
  32435. *
  32436. * // Create custom iteratee shorthands.
  32437. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32438. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32439. * return func.test(string);
  32440. * };
  32441. * });
  32442. *
  32443. * _.filter(['abc', 'def'], /ef/);
  32444. * // => ['def']
  32445. */
  32446. function iteratee(func) {
  32447. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32448. }
  32449. /**
  32450. * Creates a function that performs a partial deep comparison between a given
  32451. * object and `source`, returning `true` if the given object has equivalent
  32452. * property values, else `false`.
  32453. *
  32454. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32455. * partially applied.
  32456. *
  32457. * Partial comparisons will match empty array and empty object `source`
  32458. * values against any array or object value, respectively. See `_.isEqual`
  32459. * for a list of supported value comparisons.
  32460. *
  32461. * @static
  32462. * @memberOf _
  32463. * @since 3.0.0
  32464. * @category Util
  32465. * @param {Object} source The object of property values to match.
  32466. * @returns {Function} Returns the new spec function.
  32467. * @example
  32468. *
  32469. * var objects = [
  32470. * { 'a': 1, 'b': 2, 'c': 3 },
  32471. * { 'a': 4, 'b': 5, 'c': 6 }
  32472. * ];
  32473. *
  32474. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32475. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32476. */
  32477. function matches(source) {
  32478. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32479. }
  32480. /**
  32481. * Creates a function that performs a partial deep comparison between the
  32482. * value at `path` of a given object to `srcValue`, returning `true` if the
  32483. * object value is equivalent, else `false`.
  32484. *
  32485. * **Note:** Partial comparisons will match empty array and empty object
  32486. * `srcValue` values against any array or object value, respectively. See
  32487. * `_.isEqual` for a list of supported value comparisons.
  32488. *
  32489. * @static
  32490. * @memberOf _
  32491. * @since 3.2.0
  32492. * @category Util
  32493. * @param {Array|string} path The path of the property to get.
  32494. * @param {*} srcValue The value to match.
  32495. * @returns {Function} Returns the new spec function.
  32496. * @example
  32497. *
  32498. * var objects = [
  32499. * { 'a': 1, 'b': 2, 'c': 3 },
  32500. * { 'a': 4, 'b': 5, 'c': 6 }
  32501. * ];
  32502. *
  32503. * _.find(objects, _.matchesProperty('a', 4));
  32504. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32505. */
  32506. function matchesProperty(path, srcValue) {
  32507. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32508. }
  32509. /**
  32510. * Creates a function that invokes the method at `path` of a given object.
  32511. * Any additional arguments are provided to the invoked method.
  32512. *
  32513. * @static
  32514. * @memberOf _
  32515. * @since 3.7.0
  32516. * @category Util
  32517. * @param {Array|string} path The path of the method to invoke.
  32518. * @param {...*} [args] The arguments to invoke the method with.
  32519. * @returns {Function} Returns the new invoker function.
  32520. * @example
  32521. *
  32522. * var objects = [
  32523. * { 'a': { 'b': _.constant(2) } },
  32524. * { 'a': { 'b': _.constant(1) } }
  32525. * ];
  32526. *
  32527. * _.map(objects, _.method('a.b'));
  32528. * // => [2, 1]
  32529. *
  32530. * _.map(objects, _.method(['a', 'b']));
  32531. * // => [2, 1]
  32532. */
  32533. var method = baseRest(function(path, args) {
  32534. return function(object) {
  32535. return baseInvoke(object, path, args);
  32536. };
  32537. });
  32538. /**
  32539. * The opposite of `_.method`; this method creates a function that invokes
  32540. * the method at a given path of `object`. Any additional arguments are
  32541. * provided to the invoked method.
  32542. *
  32543. * @static
  32544. * @memberOf _
  32545. * @since 3.7.0
  32546. * @category Util
  32547. * @param {Object} object The object to query.
  32548. * @param {...*} [args] The arguments to invoke the method with.
  32549. * @returns {Function} Returns the new invoker function.
  32550. * @example
  32551. *
  32552. * var array = _.times(3, _.constant),
  32553. * object = { 'a': array, 'b': array, 'c': array };
  32554. *
  32555. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32556. * // => [2, 0]
  32557. *
  32558. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32559. * // => [2, 0]
  32560. */
  32561. var methodOf = baseRest(function(object, args) {
  32562. return function(path) {
  32563. return baseInvoke(object, path, args);
  32564. };
  32565. });
  32566. /**
  32567. * Adds all own enumerable string keyed function properties of a source
  32568. * object to the destination object. If `object` is a function, then methods
  32569. * are added to its prototype as well.
  32570. *
  32571. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32572. * avoid conflicts caused by modifying the original.
  32573. *
  32574. * @static
  32575. * @since 0.1.0
  32576. * @memberOf _
  32577. * @category Util
  32578. * @param {Function|Object} [object=lodash] The destination object.
  32579. * @param {Object} source The object of functions to add.
  32580. * @param {Object} [options={}] The options object.
  32581. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32582. * @returns {Function|Object} Returns `object`.
  32583. * @example
  32584. *
  32585. * function vowels(string) {
  32586. * return _.filter(string, function(v) {
  32587. * return /[aeiou]/i.test(v);
  32588. * });
  32589. * }
  32590. *
  32591. * _.mixin({ 'vowels': vowels });
  32592. * _.vowels('fred');
  32593. * // => ['e']
  32594. *
  32595. * _('fred').vowels().value();
  32596. * // => ['e']
  32597. *
  32598. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32599. * _('fred').vowels();
  32600. * // => ['e']
  32601. */
  32602. function mixin(object, source, options) {
  32603. var props = keys(source),
  32604. methodNames = baseFunctions(source, props);
  32605. if (options == null &&
  32606. !(isObject(source) && (methodNames.length || !props.length))) {
  32607. options = source;
  32608. source = object;
  32609. object = this;
  32610. methodNames = baseFunctions(source, keys(source));
  32611. }
  32612. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32613. isFunc = isFunction(object);
  32614. arrayEach(methodNames, function(methodName) {
  32615. var func = source[methodName];
  32616. object[methodName] = func;
  32617. if (isFunc) {
  32618. object.prototype[methodName] = function() {
  32619. var chainAll = this.__chain__;
  32620. if (chain || chainAll) {
  32621. var result = object(this.__wrapped__),
  32622. actions = result.__actions__ = copyArray(this.__actions__);
  32623. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32624. result.__chain__ = chainAll;
  32625. return result;
  32626. }
  32627. return func.apply(object, arrayPush([this.value()], arguments));
  32628. };
  32629. }
  32630. });
  32631. return object;
  32632. }
  32633. /**
  32634. * Reverts the `_` variable to its previous value and returns a reference to
  32635. * the `lodash` function.
  32636. *
  32637. * @static
  32638. * @since 0.1.0
  32639. * @memberOf _
  32640. * @category Util
  32641. * @returns {Function} Returns the `lodash` function.
  32642. * @example
  32643. *
  32644. * var lodash = _.noConflict();
  32645. */
  32646. function noConflict() {
  32647. if (root._ === this) {
  32648. root._ = oldDash;
  32649. }
  32650. return this;
  32651. }
  32652. /**
  32653. * This method returns `undefined`.
  32654. *
  32655. * @static
  32656. * @memberOf _
  32657. * @since 2.3.0
  32658. * @category Util
  32659. * @example
  32660. *
  32661. * _.times(2, _.noop);
  32662. * // => [undefined, undefined]
  32663. */
  32664. function noop() {
  32665. // No operation performed.
  32666. }
  32667. /**
  32668. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32669. * the nth argument from the end is returned.
  32670. *
  32671. * @static
  32672. * @memberOf _
  32673. * @since 4.0.0
  32674. * @category Util
  32675. * @param {number} [n=0] The index of the argument to return.
  32676. * @returns {Function} Returns the new pass-thru function.
  32677. * @example
  32678. *
  32679. * var func = _.nthArg(1);
  32680. * func('a', 'b', 'c', 'd');
  32681. * // => 'b'
  32682. *
  32683. * var func = _.nthArg(-2);
  32684. * func('a', 'b', 'c', 'd');
  32685. * // => 'c'
  32686. */
  32687. function nthArg(n) {
  32688. n = toInteger(n);
  32689. return baseRest(function(args) {
  32690. return baseNth(args, n);
  32691. });
  32692. }
  32693. /**
  32694. * Creates a function that invokes `iteratees` with the arguments it receives
  32695. * and returns their results.
  32696. *
  32697. * @static
  32698. * @memberOf _
  32699. * @since 4.0.0
  32700. * @category Util
  32701. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32702. * The iteratees to invoke.
  32703. * @returns {Function} Returns the new function.
  32704. * @example
  32705. *
  32706. * var func = _.over([Math.max, Math.min]);
  32707. *
  32708. * func(1, 2, 3, 4);
  32709. * // => [4, 1]
  32710. */
  32711. var over = createOver(arrayMap);
  32712. /**
  32713. * Creates a function that checks if **all** of the `predicates` return
  32714. * truthy when invoked with the arguments it receives.
  32715. *
  32716. * @static
  32717. * @memberOf _
  32718. * @since 4.0.0
  32719. * @category Util
  32720. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32721. * The predicates to check.
  32722. * @returns {Function} Returns the new function.
  32723. * @example
  32724. *
  32725. * var func = _.overEvery([Boolean, isFinite]);
  32726. *
  32727. * func('1');
  32728. * // => true
  32729. *
  32730. * func(null);
  32731. * // => false
  32732. *
  32733. * func(NaN);
  32734. * // => false
  32735. */
  32736. var overEvery = createOver(arrayEvery);
  32737. /**
  32738. * Creates a function that checks if **any** of the `predicates` return
  32739. * truthy when invoked with the arguments it receives.
  32740. *
  32741. * @static
  32742. * @memberOf _
  32743. * @since 4.0.0
  32744. * @category Util
  32745. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32746. * The predicates to check.
  32747. * @returns {Function} Returns the new function.
  32748. * @example
  32749. *
  32750. * var func = _.overSome([Boolean, isFinite]);
  32751. *
  32752. * func('1');
  32753. * // => true
  32754. *
  32755. * func(null);
  32756. * // => true
  32757. *
  32758. * func(NaN);
  32759. * // => false
  32760. */
  32761. var overSome = createOver(arraySome);
  32762. /**
  32763. * Creates a function that returns the value at `path` of a given object.
  32764. *
  32765. * @static
  32766. * @memberOf _
  32767. * @since 2.4.0
  32768. * @category Util
  32769. * @param {Array|string} path The path of the property to get.
  32770. * @returns {Function} Returns the new accessor function.
  32771. * @example
  32772. *
  32773. * var objects = [
  32774. * { 'a': { 'b': 2 } },
  32775. * { 'a': { 'b': 1 } }
  32776. * ];
  32777. *
  32778. * _.map(objects, _.property('a.b'));
  32779. * // => [2, 1]
  32780. *
  32781. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32782. * // => [1, 2]
  32783. */
  32784. function property(path) {
  32785. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32786. }
  32787. /**
  32788. * The opposite of `_.property`; this method creates a function that returns
  32789. * the value at a given path of `object`.
  32790. *
  32791. * @static
  32792. * @memberOf _
  32793. * @since 3.0.0
  32794. * @category Util
  32795. * @param {Object} object The object to query.
  32796. * @returns {Function} Returns the new accessor function.
  32797. * @example
  32798. *
  32799. * var array = [0, 1, 2],
  32800. * object = { 'a': array, 'b': array, 'c': array };
  32801. *
  32802. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32803. * // => [2, 0]
  32804. *
  32805. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32806. * // => [2, 0]
  32807. */
  32808. function propertyOf(object) {
  32809. return function(path) {
  32810. return object == null ? undefined : baseGet(object, path);
  32811. };
  32812. }
  32813. /**
  32814. * Creates an array of numbers (positive and/or negative) progressing from
  32815. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32816. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32817. * it's set to `start` with `start` then set to `0`.
  32818. *
  32819. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32820. * floating-point values which can produce unexpected results.
  32821. *
  32822. * @static
  32823. * @since 0.1.0
  32824. * @memberOf _
  32825. * @category Util
  32826. * @param {number} [start=0] The start of the range.
  32827. * @param {number} end The end of the range.
  32828. * @param {number} [step=1] The value to increment or decrement by.
  32829. * @returns {Array} Returns the range of numbers.
  32830. * @see _.inRange, _.rangeRight
  32831. * @example
  32832. *
  32833. * _.range(4);
  32834. * // => [0, 1, 2, 3]
  32835. *
  32836. * _.range(-4);
  32837. * // => [0, -1, -2, -3]
  32838. *
  32839. * _.range(1, 5);
  32840. * // => [1, 2, 3, 4]
  32841. *
  32842. * _.range(0, 20, 5);
  32843. * // => [0, 5, 10, 15]
  32844. *
  32845. * _.range(0, -4, -1);
  32846. * // => [0, -1, -2, -3]
  32847. *
  32848. * _.range(1, 4, 0);
  32849. * // => [1, 1, 1]
  32850. *
  32851. * _.range(0);
  32852. * // => []
  32853. */
  32854. var range = createRange();
  32855. /**
  32856. * This method is like `_.range` except that it populates values in
  32857. * descending order.
  32858. *
  32859. * @static
  32860. * @memberOf _
  32861. * @since 4.0.0
  32862. * @category Util
  32863. * @param {number} [start=0] The start of the range.
  32864. * @param {number} end The end of the range.
  32865. * @param {number} [step=1] The value to increment or decrement by.
  32866. * @returns {Array} Returns the range of numbers.
  32867. * @see _.inRange, _.range
  32868. * @example
  32869. *
  32870. * _.rangeRight(4);
  32871. * // => [3, 2, 1, 0]
  32872. *
  32873. * _.rangeRight(-4);
  32874. * // => [-3, -2, -1, 0]
  32875. *
  32876. * _.rangeRight(1, 5);
  32877. * // => [4, 3, 2, 1]
  32878. *
  32879. * _.rangeRight(0, 20, 5);
  32880. * // => [15, 10, 5, 0]
  32881. *
  32882. * _.rangeRight(0, -4, -1);
  32883. * // => [-3, -2, -1, 0]
  32884. *
  32885. * _.rangeRight(1, 4, 0);
  32886. * // => [1, 1, 1]
  32887. *
  32888. * _.rangeRight(0);
  32889. * // => []
  32890. */
  32891. var rangeRight = createRange(true);
  32892. /**
  32893. * This method returns a new empty array.
  32894. *
  32895. * @static
  32896. * @memberOf _
  32897. * @since 4.13.0
  32898. * @category Util
  32899. * @returns {Array} Returns the new empty array.
  32900. * @example
  32901. *
  32902. * var arrays = _.times(2, _.stubArray);
  32903. *
  32904. * console.log(arrays);
  32905. * // => [[], []]
  32906. *
  32907. * console.log(arrays[0] === arrays[1]);
  32908. * // => false
  32909. */
  32910. function stubArray() {
  32911. return [];
  32912. }
  32913. /**
  32914. * This method returns `false`.
  32915. *
  32916. * @static
  32917. * @memberOf _
  32918. * @since 4.13.0
  32919. * @category Util
  32920. * @returns {boolean} Returns `false`.
  32921. * @example
  32922. *
  32923. * _.times(2, _.stubFalse);
  32924. * // => [false, false]
  32925. */
  32926. function stubFalse() {
  32927. return false;
  32928. }
  32929. /**
  32930. * This method returns a new empty object.
  32931. *
  32932. * @static
  32933. * @memberOf _
  32934. * @since 4.13.0
  32935. * @category Util
  32936. * @returns {Object} Returns the new empty object.
  32937. * @example
  32938. *
  32939. * var objects = _.times(2, _.stubObject);
  32940. *
  32941. * console.log(objects);
  32942. * // => [{}, {}]
  32943. *
  32944. * console.log(objects[0] === objects[1]);
  32945. * // => false
  32946. */
  32947. function stubObject() {
  32948. return {};
  32949. }
  32950. /**
  32951. * This method returns an empty string.
  32952. *
  32953. * @static
  32954. * @memberOf _
  32955. * @since 4.13.0
  32956. * @category Util
  32957. * @returns {string} Returns the empty string.
  32958. * @example
  32959. *
  32960. * _.times(2, _.stubString);
  32961. * // => ['', '']
  32962. */
  32963. function stubString() {
  32964. return '';
  32965. }
  32966. /**
  32967. * This method returns `true`.
  32968. *
  32969. * @static
  32970. * @memberOf _
  32971. * @since 4.13.0
  32972. * @category Util
  32973. * @returns {boolean} Returns `true`.
  32974. * @example
  32975. *
  32976. * _.times(2, _.stubTrue);
  32977. * // => [true, true]
  32978. */
  32979. function stubTrue() {
  32980. return true;
  32981. }
  32982. /**
  32983. * Invokes the iteratee `n` times, returning an array of the results of
  32984. * each invocation. The iteratee is invoked with one argument; (index).
  32985. *
  32986. * @static
  32987. * @since 0.1.0
  32988. * @memberOf _
  32989. * @category Util
  32990. * @param {number} n The number of times to invoke `iteratee`.
  32991. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32992. * @returns {Array} Returns the array of results.
  32993. * @example
  32994. *
  32995. * _.times(3, String);
  32996. * // => ['0', '1', '2']
  32997. *
  32998. * _.times(4, _.constant(0));
  32999. * // => [0, 0, 0, 0]
  33000. */
  33001. function times(n, iteratee) {
  33002. n = toInteger(n);
  33003. if (n < 1 || n > MAX_SAFE_INTEGER) {
  33004. return [];
  33005. }
  33006. var index = MAX_ARRAY_LENGTH,
  33007. length = nativeMin(n, MAX_ARRAY_LENGTH);
  33008. iteratee = getIteratee(iteratee);
  33009. n -= MAX_ARRAY_LENGTH;
  33010. var result = baseTimes(length, iteratee);
  33011. while (++index < n) {
  33012. iteratee(index);
  33013. }
  33014. return result;
  33015. }
  33016. /**
  33017. * Converts `value` to a property path array.
  33018. *
  33019. * @static
  33020. * @memberOf _
  33021. * @since 4.0.0
  33022. * @category Util
  33023. * @param {*} value The value to convert.
  33024. * @returns {Array} Returns the new property path array.
  33025. * @example
  33026. *
  33027. * _.toPath('a.b.c');
  33028. * // => ['a', 'b', 'c']
  33029. *
  33030. * _.toPath('a[0].b.c');
  33031. * // => ['a', '0', 'b', 'c']
  33032. */
  33033. function toPath(value) {
  33034. if (isArray(value)) {
  33035. return arrayMap(value, toKey);
  33036. }
  33037. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  33038. }
  33039. /**
  33040. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  33041. *
  33042. * @static
  33043. * @since 0.1.0
  33044. * @memberOf _
  33045. * @category Util
  33046. * @param {string} [prefix=''] The value to prefix the ID with.
  33047. * @returns {string} Returns the unique ID.
  33048. * @example
  33049. *
  33050. * _.uniqueId('contact_');
  33051. * // => 'contact_104'
  33052. *
  33053. * _.uniqueId();
  33054. * // => '105'
  33055. */
  33056. function uniqueId(prefix) {
  33057. var id = ++idCounter;
  33058. return toString(prefix) + id;
  33059. }
  33060. /*------------------------------------------------------------------------*/
  33061. /**
  33062. * Adds two numbers.
  33063. *
  33064. * @static
  33065. * @memberOf _
  33066. * @since 3.4.0
  33067. * @category Math
  33068. * @param {number} augend The first number in an addition.
  33069. * @param {number} addend The second number in an addition.
  33070. * @returns {number} Returns the total.
  33071. * @example
  33072. *
  33073. * _.add(6, 4);
  33074. * // => 10
  33075. */
  33076. var add = createMathOperation(function(augend, addend) {
  33077. return augend + addend;
  33078. }, 0);
  33079. /**
  33080. * Computes `number` rounded up to `precision`.
  33081. *
  33082. * @static
  33083. * @memberOf _
  33084. * @since 3.10.0
  33085. * @category Math
  33086. * @param {number} number The number to round up.
  33087. * @param {number} [precision=0] The precision to round up to.
  33088. * @returns {number} Returns the rounded up number.
  33089. * @example
  33090. *
  33091. * _.ceil(4.006);
  33092. * // => 5
  33093. *
  33094. * _.ceil(6.004, 2);
  33095. * // => 6.01
  33096. *
  33097. * _.ceil(6040, -2);
  33098. * // => 6100
  33099. */
  33100. var ceil = createRound('ceil');
  33101. /**
  33102. * Divide two numbers.
  33103. *
  33104. * @static
  33105. * @memberOf _
  33106. * @since 4.7.0
  33107. * @category Math
  33108. * @param {number} dividend The first number in a division.
  33109. * @param {number} divisor The second number in a division.
  33110. * @returns {number} Returns the quotient.
  33111. * @example
  33112. *
  33113. * _.divide(6, 4);
  33114. * // => 1.5
  33115. */
  33116. var divide = createMathOperation(function(dividend, divisor) {
  33117. return dividend / divisor;
  33118. }, 1);
  33119. /**
  33120. * Computes `number` rounded down to `precision`.
  33121. *
  33122. * @static
  33123. * @memberOf _
  33124. * @since 3.10.0
  33125. * @category Math
  33126. * @param {number} number The number to round down.
  33127. * @param {number} [precision=0] The precision to round down to.
  33128. * @returns {number} Returns the rounded down number.
  33129. * @example
  33130. *
  33131. * _.floor(4.006);
  33132. * // => 4
  33133. *
  33134. * _.floor(0.046, 2);
  33135. * // => 0.04
  33136. *
  33137. * _.floor(4060, -2);
  33138. * // => 4000
  33139. */
  33140. var floor = createRound('floor');
  33141. /**
  33142. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33143. * `undefined` is returned.
  33144. *
  33145. * @static
  33146. * @since 0.1.0
  33147. * @memberOf _
  33148. * @category Math
  33149. * @param {Array} array The array to iterate over.
  33150. * @returns {*} Returns the maximum value.
  33151. * @example
  33152. *
  33153. * _.max([4, 2, 8, 6]);
  33154. * // => 8
  33155. *
  33156. * _.max([]);
  33157. * // => undefined
  33158. */
  33159. function max(array) {
  33160. return (array && array.length)
  33161. ? baseExtremum(array, identity, baseGt)
  33162. : undefined;
  33163. }
  33164. /**
  33165. * This method is like `_.max` except that it accepts `iteratee` which is
  33166. * invoked for each element in `array` to generate the criterion by which
  33167. * the value is ranked. The iteratee is invoked with one argument: (value).
  33168. *
  33169. * @static
  33170. * @memberOf _
  33171. * @since 4.0.0
  33172. * @category Math
  33173. * @param {Array} array The array to iterate over.
  33174. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33175. * @returns {*} Returns the maximum value.
  33176. * @example
  33177. *
  33178. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33179. *
  33180. * _.maxBy(objects, function(o) { return o.n; });
  33181. * // => { 'n': 2 }
  33182. *
  33183. * // The `_.property` iteratee shorthand.
  33184. * _.maxBy(objects, 'n');
  33185. * // => { 'n': 2 }
  33186. */
  33187. function maxBy(array, iteratee) {
  33188. return (array && array.length)
  33189. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33190. : undefined;
  33191. }
  33192. /**
  33193. * Computes the mean of the values in `array`.
  33194. *
  33195. * @static
  33196. * @memberOf _
  33197. * @since 4.0.0
  33198. * @category Math
  33199. * @param {Array} array The array to iterate over.
  33200. * @returns {number} Returns the mean.
  33201. * @example
  33202. *
  33203. * _.mean([4, 2, 8, 6]);
  33204. * // => 5
  33205. */
  33206. function mean(array) {
  33207. return baseMean(array, identity);
  33208. }
  33209. /**
  33210. * This method is like `_.mean` except that it accepts `iteratee` which is
  33211. * invoked for each element in `array` to generate the value to be averaged.
  33212. * The iteratee is invoked with one argument: (value).
  33213. *
  33214. * @static
  33215. * @memberOf _
  33216. * @since 4.7.0
  33217. * @category Math
  33218. * @param {Array} array The array to iterate over.
  33219. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33220. * @returns {number} Returns the mean.
  33221. * @example
  33222. *
  33223. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33224. *
  33225. * _.meanBy(objects, function(o) { return o.n; });
  33226. * // => 5
  33227. *
  33228. * // The `_.property` iteratee shorthand.
  33229. * _.meanBy(objects, 'n');
  33230. * // => 5
  33231. */
  33232. function meanBy(array, iteratee) {
  33233. return baseMean(array, getIteratee(iteratee, 2));
  33234. }
  33235. /**
  33236. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33237. * `undefined` is returned.
  33238. *
  33239. * @static
  33240. * @since 0.1.0
  33241. * @memberOf _
  33242. * @category Math
  33243. * @param {Array} array The array to iterate over.
  33244. * @returns {*} Returns the minimum value.
  33245. * @example
  33246. *
  33247. * _.min([4, 2, 8, 6]);
  33248. * // => 2
  33249. *
  33250. * _.min([]);
  33251. * // => undefined
  33252. */
  33253. function min(array) {
  33254. return (array && array.length)
  33255. ? baseExtremum(array, identity, baseLt)
  33256. : undefined;
  33257. }
  33258. /**
  33259. * This method is like `_.min` except that it accepts `iteratee` which is
  33260. * invoked for each element in `array` to generate the criterion by which
  33261. * the value is ranked. The iteratee is invoked with one argument: (value).
  33262. *
  33263. * @static
  33264. * @memberOf _
  33265. * @since 4.0.0
  33266. * @category Math
  33267. * @param {Array} array The array to iterate over.
  33268. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33269. * @returns {*} Returns the minimum value.
  33270. * @example
  33271. *
  33272. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33273. *
  33274. * _.minBy(objects, function(o) { return o.n; });
  33275. * // => { 'n': 1 }
  33276. *
  33277. * // The `_.property` iteratee shorthand.
  33278. * _.minBy(objects, 'n');
  33279. * // => { 'n': 1 }
  33280. */
  33281. function minBy(array, iteratee) {
  33282. return (array && array.length)
  33283. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33284. : undefined;
  33285. }
  33286. /**
  33287. * Multiply two numbers.
  33288. *
  33289. * @static
  33290. * @memberOf _
  33291. * @since 4.7.0
  33292. * @category Math
  33293. * @param {number} multiplier The first number in a multiplication.
  33294. * @param {number} multiplicand The second number in a multiplication.
  33295. * @returns {number} Returns the product.
  33296. * @example
  33297. *
  33298. * _.multiply(6, 4);
  33299. * // => 24
  33300. */
  33301. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33302. return multiplier * multiplicand;
  33303. }, 1);
  33304. /**
  33305. * Computes `number` rounded to `precision`.
  33306. *
  33307. * @static
  33308. * @memberOf _
  33309. * @since 3.10.0
  33310. * @category Math
  33311. * @param {number} number The number to round.
  33312. * @param {number} [precision=0] The precision to round to.
  33313. * @returns {number} Returns the rounded number.
  33314. * @example
  33315. *
  33316. * _.round(4.006);
  33317. * // => 4
  33318. *
  33319. * _.round(4.006, 2);
  33320. * // => 4.01
  33321. *
  33322. * _.round(4060, -2);
  33323. * // => 4100
  33324. */
  33325. var round = createRound('round');
  33326. /**
  33327. * Subtract two numbers.
  33328. *
  33329. * @static
  33330. * @memberOf _
  33331. * @since 4.0.0
  33332. * @category Math
  33333. * @param {number} minuend The first number in a subtraction.
  33334. * @param {number} subtrahend The second number in a subtraction.
  33335. * @returns {number} Returns the difference.
  33336. * @example
  33337. *
  33338. * _.subtract(6, 4);
  33339. * // => 2
  33340. */
  33341. var subtract = createMathOperation(function(minuend, subtrahend) {
  33342. return minuend - subtrahend;
  33343. }, 0);
  33344. /**
  33345. * Computes the sum of the values in `array`.
  33346. *
  33347. * @static
  33348. * @memberOf _
  33349. * @since 3.4.0
  33350. * @category Math
  33351. * @param {Array} array The array to iterate over.
  33352. * @returns {number} Returns the sum.
  33353. * @example
  33354. *
  33355. * _.sum([4, 2, 8, 6]);
  33356. * // => 20
  33357. */
  33358. function sum(array) {
  33359. return (array && array.length)
  33360. ? baseSum(array, identity)
  33361. : 0;
  33362. }
  33363. /**
  33364. * This method is like `_.sum` except that it accepts `iteratee` which is
  33365. * invoked for each element in `array` to generate the value to be summed.
  33366. * The iteratee is invoked with one argument: (value).
  33367. *
  33368. * @static
  33369. * @memberOf _
  33370. * @since 4.0.0
  33371. * @category Math
  33372. * @param {Array} array The array to iterate over.
  33373. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33374. * @returns {number} Returns the sum.
  33375. * @example
  33376. *
  33377. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33378. *
  33379. * _.sumBy(objects, function(o) { return o.n; });
  33380. * // => 20
  33381. *
  33382. * // The `_.property` iteratee shorthand.
  33383. * _.sumBy(objects, 'n');
  33384. * // => 20
  33385. */
  33386. function sumBy(array, iteratee) {
  33387. return (array && array.length)
  33388. ? baseSum(array, getIteratee(iteratee, 2))
  33389. : 0;
  33390. }
  33391. /*------------------------------------------------------------------------*/
  33392. // Add methods that return wrapped values in chain sequences.
  33393. lodash.after = after;
  33394. lodash.ary = ary;
  33395. lodash.assign = assign;
  33396. lodash.assignIn = assignIn;
  33397. lodash.assignInWith = assignInWith;
  33398. lodash.assignWith = assignWith;
  33399. lodash.at = at;
  33400. lodash.before = before;
  33401. lodash.bind = bind;
  33402. lodash.bindAll = bindAll;
  33403. lodash.bindKey = bindKey;
  33404. lodash.castArray = castArray;
  33405. lodash.chain = chain;
  33406. lodash.chunk = chunk;
  33407. lodash.compact = compact;
  33408. lodash.concat = concat;
  33409. lodash.cond = cond;
  33410. lodash.conforms = conforms;
  33411. lodash.constant = constant;
  33412. lodash.countBy = countBy;
  33413. lodash.create = create;
  33414. lodash.curry = curry;
  33415. lodash.curryRight = curryRight;
  33416. lodash.debounce = debounce;
  33417. lodash.defaults = defaults;
  33418. lodash.defaultsDeep = defaultsDeep;
  33419. lodash.defer = defer;
  33420. lodash.delay = delay;
  33421. lodash.difference = difference;
  33422. lodash.differenceBy = differenceBy;
  33423. lodash.differenceWith = differenceWith;
  33424. lodash.drop = drop;
  33425. lodash.dropRight = dropRight;
  33426. lodash.dropRightWhile = dropRightWhile;
  33427. lodash.dropWhile = dropWhile;
  33428. lodash.fill = fill;
  33429. lodash.filter = filter;
  33430. lodash.flatMap = flatMap;
  33431. lodash.flatMapDeep = flatMapDeep;
  33432. lodash.flatMapDepth = flatMapDepth;
  33433. lodash.flatten = flatten;
  33434. lodash.flattenDeep = flattenDeep;
  33435. lodash.flattenDepth = flattenDepth;
  33436. lodash.flip = flip;
  33437. lodash.flow = flow;
  33438. lodash.flowRight = flowRight;
  33439. lodash.fromPairs = fromPairs;
  33440. lodash.functions = functions;
  33441. lodash.functionsIn = functionsIn;
  33442. lodash.groupBy = groupBy;
  33443. lodash.initial = initial;
  33444. lodash.intersection = intersection;
  33445. lodash.intersectionBy = intersectionBy;
  33446. lodash.intersectionWith = intersectionWith;
  33447. lodash.invert = invert;
  33448. lodash.invertBy = invertBy;
  33449. lodash.invokeMap = invokeMap;
  33450. lodash.iteratee = iteratee;
  33451. lodash.keyBy = keyBy;
  33452. lodash.keys = keys;
  33453. lodash.keysIn = keysIn;
  33454. lodash.map = map;
  33455. lodash.mapKeys = mapKeys;
  33456. lodash.mapValues = mapValues;
  33457. lodash.matches = matches;
  33458. lodash.matchesProperty = matchesProperty;
  33459. lodash.memoize = memoize;
  33460. lodash.merge = merge;
  33461. lodash.mergeWith = mergeWith;
  33462. lodash.method = method;
  33463. lodash.methodOf = methodOf;
  33464. lodash.mixin = mixin;
  33465. lodash.negate = negate;
  33466. lodash.nthArg = nthArg;
  33467. lodash.omit = omit;
  33468. lodash.omitBy = omitBy;
  33469. lodash.once = once;
  33470. lodash.orderBy = orderBy;
  33471. lodash.over = over;
  33472. lodash.overArgs = overArgs;
  33473. lodash.overEvery = overEvery;
  33474. lodash.overSome = overSome;
  33475. lodash.partial = partial;
  33476. lodash.partialRight = partialRight;
  33477. lodash.partition = partition;
  33478. lodash.pick = pick;
  33479. lodash.pickBy = pickBy;
  33480. lodash.property = property;
  33481. lodash.propertyOf = propertyOf;
  33482. lodash.pull = pull;
  33483. lodash.pullAll = pullAll;
  33484. lodash.pullAllBy = pullAllBy;
  33485. lodash.pullAllWith = pullAllWith;
  33486. lodash.pullAt = pullAt;
  33487. lodash.range = range;
  33488. lodash.rangeRight = rangeRight;
  33489. lodash.rearg = rearg;
  33490. lodash.reject = reject;
  33491. lodash.remove = remove;
  33492. lodash.rest = rest;
  33493. lodash.reverse = reverse;
  33494. lodash.sampleSize = sampleSize;
  33495. lodash.set = set;
  33496. lodash.setWith = setWith;
  33497. lodash.shuffle = shuffle;
  33498. lodash.slice = slice;
  33499. lodash.sortBy = sortBy;
  33500. lodash.sortedUniq = sortedUniq;
  33501. lodash.sortedUniqBy = sortedUniqBy;
  33502. lodash.split = split;
  33503. lodash.spread = spread;
  33504. lodash.tail = tail;
  33505. lodash.take = take;
  33506. lodash.takeRight = takeRight;
  33507. lodash.takeRightWhile = takeRightWhile;
  33508. lodash.takeWhile = takeWhile;
  33509. lodash.tap = tap;
  33510. lodash.throttle = throttle;
  33511. lodash.thru = thru;
  33512. lodash.toArray = toArray;
  33513. lodash.toPairs = toPairs;
  33514. lodash.toPairsIn = toPairsIn;
  33515. lodash.toPath = toPath;
  33516. lodash.toPlainObject = toPlainObject;
  33517. lodash.transform = transform;
  33518. lodash.unary = unary;
  33519. lodash.union = union;
  33520. lodash.unionBy = unionBy;
  33521. lodash.unionWith = unionWith;
  33522. lodash.uniq = uniq;
  33523. lodash.uniqBy = uniqBy;
  33524. lodash.uniqWith = uniqWith;
  33525. lodash.unset = unset;
  33526. lodash.unzip = unzip;
  33527. lodash.unzipWith = unzipWith;
  33528. lodash.update = update;
  33529. lodash.updateWith = updateWith;
  33530. lodash.values = values;
  33531. lodash.valuesIn = valuesIn;
  33532. lodash.without = without;
  33533. lodash.words = words;
  33534. lodash.wrap = wrap;
  33535. lodash.xor = xor;
  33536. lodash.xorBy = xorBy;
  33537. lodash.xorWith = xorWith;
  33538. lodash.zip = zip;
  33539. lodash.zipObject = zipObject;
  33540. lodash.zipObjectDeep = zipObjectDeep;
  33541. lodash.zipWith = zipWith;
  33542. // Add aliases.
  33543. lodash.entries = toPairs;
  33544. lodash.entriesIn = toPairsIn;
  33545. lodash.extend = assignIn;
  33546. lodash.extendWith = assignInWith;
  33547. // Add methods to `lodash.prototype`.
  33548. mixin(lodash, lodash);
  33549. /*------------------------------------------------------------------------*/
  33550. // Add methods that return unwrapped values in chain sequences.
  33551. lodash.add = add;
  33552. lodash.attempt = attempt;
  33553. lodash.camelCase = camelCase;
  33554. lodash.capitalize = capitalize;
  33555. lodash.ceil = ceil;
  33556. lodash.clamp = clamp;
  33557. lodash.clone = clone;
  33558. lodash.cloneDeep = cloneDeep;
  33559. lodash.cloneDeepWith = cloneDeepWith;
  33560. lodash.cloneWith = cloneWith;
  33561. lodash.conformsTo = conformsTo;
  33562. lodash.deburr = deburr;
  33563. lodash.defaultTo = defaultTo;
  33564. lodash.divide = divide;
  33565. lodash.endsWith = endsWith;
  33566. lodash.eq = eq;
  33567. lodash.escape = escape;
  33568. lodash.escapeRegExp = escapeRegExp;
  33569. lodash.every = every;
  33570. lodash.find = find;
  33571. lodash.findIndex = findIndex;
  33572. lodash.findKey = findKey;
  33573. lodash.findLast = findLast;
  33574. lodash.findLastIndex = findLastIndex;
  33575. lodash.findLastKey = findLastKey;
  33576. lodash.floor = floor;
  33577. lodash.forEach = forEach;
  33578. lodash.forEachRight = forEachRight;
  33579. lodash.forIn = forIn;
  33580. lodash.forInRight = forInRight;
  33581. lodash.forOwn = forOwn;
  33582. lodash.forOwnRight = forOwnRight;
  33583. lodash.get = get;
  33584. lodash.gt = gt;
  33585. lodash.gte = gte;
  33586. lodash.has = has;
  33587. lodash.hasIn = hasIn;
  33588. lodash.head = head;
  33589. lodash.identity = identity;
  33590. lodash.includes = includes;
  33591. lodash.indexOf = indexOf;
  33592. lodash.inRange = inRange;
  33593. lodash.invoke = invoke;
  33594. lodash.isArguments = isArguments;
  33595. lodash.isArray = isArray;
  33596. lodash.isArrayBuffer = isArrayBuffer;
  33597. lodash.isArrayLike = isArrayLike;
  33598. lodash.isArrayLikeObject = isArrayLikeObject;
  33599. lodash.isBoolean = isBoolean;
  33600. lodash.isBuffer = isBuffer;
  33601. lodash.isDate = isDate;
  33602. lodash.isElement = isElement;
  33603. lodash.isEmpty = isEmpty;
  33604. lodash.isEqual = isEqual;
  33605. lodash.isEqualWith = isEqualWith;
  33606. lodash.isError = isError;
  33607. lodash.isFinite = isFinite;
  33608. lodash.isFunction = isFunction;
  33609. lodash.isInteger = isInteger;
  33610. lodash.isLength = isLength;
  33611. lodash.isMap = isMap;
  33612. lodash.isMatch = isMatch;
  33613. lodash.isMatchWith = isMatchWith;
  33614. lodash.isNaN = isNaN;
  33615. lodash.isNative = isNative;
  33616. lodash.isNil = isNil;
  33617. lodash.isNull = isNull;
  33618. lodash.isNumber = isNumber;
  33619. lodash.isObject = isObject;
  33620. lodash.isObjectLike = isObjectLike;
  33621. lodash.isPlainObject = isPlainObject;
  33622. lodash.isRegExp = isRegExp;
  33623. lodash.isSafeInteger = isSafeInteger;
  33624. lodash.isSet = isSet;
  33625. lodash.isString = isString;
  33626. lodash.isSymbol = isSymbol;
  33627. lodash.isTypedArray = isTypedArray;
  33628. lodash.isUndefined = isUndefined;
  33629. lodash.isWeakMap = isWeakMap;
  33630. lodash.isWeakSet = isWeakSet;
  33631. lodash.join = join;
  33632. lodash.kebabCase = kebabCase;
  33633. lodash.last = last;
  33634. lodash.lastIndexOf = lastIndexOf;
  33635. lodash.lowerCase = lowerCase;
  33636. lodash.lowerFirst = lowerFirst;
  33637. lodash.lt = lt;
  33638. lodash.lte = lte;
  33639. lodash.max = max;
  33640. lodash.maxBy = maxBy;
  33641. lodash.mean = mean;
  33642. lodash.meanBy = meanBy;
  33643. lodash.min = min;
  33644. lodash.minBy = minBy;
  33645. lodash.stubArray = stubArray;
  33646. lodash.stubFalse = stubFalse;
  33647. lodash.stubObject = stubObject;
  33648. lodash.stubString = stubString;
  33649. lodash.stubTrue = stubTrue;
  33650. lodash.multiply = multiply;
  33651. lodash.nth = nth;
  33652. lodash.noConflict = noConflict;
  33653. lodash.noop = noop;
  33654. lodash.now = now;
  33655. lodash.pad = pad;
  33656. lodash.padEnd = padEnd;
  33657. lodash.padStart = padStart;
  33658. lodash.parseInt = parseInt;
  33659. lodash.random = random;
  33660. lodash.reduce = reduce;
  33661. lodash.reduceRight = reduceRight;
  33662. lodash.repeat = repeat;
  33663. lodash.replace = replace;
  33664. lodash.result = result;
  33665. lodash.round = round;
  33666. lodash.runInContext = runInContext;
  33667. lodash.sample = sample;
  33668. lodash.size = size;
  33669. lodash.snakeCase = snakeCase;
  33670. lodash.some = some;
  33671. lodash.sortedIndex = sortedIndex;
  33672. lodash.sortedIndexBy = sortedIndexBy;
  33673. lodash.sortedIndexOf = sortedIndexOf;
  33674. lodash.sortedLastIndex = sortedLastIndex;
  33675. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33676. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33677. lodash.startCase = startCase;
  33678. lodash.startsWith = startsWith;
  33679. lodash.subtract = subtract;
  33680. lodash.sum = sum;
  33681. lodash.sumBy = sumBy;
  33682. lodash.template = template;
  33683. lodash.times = times;
  33684. lodash.toFinite = toFinite;
  33685. lodash.toInteger = toInteger;
  33686. lodash.toLength = toLength;
  33687. lodash.toLower = toLower;
  33688. lodash.toNumber = toNumber;
  33689. lodash.toSafeInteger = toSafeInteger;
  33690. lodash.toString = toString;
  33691. lodash.toUpper = toUpper;
  33692. lodash.trim = trim;
  33693. lodash.trimEnd = trimEnd;
  33694. lodash.trimStart = trimStart;
  33695. lodash.truncate = truncate;
  33696. lodash.unescape = unescape;
  33697. lodash.uniqueId = uniqueId;
  33698. lodash.upperCase = upperCase;
  33699. lodash.upperFirst = upperFirst;
  33700. // Add aliases.
  33701. lodash.each = forEach;
  33702. lodash.eachRight = forEachRight;
  33703. lodash.first = head;
  33704. mixin(lodash, (function() {
  33705. var source = {};
  33706. baseForOwn(lodash, function(func, methodName) {
  33707. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33708. source[methodName] = func;
  33709. }
  33710. });
  33711. return source;
  33712. }()), { 'chain': false });
  33713. /*------------------------------------------------------------------------*/
  33714. /**
  33715. * The semantic version number.
  33716. *
  33717. * @static
  33718. * @memberOf _
  33719. * @type {string}
  33720. */
  33721. lodash.VERSION = VERSION;
  33722. // Assign default placeholders.
  33723. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33724. lodash[methodName].placeholder = lodash;
  33725. });
  33726. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33727. arrayEach(['drop', 'take'], function(methodName, index) {
  33728. LazyWrapper.prototype[methodName] = function(n) {
  33729. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33730. var result = (this.__filtered__ && !index)
  33731. ? new LazyWrapper(this)
  33732. : this.clone();
  33733. if (result.__filtered__) {
  33734. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33735. } else {
  33736. result.__views__.push({
  33737. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33738. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33739. });
  33740. }
  33741. return result;
  33742. };
  33743. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33744. return this.reverse()[methodName](n).reverse();
  33745. };
  33746. });
  33747. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33748. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33749. var type = index + 1,
  33750. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33751. LazyWrapper.prototype[methodName] = function(iteratee) {
  33752. var result = this.clone();
  33753. result.__iteratees__.push({
  33754. 'iteratee': getIteratee(iteratee, 3),
  33755. 'type': type
  33756. });
  33757. result.__filtered__ = result.__filtered__ || isFilter;
  33758. return result;
  33759. };
  33760. });
  33761. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33762. arrayEach(['head', 'last'], function(methodName, index) {
  33763. var takeName = 'take' + (index ? 'Right' : '');
  33764. LazyWrapper.prototype[methodName] = function() {
  33765. return this[takeName](1).value()[0];
  33766. };
  33767. });
  33768. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33769. arrayEach(['initial', 'tail'], function(methodName, index) {
  33770. var dropName = 'drop' + (index ? '' : 'Right');
  33771. LazyWrapper.prototype[methodName] = function() {
  33772. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33773. };
  33774. });
  33775. LazyWrapper.prototype.compact = function() {
  33776. return this.filter(identity);
  33777. };
  33778. LazyWrapper.prototype.find = function(predicate) {
  33779. return this.filter(predicate).head();
  33780. };
  33781. LazyWrapper.prototype.findLast = function(predicate) {
  33782. return this.reverse().find(predicate);
  33783. };
  33784. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33785. if (typeof path == 'function') {
  33786. return new LazyWrapper(this);
  33787. }
  33788. return this.map(function(value) {
  33789. return baseInvoke(value, path, args);
  33790. });
  33791. });
  33792. LazyWrapper.prototype.reject = function(predicate) {
  33793. return this.filter(negate(getIteratee(predicate)));
  33794. };
  33795. LazyWrapper.prototype.slice = function(start, end) {
  33796. start = toInteger(start);
  33797. var result = this;
  33798. if (result.__filtered__ && (start > 0 || end < 0)) {
  33799. return new LazyWrapper(result);
  33800. }
  33801. if (start < 0) {
  33802. result = result.takeRight(-start);
  33803. } else if (start) {
  33804. result = result.drop(start);
  33805. }
  33806. if (end !== undefined) {
  33807. end = toInteger(end);
  33808. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33809. }
  33810. return result;
  33811. };
  33812. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33813. return this.reverse().takeWhile(predicate).reverse();
  33814. };
  33815. LazyWrapper.prototype.toArray = function() {
  33816. return this.take(MAX_ARRAY_LENGTH);
  33817. };
  33818. // Add `LazyWrapper` methods to `lodash.prototype`.
  33819. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33820. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33821. isTaker = /^(?:head|last)$/.test(methodName),
  33822. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33823. retUnwrapped = isTaker || /^find/.test(methodName);
  33824. if (!lodashFunc) {
  33825. return;
  33826. }
  33827. lodash.prototype[methodName] = function() {
  33828. var value = this.__wrapped__,
  33829. args = isTaker ? [1] : arguments,
  33830. isLazy = value instanceof LazyWrapper,
  33831. iteratee = args[0],
  33832. useLazy = isLazy || isArray(value);
  33833. var interceptor = function(value) {
  33834. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33835. return (isTaker && chainAll) ? result[0] : result;
  33836. };
  33837. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33838. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33839. isLazy = useLazy = false;
  33840. }
  33841. var chainAll = this.__chain__,
  33842. isHybrid = !!this.__actions__.length,
  33843. isUnwrapped = retUnwrapped && !chainAll,
  33844. onlyLazy = isLazy && !isHybrid;
  33845. if (!retUnwrapped && useLazy) {
  33846. value = onlyLazy ? value : new LazyWrapper(this);
  33847. var result = func.apply(value, args);
  33848. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33849. return new LodashWrapper(result, chainAll);
  33850. }
  33851. if (isUnwrapped && onlyLazy) {
  33852. return func.apply(this, args);
  33853. }
  33854. result = this.thru(interceptor);
  33855. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33856. };
  33857. });
  33858. // Add `Array` methods to `lodash.prototype`.
  33859. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33860. var func = arrayProto[methodName],
  33861. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33862. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33863. lodash.prototype[methodName] = function() {
  33864. var args = arguments;
  33865. if (retUnwrapped && !this.__chain__) {
  33866. var value = this.value();
  33867. return func.apply(isArray(value) ? value : [], args);
  33868. }
  33869. return this[chainName](function(value) {
  33870. return func.apply(isArray(value) ? value : [], args);
  33871. });
  33872. };
  33873. });
  33874. // Map minified method names to their real names.
  33875. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33876. var lodashFunc = lodash[methodName];
  33877. if (lodashFunc) {
  33878. var key = lodashFunc.name + '';
  33879. if (!hasOwnProperty.call(realNames, key)) {
  33880. realNames[key] = [];
  33881. }
  33882. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33883. }
  33884. });
  33885. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33886. 'name': 'wrapper',
  33887. 'func': undefined
  33888. }];
  33889. // Add methods to `LazyWrapper`.
  33890. LazyWrapper.prototype.clone = lazyClone;
  33891. LazyWrapper.prototype.reverse = lazyReverse;
  33892. LazyWrapper.prototype.value = lazyValue;
  33893. // Add chain sequence methods to the `lodash` wrapper.
  33894. lodash.prototype.at = wrapperAt;
  33895. lodash.prototype.chain = wrapperChain;
  33896. lodash.prototype.commit = wrapperCommit;
  33897. lodash.prototype.next = wrapperNext;
  33898. lodash.prototype.plant = wrapperPlant;
  33899. lodash.prototype.reverse = wrapperReverse;
  33900. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33901. // Add lazy aliases.
  33902. lodash.prototype.first = lodash.prototype.head;
  33903. if (symIterator) {
  33904. lodash.prototype[symIterator] = wrapperToIterator;
  33905. }
  33906. return lodash;
  33907. });
  33908. /*--------------------------------------------------------------------------*/
  33909. // Export lodash.
  33910. var _ = runInContext();
  33911. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33912. if (true) {
  33913. // Expose Lodash on the global object to prevent errors when Lodash is
  33914. // loaded by a script tag in the presence of an AMD loader.
  33915. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33916. // Use `_.noConflict` to remove Lodash from the global object.
  33917. root._ = _;
  33918. // Define as an anonymous module so, through path mapping, it can be
  33919. // referenced as the "underscore" module.
  33920. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33921. return _;
  33922. }).call(exports, __webpack_require__, exports, module),
  33923. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33924. }
  33925. // Check for `exports` after `define` in case a build optimizer adds it.
  33926. else {}
  33927. }.call(this));
  33928. /* 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)))
  33929. /***/ }),
  33930. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33931. /*!***************************************************!*\
  33932. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33933. \***************************************************/
  33934. /*! exports provided: default */
  33935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33936. "use strict";
  33937. __webpack_require__.r(__webpack_exports__);
  33938. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33939. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33940. * @version 1.16.1
  33941. * @license
  33942. * Copyright (c) 2016 Federico Zivolo and contributors
  33943. *
  33944. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33945. * of this software and associated documentation files (the "Software"), to deal
  33946. * in the Software without restriction, including without limitation the rights
  33947. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33948. * copies of the Software, and to permit persons to whom the Software is
  33949. * furnished to do so, subject to the following conditions:
  33950. *
  33951. * The above copyright notice and this permission notice shall be included in all
  33952. * copies or substantial portions of the Software.
  33953. *
  33954. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33955. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33956. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33957. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33958. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33959. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33960. * SOFTWARE.
  33961. */
  33962. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33963. var timeoutDuration = function () {
  33964. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33965. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33966. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33967. return 1;
  33968. }
  33969. }
  33970. return 0;
  33971. }();
  33972. function microtaskDebounce(fn) {
  33973. var called = false;
  33974. return function () {
  33975. if (called) {
  33976. return;
  33977. }
  33978. called = true;
  33979. window.Promise.resolve().then(function () {
  33980. called = false;
  33981. fn();
  33982. });
  33983. };
  33984. }
  33985. function taskDebounce(fn) {
  33986. var scheduled = false;
  33987. return function () {
  33988. if (!scheduled) {
  33989. scheduled = true;
  33990. setTimeout(function () {
  33991. scheduled = false;
  33992. fn();
  33993. }, timeoutDuration);
  33994. }
  33995. };
  33996. }
  33997. var supportsMicroTasks = isBrowser && window.Promise;
  33998. /**
  33999. * Create a debounced version of a method, that's asynchronously deferred
  34000. * but called in the minimum time possible.
  34001. *
  34002. * @method
  34003. * @memberof Popper.Utils
  34004. * @argument {Function} fn
  34005. * @returns {Function}
  34006. */
  34007. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  34008. /**
  34009. * Check if the given variable is a function
  34010. * @method
  34011. * @memberof Popper.Utils
  34012. * @argument {Any} functionToCheck - variable to check
  34013. * @returns {Boolean} answer to: is a function?
  34014. */
  34015. function isFunction(functionToCheck) {
  34016. var getType = {};
  34017. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  34018. }
  34019. /**
  34020. * Get CSS computed property of the given element
  34021. * @method
  34022. * @memberof Popper.Utils
  34023. * @argument {Eement} element
  34024. * @argument {String} property
  34025. */
  34026. function getStyleComputedProperty(element, property) {
  34027. if (element.nodeType !== 1) {
  34028. return [];
  34029. }
  34030. // NOTE: 1 DOM access here
  34031. var window = element.ownerDocument.defaultView;
  34032. var css = window.getComputedStyle(element, null);
  34033. return property ? css[property] : css;
  34034. }
  34035. /**
  34036. * Returns the parentNode or the host of the element
  34037. * @method
  34038. * @memberof Popper.Utils
  34039. * @argument {Element} element
  34040. * @returns {Element} parent
  34041. */
  34042. function getParentNode(element) {
  34043. if (element.nodeName === 'HTML') {
  34044. return element;
  34045. }
  34046. return element.parentNode || element.host;
  34047. }
  34048. /**
  34049. * Returns the scrolling parent of the given element
  34050. * @method
  34051. * @memberof Popper.Utils
  34052. * @argument {Element} element
  34053. * @returns {Element} scroll parent
  34054. */
  34055. function getScrollParent(element) {
  34056. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  34057. if (!element) {
  34058. return document.body;
  34059. }
  34060. switch (element.nodeName) {
  34061. case 'HTML':
  34062. case 'BODY':
  34063. return element.ownerDocument.body;
  34064. case '#document':
  34065. return element.body;
  34066. }
  34067. // Firefox want us to check `-x` and `-y` variations as well
  34068. var _getStyleComputedProp = getStyleComputedProperty(element),
  34069. overflow = _getStyleComputedProp.overflow,
  34070. overflowX = _getStyleComputedProp.overflowX,
  34071. overflowY = _getStyleComputedProp.overflowY;
  34072. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  34073. return element;
  34074. }
  34075. return getScrollParent(getParentNode(element));
  34076. }
  34077. /**
  34078. * Returns the reference node of the reference object, or the reference object itself.
  34079. * @method
  34080. * @memberof Popper.Utils
  34081. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  34082. * @returns {Element} parent
  34083. */
  34084. function getReferenceNode(reference) {
  34085. return reference && reference.referenceNode ? reference.referenceNode : reference;
  34086. }
  34087. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  34088. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  34089. /**
  34090. * Determines if the browser is Internet Explorer
  34091. * @method
  34092. * @memberof Popper.Utils
  34093. * @param {Number} version to check
  34094. * @returns {Boolean} isIE
  34095. */
  34096. function isIE(version) {
  34097. if (version === 11) {
  34098. return isIE11;
  34099. }
  34100. if (version === 10) {
  34101. return isIE10;
  34102. }
  34103. return isIE11 || isIE10;
  34104. }
  34105. /**
  34106. * Returns the offset parent of the given element
  34107. * @method
  34108. * @memberof Popper.Utils
  34109. * @argument {Element} element
  34110. * @returns {Element} offset parent
  34111. */
  34112. function getOffsetParent(element) {
  34113. if (!element) {
  34114. return document.documentElement;
  34115. }
  34116. var noOffsetParent = isIE(10) ? document.body : null;
  34117. // NOTE: 1 DOM access here
  34118. var offsetParent = element.offsetParent || null;
  34119. // Skip hidden elements which don't have an offsetParent
  34120. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  34121. offsetParent = (element = element.nextElementSibling).offsetParent;
  34122. }
  34123. var nodeName = offsetParent && offsetParent.nodeName;
  34124. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  34125. return element ? element.ownerDocument.documentElement : document.documentElement;
  34126. }
  34127. // .offsetParent will return the closest TH, TD or TABLE in case
  34128. // no offsetParent is present, I hate this job...
  34129. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  34130. return getOffsetParent(offsetParent);
  34131. }
  34132. return offsetParent;
  34133. }
  34134. function isOffsetContainer(element) {
  34135. var nodeName = element.nodeName;
  34136. if (nodeName === 'BODY') {
  34137. return false;
  34138. }
  34139. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34140. }
  34141. /**
  34142. * Finds the root node (document, shadowDOM root) of the given element
  34143. * @method
  34144. * @memberof Popper.Utils
  34145. * @argument {Element} node
  34146. * @returns {Element} root node
  34147. */
  34148. function getRoot(node) {
  34149. if (node.parentNode !== null) {
  34150. return getRoot(node.parentNode);
  34151. }
  34152. return node;
  34153. }
  34154. /**
  34155. * Finds the offset parent common to the two provided nodes
  34156. * @method
  34157. * @memberof Popper.Utils
  34158. * @argument {Element} element1
  34159. * @argument {Element} element2
  34160. * @returns {Element} common offset parent
  34161. */
  34162. function findCommonOffsetParent(element1, element2) {
  34163. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34164. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34165. return document.documentElement;
  34166. }
  34167. // Here we make sure to give as "start" the element that comes first in the DOM
  34168. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34169. var start = order ? element1 : element2;
  34170. var end = order ? element2 : element1;
  34171. // Get common ancestor container
  34172. var range = document.createRange();
  34173. range.setStart(start, 0);
  34174. range.setEnd(end, 0);
  34175. var commonAncestorContainer = range.commonAncestorContainer;
  34176. // Both nodes are inside #document
  34177. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34178. if (isOffsetContainer(commonAncestorContainer)) {
  34179. return commonAncestorContainer;
  34180. }
  34181. return getOffsetParent(commonAncestorContainer);
  34182. }
  34183. // one of the nodes is inside shadowDOM, find which one
  34184. var element1root = getRoot(element1);
  34185. if (element1root.host) {
  34186. return findCommonOffsetParent(element1root.host, element2);
  34187. } else {
  34188. return findCommonOffsetParent(element1, getRoot(element2).host);
  34189. }
  34190. }
  34191. /**
  34192. * Gets the scroll value of the given element in the given side (top and left)
  34193. * @method
  34194. * @memberof Popper.Utils
  34195. * @argument {Element} element
  34196. * @argument {String} side `top` or `left`
  34197. * @returns {number} amount of scrolled pixels
  34198. */
  34199. function getScroll(element) {
  34200. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34201. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34202. var nodeName = element.nodeName;
  34203. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34204. var html = element.ownerDocument.documentElement;
  34205. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34206. return scrollingElement[upperSide];
  34207. }
  34208. return element[upperSide];
  34209. }
  34210. /*
  34211. * Sum or subtract the element scroll values (left and top) from a given rect object
  34212. * @method
  34213. * @memberof Popper.Utils
  34214. * @param {Object} rect - Rect object you want to change
  34215. * @param {HTMLElement} element - The element from the function reads the scroll values
  34216. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34217. * @return {Object} rect - The modifier rect object
  34218. */
  34219. function includeScroll(rect, element) {
  34220. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34221. var scrollTop = getScroll(element, 'top');
  34222. var scrollLeft = getScroll(element, 'left');
  34223. var modifier = subtract ? -1 : 1;
  34224. rect.top += scrollTop * modifier;
  34225. rect.bottom += scrollTop * modifier;
  34226. rect.left += scrollLeft * modifier;
  34227. rect.right += scrollLeft * modifier;
  34228. return rect;
  34229. }
  34230. /*
  34231. * Helper to detect borders of a given element
  34232. * @method
  34233. * @memberof Popper.Utils
  34234. * @param {CSSStyleDeclaration} styles
  34235. * Result of `getStyleComputedProperty` on the given element
  34236. * @param {String} axis - `x` or `y`
  34237. * @return {number} borders - The borders size of the given axis
  34238. */
  34239. function getBordersSize(styles, axis) {
  34240. var sideA = axis === 'x' ? 'Left' : 'Top';
  34241. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34242. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34243. }
  34244. function getSize(axis, body, html, computedStyle) {
  34245. 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);
  34246. }
  34247. function getWindowSizes(document) {
  34248. var body = document.body;
  34249. var html = document.documentElement;
  34250. var computedStyle = isIE(10) && getComputedStyle(html);
  34251. return {
  34252. height: getSize('Height', body, html, computedStyle),
  34253. width: getSize('Width', body, html, computedStyle)
  34254. };
  34255. }
  34256. var classCallCheck = function (instance, Constructor) {
  34257. if (!(instance instanceof Constructor)) {
  34258. throw new TypeError("Cannot call a class as a function");
  34259. }
  34260. };
  34261. var createClass = function () {
  34262. function defineProperties(target, props) {
  34263. for (var i = 0; i < props.length; i++) {
  34264. var descriptor = props[i];
  34265. descriptor.enumerable = descriptor.enumerable || false;
  34266. descriptor.configurable = true;
  34267. if ("value" in descriptor) descriptor.writable = true;
  34268. Object.defineProperty(target, descriptor.key, descriptor);
  34269. }
  34270. }
  34271. return function (Constructor, protoProps, staticProps) {
  34272. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34273. if (staticProps) defineProperties(Constructor, staticProps);
  34274. return Constructor;
  34275. };
  34276. }();
  34277. var defineProperty = function (obj, key, value) {
  34278. if (key in obj) {
  34279. Object.defineProperty(obj, key, {
  34280. value: value,
  34281. enumerable: true,
  34282. configurable: true,
  34283. writable: true
  34284. });
  34285. } else {
  34286. obj[key] = value;
  34287. }
  34288. return obj;
  34289. };
  34290. var _extends = Object.assign || function (target) {
  34291. for (var i = 1; i < arguments.length; i++) {
  34292. var source = arguments[i];
  34293. for (var key in source) {
  34294. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34295. target[key] = source[key];
  34296. }
  34297. }
  34298. }
  34299. return target;
  34300. };
  34301. /**
  34302. * Given element offsets, generate an output similar to getBoundingClientRect
  34303. * @method
  34304. * @memberof Popper.Utils
  34305. * @argument {Object} offsets
  34306. * @returns {Object} ClientRect like output
  34307. */
  34308. function getClientRect(offsets) {
  34309. return _extends({}, offsets, {
  34310. right: offsets.left + offsets.width,
  34311. bottom: offsets.top + offsets.height
  34312. });
  34313. }
  34314. /**
  34315. * Get bounding client rect of given element
  34316. * @method
  34317. * @memberof Popper.Utils
  34318. * @param {HTMLElement} element
  34319. * @return {Object} client rect
  34320. */
  34321. function getBoundingClientRect(element) {
  34322. var rect = {};
  34323. // IE10 10 FIX: Please, don't ask, the element isn't
  34324. // considered in DOM in some circumstances...
  34325. // This isn't reproducible in IE10 compatibility mode of IE11
  34326. try {
  34327. if (isIE(10)) {
  34328. rect = element.getBoundingClientRect();
  34329. var scrollTop = getScroll(element, 'top');
  34330. var scrollLeft = getScroll(element, 'left');
  34331. rect.top += scrollTop;
  34332. rect.left += scrollLeft;
  34333. rect.bottom += scrollTop;
  34334. rect.right += scrollLeft;
  34335. } else {
  34336. rect = element.getBoundingClientRect();
  34337. }
  34338. } catch (e) {}
  34339. var result = {
  34340. left: rect.left,
  34341. top: rect.top,
  34342. width: rect.right - rect.left,
  34343. height: rect.bottom - rect.top
  34344. };
  34345. // subtract scrollbar size from sizes
  34346. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34347. var width = sizes.width || element.clientWidth || result.width;
  34348. var height = sizes.height || element.clientHeight || result.height;
  34349. var horizScrollbar = element.offsetWidth - width;
  34350. var vertScrollbar = element.offsetHeight - height;
  34351. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34352. // we make this check conditional for performance reasons
  34353. if (horizScrollbar || vertScrollbar) {
  34354. var styles = getStyleComputedProperty(element);
  34355. horizScrollbar -= getBordersSize(styles, 'x');
  34356. vertScrollbar -= getBordersSize(styles, 'y');
  34357. result.width -= horizScrollbar;
  34358. result.height -= vertScrollbar;
  34359. }
  34360. return getClientRect(result);
  34361. }
  34362. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34363. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34364. var isIE10 = isIE(10);
  34365. var isHTML = parent.nodeName === 'HTML';
  34366. var childrenRect = getBoundingClientRect(children);
  34367. var parentRect = getBoundingClientRect(parent);
  34368. var scrollParent = getScrollParent(children);
  34369. var styles = getStyleComputedProperty(parent);
  34370. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34371. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34372. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34373. if (fixedPosition && isHTML) {
  34374. parentRect.top = Math.max(parentRect.top, 0);
  34375. parentRect.left = Math.max(parentRect.left, 0);
  34376. }
  34377. var offsets = getClientRect({
  34378. top: childrenRect.top - parentRect.top - borderTopWidth,
  34379. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34380. width: childrenRect.width,
  34381. height: childrenRect.height
  34382. });
  34383. offsets.marginTop = 0;
  34384. offsets.marginLeft = 0;
  34385. // Subtract margins of documentElement in case it's being used as parent
  34386. // we do this only on HTML because it's the only element that behaves
  34387. // differently when margins are applied to it. The margins are included in
  34388. // the box of the documentElement, in the other cases not.
  34389. if (!isIE10 && isHTML) {
  34390. var marginTop = parseFloat(styles.marginTop);
  34391. var marginLeft = parseFloat(styles.marginLeft);
  34392. offsets.top -= borderTopWidth - marginTop;
  34393. offsets.bottom -= borderTopWidth - marginTop;
  34394. offsets.left -= borderLeftWidth - marginLeft;
  34395. offsets.right -= borderLeftWidth - marginLeft;
  34396. // Attach marginTop and marginLeft because in some circumstances we may need them
  34397. offsets.marginTop = marginTop;
  34398. offsets.marginLeft = marginLeft;
  34399. }
  34400. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34401. offsets = includeScroll(offsets, parent);
  34402. }
  34403. return offsets;
  34404. }
  34405. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34406. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34407. var html = element.ownerDocument.documentElement;
  34408. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34409. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34410. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34411. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34412. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34413. var offset = {
  34414. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34415. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34416. width: width,
  34417. height: height
  34418. };
  34419. return getClientRect(offset);
  34420. }
  34421. /**
  34422. * Check if the given element is fixed or is inside a fixed parent
  34423. * @method
  34424. * @memberof Popper.Utils
  34425. * @argument {Element} element
  34426. * @argument {Element} customContainer
  34427. * @returns {Boolean} answer to "isFixed?"
  34428. */
  34429. function isFixed(element) {
  34430. var nodeName = element.nodeName;
  34431. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34432. return false;
  34433. }
  34434. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34435. return true;
  34436. }
  34437. var parentNode = getParentNode(element);
  34438. if (!parentNode) {
  34439. return false;
  34440. }
  34441. return isFixed(parentNode);
  34442. }
  34443. /**
  34444. * Finds the first parent of an element that has a transformed property defined
  34445. * @method
  34446. * @memberof Popper.Utils
  34447. * @argument {Element} element
  34448. * @returns {Element} first transformed parent or documentElement
  34449. */
  34450. function getFixedPositionOffsetParent(element) {
  34451. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34452. if (!element || !element.parentElement || isIE()) {
  34453. return document.documentElement;
  34454. }
  34455. var el = element.parentElement;
  34456. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34457. el = el.parentElement;
  34458. }
  34459. return el || document.documentElement;
  34460. }
  34461. /**
  34462. * Computed the boundaries limits and return them
  34463. * @method
  34464. * @memberof Popper.Utils
  34465. * @param {HTMLElement} popper
  34466. * @param {HTMLElement} reference
  34467. * @param {number} padding
  34468. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34469. * @param {Boolean} fixedPosition - Is in fixed position mode
  34470. * @returns {Object} Coordinates of the boundaries
  34471. */
  34472. function getBoundaries(popper, reference, padding, boundariesElement) {
  34473. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34474. // NOTE: 1 DOM access here
  34475. var boundaries = { top: 0, left: 0 };
  34476. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34477. // Handle viewport case
  34478. if (boundariesElement === 'viewport') {
  34479. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34480. } else {
  34481. // Handle other cases based on DOM element used as boundaries
  34482. var boundariesNode = void 0;
  34483. if (boundariesElement === 'scrollParent') {
  34484. boundariesNode = getScrollParent(getParentNode(reference));
  34485. if (boundariesNode.nodeName === 'BODY') {
  34486. boundariesNode = popper.ownerDocument.documentElement;
  34487. }
  34488. } else if (boundariesElement === 'window') {
  34489. boundariesNode = popper.ownerDocument.documentElement;
  34490. } else {
  34491. boundariesNode = boundariesElement;
  34492. }
  34493. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34494. // In case of HTML, we need a different computation
  34495. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34496. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34497. height = _getWindowSizes.height,
  34498. width = _getWindowSizes.width;
  34499. boundaries.top += offsets.top - offsets.marginTop;
  34500. boundaries.bottom = height + offsets.top;
  34501. boundaries.left += offsets.left - offsets.marginLeft;
  34502. boundaries.right = width + offsets.left;
  34503. } else {
  34504. // for all the other DOM elements, this one is good
  34505. boundaries = offsets;
  34506. }
  34507. }
  34508. // Add paddings
  34509. padding = padding || 0;
  34510. var isPaddingNumber = typeof padding === 'number';
  34511. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34512. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34513. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34514. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34515. return boundaries;
  34516. }
  34517. function getArea(_ref) {
  34518. var width = _ref.width,
  34519. height = _ref.height;
  34520. return width * height;
  34521. }
  34522. /**
  34523. * Utility used to transform the `auto` placement to the placement with more
  34524. * available space.
  34525. * @method
  34526. * @memberof Popper.Utils
  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 computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34532. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34533. if (placement.indexOf('auto') === -1) {
  34534. return placement;
  34535. }
  34536. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34537. var rects = {
  34538. top: {
  34539. width: boundaries.width,
  34540. height: refRect.top - boundaries.top
  34541. },
  34542. right: {
  34543. width: boundaries.right - refRect.right,
  34544. height: boundaries.height
  34545. },
  34546. bottom: {
  34547. width: boundaries.width,
  34548. height: boundaries.bottom - refRect.bottom
  34549. },
  34550. left: {
  34551. width: refRect.left - boundaries.left,
  34552. height: boundaries.height
  34553. }
  34554. };
  34555. var sortedAreas = Object.keys(rects).map(function (key) {
  34556. return _extends({
  34557. key: key
  34558. }, rects[key], {
  34559. area: getArea(rects[key])
  34560. });
  34561. }).sort(function (a, b) {
  34562. return b.area - a.area;
  34563. });
  34564. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34565. var width = _ref2.width,
  34566. height = _ref2.height;
  34567. return width >= popper.clientWidth && height >= popper.clientHeight;
  34568. });
  34569. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34570. var variation = placement.split('-')[1];
  34571. return computedPlacement + (variation ? '-' + variation : '');
  34572. }
  34573. /**
  34574. * Get offsets to the reference element
  34575. * @method
  34576. * @memberof Popper.Utils
  34577. * @param {Object} state
  34578. * @param {Element} popper - the popper element
  34579. * @param {Element} reference - the reference element (the popper will be relative to this)
  34580. * @param {Element} fixedPosition - is in fixed position mode
  34581. * @returns {Object} An object containing the offsets which will be applied to the popper
  34582. */
  34583. function getReferenceOffsets(state, popper, reference) {
  34584. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34585. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34586. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34587. }
  34588. /**
  34589. * Get the outer sizes of the given element (offset size + margins)
  34590. * @method
  34591. * @memberof Popper.Utils
  34592. * @argument {Element} element
  34593. * @returns {Object} object containing width and height properties
  34594. */
  34595. function getOuterSizes(element) {
  34596. var window = element.ownerDocument.defaultView;
  34597. var styles = window.getComputedStyle(element);
  34598. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34599. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34600. var result = {
  34601. width: element.offsetWidth + y,
  34602. height: element.offsetHeight + x
  34603. };
  34604. return result;
  34605. }
  34606. /**
  34607. * Get the opposite placement of the given one
  34608. * @method
  34609. * @memberof Popper.Utils
  34610. * @argument {String} placement
  34611. * @returns {String} flipped placement
  34612. */
  34613. function getOppositePlacement(placement) {
  34614. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34615. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34616. return hash[matched];
  34617. });
  34618. }
  34619. /**
  34620. * Get offsets to the popper
  34621. * @method
  34622. * @memberof Popper.Utils
  34623. * @param {Object} position - CSS position the Popper will get applied
  34624. * @param {HTMLElement} popper - the popper element
  34625. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34626. * @param {String} placement - one of the valid placement options
  34627. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34628. */
  34629. function getPopperOffsets(popper, referenceOffsets, placement) {
  34630. placement = placement.split('-')[0];
  34631. // Get popper node sizes
  34632. var popperRect = getOuterSizes(popper);
  34633. // Add position, width and height to our offsets object
  34634. var popperOffsets = {
  34635. width: popperRect.width,
  34636. height: popperRect.height
  34637. };
  34638. // depending by the popper placement we have to compute its offsets slightly differently
  34639. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34640. var mainSide = isHoriz ? 'top' : 'left';
  34641. var secondarySide = isHoriz ? 'left' : 'top';
  34642. var measurement = isHoriz ? 'height' : 'width';
  34643. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34644. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34645. if (placement === secondarySide) {
  34646. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34647. } else {
  34648. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34649. }
  34650. return popperOffsets;
  34651. }
  34652. /**
  34653. * Mimics the `find` method of Array
  34654. * @method
  34655. * @memberof Popper.Utils
  34656. * @argument {Array} arr
  34657. * @argument prop
  34658. * @argument value
  34659. * @returns index or -1
  34660. */
  34661. function find(arr, check) {
  34662. // use native find if supported
  34663. if (Array.prototype.find) {
  34664. return arr.find(check);
  34665. }
  34666. // use `filter` to obtain the same behavior of `find`
  34667. return arr.filter(check)[0];
  34668. }
  34669. /**
  34670. * Return the index of the matching object
  34671. * @method
  34672. * @memberof Popper.Utils
  34673. * @argument {Array} arr
  34674. * @argument prop
  34675. * @argument value
  34676. * @returns index or -1
  34677. */
  34678. function findIndex(arr, prop, value) {
  34679. // use native findIndex if supported
  34680. if (Array.prototype.findIndex) {
  34681. return arr.findIndex(function (cur) {
  34682. return cur[prop] === value;
  34683. });
  34684. }
  34685. // use `find` + `indexOf` if `findIndex` isn't supported
  34686. var match = find(arr, function (obj) {
  34687. return obj[prop] === value;
  34688. });
  34689. return arr.indexOf(match);
  34690. }
  34691. /**
  34692. * Loop trough the list of modifiers and run them in order,
  34693. * each of them will then edit the data object.
  34694. * @method
  34695. * @memberof Popper.Utils
  34696. * @param {dataObject} data
  34697. * @param {Array} modifiers
  34698. * @param {String} ends - Optional modifier name used as stopper
  34699. * @returns {dataObject}
  34700. */
  34701. function runModifiers(modifiers, data, ends) {
  34702. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34703. modifiersToRun.forEach(function (modifier) {
  34704. if (modifier['function']) {
  34705. // eslint-disable-line dot-notation
  34706. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34707. }
  34708. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34709. if (modifier.enabled && isFunction(fn)) {
  34710. // Add properties to offsets to make them a complete clientRect object
  34711. // we do this before each modifier to make sure the previous one doesn't
  34712. // mess with these values
  34713. data.offsets.popper = getClientRect(data.offsets.popper);
  34714. data.offsets.reference = getClientRect(data.offsets.reference);
  34715. data = fn(data, modifier);
  34716. }
  34717. });
  34718. return data;
  34719. }
  34720. /**
  34721. * Updates the position of the popper, computing the new offsets and applying
  34722. * the new style.<br />
  34723. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34724. * @method
  34725. * @memberof Popper
  34726. */
  34727. function update() {
  34728. // if popper is destroyed, don't perform any further update
  34729. if (this.state.isDestroyed) {
  34730. return;
  34731. }
  34732. var data = {
  34733. instance: this,
  34734. styles: {},
  34735. arrowStyles: {},
  34736. attributes: {},
  34737. flipped: false,
  34738. offsets: {}
  34739. };
  34740. // compute reference element offsets
  34741. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34742. // compute auto placement, store placement inside the data object,
  34743. // modifiers will be able to edit `placement` if needed
  34744. // and refer to originalPlacement to know the original value
  34745. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34746. // store the computed placement inside `originalPlacement`
  34747. data.originalPlacement = data.placement;
  34748. data.positionFixed = this.options.positionFixed;
  34749. // compute the popper offsets
  34750. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34751. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34752. // run the modifiers
  34753. data = runModifiers(this.modifiers, data);
  34754. // the first `update` will call `onCreate` callback
  34755. // the other ones will call `onUpdate` callback
  34756. if (!this.state.isCreated) {
  34757. this.state.isCreated = true;
  34758. this.options.onCreate(data);
  34759. } else {
  34760. this.options.onUpdate(data);
  34761. }
  34762. }
  34763. /**
  34764. * Helper used to know if the given modifier is enabled.
  34765. * @method
  34766. * @memberof Popper.Utils
  34767. * @returns {Boolean}
  34768. */
  34769. function isModifierEnabled(modifiers, modifierName) {
  34770. return modifiers.some(function (_ref) {
  34771. var name = _ref.name,
  34772. enabled = _ref.enabled;
  34773. return enabled && name === modifierName;
  34774. });
  34775. }
  34776. /**
  34777. * Get the prefixed supported property name
  34778. * @method
  34779. * @memberof Popper.Utils
  34780. * @argument {String} property (camelCase)
  34781. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34782. */
  34783. function getSupportedPropertyName(property) {
  34784. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34785. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34786. for (var i = 0; i < prefixes.length; i++) {
  34787. var prefix = prefixes[i];
  34788. var toCheck = prefix ? '' + prefix + upperProp : property;
  34789. if (typeof document.body.style[toCheck] !== 'undefined') {
  34790. return toCheck;
  34791. }
  34792. }
  34793. return null;
  34794. }
  34795. /**
  34796. * Destroys the popper.
  34797. * @method
  34798. * @memberof Popper
  34799. */
  34800. function destroy() {
  34801. this.state.isDestroyed = true;
  34802. // touch DOM only if `applyStyle` modifier is enabled
  34803. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34804. this.popper.removeAttribute('x-placement');
  34805. this.popper.style.position = '';
  34806. this.popper.style.top = '';
  34807. this.popper.style.left = '';
  34808. this.popper.style.right = '';
  34809. this.popper.style.bottom = '';
  34810. this.popper.style.willChange = '';
  34811. this.popper.style[getSupportedPropertyName('transform')] = '';
  34812. }
  34813. this.disableEventListeners();
  34814. // remove the popper if user explicitly asked for the deletion on destroy
  34815. // do not use `remove` because IE11 doesn't support it
  34816. if (this.options.removeOnDestroy) {
  34817. this.popper.parentNode.removeChild(this.popper);
  34818. }
  34819. return this;
  34820. }
  34821. /**
  34822. * Get the window associated with the element
  34823. * @argument {Element} element
  34824. * @returns {Window}
  34825. */
  34826. function getWindow(element) {
  34827. var ownerDocument = element.ownerDocument;
  34828. return ownerDocument ? ownerDocument.defaultView : window;
  34829. }
  34830. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34831. var isBody = scrollParent.nodeName === 'BODY';
  34832. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34833. target.addEventListener(event, callback, { passive: true });
  34834. if (!isBody) {
  34835. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34836. }
  34837. scrollParents.push(target);
  34838. }
  34839. /**
  34840. * Setup needed event listeners used to update the popper position
  34841. * @method
  34842. * @memberof Popper.Utils
  34843. * @private
  34844. */
  34845. function setupEventListeners(reference, options, state, updateBound) {
  34846. // Resize event listener on window
  34847. state.updateBound = updateBound;
  34848. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34849. // Scroll event listener on scroll parents
  34850. var scrollElement = getScrollParent(reference);
  34851. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34852. state.scrollElement = scrollElement;
  34853. state.eventsEnabled = true;
  34854. return state;
  34855. }
  34856. /**
  34857. * It will add resize/scroll events and start recalculating
  34858. * position of the popper element when they are triggered.
  34859. * @method
  34860. * @memberof Popper
  34861. */
  34862. function enableEventListeners() {
  34863. if (!this.state.eventsEnabled) {
  34864. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34865. }
  34866. }
  34867. /**
  34868. * Remove event listeners used to update the popper position
  34869. * @method
  34870. * @memberof Popper.Utils
  34871. * @private
  34872. */
  34873. function removeEventListeners(reference, state) {
  34874. // Remove resize event listener on window
  34875. getWindow(reference).removeEventListener('resize', state.updateBound);
  34876. // Remove scroll event listener on scroll parents
  34877. state.scrollParents.forEach(function (target) {
  34878. target.removeEventListener('scroll', state.updateBound);
  34879. });
  34880. // Reset state
  34881. state.updateBound = null;
  34882. state.scrollParents = [];
  34883. state.scrollElement = null;
  34884. state.eventsEnabled = false;
  34885. return state;
  34886. }
  34887. /**
  34888. * It will remove resize/scroll events and won't recalculate popper position
  34889. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34890. * unless you call `update` method manually.
  34891. * @method
  34892. * @memberof Popper
  34893. */
  34894. function disableEventListeners() {
  34895. if (this.state.eventsEnabled) {
  34896. cancelAnimationFrame(this.scheduleUpdate);
  34897. this.state = removeEventListeners(this.reference, this.state);
  34898. }
  34899. }
  34900. /**
  34901. * Tells if a given input is a number
  34902. * @method
  34903. * @memberof Popper.Utils
  34904. * @param {*} input to check
  34905. * @return {Boolean}
  34906. */
  34907. function isNumeric(n) {
  34908. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34909. }
  34910. /**
  34911. * Set the style to the given popper
  34912. * @method
  34913. * @memberof Popper.Utils
  34914. * @argument {Element} element - Element to apply the style to
  34915. * @argument {Object} styles
  34916. * Object with a list of properties and values which will be applied to the element
  34917. */
  34918. function setStyles(element, styles) {
  34919. Object.keys(styles).forEach(function (prop) {
  34920. var unit = '';
  34921. // add unit if the value is numeric and is one of the following
  34922. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34923. unit = 'px';
  34924. }
  34925. element.style[prop] = styles[prop] + unit;
  34926. });
  34927. }
  34928. /**
  34929. * Set the attributes to the given popper
  34930. * @method
  34931. * @memberof Popper.Utils
  34932. * @argument {Element} element - Element to apply the attributes to
  34933. * @argument {Object} styles
  34934. * Object with a list of properties and values which will be applied to the element
  34935. */
  34936. function setAttributes(element, attributes) {
  34937. Object.keys(attributes).forEach(function (prop) {
  34938. var value = attributes[prop];
  34939. if (value !== false) {
  34940. element.setAttribute(prop, attributes[prop]);
  34941. } else {
  34942. element.removeAttribute(prop);
  34943. }
  34944. });
  34945. }
  34946. /**
  34947. * @function
  34948. * @memberof Modifiers
  34949. * @argument {Object} data - The data object generated by `update` method
  34950. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34951. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34952. * @argument {Object} options - Modifiers configuration and options
  34953. * @returns {Object} The same data object
  34954. */
  34955. function applyStyle(data) {
  34956. // any property present in `data.styles` will be applied to the popper,
  34957. // in this way we can make the 3rd party modifiers add custom styles to it
  34958. // Be aware, modifiers could override the properties defined in the previous
  34959. // lines of this modifier!
  34960. setStyles(data.instance.popper, data.styles);
  34961. // any property present in `data.attributes` will be applied to the popper,
  34962. // they will be set as HTML attributes of the element
  34963. setAttributes(data.instance.popper, data.attributes);
  34964. // if arrowElement is defined and arrowStyles has some properties
  34965. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34966. setStyles(data.arrowElement, data.arrowStyles);
  34967. }
  34968. return data;
  34969. }
  34970. /**
  34971. * Set the x-placement attribute before everything else because it could be used
  34972. * to add margins to the popper margins needs to be calculated to get the
  34973. * correct popper offsets.
  34974. * @method
  34975. * @memberof Popper.modifiers
  34976. * @param {HTMLElement} reference - The reference element used to position the popper
  34977. * @param {HTMLElement} popper - The HTML element used as popper
  34978. * @param {Object} options - Popper.js options
  34979. */
  34980. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34981. // compute reference element offsets
  34982. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34983. // compute auto placement, store placement inside the data object,
  34984. // modifiers will be able to edit `placement` if needed
  34985. // and refer to originalPlacement to know the original value
  34986. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34987. popper.setAttribute('x-placement', placement);
  34988. // Apply `position` to popper before anything else because
  34989. // without the position applied we can't guarantee correct computations
  34990. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34991. return options;
  34992. }
  34993. /**
  34994. * @function
  34995. * @memberof Popper.Utils
  34996. * @argument {Object} data - The data object generated by `update` method
  34997. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34998. * @returns {Object} The popper's position offsets rounded
  34999. *
  35000. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  35001. * good as it can be within reason.
  35002. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  35003. *
  35004. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  35005. * as well on High DPI screens).
  35006. *
  35007. * Firefox prefers no rounding for positioning and does not have blurriness on
  35008. * high DPI screens.
  35009. *
  35010. * Only horizontal placement and left/right values need to be considered.
  35011. */
  35012. function getRoundedOffsets(data, shouldRound) {
  35013. var _data$offsets = data.offsets,
  35014. popper = _data$offsets.popper,
  35015. reference = _data$offsets.reference;
  35016. var round = Math.round,
  35017. floor = Math.floor;
  35018. var noRound = function noRound(v) {
  35019. return v;
  35020. };
  35021. var referenceWidth = round(reference.width);
  35022. var popperWidth = round(popper.width);
  35023. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  35024. var isVariation = data.placement.indexOf('-') !== -1;
  35025. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  35026. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  35027. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  35028. var verticalToInteger = !shouldRound ? noRound : round;
  35029. return {
  35030. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  35031. top: verticalToInteger(popper.top),
  35032. bottom: verticalToInteger(popper.bottom),
  35033. right: horizontalToInteger(popper.right)
  35034. };
  35035. }
  35036. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  35037. /**
  35038. * @function
  35039. * @memberof Modifiers
  35040. * @argument {Object} data - The data object generated by `update` method
  35041. * @argument {Object} options - Modifiers configuration and options
  35042. * @returns {Object} The data object, properly modified
  35043. */
  35044. function computeStyle(data, options) {
  35045. var x = options.x,
  35046. y = options.y;
  35047. var popper = data.offsets.popper;
  35048. // Remove this legacy support in Popper.js v2
  35049. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  35050. return modifier.name === 'applyStyle';
  35051. }).gpuAcceleration;
  35052. if (legacyGpuAccelerationOption !== undefined) {
  35053. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  35054. }
  35055. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  35056. var offsetParent = getOffsetParent(data.instance.popper);
  35057. var offsetParentRect = getBoundingClientRect(offsetParent);
  35058. // Styles
  35059. var styles = {
  35060. position: popper.position
  35061. };
  35062. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  35063. var sideA = x === 'bottom' ? 'top' : 'bottom';
  35064. var sideB = y === 'right' ? 'left' : 'right';
  35065. // if gpuAcceleration is set to `true` and transform is supported,
  35066. // we use `translate3d` to apply the position to the popper we
  35067. // automatically use the supported prefixed version if needed
  35068. var prefixedProperty = getSupportedPropertyName('transform');
  35069. // now, let's make a step back and look at this code closely (wtf?)
  35070. // If the content of the popper grows once it's been positioned, it
  35071. // may happen that the popper gets misplaced because of the new content
  35072. // overflowing its reference element
  35073. // To avoid this problem, we provide two options (x and y), which allow
  35074. // the consumer to define the offset origin.
  35075. // If we position a popper on top of a reference element, we can set
  35076. // `x` to `top` to make the popper grow towards its top instead of
  35077. // its bottom.
  35078. var left = void 0,
  35079. top = void 0;
  35080. if (sideA === 'bottom') {
  35081. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  35082. // and not the bottom of the html element
  35083. if (offsetParent.nodeName === 'HTML') {
  35084. top = -offsetParent.clientHeight + offsets.bottom;
  35085. } else {
  35086. top = -offsetParentRect.height + offsets.bottom;
  35087. }
  35088. } else {
  35089. top = offsets.top;
  35090. }
  35091. if (sideB === 'right') {
  35092. if (offsetParent.nodeName === 'HTML') {
  35093. left = -offsetParent.clientWidth + offsets.right;
  35094. } else {
  35095. left = -offsetParentRect.width + offsets.right;
  35096. }
  35097. } else {
  35098. left = offsets.left;
  35099. }
  35100. if (gpuAcceleration && prefixedProperty) {
  35101. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  35102. styles[sideA] = 0;
  35103. styles[sideB] = 0;
  35104. styles.willChange = 'transform';
  35105. } else {
  35106. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  35107. var invertTop = sideA === 'bottom' ? -1 : 1;
  35108. var invertLeft = sideB === 'right' ? -1 : 1;
  35109. styles[sideA] = top * invertTop;
  35110. styles[sideB] = left * invertLeft;
  35111. styles.willChange = sideA + ', ' + sideB;
  35112. }
  35113. // Attributes
  35114. var attributes = {
  35115. 'x-placement': data.placement
  35116. };
  35117. // Update `data` attributes, styles and arrowStyles
  35118. data.attributes = _extends({}, attributes, data.attributes);
  35119. data.styles = _extends({}, styles, data.styles);
  35120. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  35121. return data;
  35122. }
  35123. /**
  35124. * Helper used to know if the given modifier depends from another one.<br />
  35125. * It checks if the needed modifier is listed and enabled.
  35126. * @method
  35127. * @memberof Popper.Utils
  35128. * @param {Array} modifiers - list of modifiers
  35129. * @param {String} requestingName - name of requesting modifier
  35130. * @param {String} requestedName - name of requested modifier
  35131. * @returns {Boolean}
  35132. */
  35133. function isModifierRequired(modifiers, requestingName, requestedName) {
  35134. var requesting = find(modifiers, function (_ref) {
  35135. var name = _ref.name;
  35136. return name === requestingName;
  35137. });
  35138. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35139. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35140. });
  35141. if (!isRequired) {
  35142. var _requesting = '`' + requestingName + '`';
  35143. var requested = '`' + requestedName + '`';
  35144. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35145. }
  35146. return isRequired;
  35147. }
  35148. /**
  35149. * @function
  35150. * @memberof Modifiers
  35151. * @argument {Object} data - The data object generated by update method
  35152. * @argument {Object} options - Modifiers configuration and options
  35153. * @returns {Object} The data object, properly modified
  35154. */
  35155. function arrow(data, options) {
  35156. var _data$offsets$arrow;
  35157. // arrow depends on keepTogether in order to work
  35158. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35159. return data;
  35160. }
  35161. var arrowElement = options.element;
  35162. // if arrowElement is a string, suppose it's a CSS selector
  35163. if (typeof arrowElement === 'string') {
  35164. arrowElement = data.instance.popper.querySelector(arrowElement);
  35165. // if arrowElement is not found, don't run the modifier
  35166. if (!arrowElement) {
  35167. return data;
  35168. }
  35169. } else {
  35170. // if the arrowElement isn't a query selector we must check that the
  35171. // provided DOM node is child of its popper node
  35172. if (!data.instance.popper.contains(arrowElement)) {
  35173. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35174. return data;
  35175. }
  35176. }
  35177. var placement = data.placement.split('-')[0];
  35178. var _data$offsets = data.offsets,
  35179. popper = _data$offsets.popper,
  35180. reference = _data$offsets.reference;
  35181. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35182. var len = isVertical ? 'height' : 'width';
  35183. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35184. var side = sideCapitalized.toLowerCase();
  35185. var altSide = isVertical ? 'left' : 'top';
  35186. var opSide = isVertical ? 'bottom' : 'right';
  35187. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35188. //
  35189. // extends keepTogether behavior making sure the popper and its
  35190. // reference have enough pixels in conjunction
  35191. //
  35192. // top/left side
  35193. if (reference[opSide] - arrowElementSize < popper[side]) {
  35194. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35195. }
  35196. // bottom/right side
  35197. if (reference[side] + arrowElementSize > popper[opSide]) {
  35198. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35199. }
  35200. data.offsets.popper = getClientRect(data.offsets.popper);
  35201. // compute center of the popper
  35202. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35203. // Compute the sideValue using the updated popper offsets
  35204. // take popper margin in account because we don't have this info available
  35205. var css = getStyleComputedProperty(data.instance.popper);
  35206. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35207. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35208. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35209. // prevent arrowElement from being placed not contiguously to its popper
  35210. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35211. data.arrowElement = arrowElement;
  35212. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35213. return data;
  35214. }
  35215. /**
  35216. * Get the opposite placement variation of the given one
  35217. * @method
  35218. * @memberof Popper.Utils
  35219. * @argument {String} placement variation
  35220. * @returns {String} flipped placement variation
  35221. */
  35222. function getOppositeVariation(variation) {
  35223. if (variation === 'end') {
  35224. return 'start';
  35225. } else if (variation === 'start') {
  35226. return 'end';
  35227. }
  35228. return variation;
  35229. }
  35230. /**
  35231. * List of accepted placements to use as values of the `placement` option.<br />
  35232. * Valid placements are:
  35233. * - `auto`
  35234. * - `top`
  35235. * - `right`
  35236. * - `bottom`
  35237. * - `left`
  35238. *
  35239. * Each placement can have a variation from this list:
  35240. * - `-start`
  35241. * - `-end`
  35242. *
  35243. * Variations are interpreted easily if you think of them as the left to right
  35244. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35245. * is right.<br />
  35246. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35247. *
  35248. * Some valid examples are:
  35249. * - `top-end` (on top of reference, right aligned)
  35250. * - `right-start` (on right of reference, top aligned)
  35251. * - `bottom` (on bottom, centered)
  35252. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35253. *
  35254. * @static
  35255. * @type {Array}
  35256. * @enum {String}
  35257. * @readonly
  35258. * @method placements
  35259. * @memberof Popper
  35260. */
  35261. 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'];
  35262. // Get rid of `auto` `auto-start` and `auto-end`
  35263. var validPlacements = placements.slice(3);
  35264. /**
  35265. * Given an initial placement, returns all the subsequent placements
  35266. * clockwise (or counter-clockwise).
  35267. *
  35268. * @method
  35269. * @memberof Popper.Utils
  35270. * @argument {String} placement - A valid placement (it accepts variations)
  35271. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35272. * @returns {Array} placements including their variations
  35273. */
  35274. function clockwise(placement) {
  35275. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35276. var index = validPlacements.indexOf(placement);
  35277. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35278. return counter ? arr.reverse() : arr;
  35279. }
  35280. var BEHAVIORS = {
  35281. FLIP: 'flip',
  35282. CLOCKWISE: 'clockwise',
  35283. COUNTERCLOCKWISE: 'counterclockwise'
  35284. };
  35285. /**
  35286. * @function
  35287. * @memberof Modifiers
  35288. * @argument {Object} data - The data object generated by update method
  35289. * @argument {Object} options - Modifiers configuration and options
  35290. * @returns {Object} The data object, properly modified
  35291. */
  35292. function flip(data, options) {
  35293. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35294. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35295. return data;
  35296. }
  35297. if (data.flipped && data.placement === data.originalPlacement) {
  35298. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35299. return data;
  35300. }
  35301. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35302. var placement = data.placement.split('-')[0];
  35303. var placementOpposite = getOppositePlacement(placement);
  35304. var variation = data.placement.split('-')[1] || '';
  35305. var flipOrder = [];
  35306. switch (options.behavior) {
  35307. case BEHAVIORS.FLIP:
  35308. flipOrder = [placement, placementOpposite];
  35309. break;
  35310. case BEHAVIORS.CLOCKWISE:
  35311. flipOrder = clockwise(placement);
  35312. break;
  35313. case BEHAVIORS.COUNTERCLOCKWISE:
  35314. flipOrder = clockwise(placement, true);
  35315. break;
  35316. default:
  35317. flipOrder = options.behavior;
  35318. }
  35319. flipOrder.forEach(function (step, index) {
  35320. if (placement !== step || flipOrder.length === index + 1) {
  35321. return data;
  35322. }
  35323. placement = data.placement.split('-')[0];
  35324. placementOpposite = getOppositePlacement(placement);
  35325. var popperOffsets = data.offsets.popper;
  35326. var refOffsets = data.offsets.reference;
  35327. // using floor because the reference offsets may contain decimals we are not going to consider here
  35328. var floor = Math.floor;
  35329. 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);
  35330. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35331. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35332. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35333. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35334. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35335. // flip the variation if required
  35336. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35337. // flips variation if reference element overflows boundaries
  35338. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35339. // flips variation if popper content overflows boundaries
  35340. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35341. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35342. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35343. // this boolean to detect any flip loop
  35344. data.flipped = true;
  35345. if (overlapsRef || overflowsBoundaries) {
  35346. placement = flipOrder[index + 1];
  35347. }
  35348. if (flippedVariation) {
  35349. variation = getOppositeVariation(variation);
  35350. }
  35351. data.placement = placement + (variation ? '-' + variation : '');
  35352. // this object contains `position`, we want to preserve it along with
  35353. // any additional property we may add in the future
  35354. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35355. data = runModifiers(data.instance.modifiers, data, 'flip');
  35356. }
  35357. });
  35358. return data;
  35359. }
  35360. /**
  35361. * @function
  35362. * @memberof Modifiers
  35363. * @argument {Object} data - The data object generated by update method
  35364. * @argument {Object} options - Modifiers configuration and options
  35365. * @returns {Object} The data object, properly modified
  35366. */
  35367. function keepTogether(data) {
  35368. var _data$offsets = data.offsets,
  35369. popper = _data$offsets.popper,
  35370. reference = _data$offsets.reference;
  35371. var placement = data.placement.split('-')[0];
  35372. var floor = Math.floor;
  35373. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35374. var side = isVertical ? 'right' : 'bottom';
  35375. var opSide = isVertical ? 'left' : 'top';
  35376. var measurement = isVertical ? 'width' : 'height';
  35377. if (popper[side] < floor(reference[opSide])) {
  35378. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35379. }
  35380. if (popper[opSide] > floor(reference[side])) {
  35381. data.offsets.popper[opSide] = floor(reference[side]);
  35382. }
  35383. return data;
  35384. }
  35385. /**
  35386. * Converts a string containing value + unit into a px value number
  35387. * @function
  35388. * @memberof {modifiers~offset}
  35389. * @private
  35390. * @argument {String} str - Value + unit string
  35391. * @argument {String} measurement - `height` or `width`
  35392. * @argument {Object} popperOffsets
  35393. * @argument {Object} referenceOffsets
  35394. * @returns {Number|String}
  35395. * Value in pixels, or original string if no values were extracted
  35396. */
  35397. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35398. // separate value from unit
  35399. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35400. var value = +split[1];
  35401. var unit = split[2];
  35402. // If it's not a number it's an operator, I guess
  35403. if (!value) {
  35404. return str;
  35405. }
  35406. if (unit.indexOf('%') === 0) {
  35407. var element = void 0;
  35408. switch (unit) {
  35409. case '%p':
  35410. element = popperOffsets;
  35411. break;
  35412. case '%':
  35413. case '%r':
  35414. default:
  35415. element = referenceOffsets;
  35416. }
  35417. var rect = getClientRect(element);
  35418. return rect[measurement] / 100 * value;
  35419. } else if (unit === 'vh' || unit === 'vw') {
  35420. // if is a vh or vw, we calculate the size based on the viewport
  35421. var size = void 0;
  35422. if (unit === 'vh') {
  35423. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35424. } else {
  35425. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35426. }
  35427. return size / 100 * value;
  35428. } else {
  35429. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35430. // if is an implicit unit, it's px, and we return just the value
  35431. return value;
  35432. }
  35433. }
  35434. /**
  35435. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35436. * @function
  35437. * @memberof {modifiers~offset}
  35438. * @private
  35439. * @argument {String} offset
  35440. * @argument {Object} popperOffsets
  35441. * @argument {Object} referenceOffsets
  35442. * @argument {String} basePlacement
  35443. * @returns {Array} a two cells array with x and y offsets in numbers
  35444. */
  35445. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35446. var offsets = [0, 0];
  35447. // Use height if placement is left or right and index is 0 otherwise use width
  35448. // in this way the first offset will use an axis and the second one
  35449. // will use the other one
  35450. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35451. // Split the offset string to obtain a list of values and operands
  35452. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35453. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35454. return frag.trim();
  35455. });
  35456. // Detect if the offset string contains a pair of values or a single one
  35457. // they could be separated by comma or space
  35458. var divider = fragments.indexOf(find(fragments, function (frag) {
  35459. return frag.search(/,|\s/) !== -1;
  35460. }));
  35461. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35462. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35463. }
  35464. // If divider is found, we divide the list of values and operands to divide
  35465. // them by ofset X and Y.
  35466. var splitRegex = /\s*,\s*|\s+/;
  35467. 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];
  35468. // Convert the values with units to absolute pixels to allow our computations
  35469. ops = ops.map(function (op, index) {
  35470. // Most of the units rely on the orientation of the popper
  35471. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35472. var mergeWithPrevious = false;
  35473. return op
  35474. // This aggregates any `+` or `-` sign that aren't considered operators
  35475. // e.g.: 10 + +5 => [10, +, +5]
  35476. .reduce(function (a, b) {
  35477. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35478. a[a.length - 1] = b;
  35479. mergeWithPrevious = true;
  35480. return a;
  35481. } else if (mergeWithPrevious) {
  35482. a[a.length - 1] += b;
  35483. mergeWithPrevious = false;
  35484. return a;
  35485. } else {
  35486. return a.concat(b);
  35487. }
  35488. }, [])
  35489. // Here we convert the string values into number values (in px)
  35490. .map(function (str) {
  35491. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35492. });
  35493. });
  35494. // Loop trough the offsets arrays and execute the operations
  35495. ops.forEach(function (op, index) {
  35496. op.forEach(function (frag, index2) {
  35497. if (isNumeric(frag)) {
  35498. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35499. }
  35500. });
  35501. });
  35502. return offsets;
  35503. }
  35504. /**
  35505. * @function
  35506. * @memberof Modifiers
  35507. * @argument {Object} data - The data object generated by update method
  35508. * @argument {Object} options - Modifiers configuration and options
  35509. * @argument {Number|String} options.offset=0
  35510. * The offset value as described in the modifier description
  35511. * @returns {Object} The data object, properly modified
  35512. */
  35513. function offset(data, _ref) {
  35514. var offset = _ref.offset;
  35515. var placement = data.placement,
  35516. _data$offsets = data.offsets,
  35517. popper = _data$offsets.popper,
  35518. reference = _data$offsets.reference;
  35519. var basePlacement = placement.split('-')[0];
  35520. var offsets = void 0;
  35521. if (isNumeric(+offset)) {
  35522. offsets = [+offset, 0];
  35523. } else {
  35524. offsets = parseOffset(offset, popper, reference, basePlacement);
  35525. }
  35526. if (basePlacement === 'left') {
  35527. popper.top += offsets[0];
  35528. popper.left -= offsets[1];
  35529. } else if (basePlacement === 'right') {
  35530. popper.top += offsets[0];
  35531. popper.left += offsets[1];
  35532. } else if (basePlacement === 'top') {
  35533. popper.left += offsets[0];
  35534. popper.top -= offsets[1];
  35535. } else if (basePlacement === 'bottom') {
  35536. popper.left += offsets[0];
  35537. popper.top += offsets[1];
  35538. }
  35539. data.popper = popper;
  35540. return data;
  35541. }
  35542. /**
  35543. * @function
  35544. * @memberof Modifiers
  35545. * @argument {Object} data - The data object generated by `update` method
  35546. * @argument {Object} options - Modifiers configuration and options
  35547. * @returns {Object} The data object, properly modified
  35548. */
  35549. function preventOverflow(data, options) {
  35550. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35551. // If offsetParent is the reference element, we really want to
  35552. // go one step up and use the next offsetParent as reference to
  35553. // avoid to make this modifier completely useless and look like broken
  35554. if (data.instance.reference === boundariesElement) {
  35555. boundariesElement = getOffsetParent(boundariesElement);
  35556. }
  35557. // NOTE: DOM access here
  35558. // resets the popper's position so that the document size can be calculated excluding
  35559. // the size of the popper element itself
  35560. var transformProp = getSupportedPropertyName('transform');
  35561. var popperStyles = data.instance.popper.style; // assignment to help minification
  35562. var top = popperStyles.top,
  35563. left = popperStyles.left,
  35564. transform = popperStyles[transformProp];
  35565. popperStyles.top = '';
  35566. popperStyles.left = '';
  35567. popperStyles[transformProp] = '';
  35568. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35569. // NOTE: DOM access here
  35570. // restores the original style properties after the offsets have been computed
  35571. popperStyles.top = top;
  35572. popperStyles.left = left;
  35573. popperStyles[transformProp] = transform;
  35574. options.boundaries = boundaries;
  35575. var order = options.priority;
  35576. var popper = data.offsets.popper;
  35577. var check = {
  35578. primary: function primary(placement) {
  35579. var value = popper[placement];
  35580. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35581. value = Math.max(popper[placement], boundaries[placement]);
  35582. }
  35583. return defineProperty({}, placement, value);
  35584. },
  35585. secondary: function secondary(placement) {
  35586. var mainSide = placement === 'right' ? 'left' : 'top';
  35587. var value = popper[mainSide];
  35588. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35589. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35590. }
  35591. return defineProperty({}, mainSide, value);
  35592. }
  35593. };
  35594. order.forEach(function (placement) {
  35595. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35596. popper = _extends({}, popper, check[side](placement));
  35597. });
  35598. data.offsets.popper = popper;
  35599. return data;
  35600. }
  35601. /**
  35602. * @function
  35603. * @memberof Modifiers
  35604. * @argument {Object} data - The data object generated by `update` method
  35605. * @argument {Object} options - Modifiers configuration and options
  35606. * @returns {Object} The data object, properly modified
  35607. */
  35608. function shift(data) {
  35609. var placement = data.placement;
  35610. var basePlacement = placement.split('-')[0];
  35611. var shiftvariation = placement.split('-')[1];
  35612. // if shift shiftvariation is specified, run the modifier
  35613. if (shiftvariation) {
  35614. var _data$offsets = data.offsets,
  35615. reference = _data$offsets.reference,
  35616. popper = _data$offsets.popper;
  35617. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35618. var side = isVertical ? 'left' : 'top';
  35619. var measurement = isVertical ? 'width' : 'height';
  35620. var shiftOffsets = {
  35621. start: defineProperty({}, side, reference[side]),
  35622. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35623. };
  35624. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35625. }
  35626. return data;
  35627. }
  35628. /**
  35629. * @function
  35630. * @memberof Modifiers
  35631. * @argument {Object} data - The data object generated by update method
  35632. * @argument {Object} options - Modifiers configuration and options
  35633. * @returns {Object} The data object, properly modified
  35634. */
  35635. function hide(data) {
  35636. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35637. return data;
  35638. }
  35639. var refRect = data.offsets.reference;
  35640. var bound = find(data.instance.modifiers, function (modifier) {
  35641. return modifier.name === 'preventOverflow';
  35642. }).boundaries;
  35643. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35644. // Avoid unnecessary DOM access if visibility hasn't changed
  35645. if (data.hide === true) {
  35646. return data;
  35647. }
  35648. data.hide = true;
  35649. data.attributes['x-out-of-boundaries'] = '';
  35650. } else {
  35651. // Avoid unnecessary DOM access if visibility hasn't changed
  35652. if (data.hide === false) {
  35653. return data;
  35654. }
  35655. data.hide = false;
  35656. data.attributes['x-out-of-boundaries'] = false;
  35657. }
  35658. return data;
  35659. }
  35660. /**
  35661. * @function
  35662. * @memberof Modifiers
  35663. * @argument {Object} data - The data object generated by `update` method
  35664. * @argument {Object} options - Modifiers configuration and options
  35665. * @returns {Object} The data object, properly modified
  35666. */
  35667. function inner(data) {
  35668. var placement = data.placement;
  35669. var basePlacement = placement.split('-')[0];
  35670. var _data$offsets = data.offsets,
  35671. popper = _data$offsets.popper,
  35672. reference = _data$offsets.reference;
  35673. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35674. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35675. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35676. data.placement = getOppositePlacement(placement);
  35677. data.offsets.popper = getClientRect(popper);
  35678. return data;
  35679. }
  35680. /**
  35681. * Modifier function, each modifier can have a function of this type assigned
  35682. * to its `fn` property.<br />
  35683. * These functions will be called on each update, this means that you must
  35684. * make sure they are performant enough to avoid performance bottlenecks.
  35685. *
  35686. * @function ModifierFn
  35687. * @argument {dataObject} data - The data object generated by `update` method
  35688. * @argument {Object} options - Modifiers configuration and options
  35689. * @returns {dataObject} The data object, properly modified
  35690. */
  35691. /**
  35692. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35693. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35694. * needed by the library.
  35695. *
  35696. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35697. * All the other properties are configurations that could be tweaked.
  35698. * @namespace modifiers
  35699. */
  35700. var modifiers = {
  35701. /**
  35702. * Modifier used to shift the popper on the start or end of its reference
  35703. * element.<br />
  35704. * It will read the variation of the `placement` property.<br />
  35705. * It can be one either `-end` or `-start`.
  35706. * @memberof modifiers
  35707. * @inner
  35708. */
  35709. shift: {
  35710. /** @prop {number} order=100 - Index used to define the order of execution */
  35711. order: 100,
  35712. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35713. enabled: true,
  35714. /** @prop {ModifierFn} */
  35715. fn: shift
  35716. },
  35717. /**
  35718. * The `offset` modifier can shift your popper on both its axis.
  35719. *
  35720. * It accepts the following units:
  35721. * - `px` or unit-less, interpreted as pixels
  35722. * - `%` or `%r`, percentage relative to the length of the reference element
  35723. * - `%p`, percentage relative to the length of the popper element
  35724. * - `vw`, CSS viewport width unit
  35725. * - `vh`, CSS viewport height unit
  35726. *
  35727. * For length is intended the main axis relative to the placement of the popper.<br />
  35728. * This means that if the placement is `top` or `bottom`, the length will be the
  35729. * `width`. In case of `left` or `right`, it will be the `height`.
  35730. *
  35731. * You can provide a single value (as `Number` or `String`), or a pair of values
  35732. * as `String` divided by a comma or one (or more) white spaces.<br />
  35733. * The latter is a deprecated method because it leads to confusion and will be
  35734. * removed in v2.<br />
  35735. * Additionally, it accepts additions and subtractions between different units.
  35736. * Note that multiplications and divisions aren't supported.
  35737. *
  35738. * Valid examples are:
  35739. * ```
  35740. * 10
  35741. * '10%'
  35742. * '10, 10'
  35743. * '10%, 10'
  35744. * '10 + 10%'
  35745. * '10 - 5vh + 3%'
  35746. * '-10px + 5vh, 5px - 6%'
  35747. * ```
  35748. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35749. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35750. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35751. *
  35752. * @memberof modifiers
  35753. * @inner
  35754. */
  35755. offset: {
  35756. /** @prop {number} order=200 - Index used to define the order of execution */
  35757. order: 200,
  35758. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35759. enabled: true,
  35760. /** @prop {ModifierFn} */
  35761. fn: offset,
  35762. /** @prop {Number|String} offset=0
  35763. * The offset value as described in the modifier description
  35764. */
  35765. offset: 0
  35766. },
  35767. /**
  35768. * Modifier used to prevent the popper from being positioned outside the boundary.
  35769. *
  35770. * A scenario exists where the reference itself is not within the boundaries.<br />
  35771. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35772. * In this case we need to decide whether the popper should either:
  35773. *
  35774. * - detach from the reference and remain "trapped" in the boundaries, or
  35775. * - if it should ignore the boundary and "escape with its reference"
  35776. *
  35777. * When `escapeWithReference` is set to`true` and reference is completely
  35778. * outside its boundaries, the popper will overflow (or completely leave)
  35779. * the boundaries in order to remain attached to the edge of the reference.
  35780. *
  35781. * @memberof modifiers
  35782. * @inner
  35783. */
  35784. preventOverflow: {
  35785. /** @prop {number} order=300 - Index used to define the order of execution */
  35786. order: 300,
  35787. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35788. enabled: true,
  35789. /** @prop {ModifierFn} */
  35790. fn: preventOverflow,
  35791. /**
  35792. * @prop {Array} [priority=['left','right','top','bottom']]
  35793. * Popper will try to prevent overflow following these priorities by default,
  35794. * then, it could overflow on the left and on top of the `boundariesElement`
  35795. */
  35796. priority: ['left', 'right', 'top', 'bottom'],
  35797. /**
  35798. * @prop {number} padding=5
  35799. * Amount of pixel used to define a minimum distance between the boundaries
  35800. * and the popper. This makes sure the popper always has a little padding
  35801. * between the edges of its container
  35802. */
  35803. padding: 5,
  35804. /**
  35805. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35806. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35807. * `viewport` or any DOM element.
  35808. */
  35809. boundariesElement: 'scrollParent'
  35810. },
  35811. /**
  35812. * Modifier used to make sure the reference and its popper stay near each other
  35813. * without leaving any gap between the two. Especially useful when the arrow is
  35814. * enabled and you want to ensure that it points to its reference element.
  35815. * It cares only about the first axis. You can still have poppers with margin
  35816. * between the popper and its reference element.
  35817. * @memberof modifiers
  35818. * @inner
  35819. */
  35820. keepTogether: {
  35821. /** @prop {number} order=400 - Index used to define the order of execution */
  35822. order: 400,
  35823. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35824. enabled: true,
  35825. /** @prop {ModifierFn} */
  35826. fn: keepTogether
  35827. },
  35828. /**
  35829. * This modifier is used to move the `arrowElement` of the popper to make
  35830. * sure it is positioned between the reference element and its popper element.
  35831. * It will read the outer size of the `arrowElement` node to detect how many
  35832. * pixels of conjunction are needed.
  35833. *
  35834. * It has no effect if no `arrowElement` is provided.
  35835. * @memberof modifiers
  35836. * @inner
  35837. */
  35838. arrow: {
  35839. /** @prop {number} order=500 - Index used to define the order of execution */
  35840. order: 500,
  35841. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35842. enabled: true,
  35843. /** @prop {ModifierFn} */
  35844. fn: arrow,
  35845. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35846. element: '[x-arrow]'
  35847. },
  35848. /**
  35849. * Modifier used to flip the popper's placement when it starts to overlap its
  35850. * reference element.
  35851. *
  35852. * Requires the `preventOverflow` modifier before it in order to work.
  35853. *
  35854. * **NOTE:** this modifier will interrupt the current update cycle and will
  35855. * restart it if it detects the need to flip the placement.
  35856. * @memberof modifiers
  35857. * @inner
  35858. */
  35859. flip: {
  35860. /** @prop {number} order=600 - Index used to define the order of execution */
  35861. order: 600,
  35862. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35863. enabled: true,
  35864. /** @prop {ModifierFn} */
  35865. fn: flip,
  35866. /**
  35867. * @prop {String|Array} behavior='flip'
  35868. * The behavior used to change the popper's placement. It can be one of
  35869. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35870. * placements (with optional variations)
  35871. */
  35872. behavior: 'flip',
  35873. /**
  35874. * @prop {number} padding=5
  35875. * The popper will flip if it hits the edges of the `boundariesElement`
  35876. */
  35877. padding: 5,
  35878. /**
  35879. * @prop {String|HTMLElement} boundariesElement='viewport'
  35880. * The element which will define the boundaries of the popper position.
  35881. * The popper will never be placed outside of the defined boundaries
  35882. * (except if `keepTogether` is enabled)
  35883. */
  35884. boundariesElement: 'viewport',
  35885. /**
  35886. * @prop {Boolean} flipVariations=false
  35887. * The popper will switch placement variation between `-start` and `-end` when
  35888. * the reference element overlaps its boundaries.
  35889. *
  35890. * The original placement should have a set variation.
  35891. */
  35892. flipVariations: false,
  35893. /**
  35894. * @prop {Boolean} flipVariationsByContent=false
  35895. * The popper will switch placement variation between `-start` and `-end` when
  35896. * the popper element overlaps its reference boundaries.
  35897. *
  35898. * The original placement should have a set variation.
  35899. */
  35900. flipVariationsByContent: false
  35901. },
  35902. /**
  35903. * Modifier used to make the popper flow toward the inner of the reference element.
  35904. * By default, when this modifier is disabled, the popper will be placed outside
  35905. * the reference element.
  35906. * @memberof modifiers
  35907. * @inner
  35908. */
  35909. inner: {
  35910. /** @prop {number} order=700 - Index used to define the order of execution */
  35911. order: 700,
  35912. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35913. enabled: false,
  35914. /** @prop {ModifierFn} */
  35915. fn: inner
  35916. },
  35917. /**
  35918. * Modifier used to hide the popper when its reference element is outside of the
  35919. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35920. * be used to hide with a CSS selector the popper when its reference is
  35921. * out of boundaries.
  35922. *
  35923. * Requires the `preventOverflow` modifier before it in order to work.
  35924. * @memberof modifiers
  35925. * @inner
  35926. */
  35927. hide: {
  35928. /** @prop {number} order=800 - Index used to define the order of execution */
  35929. order: 800,
  35930. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35931. enabled: true,
  35932. /** @prop {ModifierFn} */
  35933. fn: hide
  35934. },
  35935. /**
  35936. * Computes the style that will be applied to the popper element to gets
  35937. * properly positioned.
  35938. *
  35939. * Note that this modifier will not touch the DOM, it just prepares the styles
  35940. * so that `applyStyle` modifier can apply it. This separation is useful
  35941. * in case you need to replace `applyStyle` with a custom implementation.
  35942. *
  35943. * This modifier has `850` as `order` value to maintain backward compatibility
  35944. * with previous versions of Popper.js. Expect the modifiers ordering method
  35945. * to change in future major versions of the library.
  35946. *
  35947. * @memberof modifiers
  35948. * @inner
  35949. */
  35950. computeStyle: {
  35951. /** @prop {number} order=850 - Index used to define the order of execution */
  35952. order: 850,
  35953. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35954. enabled: true,
  35955. /** @prop {ModifierFn} */
  35956. fn: computeStyle,
  35957. /**
  35958. * @prop {Boolean} gpuAcceleration=true
  35959. * If true, it uses the CSS 3D transformation to position the popper.
  35960. * Otherwise, it will use the `top` and `left` properties
  35961. */
  35962. gpuAcceleration: true,
  35963. /**
  35964. * @prop {string} [x='bottom']
  35965. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35966. * Change this if your popper should grow in a direction different from `bottom`
  35967. */
  35968. x: 'bottom',
  35969. /**
  35970. * @prop {string} [x='left']
  35971. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35972. * Change this if your popper should grow in a direction different from `right`
  35973. */
  35974. y: 'right'
  35975. },
  35976. /**
  35977. * Applies the computed styles to the popper element.
  35978. *
  35979. * All the DOM manipulations are limited to this modifier. This is useful in case
  35980. * you want to integrate Popper.js inside a framework or view library and you
  35981. * want to delegate all the DOM manipulations to it.
  35982. *
  35983. * Note that if you disable this modifier, you must make sure the popper element
  35984. * has its position set to `absolute` before Popper.js can do its work!
  35985. *
  35986. * Just disable this modifier and define your own to achieve the desired effect.
  35987. *
  35988. * @memberof modifiers
  35989. * @inner
  35990. */
  35991. applyStyle: {
  35992. /** @prop {number} order=900 - Index used to define the order of execution */
  35993. order: 900,
  35994. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35995. enabled: true,
  35996. /** @prop {ModifierFn} */
  35997. fn: applyStyle,
  35998. /** @prop {Function} */
  35999. onLoad: applyStyleOnLoad,
  36000. /**
  36001. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  36002. * @prop {Boolean} gpuAcceleration=true
  36003. * If true, it uses the CSS 3D transformation to position the popper.
  36004. * Otherwise, it will use the `top` and `left` properties
  36005. */
  36006. gpuAcceleration: undefined
  36007. }
  36008. };
  36009. /**
  36010. * The `dataObject` is an object containing all the information used by Popper.js.
  36011. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  36012. * @name dataObject
  36013. * @property {Object} data.instance The Popper.js instance
  36014. * @property {String} data.placement Placement applied to popper
  36015. * @property {String} data.originalPlacement Placement originally defined on init
  36016. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  36017. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  36018. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  36019. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  36020. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  36021. * @property {Object} data.boundaries Offsets of the popper boundaries
  36022. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  36023. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  36024. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  36025. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  36026. */
  36027. /**
  36028. * Default options provided to Popper.js constructor.<br />
  36029. * These can be overridden using the `options` argument of Popper.js.<br />
  36030. * To override an option, simply pass an object with the same
  36031. * structure of the `options` object, as the 3rd argument. For example:
  36032. * ```
  36033. * new Popper(ref, pop, {
  36034. * modifiers: {
  36035. * preventOverflow: { enabled: false }
  36036. * }
  36037. * })
  36038. * ```
  36039. * @type {Object}
  36040. * @static
  36041. * @memberof Popper
  36042. */
  36043. var Defaults = {
  36044. /**
  36045. * Popper's placement.
  36046. * @prop {Popper.placements} placement='bottom'
  36047. */
  36048. placement: 'bottom',
  36049. /**
  36050. * Set this to true if you want popper to position it self in 'fixed' mode
  36051. * @prop {Boolean} positionFixed=false
  36052. */
  36053. positionFixed: false,
  36054. /**
  36055. * Whether events (resize, scroll) are initially enabled.
  36056. * @prop {Boolean} eventsEnabled=true
  36057. */
  36058. eventsEnabled: true,
  36059. /**
  36060. * Set to true if you want to automatically remove the popper when
  36061. * you call the `destroy` method.
  36062. * @prop {Boolean} removeOnDestroy=false
  36063. */
  36064. removeOnDestroy: false,
  36065. /**
  36066. * Callback called when the popper is created.<br />
  36067. * By default, it is set to no-op.<br />
  36068. * Access Popper.js instance with `data.instance`.
  36069. * @prop {onCreate}
  36070. */
  36071. onCreate: function onCreate() {},
  36072. /**
  36073. * Callback called when the popper is updated. This callback is not called
  36074. * on the initialization/creation of the popper, but only on subsequent
  36075. * updates.<br />
  36076. * By default, it is set to no-op.<br />
  36077. * Access Popper.js instance with `data.instance`.
  36078. * @prop {onUpdate}
  36079. */
  36080. onUpdate: function onUpdate() {},
  36081. /**
  36082. * List of modifiers used to modify the offsets before they are applied to the popper.
  36083. * They provide most of the functionalities of Popper.js.
  36084. * @prop {modifiers}
  36085. */
  36086. modifiers: modifiers
  36087. };
  36088. /**
  36089. * @callback onCreate
  36090. * @param {dataObject} data
  36091. */
  36092. /**
  36093. * @callback onUpdate
  36094. * @param {dataObject} data
  36095. */
  36096. // Utils
  36097. // Methods
  36098. var Popper = function () {
  36099. /**
  36100. * Creates a new Popper.js instance.
  36101. * @class Popper
  36102. * @param {Element|referenceObject} reference - The reference element used to position the popper
  36103. * @param {Element} popper - The HTML / XML element used as the popper
  36104. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  36105. * @return {Object} instance - The generated Popper.js instance
  36106. */
  36107. function Popper(reference, popper) {
  36108. var _this = this;
  36109. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  36110. classCallCheck(this, Popper);
  36111. this.scheduleUpdate = function () {
  36112. return requestAnimationFrame(_this.update);
  36113. };
  36114. // make update() debounced, so that it only runs at most once-per-tick
  36115. this.update = debounce(this.update.bind(this));
  36116. // with {} we create a new object with the options inside it
  36117. this.options = _extends({}, Popper.Defaults, options);
  36118. // init state
  36119. this.state = {
  36120. isDestroyed: false,
  36121. isCreated: false,
  36122. scrollParents: []
  36123. };
  36124. // get reference and popper elements (allow jQuery wrappers)
  36125. this.reference = reference && reference.jquery ? reference[0] : reference;
  36126. this.popper = popper && popper.jquery ? popper[0] : popper;
  36127. // Deep merge modifiers options
  36128. this.options.modifiers = {};
  36129. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  36130. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36131. });
  36132. // Refactoring modifiers' list (Object => Array)
  36133. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36134. return _extends({
  36135. name: name
  36136. }, _this.options.modifiers[name]);
  36137. })
  36138. // sort the modifiers by order
  36139. .sort(function (a, b) {
  36140. return a.order - b.order;
  36141. });
  36142. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36143. // such code is executed in the same order of its modifier
  36144. // they could add new properties to their options configuration
  36145. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36146. this.modifiers.forEach(function (modifierOptions) {
  36147. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36148. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36149. }
  36150. });
  36151. // fire the first update to position the popper in the right place
  36152. this.update();
  36153. var eventsEnabled = this.options.eventsEnabled;
  36154. if (eventsEnabled) {
  36155. // setup event listeners, they will take care of update the position in specific situations
  36156. this.enableEventListeners();
  36157. }
  36158. this.state.eventsEnabled = eventsEnabled;
  36159. }
  36160. // We can't use class properties because they don't get listed in the
  36161. // class prototype and break stuff like Sinon stubs
  36162. createClass(Popper, [{
  36163. key: 'update',
  36164. value: function update$$1() {
  36165. return update.call(this);
  36166. }
  36167. }, {
  36168. key: 'destroy',
  36169. value: function destroy$$1() {
  36170. return destroy.call(this);
  36171. }
  36172. }, {
  36173. key: 'enableEventListeners',
  36174. value: function enableEventListeners$$1() {
  36175. return enableEventListeners.call(this);
  36176. }
  36177. }, {
  36178. key: 'disableEventListeners',
  36179. value: function disableEventListeners$$1() {
  36180. return disableEventListeners.call(this);
  36181. }
  36182. /**
  36183. * Schedules an update. It will run on the next UI update available.
  36184. * @method scheduleUpdate
  36185. * @memberof Popper
  36186. */
  36187. /**
  36188. * Collection of utilities useful when writing custom modifiers.
  36189. * Starting from version 1.7, this method is available only if you
  36190. * include `popper-utils.js` before `popper.js`.
  36191. *
  36192. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36193. * and will be removed in v2! Use the PopperUtils module directly instead.
  36194. * Due to the high instability of the methods contained in Utils, we can't
  36195. * guarantee them to follow semver. Use them at your own risk!
  36196. * @static
  36197. * @private
  36198. * @type {Object}
  36199. * @deprecated since version 1.8
  36200. * @member Utils
  36201. * @memberof Popper
  36202. */
  36203. }]);
  36204. return Popper;
  36205. }();
  36206. /**
  36207. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36208. * and lets you use it as replacement of a real DOM node.<br />
  36209. * You can use this method to position a popper relatively to a set of coordinates
  36210. * in case you don't have a DOM node to use as reference.
  36211. *
  36212. * ```
  36213. * new Popper(referenceObject, popperNode);
  36214. * ```
  36215. *
  36216. * NB: This feature isn't supported in Internet Explorer 10.
  36217. * @name referenceObject
  36218. * @property {Function} data.getBoundingClientRect
  36219. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36220. * @property {number} data.clientWidth
  36221. * An ES6 getter that will return the width of the virtual reference element.
  36222. * @property {number} data.clientHeight
  36223. * An ES6 getter that will return the height of the virtual reference element.
  36224. */
  36225. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36226. Popper.placements = placements;
  36227. Popper.Defaults = Defaults;
  36228. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36229. //# sourceMappingURL=popper.js.map
  36230. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36231. /***/ }),
  36232. /***/ "./node_modules/process/browser.js":
  36233. /*!*****************************************!*\
  36234. !*** ./node_modules/process/browser.js ***!
  36235. \*****************************************/
  36236. /*! no static exports found */
  36237. /***/ (function(module, exports) {
  36238. // shim for using process in browser
  36239. var process = module.exports = {};
  36240. // cached from whatever global is present so that test runners that stub it
  36241. // don't break things. But we need to wrap it in a try catch in case it is
  36242. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36243. // function because try/catches deoptimize in certain engines.
  36244. var cachedSetTimeout;
  36245. var cachedClearTimeout;
  36246. function defaultSetTimout() {
  36247. throw new Error('setTimeout has not been defined');
  36248. }
  36249. function defaultClearTimeout () {
  36250. throw new Error('clearTimeout has not been defined');
  36251. }
  36252. (function () {
  36253. try {
  36254. if (typeof setTimeout === 'function') {
  36255. cachedSetTimeout = setTimeout;
  36256. } else {
  36257. cachedSetTimeout = defaultSetTimout;
  36258. }
  36259. } catch (e) {
  36260. cachedSetTimeout = defaultSetTimout;
  36261. }
  36262. try {
  36263. if (typeof clearTimeout === 'function') {
  36264. cachedClearTimeout = clearTimeout;
  36265. } else {
  36266. cachedClearTimeout = defaultClearTimeout;
  36267. }
  36268. } catch (e) {
  36269. cachedClearTimeout = defaultClearTimeout;
  36270. }
  36271. } ())
  36272. function runTimeout(fun) {
  36273. if (cachedSetTimeout === setTimeout) {
  36274. //normal enviroments in sane situations
  36275. return setTimeout(fun, 0);
  36276. }
  36277. // if setTimeout wasn't available but was latter defined
  36278. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36279. cachedSetTimeout = setTimeout;
  36280. return setTimeout(fun, 0);
  36281. }
  36282. try {
  36283. // when when somebody has screwed with setTimeout but no I.E. maddness
  36284. return cachedSetTimeout(fun, 0);
  36285. } catch(e){
  36286. try {
  36287. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36288. return cachedSetTimeout.call(null, fun, 0);
  36289. } catch(e){
  36290. // 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
  36291. return cachedSetTimeout.call(this, fun, 0);
  36292. }
  36293. }
  36294. }
  36295. function runClearTimeout(marker) {
  36296. if (cachedClearTimeout === clearTimeout) {
  36297. //normal enviroments in sane situations
  36298. return clearTimeout(marker);
  36299. }
  36300. // if clearTimeout wasn't available but was latter defined
  36301. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36302. cachedClearTimeout = clearTimeout;
  36303. return clearTimeout(marker);
  36304. }
  36305. try {
  36306. // when when somebody has screwed with setTimeout but no I.E. maddness
  36307. return cachedClearTimeout(marker);
  36308. } catch (e){
  36309. try {
  36310. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36311. return cachedClearTimeout.call(null, marker);
  36312. } catch (e){
  36313. // 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.
  36314. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36315. return cachedClearTimeout.call(this, marker);
  36316. }
  36317. }
  36318. }
  36319. var queue = [];
  36320. var draining = false;
  36321. var currentQueue;
  36322. var queueIndex = -1;
  36323. function cleanUpNextTick() {
  36324. if (!draining || !currentQueue) {
  36325. return;
  36326. }
  36327. draining = false;
  36328. if (currentQueue.length) {
  36329. queue = currentQueue.concat(queue);
  36330. } else {
  36331. queueIndex = -1;
  36332. }
  36333. if (queue.length) {
  36334. drainQueue();
  36335. }
  36336. }
  36337. function drainQueue() {
  36338. if (draining) {
  36339. return;
  36340. }
  36341. var timeout = runTimeout(cleanUpNextTick);
  36342. draining = true;
  36343. var len = queue.length;
  36344. while(len) {
  36345. currentQueue = queue;
  36346. queue = [];
  36347. while (++queueIndex < len) {
  36348. if (currentQueue) {
  36349. currentQueue[queueIndex].run();
  36350. }
  36351. }
  36352. queueIndex = -1;
  36353. len = queue.length;
  36354. }
  36355. currentQueue = null;
  36356. draining = false;
  36357. runClearTimeout(timeout);
  36358. }
  36359. process.nextTick = function (fun) {
  36360. var args = new Array(arguments.length - 1);
  36361. if (arguments.length > 1) {
  36362. for (var i = 1; i < arguments.length; i++) {
  36363. args[i - 1] = arguments[i];
  36364. }
  36365. }
  36366. queue.push(new Item(fun, args));
  36367. if (queue.length === 1 && !draining) {
  36368. runTimeout(drainQueue);
  36369. }
  36370. };
  36371. // v8 likes predictible objects
  36372. function Item(fun, array) {
  36373. this.fun = fun;
  36374. this.array = array;
  36375. }
  36376. Item.prototype.run = function () {
  36377. this.fun.apply(null, this.array);
  36378. };
  36379. process.title = 'browser';
  36380. process.browser = true;
  36381. process.env = {};
  36382. process.argv = [];
  36383. process.version = ''; // empty string to avoid regexp issues
  36384. process.versions = {};
  36385. function noop() {}
  36386. process.on = noop;
  36387. process.addListener = noop;
  36388. process.once = noop;
  36389. process.off = noop;
  36390. process.removeListener = noop;
  36391. process.removeAllListeners = noop;
  36392. process.emit = noop;
  36393. process.prependListener = noop;
  36394. process.prependOnceListener = noop;
  36395. process.listeners = function (name) { return [] }
  36396. process.binding = function (name) {
  36397. throw new Error('process.binding is not supported');
  36398. };
  36399. process.cwd = function () { return '/' };
  36400. process.chdir = function (dir) {
  36401. throw new Error('process.chdir is not supported');
  36402. };
  36403. process.umask = function() { return 0; };
  36404. /***/ }),
  36405. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36406. /*!***************************************************!*\
  36407. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36408. \***************************************************/
  36409. /*! no static exports found */
  36410. /***/ (function(module, exports, __webpack_require__) {
  36411. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36412. * Pusher JavaScript Library v5.0.3
  36413. * https://pusher.com/
  36414. *
  36415. * Copyright 2017, Pusher
  36416. * Released under the MIT licence.
  36417. */
  36418. (function webpackUniversalModuleDefinition(root, factory) {
  36419. if(true)
  36420. module.exports = factory();
  36421. else {}
  36422. })(window, function() {
  36423. return /******/ (function(modules) { // webpackBootstrap
  36424. /******/ // The module cache
  36425. /******/ var installedModules = {};
  36426. /******/
  36427. /******/ // The require function
  36428. /******/ function __webpack_require__(moduleId) {
  36429. /******/
  36430. /******/ // Check if module is in cache
  36431. /******/ if(installedModules[moduleId]) {
  36432. /******/ return installedModules[moduleId].exports;
  36433. /******/ }
  36434. /******/ // Create a new module (and put it into the cache)
  36435. /******/ var module = installedModules[moduleId] = {
  36436. /******/ i: moduleId,
  36437. /******/ l: false,
  36438. /******/ exports: {}
  36439. /******/ };
  36440. /******/
  36441. /******/ // Execute the module function
  36442. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36443. /******/
  36444. /******/ // Flag the module as loaded
  36445. /******/ module.l = true;
  36446. /******/
  36447. /******/ // Return the exports of the module
  36448. /******/ return module.exports;
  36449. /******/ }
  36450. /******/
  36451. /******/
  36452. /******/ // expose the modules object (__webpack_modules__)
  36453. /******/ __webpack_require__.m = modules;
  36454. /******/
  36455. /******/ // expose the module cache
  36456. /******/ __webpack_require__.c = installedModules;
  36457. /******/
  36458. /******/ // define getter function for harmony exports
  36459. /******/ __webpack_require__.d = function(exports, name, getter) {
  36460. /******/ if(!__webpack_require__.o(exports, name)) {
  36461. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36462. /******/ }
  36463. /******/ };
  36464. /******/
  36465. /******/ // define __esModule on exports
  36466. /******/ __webpack_require__.r = function(exports) {
  36467. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36468. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36469. /******/ }
  36470. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36471. /******/ };
  36472. /******/
  36473. /******/ // create a fake namespace object
  36474. /******/ // mode & 1: value is a module id, require it
  36475. /******/ // mode & 2: merge all properties of value into the ns
  36476. /******/ // mode & 4: return value when already ns object
  36477. /******/ // mode & 8|1: behave like require
  36478. /******/ __webpack_require__.t = function(value, mode) {
  36479. /******/ if(mode & 1) value = __webpack_require__(value);
  36480. /******/ if(mode & 8) return value;
  36481. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36482. /******/ var ns = Object.create(null);
  36483. /******/ __webpack_require__.r(ns);
  36484. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36485. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36486. /******/ return ns;
  36487. /******/ };
  36488. /******/
  36489. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36490. /******/ __webpack_require__.n = function(module) {
  36491. /******/ var getter = module && module.__esModule ?
  36492. /******/ function getDefault() { return module['default']; } :
  36493. /******/ function getModuleExports() { return module; };
  36494. /******/ __webpack_require__.d(getter, 'a', getter);
  36495. /******/ return getter;
  36496. /******/ };
  36497. /******/
  36498. /******/ // Object.prototype.hasOwnProperty.call
  36499. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36500. /******/
  36501. /******/ // __webpack_public_path__
  36502. /******/ __webpack_require__.p = "";
  36503. /******/
  36504. /******/
  36505. /******/ // Load entry module and return exports
  36506. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36507. /******/ })
  36508. /************************************************************************/
  36509. /******/ ([
  36510. /* 0 */
  36511. /***/ (function(module, exports, __webpack_require__) {
  36512. (function(nacl) {
  36513. 'use strict';
  36514. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36515. // Public domain.
  36516. //
  36517. // Implementation derived from TweetNaCl version 20140427.
  36518. // See for details: http://tweetnacl.cr.yp.to/
  36519. var gf = function(init) {
  36520. var i, r = new Float64Array(16);
  36521. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36522. return r;
  36523. };
  36524. // Pluggable, initialized in high-level API below.
  36525. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36526. var _0 = new Uint8Array(16);
  36527. var _9 = new Uint8Array(32); _9[0] = 9;
  36528. var gf0 = gf(),
  36529. gf1 = gf([1]),
  36530. _121665 = gf([0xdb41, 1]),
  36531. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36532. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36533. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36534. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36535. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36536. function ts64(x, i, h, l) {
  36537. x[i] = (h >> 24) & 0xff;
  36538. x[i+1] = (h >> 16) & 0xff;
  36539. x[i+2] = (h >> 8) & 0xff;
  36540. x[i+3] = h & 0xff;
  36541. x[i+4] = (l >> 24) & 0xff;
  36542. x[i+5] = (l >> 16) & 0xff;
  36543. x[i+6] = (l >> 8) & 0xff;
  36544. x[i+7] = l & 0xff;
  36545. }
  36546. function vn(x, xi, y, yi, n) {
  36547. var i,d = 0;
  36548. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36549. return (1 & ((d - 1) >>> 8)) - 1;
  36550. }
  36551. function crypto_verify_16(x, xi, y, yi) {
  36552. return vn(x,xi,y,yi,16);
  36553. }
  36554. function crypto_verify_32(x, xi, y, yi) {
  36555. return vn(x,xi,y,yi,32);
  36556. }
  36557. function core_salsa20(o, p, k, c) {
  36558. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36559. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36560. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36561. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36562. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36563. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36564. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36565. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36566. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36567. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36568. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36569. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36570. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36571. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36572. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36573. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36574. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36575. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36576. x15 = j15, u;
  36577. for (var i = 0; i < 20; i += 2) {
  36578. u = x0 + x12 | 0;
  36579. x4 ^= u<<7 | u>>>(32-7);
  36580. u = x4 + x0 | 0;
  36581. x8 ^= u<<9 | u>>>(32-9);
  36582. u = x8 + x4 | 0;
  36583. x12 ^= u<<13 | u>>>(32-13);
  36584. u = x12 + x8 | 0;
  36585. x0 ^= u<<18 | u>>>(32-18);
  36586. u = x5 + x1 | 0;
  36587. x9 ^= u<<7 | u>>>(32-7);
  36588. u = x9 + x5 | 0;
  36589. x13 ^= u<<9 | u>>>(32-9);
  36590. u = x13 + x9 | 0;
  36591. x1 ^= u<<13 | u>>>(32-13);
  36592. u = x1 + x13 | 0;
  36593. x5 ^= u<<18 | u>>>(32-18);
  36594. u = x10 + x6 | 0;
  36595. x14 ^= u<<7 | u>>>(32-7);
  36596. u = x14 + x10 | 0;
  36597. x2 ^= u<<9 | u>>>(32-9);
  36598. u = x2 + x14 | 0;
  36599. x6 ^= u<<13 | u>>>(32-13);
  36600. u = x6 + x2 | 0;
  36601. x10 ^= u<<18 | u>>>(32-18);
  36602. u = x15 + x11 | 0;
  36603. x3 ^= u<<7 | u>>>(32-7);
  36604. u = x3 + x15 | 0;
  36605. x7 ^= u<<9 | u>>>(32-9);
  36606. u = x7 + x3 | 0;
  36607. x11 ^= u<<13 | u>>>(32-13);
  36608. u = x11 + x7 | 0;
  36609. x15 ^= u<<18 | u>>>(32-18);
  36610. u = x0 + x3 | 0;
  36611. x1 ^= u<<7 | u>>>(32-7);
  36612. u = x1 + x0 | 0;
  36613. x2 ^= u<<9 | u>>>(32-9);
  36614. u = x2 + x1 | 0;
  36615. x3 ^= u<<13 | u>>>(32-13);
  36616. u = x3 + x2 | 0;
  36617. x0 ^= u<<18 | u>>>(32-18);
  36618. u = x5 + x4 | 0;
  36619. x6 ^= u<<7 | u>>>(32-7);
  36620. u = x6 + x5 | 0;
  36621. x7 ^= u<<9 | u>>>(32-9);
  36622. u = x7 + x6 | 0;
  36623. x4 ^= u<<13 | u>>>(32-13);
  36624. u = x4 + x7 | 0;
  36625. x5 ^= u<<18 | u>>>(32-18);
  36626. u = x10 + x9 | 0;
  36627. x11 ^= u<<7 | u>>>(32-7);
  36628. u = x11 + x10 | 0;
  36629. x8 ^= u<<9 | u>>>(32-9);
  36630. u = x8 + x11 | 0;
  36631. x9 ^= u<<13 | u>>>(32-13);
  36632. u = x9 + x8 | 0;
  36633. x10 ^= u<<18 | u>>>(32-18);
  36634. u = x15 + x14 | 0;
  36635. x12 ^= u<<7 | u>>>(32-7);
  36636. u = x12 + x15 | 0;
  36637. x13 ^= u<<9 | u>>>(32-9);
  36638. u = x13 + x12 | 0;
  36639. x14 ^= u<<13 | u>>>(32-13);
  36640. u = x14 + x13 | 0;
  36641. x15 ^= u<<18 | u>>>(32-18);
  36642. }
  36643. x0 = x0 + j0 | 0;
  36644. x1 = x1 + j1 | 0;
  36645. x2 = x2 + j2 | 0;
  36646. x3 = x3 + j3 | 0;
  36647. x4 = x4 + j4 | 0;
  36648. x5 = x5 + j5 | 0;
  36649. x6 = x6 + j6 | 0;
  36650. x7 = x7 + j7 | 0;
  36651. x8 = x8 + j8 | 0;
  36652. x9 = x9 + j9 | 0;
  36653. x10 = x10 + j10 | 0;
  36654. x11 = x11 + j11 | 0;
  36655. x12 = x12 + j12 | 0;
  36656. x13 = x13 + j13 | 0;
  36657. x14 = x14 + j14 | 0;
  36658. x15 = x15 + j15 | 0;
  36659. o[ 0] = x0 >>> 0 & 0xff;
  36660. o[ 1] = x0 >>> 8 & 0xff;
  36661. o[ 2] = x0 >>> 16 & 0xff;
  36662. o[ 3] = x0 >>> 24 & 0xff;
  36663. o[ 4] = x1 >>> 0 & 0xff;
  36664. o[ 5] = x1 >>> 8 & 0xff;
  36665. o[ 6] = x1 >>> 16 & 0xff;
  36666. o[ 7] = x1 >>> 24 & 0xff;
  36667. o[ 8] = x2 >>> 0 & 0xff;
  36668. o[ 9] = x2 >>> 8 & 0xff;
  36669. o[10] = x2 >>> 16 & 0xff;
  36670. o[11] = x2 >>> 24 & 0xff;
  36671. o[12] = x3 >>> 0 & 0xff;
  36672. o[13] = x3 >>> 8 & 0xff;
  36673. o[14] = x3 >>> 16 & 0xff;
  36674. o[15] = x3 >>> 24 & 0xff;
  36675. o[16] = x4 >>> 0 & 0xff;
  36676. o[17] = x4 >>> 8 & 0xff;
  36677. o[18] = x4 >>> 16 & 0xff;
  36678. o[19] = x4 >>> 24 & 0xff;
  36679. o[20] = x5 >>> 0 & 0xff;
  36680. o[21] = x5 >>> 8 & 0xff;
  36681. o[22] = x5 >>> 16 & 0xff;
  36682. o[23] = x5 >>> 24 & 0xff;
  36683. o[24] = x6 >>> 0 & 0xff;
  36684. o[25] = x6 >>> 8 & 0xff;
  36685. o[26] = x6 >>> 16 & 0xff;
  36686. o[27] = x6 >>> 24 & 0xff;
  36687. o[28] = x7 >>> 0 & 0xff;
  36688. o[29] = x7 >>> 8 & 0xff;
  36689. o[30] = x7 >>> 16 & 0xff;
  36690. o[31] = x7 >>> 24 & 0xff;
  36691. o[32] = x8 >>> 0 & 0xff;
  36692. o[33] = x8 >>> 8 & 0xff;
  36693. o[34] = x8 >>> 16 & 0xff;
  36694. o[35] = x8 >>> 24 & 0xff;
  36695. o[36] = x9 >>> 0 & 0xff;
  36696. o[37] = x9 >>> 8 & 0xff;
  36697. o[38] = x9 >>> 16 & 0xff;
  36698. o[39] = x9 >>> 24 & 0xff;
  36699. o[40] = x10 >>> 0 & 0xff;
  36700. o[41] = x10 >>> 8 & 0xff;
  36701. o[42] = x10 >>> 16 & 0xff;
  36702. o[43] = x10 >>> 24 & 0xff;
  36703. o[44] = x11 >>> 0 & 0xff;
  36704. o[45] = x11 >>> 8 & 0xff;
  36705. o[46] = x11 >>> 16 & 0xff;
  36706. o[47] = x11 >>> 24 & 0xff;
  36707. o[48] = x12 >>> 0 & 0xff;
  36708. o[49] = x12 >>> 8 & 0xff;
  36709. o[50] = x12 >>> 16 & 0xff;
  36710. o[51] = x12 >>> 24 & 0xff;
  36711. o[52] = x13 >>> 0 & 0xff;
  36712. o[53] = x13 >>> 8 & 0xff;
  36713. o[54] = x13 >>> 16 & 0xff;
  36714. o[55] = x13 >>> 24 & 0xff;
  36715. o[56] = x14 >>> 0 & 0xff;
  36716. o[57] = x14 >>> 8 & 0xff;
  36717. o[58] = x14 >>> 16 & 0xff;
  36718. o[59] = x14 >>> 24 & 0xff;
  36719. o[60] = x15 >>> 0 & 0xff;
  36720. o[61] = x15 >>> 8 & 0xff;
  36721. o[62] = x15 >>> 16 & 0xff;
  36722. o[63] = x15 >>> 24 & 0xff;
  36723. }
  36724. function core_hsalsa20(o,p,k,c) {
  36725. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36726. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36727. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36728. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36729. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36730. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36731. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36732. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36733. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36734. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36735. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36736. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36737. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36738. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36739. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36740. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36741. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36742. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36743. x15 = j15, u;
  36744. for (var i = 0; i < 20; i += 2) {
  36745. u = x0 + x12 | 0;
  36746. x4 ^= u<<7 | u>>>(32-7);
  36747. u = x4 + x0 | 0;
  36748. x8 ^= u<<9 | u>>>(32-9);
  36749. u = x8 + x4 | 0;
  36750. x12 ^= u<<13 | u>>>(32-13);
  36751. u = x12 + x8 | 0;
  36752. x0 ^= u<<18 | u>>>(32-18);
  36753. u = x5 + x1 | 0;
  36754. x9 ^= u<<7 | u>>>(32-7);
  36755. u = x9 + x5 | 0;
  36756. x13 ^= u<<9 | u>>>(32-9);
  36757. u = x13 + x9 | 0;
  36758. x1 ^= u<<13 | u>>>(32-13);
  36759. u = x1 + x13 | 0;
  36760. x5 ^= u<<18 | u>>>(32-18);
  36761. u = x10 + x6 | 0;
  36762. x14 ^= u<<7 | u>>>(32-7);
  36763. u = x14 + x10 | 0;
  36764. x2 ^= u<<9 | u>>>(32-9);
  36765. u = x2 + x14 | 0;
  36766. x6 ^= u<<13 | u>>>(32-13);
  36767. u = x6 + x2 | 0;
  36768. x10 ^= u<<18 | u>>>(32-18);
  36769. u = x15 + x11 | 0;
  36770. x3 ^= u<<7 | u>>>(32-7);
  36771. u = x3 + x15 | 0;
  36772. x7 ^= u<<9 | u>>>(32-9);
  36773. u = x7 + x3 | 0;
  36774. x11 ^= u<<13 | u>>>(32-13);
  36775. u = x11 + x7 | 0;
  36776. x15 ^= u<<18 | u>>>(32-18);
  36777. u = x0 + x3 | 0;
  36778. x1 ^= u<<7 | u>>>(32-7);
  36779. u = x1 + x0 | 0;
  36780. x2 ^= u<<9 | u>>>(32-9);
  36781. u = x2 + x1 | 0;
  36782. x3 ^= u<<13 | u>>>(32-13);
  36783. u = x3 + x2 | 0;
  36784. x0 ^= u<<18 | u>>>(32-18);
  36785. u = x5 + x4 | 0;
  36786. x6 ^= u<<7 | u>>>(32-7);
  36787. u = x6 + x5 | 0;
  36788. x7 ^= u<<9 | u>>>(32-9);
  36789. u = x7 + x6 | 0;
  36790. x4 ^= u<<13 | u>>>(32-13);
  36791. u = x4 + x7 | 0;
  36792. x5 ^= u<<18 | u>>>(32-18);
  36793. u = x10 + x9 | 0;
  36794. x11 ^= u<<7 | u>>>(32-7);
  36795. u = x11 + x10 | 0;
  36796. x8 ^= u<<9 | u>>>(32-9);
  36797. u = x8 + x11 | 0;
  36798. x9 ^= u<<13 | u>>>(32-13);
  36799. u = x9 + x8 | 0;
  36800. x10 ^= u<<18 | u>>>(32-18);
  36801. u = x15 + x14 | 0;
  36802. x12 ^= u<<7 | u>>>(32-7);
  36803. u = x12 + x15 | 0;
  36804. x13 ^= u<<9 | u>>>(32-9);
  36805. u = x13 + x12 | 0;
  36806. x14 ^= u<<13 | u>>>(32-13);
  36807. u = x14 + x13 | 0;
  36808. x15 ^= u<<18 | u>>>(32-18);
  36809. }
  36810. o[ 0] = x0 >>> 0 & 0xff;
  36811. o[ 1] = x0 >>> 8 & 0xff;
  36812. o[ 2] = x0 >>> 16 & 0xff;
  36813. o[ 3] = x0 >>> 24 & 0xff;
  36814. o[ 4] = x5 >>> 0 & 0xff;
  36815. o[ 5] = x5 >>> 8 & 0xff;
  36816. o[ 6] = x5 >>> 16 & 0xff;
  36817. o[ 7] = x5 >>> 24 & 0xff;
  36818. o[ 8] = x10 >>> 0 & 0xff;
  36819. o[ 9] = x10 >>> 8 & 0xff;
  36820. o[10] = x10 >>> 16 & 0xff;
  36821. o[11] = x10 >>> 24 & 0xff;
  36822. o[12] = x15 >>> 0 & 0xff;
  36823. o[13] = x15 >>> 8 & 0xff;
  36824. o[14] = x15 >>> 16 & 0xff;
  36825. o[15] = x15 >>> 24 & 0xff;
  36826. o[16] = x6 >>> 0 & 0xff;
  36827. o[17] = x6 >>> 8 & 0xff;
  36828. o[18] = x6 >>> 16 & 0xff;
  36829. o[19] = x6 >>> 24 & 0xff;
  36830. o[20] = x7 >>> 0 & 0xff;
  36831. o[21] = x7 >>> 8 & 0xff;
  36832. o[22] = x7 >>> 16 & 0xff;
  36833. o[23] = x7 >>> 24 & 0xff;
  36834. o[24] = x8 >>> 0 & 0xff;
  36835. o[25] = x8 >>> 8 & 0xff;
  36836. o[26] = x8 >>> 16 & 0xff;
  36837. o[27] = x8 >>> 24 & 0xff;
  36838. o[28] = x9 >>> 0 & 0xff;
  36839. o[29] = x9 >>> 8 & 0xff;
  36840. o[30] = x9 >>> 16 & 0xff;
  36841. o[31] = x9 >>> 24 & 0xff;
  36842. }
  36843. function crypto_core_salsa20(out,inp,k,c) {
  36844. core_salsa20(out,inp,k,c);
  36845. }
  36846. function crypto_core_hsalsa20(out,inp,k,c) {
  36847. core_hsalsa20(out,inp,k,c);
  36848. }
  36849. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36850. // "expand 32-byte k"
  36851. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36852. var z = new Uint8Array(16), x = new Uint8Array(64);
  36853. var u, i;
  36854. for (i = 0; i < 16; i++) z[i] = 0;
  36855. for (i = 0; i < 8; i++) z[i] = n[i];
  36856. while (b >= 64) {
  36857. crypto_core_salsa20(x,z,k,sigma);
  36858. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36859. u = 1;
  36860. for (i = 8; i < 16; i++) {
  36861. u = u + (z[i] & 0xff) | 0;
  36862. z[i] = u & 0xff;
  36863. u >>>= 8;
  36864. }
  36865. b -= 64;
  36866. cpos += 64;
  36867. mpos += 64;
  36868. }
  36869. if (b > 0) {
  36870. crypto_core_salsa20(x,z,k,sigma);
  36871. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36872. }
  36873. return 0;
  36874. }
  36875. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36876. var z = new Uint8Array(16), x = new Uint8Array(64);
  36877. var u, i;
  36878. for (i = 0; i < 16; i++) z[i] = 0;
  36879. for (i = 0; i < 8; i++) z[i] = n[i];
  36880. while (b >= 64) {
  36881. crypto_core_salsa20(x,z,k,sigma);
  36882. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36883. u = 1;
  36884. for (i = 8; i < 16; i++) {
  36885. u = u + (z[i] & 0xff) | 0;
  36886. z[i] = u & 0xff;
  36887. u >>>= 8;
  36888. }
  36889. b -= 64;
  36890. cpos += 64;
  36891. }
  36892. if (b > 0) {
  36893. crypto_core_salsa20(x,z,k,sigma);
  36894. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36895. }
  36896. return 0;
  36897. }
  36898. function crypto_stream(c,cpos,d,n,k) {
  36899. var s = new Uint8Array(32);
  36900. crypto_core_hsalsa20(s,n,k,sigma);
  36901. var sn = new Uint8Array(8);
  36902. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36903. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36904. }
  36905. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36906. var s = new Uint8Array(32);
  36907. crypto_core_hsalsa20(s,n,k,sigma);
  36908. var sn = new Uint8Array(8);
  36909. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36910. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36911. }
  36912. /*
  36913. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36914. * https://github.com/floodyberry/poly1305-donna
  36915. */
  36916. var poly1305 = function(key) {
  36917. this.buffer = new Uint8Array(16);
  36918. this.r = new Uint16Array(10);
  36919. this.h = new Uint16Array(10);
  36920. this.pad = new Uint16Array(8);
  36921. this.leftover = 0;
  36922. this.fin = 0;
  36923. var t0, t1, t2, t3, t4, t5, t6, t7;
  36924. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36925. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36926. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36927. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36928. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36929. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36930. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36931. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36932. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36933. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36934. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36935. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36936. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36937. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36938. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36939. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36940. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36941. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36942. };
  36943. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36944. var hibit = this.fin ? 0 : (1 << 11);
  36945. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36946. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36947. var h0 = this.h[0],
  36948. h1 = this.h[1],
  36949. h2 = this.h[2],
  36950. h3 = this.h[3],
  36951. h4 = this.h[4],
  36952. h5 = this.h[5],
  36953. h6 = this.h[6],
  36954. h7 = this.h[7],
  36955. h8 = this.h[8],
  36956. h9 = this.h[9];
  36957. var r0 = this.r[0],
  36958. r1 = this.r[1],
  36959. r2 = this.r[2],
  36960. r3 = this.r[3],
  36961. r4 = this.r[4],
  36962. r5 = this.r[5],
  36963. r6 = this.r[6],
  36964. r7 = this.r[7],
  36965. r8 = this.r[8],
  36966. r9 = this.r[9];
  36967. while (bytes >= 16) {
  36968. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36969. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36970. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36971. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36972. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36973. h5 += ((t4 >>> 1)) & 0x1fff;
  36974. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36975. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36976. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36977. h9 += ((t7 >>> 5)) | hibit;
  36978. c = 0;
  36979. d0 = c;
  36980. d0 += h0 * r0;
  36981. d0 += h1 * (5 * r9);
  36982. d0 += h2 * (5 * r8);
  36983. d0 += h3 * (5 * r7);
  36984. d0 += h4 * (5 * r6);
  36985. c = (d0 >>> 13); d0 &= 0x1fff;
  36986. d0 += h5 * (5 * r5);
  36987. d0 += h6 * (5 * r4);
  36988. d0 += h7 * (5 * r3);
  36989. d0 += h8 * (5 * r2);
  36990. d0 += h9 * (5 * r1);
  36991. c += (d0 >>> 13); d0 &= 0x1fff;
  36992. d1 = c;
  36993. d1 += h0 * r1;
  36994. d1 += h1 * r0;
  36995. d1 += h2 * (5 * r9);
  36996. d1 += h3 * (5 * r8);
  36997. d1 += h4 * (5 * r7);
  36998. c = (d1 >>> 13); d1 &= 0x1fff;
  36999. d1 += h5 * (5 * r6);
  37000. d1 += h6 * (5 * r5);
  37001. d1 += h7 * (5 * r4);
  37002. d1 += h8 * (5 * r3);
  37003. d1 += h9 * (5 * r2);
  37004. c += (d1 >>> 13); d1 &= 0x1fff;
  37005. d2 = c;
  37006. d2 += h0 * r2;
  37007. d2 += h1 * r1;
  37008. d2 += h2 * r0;
  37009. d2 += h3 * (5 * r9);
  37010. d2 += h4 * (5 * r8);
  37011. c = (d2 >>> 13); d2 &= 0x1fff;
  37012. d2 += h5 * (5 * r7);
  37013. d2 += h6 * (5 * r6);
  37014. d2 += h7 * (5 * r5);
  37015. d2 += h8 * (5 * r4);
  37016. d2 += h9 * (5 * r3);
  37017. c += (d2 >>> 13); d2 &= 0x1fff;
  37018. d3 = c;
  37019. d3 += h0 * r3;
  37020. d3 += h1 * r2;
  37021. d3 += h2 * r1;
  37022. d3 += h3 * r0;
  37023. d3 += h4 * (5 * r9);
  37024. c = (d3 >>> 13); d3 &= 0x1fff;
  37025. d3 += h5 * (5 * r8);
  37026. d3 += h6 * (5 * r7);
  37027. d3 += h7 * (5 * r6);
  37028. d3 += h8 * (5 * r5);
  37029. d3 += h9 * (5 * r4);
  37030. c += (d3 >>> 13); d3 &= 0x1fff;
  37031. d4 = c;
  37032. d4 += h0 * r4;
  37033. d4 += h1 * r3;
  37034. d4 += h2 * r2;
  37035. d4 += h3 * r1;
  37036. d4 += h4 * r0;
  37037. c = (d4 >>> 13); d4 &= 0x1fff;
  37038. d4 += h5 * (5 * r9);
  37039. d4 += h6 * (5 * r8);
  37040. d4 += h7 * (5 * r7);
  37041. d4 += h8 * (5 * r6);
  37042. d4 += h9 * (5 * r5);
  37043. c += (d4 >>> 13); d4 &= 0x1fff;
  37044. d5 = c;
  37045. d5 += h0 * r5;
  37046. d5 += h1 * r4;
  37047. d5 += h2 * r3;
  37048. d5 += h3 * r2;
  37049. d5 += h4 * r1;
  37050. c = (d5 >>> 13); d5 &= 0x1fff;
  37051. d5 += h5 * r0;
  37052. d5 += h6 * (5 * r9);
  37053. d5 += h7 * (5 * r8);
  37054. d5 += h8 * (5 * r7);
  37055. d5 += h9 * (5 * r6);
  37056. c += (d5 >>> 13); d5 &= 0x1fff;
  37057. d6 = c;
  37058. d6 += h0 * r6;
  37059. d6 += h1 * r5;
  37060. d6 += h2 * r4;
  37061. d6 += h3 * r3;
  37062. d6 += h4 * r2;
  37063. c = (d6 >>> 13); d6 &= 0x1fff;
  37064. d6 += h5 * r1;
  37065. d6 += h6 * r0;
  37066. d6 += h7 * (5 * r9);
  37067. d6 += h8 * (5 * r8);
  37068. d6 += h9 * (5 * r7);
  37069. c += (d6 >>> 13); d6 &= 0x1fff;
  37070. d7 = c;
  37071. d7 += h0 * r7;
  37072. d7 += h1 * r6;
  37073. d7 += h2 * r5;
  37074. d7 += h3 * r4;
  37075. d7 += h4 * r3;
  37076. c = (d7 >>> 13); d7 &= 0x1fff;
  37077. d7 += h5 * r2;
  37078. d7 += h6 * r1;
  37079. d7 += h7 * r0;
  37080. d7 += h8 * (5 * r9);
  37081. d7 += h9 * (5 * r8);
  37082. c += (d7 >>> 13); d7 &= 0x1fff;
  37083. d8 = c;
  37084. d8 += h0 * r8;
  37085. d8 += h1 * r7;
  37086. d8 += h2 * r6;
  37087. d8 += h3 * r5;
  37088. d8 += h4 * r4;
  37089. c = (d8 >>> 13); d8 &= 0x1fff;
  37090. d8 += h5 * r3;
  37091. d8 += h6 * r2;
  37092. d8 += h7 * r1;
  37093. d8 += h8 * r0;
  37094. d8 += h9 * (5 * r9);
  37095. c += (d8 >>> 13); d8 &= 0x1fff;
  37096. d9 = c;
  37097. d9 += h0 * r9;
  37098. d9 += h1 * r8;
  37099. d9 += h2 * r7;
  37100. d9 += h3 * r6;
  37101. d9 += h4 * r5;
  37102. c = (d9 >>> 13); d9 &= 0x1fff;
  37103. d9 += h5 * r4;
  37104. d9 += h6 * r3;
  37105. d9 += h7 * r2;
  37106. d9 += h8 * r1;
  37107. d9 += h9 * r0;
  37108. c += (d9 >>> 13); d9 &= 0x1fff;
  37109. c = (((c << 2) + c)) | 0;
  37110. c = (c + d0) | 0;
  37111. d0 = c & 0x1fff;
  37112. c = (c >>> 13);
  37113. d1 += c;
  37114. h0 = d0;
  37115. h1 = d1;
  37116. h2 = d2;
  37117. h3 = d3;
  37118. h4 = d4;
  37119. h5 = d5;
  37120. h6 = d6;
  37121. h7 = d7;
  37122. h8 = d8;
  37123. h9 = d9;
  37124. mpos += 16;
  37125. bytes -= 16;
  37126. }
  37127. this.h[0] = h0;
  37128. this.h[1] = h1;
  37129. this.h[2] = h2;
  37130. this.h[3] = h3;
  37131. this.h[4] = h4;
  37132. this.h[5] = h5;
  37133. this.h[6] = h6;
  37134. this.h[7] = h7;
  37135. this.h[8] = h8;
  37136. this.h[9] = h9;
  37137. };
  37138. poly1305.prototype.finish = function(mac, macpos) {
  37139. var g = new Uint16Array(10);
  37140. var c, mask, f, i;
  37141. if (this.leftover) {
  37142. i = this.leftover;
  37143. this.buffer[i++] = 1;
  37144. for (; i < 16; i++) this.buffer[i] = 0;
  37145. this.fin = 1;
  37146. this.blocks(this.buffer, 0, 16);
  37147. }
  37148. c = this.h[1] >>> 13;
  37149. this.h[1] &= 0x1fff;
  37150. for (i = 2; i < 10; i++) {
  37151. this.h[i] += c;
  37152. c = this.h[i] >>> 13;
  37153. this.h[i] &= 0x1fff;
  37154. }
  37155. this.h[0] += (c * 5);
  37156. c = this.h[0] >>> 13;
  37157. this.h[0] &= 0x1fff;
  37158. this.h[1] += c;
  37159. c = this.h[1] >>> 13;
  37160. this.h[1] &= 0x1fff;
  37161. this.h[2] += c;
  37162. g[0] = this.h[0] + 5;
  37163. c = g[0] >>> 13;
  37164. g[0] &= 0x1fff;
  37165. for (i = 1; i < 10; i++) {
  37166. g[i] = this.h[i] + c;
  37167. c = g[i] >>> 13;
  37168. g[i] &= 0x1fff;
  37169. }
  37170. g[9] -= (1 << 13);
  37171. mask = (c ^ 1) - 1;
  37172. for (i = 0; i < 10; i++) g[i] &= mask;
  37173. mask = ~mask;
  37174. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37175. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37176. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37177. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37178. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37179. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37180. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37181. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37182. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37183. f = this.h[0] + this.pad[0];
  37184. this.h[0] = f & 0xffff;
  37185. for (i = 1; i < 8; i++) {
  37186. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37187. this.h[i] = f & 0xffff;
  37188. }
  37189. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37190. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37191. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37192. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37193. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37194. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37195. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37196. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37197. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37198. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37199. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37200. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37201. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37202. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37203. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37204. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37205. };
  37206. poly1305.prototype.update = function(m, mpos, bytes) {
  37207. var i, want;
  37208. if (this.leftover) {
  37209. want = (16 - this.leftover);
  37210. if (want > bytes)
  37211. want = bytes;
  37212. for (i = 0; i < want; i++)
  37213. this.buffer[this.leftover + i] = m[mpos+i];
  37214. bytes -= want;
  37215. mpos += want;
  37216. this.leftover += want;
  37217. if (this.leftover < 16)
  37218. return;
  37219. this.blocks(this.buffer, 0, 16);
  37220. this.leftover = 0;
  37221. }
  37222. if (bytes >= 16) {
  37223. want = bytes - (bytes % 16);
  37224. this.blocks(m, mpos, want);
  37225. mpos += want;
  37226. bytes -= want;
  37227. }
  37228. if (bytes) {
  37229. for (i = 0; i < bytes; i++)
  37230. this.buffer[this.leftover + i] = m[mpos+i];
  37231. this.leftover += bytes;
  37232. }
  37233. };
  37234. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37235. var s = new poly1305(k);
  37236. s.update(m, mpos, n);
  37237. s.finish(out, outpos);
  37238. return 0;
  37239. }
  37240. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37241. var x = new Uint8Array(16);
  37242. crypto_onetimeauth(x,0,m,mpos,n,k);
  37243. return crypto_verify_16(h,hpos,x,0);
  37244. }
  37245. function crypto_secretbox(c,m,d,n,k) {
  37246. var i;
  37247. if (d < 32) return -1;
  37248. crypto_stream_xor(c,0,m,0,d,n,k);
  37249. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37250. for (i = 0; i < 16; i++) c[i] = 0;
  37251. return 0;
  37252. }
  37253. function crypto_secretbox_open(m,c,d,n,k) {
  37254. var i;
  37255. var x = new Uint8Array(32);
  37256. if (d < 32) return -1;
  37257. crypto_stream(x,0,32,n,k);
  37258. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37259. crypto_stream_xor(m,0,c,0,d,n,k);
  37260. for (i = 0; i < 32; i++) m[i] = 0;
  37261. return 0;
  37262. }
  37263. function set25519(r, a) {
  37264. var i;
  37265. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37266. }
  37267. function car25519(o) {
  37268. var i, v, c = 1;
  37269. for (i = 0; i < 16; i++) {
  37270. v = o[i] + c + 65535;
  37271. c = Math.floor(v / 65536);
  37272. o[i] = v - c * 65536;
  37273. }
  37274. o[0] += c-1 + 37 * (c-1);
  37275. }
  37276. function sel25519(p, q, b) {
  37277. var t, c = ~(b-1);
  37278. for (var i = 0; i < 16; i++) {
  37279. t = c & (p[i] ^ q[i]);
  37280. p[i] ^= t;
  37281. q[i] ^= t;
  37282. }
  37283. }
  37284. function pack25519(o, n) {
  37285. var i, j, b;
  37286. var m = gf(), t = gf();
  37287. for (i = 0; i < 16; i++) t[i] = n[i];
  37288. car25519(t);
  37289. car25519(t);
  37290. car25519(t);
  37291. for (j = 0; j < 2; j++) {
  37292. m[0] = t[0] - 0xffed;
  37293. for (i = 1; i < 15; i++) {
  37294. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37295. m[i-1] &= 0xffff;
  37296. }
  37297. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37298. b = (m[15]>>16) & 1;
  37299. m[14] &= 0xffff;
  37300. sel25519(t, m, 1-b);
  37301. }
  37302. for (i = 0; i < 16; i++) {
  37303. o[2*i] = t[i] & 0xff;
  37304. o[2*i+1] = t[i]>>8;
  37305. }
  37306. }
  37307. function neq25519(a, b) {
  37308. var c = new Uint8Array(32), d = new Uint8Array(32);
  37309. pack25519(c, a);
  37310. pack25519(d, b);
  37311. return crypto_verify_32(c, 0, d, 0);
  37312. }
  37313. function par25519(a) {
  37314. var d = new Uint8Array(32);
  37315. pack25519(d, a);
  37316. return d[0] & 1;
  37317. }
  37318. function unpack25519(o, n) {
  37319. var i;
  37320. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37321. o[15] &= 0x7fff;
  37322. }
  37323. function A(o, a, b) {
  37324. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37325. }
  37326. function Z(o, a, b) {
  37327. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37328. }
  37329. function M(o, a, b) {
  37330. var v, c,
  37331. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37332. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37333. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37334. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37335. b0 = b[0],
  37336. b1 = b[1],
  37337. b2 = b[2],
  37338. b3 = b[3],
  37339. b4 = b[4],
  37340. b5 = b[5],
  37341. b6 = b[6],
  37342. b7 = b[7],
  37343. b8 = b[8],
  37344. b9 = b[9],
  37345. b10 = b[10],
  37346. b11 = b[11],
  37347. b12 = b[12],
  37348. b13 = b[13],
  37349. b14 = b[14],
  37350. b15 = b[15];
  37351. v = a[0];
  37352. t0 += v * b0;
  37353. t1 += v * b1;
  37354. t2 += v * b2;
  37355. t3 += v * b3;
  37356. t4 += v * b4;
  37357. t5 += v * b5;
  37358. t6 += v * b6;
  37359. t7 += v * b7;
  37360. t8 += v * b8;
  37361. t9 += v * b9;
  37362. t10 += v * b10;
  37363. t11 += v * b11;
  37364. t12 += v * b12;
  37365. t13 += v * b13;
  37366. t14 += v * b14;
  37367. t15 += v * b15;
  37368. v = a[1];
  37369. t1 += v * b0;
  37370. t2 += v * b1;
  37371. t3 += v * b2;
  37372. t4 += v * b3;
  37373. t5 += v * b4;
  37374. t6 += v * b5;
  37375. t7 += v * b6;
  37376. t8 += v * b7;
  37377. t9 += v * b8;
  37378. t10 += v * b9;
  37379. t11 += v * b10;
  37380. t12 += v * b11;
  37381. t13 += v * b12;
  37382. t14 += v * b13;
  37383. t15 += v * b14;
  37384. t16 += v * b15;
  37385. v = a[2];
  37386. t2 += v * b0;
  37387. t3 += v * b1;
  37388. t4 += v * b2;
  37389. t5 += v * b3;
  37390. t6 += v * b4;
  37391. t7 += v * b5;
  37392. t8 += v * b6;
  37393. t9 += v * b7;
  37394. t10 += v * b8;
  37395. t11 += v * b9;
  37396. t12 += v * b10;
  37397. t13 += v * b11;
  37398. t14 += v * b12;
  37399. t15 += v * b13;
  37400. t16 += v * b14;
  37401. t17 += v * b15;
  37402. v = a[3];
  37403. t3 += v * b0;
  37404. t4 += v * b1;
  37405. t5 += v * b2;
  37406. t6 += v * b3;
  37407. t7 += v * b4;
  37408. t8 += v * b5;
  37409. t9 += v * b6;
  37410. t10 += v * b7;
  37411. t11 += v * b8;
  37412. t12 += v * b9;
  37413. t13 += v * b10;
  37414. t14 += v * b11;
  37415. t15 += v * b12;
  37416. t16 += v * b13;
  37417. t17 += v * b14;
  37418. t18 += v * b15;
  37419. v = a[4];
  37420. t4 += v * b0;
  37421. t5 += v * b1;
  37422. t6 += v * b2;
  37423. t7 += v * b3;
  37424. t8 += v * b4;
  37425. t9 += v * b5;
  37426. t10 += v * b6;
  37427. t11 += v * b7;
  37428. t12 += v * b8;
  37429. t13 += v * b9;
  37430. t14 += v * b10;
  37431. t15 += v * b11;
  37432. t16 += v * b12;
  37433. t17 += v * b13;
  37434. t18 += v * b14;
  37435. t19 += v * b15;
  37436. v = a[5];
  37437. t5 += v * b0;
  37438. t6 += v * b1;
  37439. t7 += v * b2;
  37440. t8 += v * b3;
  37441. t9 += v * b4;
  37442. t10 += v * b5;
  37443. t11 += v * b6;
  37444. t12 += v * b7;
  37445. t13 += v * b8;
  37446. t14 += v * b9;
  37447. t15 += v * b10;
  37448. t16 += v * b11;
  37449. t17 += v * b12;
  37450. t18 += v * b13;
  37451. t19 += v * b14;
  37452. t20 += v * b15;
  37453. v = a[6];
  37454. t6 += v * b0;
  37455. t7 += v * b1;
  37456. t8 += v * b2;
  37457. t9 += v * b3;
  37458. t10 += v * b4;
  37459. t11 += v * b5;
  37460. t12 += v * b6;
  37461. t13 += v * b7;
  37462. t14 += v * b8;
  37463. t15 += v * b9;
  37464. t16 += v * b10;
  37465. t17 += v * b11;
  37466. t18 += v * b12;
  37467. t19 += v * b13;
  37468. t20 += v * b14;
  37469. t21 += v * b15;
  37470. v = a[7];
  37471. t7 += v * b0;
  37472. t8 += v * b1;
  37473. t9 += v * b2;
  37474. t10 += v * b3;
  37475. t11 += v * b4;
  37476. t12 += v * b5;
  37477. t13 += v * b6;
  37478. t14 += v * b7;
  37479. t15 += v * b8;
  37480. t16 += v * b9;
  37481. t17 += v * b10;
  37482. t18 += v * b11;
  37483. t19 += v * b12;
  37484. t20 += v * b13;
  37485. t21 += v * b14;
  37486. t22 += v * b15;
  37487. v = a[8];
  37488. t8 += v * b0;
  37489. t9 += v * b1;
  37490. t10 += v * b2;
  37491. t11 += v * b3;
  37492. t12 += v * b4;
  37493. t13 += v * b5;
  37494. t14 += v * b6;
  37495. t15 += v * b7;
  37496. t16 += v * b8;
  37497. t17 += v * b9;
  37498. t18 += v * b10;
  37499. t19 += v * b11;
  37500. t20 += v * b12;
  37501. t21 += v * b13;
  37502. t22 += v * b14;
  37503. t23 += v * b15;
  37504. v = a[9];
  37505. t9 += v * b0;
  37506. t10 += v * b1;
  37507. t11 += v * b2;
  37508. t12 += v * b3;
  37509. t13 += v * b4;
  37510. t14 += v * b5;
  37511. t15 += v * b6;
  37512. t16 += v * b7;
  37513. t17 += v * b8;
  37514. t18 += v * b9;
  37515. t19 += v * b10;
  37516. t20 += v * b11;
  37517. t21 += v * b12;
  37518. t22 += v * b13;
  37519. t23 += v * b14;
  37520. t24 += v * b15;
  37521. v = a[10];
  37522. t10 += v * b0;
  37523. t11 += v * b1;
  37524. t12 += v * b2;
  37525. t13 += v * b3;
  37526. t14 += v * b4;
  37527. t15 += v * b5;
  37528. t16 += v * b6;
  37529. t17 += v * b7;
  37530. t18 += v * b8;
  37531. t19 += v * b9;
  37532. t20 += v * b10;
  37533. t21 += v * b11;
  37534. t22 += v * b12;
  37535. t23 += v * b13;
  37536. t24 += v * b14;
  37537. t25 += v * b15;
  37538. v = a[11];
  37539. t11 += v * b0;
  37540. t12 += v * b1;
  37541. t13 += v * b2;
  37542. t14 += v * b3;
  37543. t15 += v * b4;
  37544. t16 += v * b5;
  37545. t17 += v * b6;
  37546. t18 += v * b7;
  37547. t19 += v * b8;
  37548. t20 += v * b9;
  37549. t21 += v * b10;
  37550. t22 += v * b11;
  37551. t23 += v * b12;
  37552. t24 += v * b13;
  37553. t25 += v * b14;
  37554. t26 += v * b15;
  37555. v = a[12];
  37556. t12 += v * b0;
  37557. t13 += v * b1;
  37558. t14 += v * b2;
  37559. t15 += v * b3;
  37560. t16 += v * b4;
  37561. t17 += v * b5;
  37562. t18 += v * b6;
  37563. t19 += v * b7;
  37564. t20 += v * b8;
  37565. t21 += v * b9;
  37566. t22 += v * b10;
  37567. t23 += v * b11;
  37568. t24 += v * b12;
  37569. t25 += v * b13;
  37570. t26 += v * b14;
  37571. t27 += v * b15;
  37572. v = a[13];
  37573. t13 += v * b0;
  37574. t14 += v * b1;
  37575. t15 += v * b2;
  37576. t16 += v * b3;
  37577. t17 += v * b4;
  37578. t18 += v * b5;
  37579. t19 += v * b6;
  37580. t20 += v * b7;
  37581. t21 += v * b8;
  37582. t22 += v * b9;
  37583. t23 += v * b10;
  37584. t24 += v * b11;
  37585. t25 += v * b12;
  37586. t26 += v * b13;
  37587. t27 += v * b14;
  37588. t28 += v * b15;
  37589. v = a[14];
  37590. t14 += v * b0;
  37591. t15 += v * b1;
  37592. t16 += v * b2;
  37593. t17 += v * b3;
  37594. t18 += v * b4;
  37595. t19 += v * b5;
  37596. t20 += v * b6;
  37597. t21 += v * b7;
  37598. t22 += v * b8;
  37599. t23 += v * b9;
  37600. t24 += v * b10;
  37601. t25 += v * b11;
  37602. t26 += v * b12;
  37603. t27 += v * b13;
  37604. t28 += v * b14;
  37605. t29 += v * b15;
  37606. v = a[15];
  37607. t15 += v * b0;
  37608. t16 += v * b1;
  37609. t17 += v * b2;
  37610. t18 += v * b3;
  37611. t19 += v * b4;
  37612. t20 += v * b5;
  37613. t21 += v * b6;
  37614. t22 += v * b7;
  37615. t23 += v * b8;
  37616. t24 += v * b9;
  37617. t25 += v * b10;
  37618. t26 += v * b11;
  37619. t27 += v * b12;
  37620. t28 += v * b13;
  37621. t29 += v * b14;
  37622. t30 += v * b15;
  37623. t0 += 38 * t16;
  37624. t1 += 38 * t17;
  37625. t2 += 38 * t18;
  37626. t3 += 38 * t19;
  37627. t4 += 38 * t20;
  37628. t5 += 38 * t21;
  37629. t6 += 38 * t22;
  37630. t7 += 38 * t23;
  37631. t8 += 38 * t24;
  37632. t9 += 38 * t25;
  37633. t10 += 38 * t26;
  37634. t11 += 38 * t27;
  37635. t12 += 38 * t28;
  37636. t13 += 38 * t29;
  37637. t14 += 38 * t30;
  37638. // t15 left as is
  37639. // first car
  37640. c = 1;
  37641. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37642. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37643. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37644. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37645. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37646. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37647. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37648. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37649. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37650. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37651. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37652. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37653. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37654. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37655. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37656. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37657. t0 += c-1 + 37 * (c-1);
  37658. // second car
  37659. c = 1;
  37660. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37661. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37662. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37663. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37664. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37665. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37666. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37667. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37668. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37669. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37670. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37671. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37672. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37673. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37674. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37675. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37676. t0 += c-1 + 37 * (c-1);
  37677. o[ 0] = t0;
  37678. o[ 1] = t1;
  37679. o[ 2] = t2;
  37680. o[ 3] = t3;
  37681. o[ 4] = t4;
  37682. o[ 5] = t5;
  37683. o[ 6] = t6;
  37684. o[ 7] = t7;
  37685. o[ 8] = t8;
  37686. o[ 9] = t9;
  37687. o[10] = t10;
  37688. o[11] = t11;
  37689. o[12] = t12;
  37690. o[13] = t13;
  37691. o[14] = t14;
  37692. o[15] = t15;
  37693. }
  37694. function S(o, a) {
  37695. M(o, a, a);
  37696. }
  37697. function inv25519(o, i) {
  37698. var c = gf();
  37699. var a;
  37700. for (a = 0; a < 16; a++) c[a] = i[a];
  37701. for (a = 253; a >= 0; a--) {
  37702. S(c, c);
  37703. if(a !== 2 && a !== 4) M(c, c, i);
  37704. }
  37705. for (a = 0; a < 16; a++) o[a] = c[a];
  37706. }
  37707. function pow2523(o, i) {
  37708. var c = gf();
  37709. var a;
  37710. for (a = 0; a < 16; a++) c[a] = i[a];
  37711. for (a = 250; a >= 0; a--) {
  37712. S(c, c);
  37713. if(a !== 1) M(c, c, i);
  37714. }
  37715. for (a = 0; a < 16; a++) o[a] = c[a];
  37716. }
  37717. function crypto_scalarmult(q, n, p) {
  37718. var z = new Uint8Array(32);
  37719. var x = new Float64Array(80), r, i;
  37720. var a = gf(), b = gf(), c = gf(),
  37721. d = gf(), e = gf(), f = gf();
  37722. for (i = 0; i < 31; i++) z[i] = n[i];
  37723. z[31]=(n[31]&127)|64;
  37724. z[0]&=248;
  37725. unpack25519(x,p);
  37726. for (i = 0; i < 16; i++) {
  37727. b[i]=x[i];
  37728. d[i]=a[i]=c[i]=0;
  37729. }
  37730. a[0]=d[0]=1;
  37731. for (i=254; i>=0; --i) {
  37732. r=(z[i>>>3]>>>(i&7))&1;
  37733. sel25519(a,b,r);
  37734. sel25519(c,d,r);
  37735. A(e,a,c);
  37736. Z(a,a,c);
  37737. A(c,b,d);
  37738. Z(b,b,d);
  37739. S(d,e);
  37740. S(f,a);
  37741. M(a,c,a);
  37742. M(c,b,e);
  37743. A(e,a,c);
  37744. Z(a,a,c);
  37745. S(b,a);
  37746. Z(c,d,f);
  37747. M(a,c,_121665);
  37748. A(a,a,d);
  37749. M(c,c,a);
  37750. M(a,d,f);
  37751. M(d,b,x);
  37752. S(b,e);
  37753. sel25519(a,b,r);
  37754. sel25519(c,d,r);
  37755. }
  37756. for (i = 0; i < 16; i++) {
  37757. x[i+16]=a[i];
  37758. x[i+32]=c[i];
  37759. x[i+48]=b[i];
  37760. x[i+64]=d[i];
  37761. }
  37762. var x32 = x.subarray(32);
  37763. var x16 = x.subarray(16);
  37764. inv25519(x32,x32);
  37765. M(x16,x16,x32);
  37766. pack25519(q,x16);
  37767. return 0;
  37768. }
  37769. function crypto_scalarmult_base(q, n) {
  37770. return crypto_scalarmult(q, n, _9);
  37771. }
  37772. function crypto_box_keypair(y, x) {
  37773. randombytes(x, 32);
  37774. return crypto_scalarmult_base(y, x);
  37775. }
  37776. function crypto_box_beforenm(k, y, x) {
  37777. var s = new Uint8Array(32);
  37778. crypto_scalarmult(s, x, y);
  37779. return crypto_core_hsalsa20(k, _0, s, sigma);
  37780. }
  37781. var crypto_box_afternm = crypto_secretbox;
  37782. var crypto_box_open_afternm = crypto_secretbox_open;
  37783. function crypto_box(c, m, d, n, y, x) {
  37784. var k = new Uint8Array(32);
  37785. crypto_box_beforenm(k, y, x);
  37786. return crypto_box_afternm(c, m, d, n, k);
  37787. }
  37788. function crypto_box_open(m, c, d, n, y, x) {
  37789. var k = new Uint8Array(32);
  37790. crypto_box_beforenm(k, y, x);
  37791. return crypto_box_open_afternm(m, c, d, n, k);
  37792. }
  37793. var K = [
  37794. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37795. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37796. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37797. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37798. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37799. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37800. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37801. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37802. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37803. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37804. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37805. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37806. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37807. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37808. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37809. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37810. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37811. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37812. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37813. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37814. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37815. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37816. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37817. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37818. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37819. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37820. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37821. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37822. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37823. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37824. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37825. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37826. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37827. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37828. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37829. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37830. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37831. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37832. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37833. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37834. ];
  37835. function crypto_hashblocks_hl(hh, hl, m, n) {
  37836. var wh = new Int32Array(16), wl = new Int32Array(16),
  37837. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37838. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37839. th, tl, i, j, h, l, a, b, c, d;
  37840. var ah0 = hh[0],
  37841. ah1 = hh[1],
  37842. ah2 = hh[2],
  37843. ah3 = hh[3],
  37844. ah4 = hh[4],
  37845. ah5 = hh[5],
  37846. ah6 = hh[6],
  37847. ah7 = hh[7],
  37848. al0 = hl[0],
  37849. al1 = hl[1],
  37850. al2 = hl[2],
  37851. al3 = hl[3],
  37852. al4 = hl[4],
  37853. al5 = hl[5],
  37854. al6 = hl[6],
  37855. al7 = hl[7];
  37856. var pos = 0;
  37857. while (n >= 128) {
  37858. for (i = 0; i < 16; i++) {
  37859. j = 8 * i + pos;
  37860. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37861. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37862. }
  37863. for (i = 0; i < 80; i++) {
  37864. bh0 = ah0;
  37865. bh1 = ah1;
  37866. bh2 = ah2;
  37867. bh3 = ah3;
  37868. bh4 = ah4;
  37869. bh5 = ah5;
  37870. bh6 = ah6;
  37871. bh7 = ah7;
  37872. bl0 = al0;
  37873. bl1 = al1;
  37874. bl2 = al2;
  37875. bl3 = al3;
  37876. bl4 = al4;
  37877. bl5 = al5;
  37878. bl6 = al6;
  37879. bl7 = al7;
  37880. // add
  37881. h = ah7;
  37882. l = al7;
  37883. a = l & 0xffff; b = l >>> 16;
  37884. c = h & 0xffff; d = h >>> 16;
  37885. // Sigma1
  37886. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37887. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37888. a += l & 0xffff; b += l >>> 16;
  37889. c += h & 0xffff; d += h >>> 16;
  37890. // Ch
  37891. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37892. l = (al4 & al5) ^ (~al4 & al6);
  37893. a += l & 0xffff; b += l >>> 16;
  37894. c += h & 0xffff; d += h >>> 16;
  37895. // K
  37896. h = K[i*2];
  37897. l = K[i*2+1];
  37898. a += l & 0xffff; b += l >>> 16;
  37899. c += h & 0xffff; d += h >>> 16;
  37900. // w
  37901. h = wh[i%16];
  37902. l = wl[i%16];
  37903. a += l & 0xffff; b += l >>> 16;
  37904. c += h & 0xffff; d += h >>> 16;
  37905. b += a >>> 16;
  37906. c += b >>> 16;
  37907. d += c >>> 16;
  37908. th = c & 0xffff | d << 16;
  37909. tl = a & 0xffff | b << 16;
  37910. // add
  37911. h = th;
  37912. l = tl;
  37913. a = l & 0xffff; b = l >>> 16;
  37914. c = h & 0xffff; d = h >>> 16;
  37915. // Sigma0
  37916. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37917. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37918. a += l & 0xffff; b += l >>> 16;
  37919. c += h & 0xffff; d += h >>> 16;
  37920. // Maj
  37921. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37922. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37923. a += l & 0xffff; b += l >>> 16;
  37924. c += h & 0xffff; d += h >>> 16;
  37925. b += a >>> 16;
  37926. c += b >>> 16;
  37927. d += c >>> 16;
  37928. bh7 = (c & 0xffff) | (d << 16);
  37929. bl7 = (a & 0xffff) | (b << 16);
  37930. // add
  37931. h = bh3;
  37932. l = bl3;
  37933. a = l & 0xffff; b = l >>> 16;
  37934. c = h & 0xffff; d = h >>> 16;
  37935. h = th;
  37936. l = tl;
  37937. a += l & 0xffff; b += l >>> 16;
  37938. c += h & 0xffff; d += h >>> 16;
  37939. b += a >>> 16;
  37940. c += b >>> 16;
  37941. d += c >>> 16;
  37942. bh3 = (c & 0xffff) | (d << 16);
  37943. bl3 = (a & 0xffff) | (b << 16);
  37944. ah1 = bh0;
  37945. ah2 = bh1;
  37946. ah3 = bh2;
  37947. ah4 = bh3;
  37948. ah5 = bh4;
  37949. ah6 = bh5;
  37950. ah7 = bh6;
  37951. ah0 = bh7;
  37952. al1 = bl0;
  37953. al2 = bl1;
  37954. al3 = bl2;
  37955. al4 = bl3;
  37956. al5 = bl4;
  37957. al6 = bl5;
  37958. al7 = bl6;
  37959. al0 = bl7;
  37960. if (i%16 === 15) {
  37961. for (j = 0; j < 16; j++) {
  37962. // add
  37963. h = wh[j];
  37964. l = wl[j];
  37965. a = l & 0xffff; b = l >>> 16;
  37966. c = h & 0xffff; d = h >>> 16;
  37967. h = wh[(j+9)%16];
  37968. l = wl[(j+9)%16];
  37969. a += l & 0xffff; b += l >>> 16;
  37970. c += h & 0xffff; d += h >>> 16;
  37971. // sigma0
  37972. th = wh[(j+1)%16];
  37973. tl = wl[(j+1)%16];
  37974. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37975. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37976. a += l & 0xffff; b += l >>> 16;
  37977. c += h & 0xffff; d += h >>> 16;
  37978. // sigma1
  37979. th = wh[(j+14)%16];
  37980. tl = wl[(j+14)%16];
  37981. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37982. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37983. a += l & 0xffff; b += l >>> 16;
  37984. c += h & 0xffff; d += h >>> 16;
  37985. b += a >>> 16;
  37986. c += b >>> 16;
  37987. d += c >>> 16;
  37988. wh[j] = (c & 0xffff) | (d << 16);
  37989. wl[j] = (a & 0xffff) | (b << 16);
  37990. }
  37991. }
  37992. }
  37993. // add
  37994. h = ah0;
  37995. l = al0;
  37996. a = l & 0xffff; b = l >>> 16;
  37997. c = h & 0xffff; d = h >>> 16;
  37998. h = hh[0];
  37999. l = hl[0];
  38000. a += l & 0xffff; b += l >>> 16;
  38001. c += h & 0xffff; d += h >>> 16;
  38002. b += a >>> 16;
  38003. c += b >>> 16;
  38004. d += c >>> 16;
  38005. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  38006. hl[0] = al0 = (a & 0xffff) | (b << 16);
  38007. h = ah1;
  38008. l = al1;
  38009. a = l & 0xffff; b = l >>> 16;
  38010. c = h & 0xffff; d = h >>> 16;
  38011. h = hh[1];
  38012. l = hl[1];
  38013. a += l & 0xffff; b += l >>> 16;
  38014. c += h & 0xffff; d += h >>> 16;
  38015. b += a >>> 16;
  38016. c += b >>> 16;
  38017. d += c >>> 16;
  38018. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  38019. hl[1] = al1 = (a & 0xffff) | (b << 16);
  38020. h = ah2;
  38021. l = al2;
  38022. a = l & 0xffff; b = l >>> 16;
  38023. c = h & 0xffff; d = h >>> 16;
  38024. h = hh[2];
  38025. l = hl[2];
  38026. a += l & 0xffff; b += l >>> 16;
  38027. c += h & 0xffff; d += h >>> 16;
  38028. b += a >>> 16;
  38029. c += b >>> 16;
  38030. d += c >>> 16;
  38031. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  38032. hl[2] = al2 = (a & 0xffff) | (b << 16);
  38033. h = ah3;
  38034. l = al3;
  38035. a = l & 0xffff; b = l >>> 16;
  38036. c = h & 0xffff; d = h >>> 16;
  38037. h = hh[3];
  38038. l = hl[3];
  38039. a += l & 0xffff; b += l >>> 16;
  38040. c += h & 0xffff; d += h >>> 16;
  38041. b += a >>> 16;
  38042. c += b >>> 16;
  38043. d += c >>> 16;
  38044. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  38045. hl[3] = al3 = (a & 0xffff) | (b << 16);
  38046. h = ah4;
  38047. l = al4;
  38048. a = l & 0xffff; b = l >>> 16;
  38049. c = h & 0xffff; d = h >>> 16;
  38050. h = hh[4];
  38051. l = hl[4];
  38052. a += l & 0xffff; b += l >>> 16;
  38053. c += h & 0xffff; d += h >>> 16;
  38054. b += a >>> 16;
  38055. c += b >>> 16;
  38056. d += c >>> 16;
  38057. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  38058. hl[4] = al4 = (a & 0xffff) | (b << 16);
  38059. h = ah5;
  38060. l = al5;
  38061. a = l & 0xffff; b = l >>> 16;
  38062. c = h & 0xffff; d = h >>> 16;
  38063. h = hh[5];
  38064. l = hl[5];
  38065. a += l & 0xffff; b += l >>> 16;
  38066. c += h & 0xffff; d += h >>> 16;
  38067. b += a >>> 16;
  38068. c += b >>> 16;
  38069. d += c >>> 16;
  38070. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  38071. hl[5] = al5 = (a & 0xffff) | (b << 16);
  38072. h = ah6;
  38073. l = al6;
  38074. a = l & 0xffff; b = l >>> 16;
  38075. c = h & 0xffff; d = h >>> 16;
  38076. h = hh[6];
  38077. l = hl[6];
  38078. a += l & 0xffff; b += l >>> 16;
  38079. c += h & 0xffff; d += h >>> 16;
  38080. b += a >>> 16;
  38081. c += b >>> 16;
  38082. d += c >>> 16;
  38083. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  38084. hl[6] = al6 = (a & 0xffff) | (b << 16);
  38085. h = ah7;
  38086. l = al7;
  38087. a = l & 0xffff; b = l >>> 16;
  38088. c = h & 0xffff; d = h >>> 16;
  38089. h = hh[7];
  38090. l = hl[7];
  38091. a += l & 0xffff; b += l >>> 16;
  38092. c += h & 0xffff; d += h >>> 16;
  38093. b += a >>> 16;
  38094. c += b >>> 16;
  38095. d += c >>> 16;
  38096. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  38097. hl[7] = al7 = (a & 0xffff) | (b << 16);
  38098. pos += 128;
  38099. n -= 128;
  38100. }
  38101. return n;
  38102. }
  38103. function crypto_hash(out, m, n) {
  38104. var hh = new Int32Array(8),
  38105. hl = new Int32Array(8),
  38106. x = new Uint8Array(256),
  38107. i, b = n;
  38108. hh[0] = 0x6a09e667;
  38109. hh[1] = 0xbb67ae85;
  38110. hh[2] = 0x3c6ef372;
  38111. hh[3] = 0xa54ff53a;
  38112. hh[4] = 0x510e527f;
  38113. hh[5] = 0x9b05688c;
  38114. hh[6] = 0x1f83d9ab;
  38115. hh[7] = 0x5be0cd19;
  38116. hl[0] = 0xf3bcc908;
  38117. hl[1] = 0x84caa73b;
  38118. hl[2] = 0xfe94f82b;
  38119. hl[3] = 0x5f1d36f1;
  38120. hl[4] = 0xade682d1;
  38121. hl[5] = 0x2b3e6c1f;
  38122. hl[6] = 0xfb41bd6b;
  38123. hl[7] = 0x137e2179;
  38124. crypto_hashblocks_hl(hh, hl, m, n);
  38125. n %= 128;
  38126. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  38127. x[n] = 128;
  38128. n = 256-128*(n<112?1:0);
  38129. x[n-9] = 0;
  38130. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38131. crypto_hashblocks_hl(hh, hl, x, n);
  38132. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38133. return 0;
  38134. }
  38135. function add(p, q) {
  38136. var a = gf(), b = gf(), c = gf(),
  38137. d = gf(), e = gf(), f = gf(),
  38138. g = gf(), h = gf(), t = gf();
  38139. Z(a, p[1], p[0]);
  38140. Z(t, q[1], q[0]);
  38141. M(a, a, t);
  38142. A(b, p[0], p[1]);
  38143. A(t, q[0], q[1]);
  38144. M(b, b, t);
  38145. M(c, p[3], q[3]);
  38146. M(c, c, D2);
  38147. M(d, p[2], q[2]);
  38148. A(d, d, d);
  38149. Z(e, b, a);
  38150. Z(f, d, c);
  38151. A(g, d, c);
  38152. A(h, b, a);
  38153. M(p[0], e, f);
  38154. M(p[1], h, g);
  38155. M(p[2], g, f);
  38156. M(p[3], e, h);
  38157. }
  38158. function cswap(p, q, b) {
  38159. var i;
  38160. for (i = 0; i < 4; i++) {
  38161. sel25519(p[i], q[i], b);
  38162. }
  38163. }
  38164. function pack(r, p) {
  38165. var tx = gf(), ty = gf(), zi = gf();
  38166. inv25519(zi, p[2]);
  38167. M(tx, p[0], zi);
  38168. M(ty, p[1], zi);
  38169. pack25519(r, ty);
  38170. r[31] ^= par25519(tx) << 7;
  38171. }
  38172. function scalarmult(p, q, s) {
  38173. var b, i;
  38174. set25519(p[0], gf0);
  38175. set25519(p[1], gf1);
  38176. set25519(p[2], gf1);
  38177. set25519(p[3], gf0);
  38178. for (i = 255; i >= 0; --i) {
  38179. b = (s[(i/8)|0] >> (i&7)) & 1;
  38180. cswap(p, q, b);
  38181. add(q, p);
  38182. add(p, p);
  38183. cswap(p, q, b);
  38184. }
  38185. }
  38186. function scalarbase(p, s) {
  38187. var q = [gf(), gf(), gf(), gf()];
  38188. set25519(q[0], X);
  38189. set25519(q[1], Y);
  38190. set25519(q[2], gf1);
  38191. M(q[3], X, Y);
  38192. scalarmult(p, q, s);
  38193. }
  38194. function crypto_sign_keypair(pk, sk, seeded) {
  38195. var d = new Uint8Array(64);
  38196. var p = [gf(), gf(), gf(), gf()];
  38197. var i;
  38198. if (!seeded) randombytes(sk, 32);
  38199. crypto_hash(d, sk, 32);
  38200. d[0] &= 248;
  38201. d[31] &= 127;
  38202. d[31] |= 64;
  38203. scalarbase(p, d);
  38204. pack(pk, p);
  38205. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38206. return 0;
  38207. }
  38208. 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]);
  38209. function modL(r, x) {
  38210. var carry, i, j, k;
  38211. for (i = 63; i >= 32; --i) {
  38212. carry = 0;
  38213. for (j = i - 32, k = i - 12; j < k; ++j) {
  38214. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38215. carry = (x[j] + 128) >> 8;
  38216. x[j] -= carry * 256;
  38217. }
  38218. x[j] += carry;
  38219. x[i] = 0;
  38220. }
  38221. carry = 0;
  38222. for (j = 0; j < 32; j++) {
  38223. x[j] += carry - (x[31] >> 4) * L[j];
  38224. carry = x[j] >> 8;
  38225. x[j] &= 255;
  38226. }
  38227. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38228. for (i = 0; i < 32; i++) {
  38229. x[i+1] += x[i] >> 8;
  38230. r[i] = x[i] & 255;
  38231. }
  38232. }
  38233. function reduce(r) {
  38234. var x = new Float64Array(64), i;
  38235. for (i = 0; i < 64; i++) x[i] = r[i];
  38236. for (i = 0; i < 64; i++) r[i] = 0;
  38237. modL(r, x);
  38238. }
  38239. // Note: difference from C - smlen returned, not passed as argument.
  38240. function crypto_sign(sm, m, n, sk) {
  38241. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38242. var i, j, x = new Float64Array(64);
  38243. var p = [gf(), gf(), gf(), gf()];
  38244. crypto_hash(d, sk, 32);
  38245. d[0] &= 248;
  38246. d[31] &= 127;
  38247. d[31] |= 64;
  38248. var smlen = n + 64;
  38249. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38250. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38251. crypto_hash(r, sm.subarray(32), n+32);
  38252. reduce(r);
  38253. scalarbase(p, r);
  38254. pack(sm, p);
  38255. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38256. crypto_hash(h, sm, n + 64);
  38257. reduce(h);
  38258. for (i = 0; i < 64; i++) x[i] = 0;
  38259. for (i = 0; i < 32; i++) x[i] = r[i];
  38260. for (i = 0; i < 32; i++) {
  38261. for (j = 0; j < 32; j++) {
  38262. x[i+j] += h[i] * d[j];
  38263. }
  38264. }
  38265. modL(sm.subarray(32), x);
  38266. return smlen;
  38267. }
  38268. function unpackneg(r, p) {
  38269. var t = gf(), chk = gf(), num = gf(),
  38270. den = gf(), den2 = gf(), den4 = gf(),
  38271. den6 = gf();
  38272. set25519(r[2], gf1);
  38273. unpack25519(r[1], p);
  38274. S(num, r[1]);
  38275. M(den, num, D);
  38276. Z(num, num, r[2]);
  38277. A(den, r[2], den);
  38278. S(den2, den);
  38279. S(den4, den2);
  38280. M(den6, den4, den2);
  38281. M(t, den6, num);
  38282. M(t, t, den);
  38283. pow2523(t, t);
  38284. M(t, t, num);
  38285. M(t, t, den);
  38286. M(t, t, den);
  38287. M(r[0], t, den);
  38288. S(chk, r[0]);
  38289. M(chk, chk, den);
  38290. if (neq25519(chk, num)) M(r[0], r[0], I);
  38291. S(chk, r[0]);
  38292. M(chk, chk, den);
  38293. if (neq25519(chk, num)) return -1;
  38294. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38295. M(r[3], r[0], r[1]);
  38296. return 0;
  38297. }
  38298. function crypto_sign_open(m, sm, n, pk) {
  38299. var i, mlen;
  38300. var t = new Uint8Array(32), h = new Uint8Array(64);
  38301. var p = [gf(), gf(), gf(), gf()],
  38302. q = [gf(), gf(), gf(), gf()];
  38303. mlen = -1;
  38304. if (n < 64) return -1;
  38305. if (unpackneg(q, pk)) return -1;
  38306. for (i = 0; i < n; i++) m[i] = sm[i];
  38307. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38308. crypto_hash(h, m, n);
  38309. reduce(h);
  38310. scalarmult(p, q, h);
  38311. scalarbase(q, sm.subarray(32));
  38312. add(p, q);
  38313. pack(t, p);
  38314. n -= 64;
  38315. if (crypto_verify_32(sm, 0, t, 0)) {
  38316. for (i = 0; i < n; i++) m[i] = 0;
  38317. return -1;
  38318. }
  38319. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38320. mlen = n;
  38321. return mlen;
  38322. }
  38323. var crypto_secretbox_KEYBYTES = 32,
  38324. crypto_secretbox_NONCEBYTES = 24,
  38325. crypto_secretbox_ZEROBYTES = 32,
  38326. crypto_secretbox_BOXZEROBYTES = 16,
  38327. crypto_scalarmult_BYTES = 32,
  38328. crypto_scalarmult_SCALARBYTES = 32,
  38329. crypto_box_PUBLICKEYBYTES = 32,
  38330. crypto_box_SECRETKEYBYTES = 32,
  38331. crypto_box_BEFORENMBYTES = 32,
  38332. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38333. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38334. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38335. crypto_sign_BYTES = 64,
  38336. crypto_sign_PUBLICKEYBYTES = 32,
  38337. crypto_sign_SECRETKEYBYTES = 64,
  38338. crypto_sign_SEEDBYTES = 32,
  38339. crypto_hash_BYTES = 64;
  38340. nacl.lowlevel = {
  38341. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38342. crypto_stream_xor: crypto_stream_xor,
  38343. crypto_stream: crypto_stream,
  38344. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38345. crypto_stream_salsa20: crypto_stream_salsa20,
  38346. crypto_onetimeauth: crypto_onetimeauth,
  38347. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38348. crypto_verify_16: crypto_verify_16,
  38349. crypto_verify_32: crypto_verify_32,
  38350. crypto_secretbox: crypto_secretbox,
  38351. crypto_secretbox_open: crypto_secretbox_open,
  38352. crypto_scalarmult: crypto_scalarmult,
  38353. crypto_scalarmult_base: crypto_scalarmult_base,
  38354. crypto_box_beforenm: crypto_box_beforenm,
  38355. crypto_box_afternm: crypto_box_afternm,
  38356. crypto_box: crypto_box,
  38357. crypto_box_open: crypto_box_open,
  38358. crypto_box_keypair: crypto_box_keypair,
  38359. crypto_hash: crypto_hash,
  38360. crypto_sign: crypto_sign,
  38361. crypto_sign_keypair: crypto_sign_keypair,
  38362. crypto_sign_open: crypto_sign_open,
  38363. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38364. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38365. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38366. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38367. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38368. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38369. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38370. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38371. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38372. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38373. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38374. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38375. crypto_sign_BYTES: crypto_sign_BYTES,
  38376. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38377. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38378. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38379. crypto_hash_BYTES: crypto_hash_BYTES
  38380. };
  38381. /* High-level API */
  38382. function checkLengths(k, n) {
  38383. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38384. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38385. }
  38386. function checkBoxLengths(pk, sk) {
  38387. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38388. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38389. }
  38390. function checkArrayTypes() {
  38391. for (var i = 0; i < arguments.length; i++) {
  38392. if (!(arguments[i] instanceof Uint8Array))
  38393. throw new TypeError('unexpected type, use Uint8Array');
  38394. }
  38395. }
  38396. function cleanup(arr) {
  38397. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38398. }
  38399. nacl.randomBytes = function(n) {
  38400. var b = new Uint8Array(n);
  38401. randombytes(b, n);
  38402. return b;
  38403. };
  38404. nacl.secretbox = function(msg, nonce, key) {
  38405. checkArrayTypes(msg, nonce, key);
  38406. checkLengths(key, nonce);
  38407. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38408. var c = new Uint8Array(m.length);
  38409. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38410. crypto_secretbox(c, m, m.length, nonce, key);
  38411. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38412. };
  38413. nacl.secretbox.open = function(box, nonce, key) {
  38414. checkArrayTypes(box, nonce, key);
  38415. checkLengths(key, nonce);
  38416. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38417. var m = new Uint8Array(c.length);
  38418. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38419. if (c.length < 32) return null;
  38420. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38421. return m.subarray(crypto_secretbox_ZEROBYTES);
  38422. };
  38423. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38424. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38425. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38426. nacl.scalarMult = function(n, p) {
  38427. checkArrayTypes(n, p);
  38428. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38429. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38430. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38431. crypto_scalarmult(q, n, p);
  38432. return q;
  38433. };
  38434. nacl.scalarMult.base = function(n) {
  38435. checkArrayTypes(n);
  38436. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38437. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38438. crypto_scalarmult_base(q, n);
  38439. return q;
  38440. };
  38441. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38442. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38443. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38444. var k = nacl.box.before(publicKey, secretKey);
  38445. return nacl.secretbox(msg, nonce, k);
  38446. };
  38447. nacl.box.before = function(publicKey, secretKey) {
  38448. checkArrayTypes(publicKey, secretKey);
  38449. checkBoxLengths(publicKey, secretKey);
  38450. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38451. crypto_box_beforenm(k, publicKey, secretKey);
  38452. return k;
  38453. };
  38454. nacl.box.after = nacl.secretbox;
  38455. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38456. var k = nacl.box.before(publicKey, secretKey);
  38457. return nacl.secretbox.open(msg, nonce, k);
  38458. };
  38459. nacl.box.open.after = nacl.secretbox.open;
  38460. nacl.box.keyPair = function() {
  38461. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38462. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38463. crypto_box_keypair(pk, sk);
  38464. return {publicKey: pk, secretKey: sk};
  38465. };
  38466. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38467. checkArrayTypes(secretKey);
  38468. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38469. throw new Error('bad secret key size');
  38470. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38471. crypto_scalarmult_base(pk, secretKey);
  38472. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38473. };
  38474. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38475. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38476. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38477. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38478. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38479. nacl.sign = function(msg, secretKey) {
  38480. checkArrayTypes(msg, secretKey);
  38481. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38482. throw new Error('bad secret key size');
  38483. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38484. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38485. return signedMsg;
  38486. };
  38487. nacl.sign.open = function(signedMsg, publicKey) {
  38488. checkArrayTypes(signedMsg, publicKey);
  38489. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38490. throw new Error('bad public key size');
  38491. var tmp = new Uint8Array(signedMsg.length);
  38492. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38493. if (mlen < 0) return null;
  38494. var m = new Uint8Array(mlen);
  38495. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38496. return m;
  38497. };
  38498. nacl.sign.detached = function(msg, secretKey) {
  38499. var signedMsg = nacl.sign(msg, secretKey);
  38500. var sig = new Uint8Array(crypto_sign_BYTES);
  38501. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38502. return sig;
  38503. };
  38504. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38505. checkArrayTypes(msg, sig, publicKey);
  38506. if (sig.length !== crypto_sign_BYTES)
  38507. throw new Error('bad signature size');
  38508. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38509. throw new Error('bad public key size');
  38510. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38511. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38512. var i;
  38513. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38514. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38515. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38516. };
  38517. nacl.sign.keyPair = function() {
  38518. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38519. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38520. crypto_sign_keypair(pk, sk);
  38521. return {publicKey: pk, secretKey: sk};
  38522. };
  38523. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38524. checkArrayTypes(secretKey);
  38525. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38526. throw new Error('bad secret key size');
  38527. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38528. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38529. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38530. };
  38531. nacl.sign.keyPair.fromSeed = function(seed) {
  38532. checkArrayTypes(seed);
  38533. if (seed.length !== crypto_sign_SEEDBYTES)
  38534. throw new Error('bad seed size');
  38535. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38536. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38537. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38538. crypto_sign_keypair(pk, sk, true);
  38539. return {publicKey: pk, secretKey: sk};
  38540. };
  38541. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38542. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38543. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38544. nacl.sign.signatureLength = crypto_sign_BYTES;
  38545. nacl.hash = function(msg) {
  38546. checkArrayTypes(msg);
  38547. var h = new Uint8Array(crypto_hash_BYTES);
  38548. crypto_hash(h, msg, msg.length);
  38549. return h;
  38550. };
  38551. nacl.hash.hashLength = crypto_hash_BYTES;
  38552. nacl.verify = function(x, y) {
  38553. checkArrayTypes(x, y);
  38554. // Zero length arguments are considered not equal.
  38555. if (x.length === 0 || y.length === 0) return false;
  38556. if (x.length !== y.length) return false;
  38557. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38558. };
  38559. nacl.setPRNG = function(fn) {
  38560. randombytes = fn;
  38561. };
  38562. (function() {
  38563. // Initialize PRNG if environment provides CSPRNG.
  38564. // If not, methods calling randombytes will throw.
  38565. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38566. if (crypto && crypto.getRandomValues) {
  38567. // Browsers.
  38568. var QUOTA = 65536;
  38569. nacl.setPRNG(function(x, n) {
  38570. var i, v = new Uint8Array(n);
  38571. for (i = 0; i < n; i += QUOTA) {
  38572. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38573. }
  38574. for (i = 0; i < n; i++) x[i] = v[i];
  38575. cleanup(v);
  38576. });
  38577. } else if (true) {
  38578. // Node.js.
  38579. crypto = __webpack_require__(3);
  38580. if (crypto && crypto.randomBytes) {
  38581. nacl.setPRNG(function(x, n) {
  38582. var i, v = crypto.randomBytes(n);
  38583. for (i = 0; i < n; i++) x[i] = v[i];
  38584. cleanup(v);
  38585. });
  38586. }
  38587. }
  38588. })();
  38589. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38590. /***/ }),
  38591. /* 1 */
  38592. /***/ (function(module, exports, __webpack_require__) {
  38593. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38594. // Public domain.
  38595. (function(root, f) {
  38596. 'use strict';
  38597. if ( true && module.exports) module.exports = f();
  38598. else if (root.nacl) root.nacl.util = f();
  38599. else {
  38600. root.nacl = {};
  38601. root.nacl.util = f();
  38602. }
  38603. }(this, function() {
  38604. 'use strict';
  38605. var util = {};
  38606. function validateBase64(s) {
  38607. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38608. throw new TypeError('invalid encoding');
  38609. }
  38610. }
  38611. util.decodeUTF8 = function(s) {
  38612. if (typeof s !== 'string') throw new TypeError('expected string');
  38613. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38614. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38615. return b;
  38616. };
  38617. util.encodeUTF8 = function(arr) {
  38618. var i, s = [];
  38619. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38620. return decodeURIComponent(escape(s.join('')));
  38621. };
  38622. if (typeof atob === 'undefined') {
  38623. // Node.js
  38624. if (typeof Buffer.from !== 'undefined') {
  38625. // Node v6 and later
  38626. util.encodeBase64 = function (arr) { // v6 and later
  38627. return Buffer.from(arr).toString('base64');
  38628. };
  38629. util.decodeBase64 = function (s) {
  38630. validateBase64(s);
  38631. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38632. };
  38633. } else {
  38634. // Node earlier than v6
  38635. util.encodeBase64 = function (arr) { // v6 and later
  38636. return (new Buffer(arr)).toString('base64');
  38637. };
  38638. util.decodeBase64 = function(s) {
  38639. validateBase64(s);
  38640. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38641. };
  38642. }
  38643. } else {
  38644. // Browsers
  38645. util.encodeBase64 = function(arr) {
  38646. var i, s = [], len = arr.length;
  38647. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38648. return btoa(s.join(''));
  38649. };
  38650. util.decodeBase64 = function(s) {
  38651. validateBase64(s);
  38652. var i, d = atob(s), b = new Uint8Array(d.length);
  38653. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38654. return b;
  38655. };
  38656. }
  38657. return util;
  38658. }));
  38659. /***/ }),
  38660. /* 2 */
  38661. /***/ (function(module, exports, __webpack_require__) {
  38662. // required so we don't have to do require('pusher').default etc.
  38663. module.exports = __webpack_require__(4).default;
  38664. /***/ }),
  38665. /* 3 */
  38666. /***/ (function(module, exports) {
  38667. /* (ignored) */
  38668. /***/ }),
  38669. /* 4 */
  38670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38671. "use strict";
  38672. __webpack_require__.r(__webpack_exports__);
  38673. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38674. var ScriptReceiverFactory = (function () {
  38675. function ScriptReceiverFactory(prefix, name) {
  38676. this.lastId = 0;
  38677. this.prefix = prefix;
  38678. this.name = name;
  38679. }
  38680. ScriptReceiverFactory.prototype.create = function (callback) {
  38681. this.lastId++;
  38682. var number = this.lastId;
  38683. var id = this.prefix + number;
  38684. var name = this.name + "[" + number + "]";
  38685. var called = false;
  38686. var callbackWrapper = function () {
  38687. if (!called) {
  38688. callback.apply(null, arguments);
  38689. called = true;
  38690. }
  38691. };
  38692. this[number] = callbackWrapper;
  38693. return { number: number, id: id, name: name, callback: callbackWrapper };
  38694. };
  38695. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38696. delete this[receiver.number];
  38697. };
  38698. return ScriptReceiverFactory;
  38699. }());
  38700. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38701. // CONCATENATED MODULE: ./src/core/defaults.ts
  38702. var Defaults = {
  38703. VERSION: "5.0.3",
  38704. PROTOCOL: 7,
  38705. host: 'ws.pusherapp.com',
  38706. ws_port: 80,
  38707. wss_port: 443,
  38708. ws_path: '',
  38709. sockjs_host: 'sockjs.pusher.com',
  38710. sockjs_http_port: 80,
  38711. sockjs_https_port: 443,
  38712. sockjs_path: '/pusher',
  38713. stats_host: 'stats.pusher.com',
  38714. channel_auth_endpoint: '/pusher/auth',
  38715. channel_auth_transport: 'ajax',
  38716. activity_timeout: 120000,
  38717. pong_timeout: 30000,
  38718. unavailable_timeout: 10000,
  38719. cdn_http: "http://js.pusher.com",
  38720. cdn_https: "https://js.pusher.com",
  38721. dependency_suffix: ""
  38722. };
  38723. /* harmony default export */ var defaults = (Defaults);
  38724. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38725. var dependency_loader_DependencyLoader = (function () {
  38726. function DependencyLoader(options) {
  38727. this.options = options;
  38728. this.receivers = options.receivers || ScriptReceivers;
  38729. this.loading = {};
  38730. }
  38731. DependencyLoader.prototype.load = function (name, options, callback) {
  38732. var self = this;
  38733. if (self.loading[name] && self.loading[name].length > 0) {
  38734. self.loading[name].push(callback);
  38735. }
  38736. else {
  38737. self.loading[name] = [callback];
  38738. var request = runtime.createScriptRequest(self.getPath(name, options));
  38739. var receiver = self.receivers.create(function (error) {
  38740. self.receivers.remove(receiver);
  38741. if (self.loading[name]) {
  38742. var callbacks = self.loading[name];
  38743. delete self.loading[name];
  38744. var successCallback = function (wasSuccessful) {
  38745. if (!wasSuccessful) {
  38746. request.cleanup();
  38747. }
  38748. };
  38749. for (var i = 0; i < callbacks.length; i++) {
  38750. callbacks[i](error, successCallback);
  38751. }
  38752. }
  38753. });
  38754. request.send(receiver);
  38755. }
  38756. };
  38757. DependencyLoader.prototype.getRoot = function (options) {
  38758. var cdn;
  38759. var protocol = runtime.getDocument().location.protocol;
  38760. if ((options && options.useTLS) || protocol === "https:") {
  38761. cdn = this.options.cdn_https;
  38762. }
  38763. else {
  38764. cdn = this.options.cdn_http;
  38765. }
  38766. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38767. };
  38768. DependencyLoader.prototype.getPath = function (name, options) {
  38769. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38770. };
  38771. ;
  38772. return DependencyLoader;
  38773. }());
  38774. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38775. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38776. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38777. var Dependencies = new dependency_loader({
  38778. cdn_http: defaults.cdn_http,
  38779. cdn_https: defaults.cdn_https,
  38780. version: defaults.VERSION,
  38781. suffix: defaults.dependency_suffix,
  38782. receivers: DependenciesReceivers
  38783. });
  38784. // CONCATENATED MODULE: ./src/core/base64.ts
  38785. function encode(s) {
  38786. return btoa(utob(s));
  38787. }
  38788. var fromCharCode = String.fromCharCode;
  38789. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38790. var b64tab = {};
  38791. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38792. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38793. }
  38794. var cb_utob = function (c) {
  38795. var cc = c.charCodeAt(0);
  38796. return cc < 0x80
  38797. ? c
  38798. : cc < 0x800
  38799. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38800. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38801. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38802. fromCharCode(0x80 | (cc & 0x3f));
  38803. };
  38804. var utob = function (u) {
  38805. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38806. };
  38807. var cb_encode = function (ccc) {
  38808. var padlen = [0, 2, 1][ccc.length % 3];
  38809. var ord = (ccc.charCodeAt(0) << 16) |
  38810. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38811. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38812. var chars = [
  38813. b64chars.charAt(ord >>> 18),
  38814. b64chars.charAt((ord >>> 12) & 63),
  38815. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38816. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38817. ];
  38818. return chars.join('');
  38819. };
  38820. var btoa = window.btoa ||
  38821. function (b) {
  38822. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38823. };
  38824. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38825. var Timer = (function () {
  38826. function Timer(set, clear, delay, callback) {
  38827. var _this = this;
  38828. this.clear = clear;
  38829. this.timer = set(function () {
  38830. if (_this.timer) {
  38831. _this.timer = callback(_this.timer);
  38832. }
  38833. }, delay);
  38834. }
  38835. Timer.prototype.isRunning = function () {
  38836. return this.timer !== null;
  38837. };
  38838. Timer.prototype.ensureAborted = function () {
  38839. if (this.timer) {
  38840. this.clear(this.timer);
  38841. this.timer = null;
  38842. }
  38843. };
  38844. return Timer;
  38845. }());
  38846. /* harmony default export */ var abstract_timer = (Timer);
  38847. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38848. var __extends = (undefined && undefined.__extends) || (function () {
  38849. var extendStatics = function (d, b) {
  38850. extendStatics = Object.setPrototypeOf ||
  38851. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38852. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38853. return extendStatics(d, b);
  38854. };
  38855. return function (d, b) {
  38856. extendStatics(d, b);
  38857. function __() { this.constructor = d; }
  38858. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38859. };
  38860. })();
  38861. function timers_clearTimeout(timer) {
  38862. window.clearTimeout(timer);
  38863. }
  38864. function timers_clearInterval(timer) {
  38865. window.clearInterval(timer);
  38866. }
  38867. var OneOffTimer = (function (_super) {
  38868. __extends(OneOffTimer, _super);
  38869. function OneOffTimer(delay, callback) {
  38870. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38871. callback();
  38872. return null;
  38873. }) || this;
  38874. }
  38875. return OneOffTimer;
  38876. }(abstract_timer));
  38877. var PeriodicTimer = (function (_super) {
  38878. __extends(PeriodicTimer, _super);
  38879. function PeriodicTimer(delay, callback) {
  38880. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38881. callback();
  38882. return timer;
  38883. }) || this;
  38884. }
  38885. return PeriodicTimer;
  38886. }(abstract_timer));
  38887. // CONCATENATED MODULE: ./src/core/util.ts
  38888. var Util = {
  38889. now: function () {
  38890. if (Date.now) {
  38891. return Date.now();
  38892. }
  38893. else {
  38894. return new Date().valueOf();
  38895. }
  38896. },
  38897. defer: function (callback) {
  38898. return new OneOffTimer(0, callback);
  38899. },
  38900. method: function (name) {
  38901. var args = [];
  38902. for (var _i = 1; _i < arguments.length; _i++) {
  38903. args[_i - 1] = arguments[_i];
  38904. }
  38905. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38906. return function (object) {
  38907. return object[name].apply(object, boundArguments.concat(arguments));
  38908. };
  38909. }
  38910. };
  38911. /* harmony default export */ var util = (Util);
  38912. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38913. function extend(target) {
  38914. var sources = [];
  38915. for (var _i = 1; _i < arguments.length; _i++) {
  38916. sources[_i - 1] = arguments[_i];
  38917. }
  38918. for (var i = 0; i < sources.length; i++) {
  38919. var extensions = sources[i];
  38920. for (var property in extensions) {
  38921. if (extensions[property] && extensions[property].constructor &&
  38922. extensions[property].constructor === Object) {
  38923. target[property] = extend(target[property] || {}, extensions[property]);
  38924. }
  38925. else {
  38926. target[property] = extensions[property];
  38927. }
  38928. }
  38929. }
  38930. return target;
  38931. }
  38932. function stringify() {
  38933. var m = ["Pusher"];
  38934. for (var i = 0; i < arguments.length; i++) {
  38935. if (typeof arguments[i] === "string") {
  38936. m.push(arguments[i]);
  38937. }
  38938. else {
  38939. m.push(safeJSONStringify(arguments[i]));
  38940. }
  38941. }
  38942. return m.join(" : ");
  38943. }
  38944. function arrayIndexOf(array, item) {
  38945. var nativeIndexOf = Array.prototype.indexOf;
  38946. if (array === null) {
  38947. return -1;
  38948. }
  38949. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38950. return array.indexOf(item);
  38951. }
  38952. for (var i = 0, l = array.length; i < l; i++) {
  38953. if (array[i] === item) {
  38954. return i;
  38955. }
  38956. }
  38957. return -1;
  38958. }
  38959. function objectApply(object, f) {
  38960. for (var key in object) {
  38961. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38962. f(object[key], key, object);
  38963. }
  38964. }
  38965. }
  38966. function keys(object) {
  38967. var keys = [];
  38968. objectApply(object, function (_, key) {
  38969. keys.push(key);
  38970. });
  38971. return keys;
  38972. }
  38973. function values(object) {
  38974. var values = [];
  38975. objectApply(object, function (value) {
  38976. values.push(value);
  38977. });
  38978. return values;
  38979. }
  38980. function apply(array, f, context) {
  38981. for (var i = 0; i < array.length; i++) {
  38982. f.call(context || window, array[i], i, array);
  38983. }
  38984. }
  38985. function map(array, f) {
  38986. var result = [];
  38987. for (var i = 0; i < array.length; i++) {
  38988. result.push(f(array[i], i, array, result));
  38989. }
  38990. return result;
  38991. }
  38992. function mapObject(object, f) {
  38993. var result = {};
  38994. objectApply(object, function (value, key) {
  38995. result[key] = f(value);
  38996. });
  38997. return result;
  38998. }
  38999. function filter(array, test) {
  39000. test = test || function (value) { return !!value; };
  39001. var result = [];
  39002. for (var i = 0; i < array.length; i++) {
  39003. if (test(array[i], i, array, result)) {
  39004. result.push(array[i]);
  39005. }
  39006. }
  39007. return result;
  39008. }
  39009. function filterObject(object, test) {
  39010. var result = {};
  39011. objectApply(object, function (value, key) {
  39012. if ((test && test(value, key, object, result)) || Boolean(value)) {
  39013. result[key] = value;
  39014. }
  39015. });
  39016. return result;
  39017. }
  39018. function flatten(object) {
  39019. var result = [];
  39020. objectApply(object, function (value, key) {
  39021. result.push([key, value]);
  39022. });
  39023. return result;
  39024. }
  39025. function any(array, test) {
  39026. for (var i = 0; i < array.length; i++) {
  39027. if (test(array[i], i, array)) {
  39028. return true;
  39029. }
  39030. }
  39031. return false;
  39032. }
  39033. function collections_all(array, test) {
  39034. for (var i = 0; i < array.length; i++) {
  39035. if (!test(array[i], i, array)) {
  39036. return false;
  39037. }
  39038. }
  39039. return true;
  39040. }
  39041. function encodeParamsObject(data) {
  39042. return mapObject(data, function (value) {
  39043. if (typeof value === "object") {
  39044. value = safeJSONStringify(value);
  39045. }
  39046. return encodeURIComponent(encode(value.toString()));
  39047. });
  39048. }
  39049. function buildQueryString(data) {
  39050. var params = filterObject(data, function (value) {
  39051. return value !== undefined;
  39052. });
  39053. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  39054. return query;
  39055. }
  39056. function decycleObject(object) {
  39057. var objects = [], paths = [];
  39058. return (function derez(value, path) {
  39059. var i, name, nu;
  39060. switch (typeof value) {
  39061. case 'object':
  39062. if (!value) {
  39063. return null;
  39064. }
  39065. for (i = 0; i < objects.length; i += 1) {
  39066. if (objects[i] === value) {
  39067. return { $ref: paths[i] };
  39068. }
  39069. }
  39070. objects.push(value);
  39071. paths.push(path);
  39072. if (Object.prototype.toString.apply(value) === '[object Array]') {
  39073. nu = [];
  39074. for (i = 0; i < value.length; i += 1) {
  39075. nu[i] = derez(value[i], path + '[' + i + ']');
  39076. }
  39077. }
  39078. else {
  39079. nu = {};
  39080. for (name in value) {
  39081. if (Object.prototype.hasOwnProperty.call(value, name)) {
  39082. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  39083. }
  39084. }
  39085. }
  39086. return nu;
  39087. case 'number':
  39088. case 'string':
  39089. case 'boolean':
  39090. return value;
  39091. }
  39092. }(object, '$'));
  39093. }
  39094. function safeJSONStringify(source) {
  39095. try {
  39096. return JSON.stringify(source);
  39097. }
  39098. catch (e) {
  39099. return JSON.stringify(decycleObject(source));
  39100. }
  39101. }
  39102. // CONCATENATED MODULE: ./src/core/logger.ts
  39103. var logger_Logger = (function () {
  39104. function Logger() {
  39105. this.globalLog = function (message) {
  39106. if (window.console && window.console.log) {
  39107. window.console.log(message);
  39108. }
  39109. };
  39110. }
  39111. Logger.prototype.debug = function () {
  39112. var args = [];
  39113. for (var _i = 0; _i < arguments.length; _i++) {
  39114. args[_i] = arguments[_i];
  39115. }
  39116. this.log(this.globalLog, args);
  39117. };
  39118. Logger.prototype.warn = function () {
  39119. var args = [];
  39120. for (var _i = 0; _i < arguments.length; _i++) {
  39121. args[_i] = arguments[_i];
  39122. }
  39123. this.log(this.globalLogWarn, args);
  39124. };
  39125. Logger.prototype.error = function () {
  39126. var args = [];
  39127. for (var _i = 0; _i < arguments.length; _i++) {
  39128. args[_i] = arguments[_i];
  39129. }
  39130. this.log(this.globalLogError, args);
  39131. };
  39132. Logger.prototype.globalLogWarn = function (message) {
  39133. if (window.console && window.console.warn) {
  39134. window.console.warn(message);
  39135. }
  39136. else {
  39137. this.globalLog(message);
  39138. }
  39139. };
  39140. Logger.prototype.globalLogError = function (message) {
  39141. if (window.console && window.console.error) {
  39142. window.console.error(message);
  39143. }
  39144. else {
  39145. this.globalLogWarn(message);
  39146. }
  39147. };
  39148. Logger.prototype.log = function (defaultLoggingFunction) {
  39149. var args = [];
  39150. for (var _i = 1; _i < arguments.length; _i++) {
  39151. args[_i - 1] = arguments[_i];
  39152. }
  39153. var message = stringify.apply(this, arguments);
  39154. if (core_pusher.log) {
  39155. core_pusher.log(message);
  39156. }
  39157. else if (core_pusher.logToConsole) {
  39158. var log = defaultLoggingFunction.bind(this);
  39159. log(message);
  39160. }
  39161. };
  39162. return Logger;
  39163. }());
  39164. /* harmony default export */ var logger = (new logger_Logger());
  39165. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39166. var urlStore = {
  39167. baseUrl: "https://pusher.com",
  39168. urls: {
  39169. authenticationEndpoint: {
  39170. path: "/docs/authenticating_users",
  39171. },
  39172. javascriptQuickStart: {
  39173. path: "/docs/javascript_quick_start"
  39174. },
  39175. triggeringClientEvents: {
  39176. path: "/docs/client_api_guide/client_events#trigger-events"
  39177. }
  39178. }
  39179. };
  39180. var buildLogSuffix = function (key) {
  39181. var urlPrefix = "See:";
  39182. var urlObj = urlStore.urls[key];
  39183. if (!urlObj)
  39184. return "";
  39185. var url;
  39186. if (urlObj.fullUrl) {
  39187. url = urlObj.fullUrl;
  39188. }
  39189. else if (urlObj.path) {
  39190. url = urlStore.baseUrl + urlObj.path;
  39191. }
  39192. if (!url)
  39193. return "";
  39194. return urlPrefix + " " + url;
  39195. };
  39196. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39197. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39198. var ajax = function (context, socketId, callback) {
  39199. var self = this, xhr;
  39200. xhr = runtime.createXHR();
  39201. xhr.open("POST", self.options.authEndpoint, true);
  39202. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39203. for (var headerName in this.authOptions.headers) {
  39204. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39205. }
  39206. xhr.onreadystatechange = function () {
  39207. if (xhr.readyState === 4) {
  39208. if (xhr.status === 200) {
  39209. var data, parsed = false;
  39210. try {
  39211. data = JSON.parse(xhr.responseText);
  39212. parsed = true;
  39213. }
  39214. catch (e) {
  39215. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39216. }
  39217. if (parsed) {
  39218. callback(false, data);
  39219. }
  39220. }
  39221. else {
  39222. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39223. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39224. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39225. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39226. callback(true, xhr.status);
  39227. }
  39228. }
  39229. };
  39230. xhr.send(this.composeQuery(socketId));
  39231. return xhr;
  39232. };
  39233. /* harmony default export */ var xhr_auth = (ajax);
  39234. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39235. var jsonp = function (context, socketId, callback) {
  39236. if (this.authOptions.headers !== undefined) {
  39237. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39238. }
  39239. var callbackName = context.nextAuthCallbackID.toString();
  39240. context.nextAuthCallbackID++;
  39241. var document = context.getDocument();
  39242. var script = document.createElement("script");
  39243. context.auth_callbacks[callbackName] = function (data) {
  39244. callback(false, data);
  39245. };
  39246. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39247. script.src = this.options.authEndpoint +
  39248. '?callback=' +
  39249. encodeURIComponent(callback_name) +
  39250. '&' +
  39251. this.composeQuery(socketId);
  39252. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39253. head.insertBefore(script, head.firstChild);
  39254. };
  39255. /* harmony default export */ var jsonp_auth = (jsonp);
  39256. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39257. var ScriptRequest = (function () {
  39258. function ScriptRequest(src) {
  39259. this.src = src;
  39260. }
  39261. ScriptRequest.prototype.send = function (receiver) {
  39262. var self = this;
  39263. var errorString = "Error loading " + self.src;
  39264. self.script = document.createElement("script");
  39265. self.script.id = receiver.id;
  39266. self.script.src = self.src;
  39267. self.script.type = "text/javascript";
  39268. self.script.charset = "UTF-8";
  39269. if (self.script.addEventListener) {
  39270. self.script.onerror = function () {
  39271. receiver.callback(errorString);
  39272. };
  39273. self.script.onload = function () {
  39274. receiver.callback(null);
  39275. };
  39276. }
  39277. else {
  39278. self.script.onreadystatechange = function () {
  39279. if (self.script.readyState === 'loaded' ||
  39280. self.script.readyState === 'complete') {
  39281. receiver.callback(null);
  39282. }
  39283. };
  39284. }
  39285. if (self.script.async === undefined && document.attachEvent &&
  39286. /opera/i.test(navigator.userAgent)) {
  39287. self.errorScript = document.createElement("script");
  39288. self.errorScript.id = receiver.id + "_error";
  39289. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39290. self.script.async = self.errorScript.async = false;
  39291. }
  39292. else {
  39293. self.script.async = true;
  39294. }
  39295. var head = document.getElementsByTagName('head')[0];
  39296. head.insertBefore(self.script, head.firstChild);
  39297. if (self.errorScript) {
  39298. head.insertBefore(self.errorScript, self.script.nextSibling);
  39299. }
  39300. };
  39301. ScriptRequest.prototype.cleanup = function () {
  39302. if (this.script) {
  39303. this.script.onload = this.script.onerror = null;
  39304. this.script.onreadystatechange = null;
  39305. }
  39306. if (this.script && this.script.parentNode) {
  39307. this.script.parentNode.removeChild(this.script);
  39308. }
  39309. if (this.errorScript && this.errorScript.parentNode) {
  39310. this.errorScript.parentNode.removeChild(this.errorScript);
  39311. }
  39312. this.script = null;
  39313. this.errorScript = null;
  39314. };
  39315. return ScriptRequest;
  39316. }());
  39317. /* harmony default export */ var script_request = (ScriptRequest);
  39318. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39319. var jsonp_request_JSONPRequest = (function () {
  39320. function JSONPRequest(url, data) {
  39321. this.url = url;
  39322. this.data = data;
  39323. }
  39324. JSONPRequest.prototype.send = function (receiver) {
  39325. if (this.request) {
  39326. return;
  39327. }
  39328. var query = buildQueryString(this.data);
  39329. var url = this.url + "/" + receiver.number + "?" + query;
  39330. this.request = runtime.createScriptRequest(url);
  39331. this.request.send(receiver);
  39332. };
  39333. JSONPRequest.prototype.cleanup = function () {
  39334. if (this.request) {
  39335. this.request.cleanup();
  39336. }
  39337. };
  39338. return JSONPRequest;
  39339. }());
  39340. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39341. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39342. var getAgent = function (sender, useTLS) {
  39343. return function (data, callback) {
  39344. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39345. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39346. var request = runtime.createJSONPRequest(url, data);
  39347. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39348. ScriptReceivers.remove(receiver);
  39349. request.cleanup();
  39350. if (result && result.host) {
  39351. sender.host = result.host;
  39352. }
  39353. if (callback) {
  39354. callback(error, result);
  39355. }
  39356. });
  39357. request.send(receiver);
  39358. };
  39359. };
  39360. var jsonp_timeline_jsonp = {
  39361. name: 'jsonp',
  39362. getAgent: getAgent
  39363. };
  39364. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39365. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39366. function getGenericURL(baseScheme, params, path) {
  39367. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39368. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39369. return scheme + "://" + host + path;
  39370. }
  39371. function getGenericPath(key, queryString) {
  39372. var path = "/app/" + key;
  39373. var query = "?protocol=" + defaults.PROTOCOL +
  39374. "&client=js" +
  39375. "&version=" + defaults.VERSION +
  39376. (queryString ? ("&" + queryString) : "");
  39377. return path + query;
  39378. }
  39379. var ws = {
  39380. getInitial: function (key, params) {
  39381. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39382. return getGenericURL("ws", params, path);
  39383. }
  39384. };
  39385. var http = {
  39386. getInitial: function (key, params) {
  39387. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39388. return getGenericURL("http", params, path);
  39389. }
  39390. };
  39391. var sockjs = {
  39392. getInitial: function (key, params) {
  39393. return getGenericURL("http", params, params.httpPath || "/pusher");
  39394. },
  39395. getPath: function (key, params) {
  39396. return getGenericPath(key);
  39397. }
  39398. };
  39399. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39400. var callback_registry_CallbackRegistry = (function () {
  39401. function CallbackRegistry() {
  39402. this._callbacks = {};
  39403. }
  39404. CallbackRegistry.prototype.get = function (name) {
  39405. return this._callbacks[prefix(name)];
  39406. };
  39407. CallbackRegistry.prototype.add = function (name, callback, context) {
  39408. var prefixedEventName = prefix(name);
  39409. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39410. this._callbacks[prefixedEventName].push({
  39411. fn: callback,
  39412. context: context
  39413. });
  39414. };
  39415. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39416. if (!name && !callback && !context) {
  39417. this._callbacks = {};
  39418. return;
  39419. }
  39420. var names = name ? [prefix(name)] : keys(this._callbacks);
  39421. if (callback || context) {
  39422. this.removeCallback(names, callback, context);
  39423. }
  39424. else {
  39425. this.removeAllCallbacks(names);
  39426. }
  39427. };
  39428. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39429. apply(names, function (name) {
  39430. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39431. return (callback && callback !== binding.fn) ||
  39432. (context && context !== binding.context);
  39433. });
  39434. if (this._callbacks[name].length === 0) {
  39435. delete this._callbacks[name];
  39436. }
  39437. }, this);
  39438. };
  39439. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39440. apply(names, function (name) {
  39441. delete this._callbacks[name];
  39442. }, this);
  39443. };
  39444. return CallbackRegistry;
  39445. }());
  39446. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39447. function prefix(name) {
  39448. return "_" + name;
  39449. }
  39450. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39451. var dispatcher_Dispatcher = (function () {
  39452. function Dispatcher(failThrough) {
  39453. this.callbacks = new callback_registry();
  39454. this.global_callbacks = [];
  39455. this.failThrough = failThrough;
  39456. }
  39457. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39458. this.callbacks.add(eventName, callback, context);
  39459. return this;
  39460. };
  39461. Dispatcher.prototype.bind_global = function (callback) {
  39462. this.global_callbacks.push(callback);
  39463. return this;
  39464. };
  39465. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39466. this.callbacks.remove(eventName, callback, context);
  39467. return this;
  39468. };
  39469. Dispatcher.prototype.unbind_global = function (callback) {
  39470. if (!callback) {
  39471. this.global_callbacks = [];
  39472. return this;
  39473. }
  39474. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39475. return this;
  39476. };
  39477. Dispatcher.prototype.unbind_all = function () {
  39478. this.unbind();
  39479. this.unbind_global();
  39480. return this;
  39481. };
  39482. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39483. for (var i = 0; i < this.global_callbacks.length; i++) {
  39484. this.global_callbacks[i](eventName, data);
  39485. }
  39486. var callbacks = this.callbacks.get(eventName);
  39487. var args = [];
  39488. if (metadata) {
  39489. args.push(data, metadata);
  39490. }
  39491. else if (data) {
  39492. args.push(data);
  39493. }
  39494. if (callbacks && callbacks.length > 0) {
  39495. for (var i = 0; i < callbacks.length; i++) {
  39496. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39497. }
  39498. }
  39499. else if (this.failThrough) {
  39500. this.failThrough(eventName, data);
  39501. }
  39502. return this;
  39503. };
  39504. return Dispatcher;
  39505. }());
  39506. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39507. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39508. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39509. var extendStatics = function (d, b) {
  39510. extendStatics = Object.setPrototypeOf ||
  39511. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39512. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39513. return extendStatics(d, b);
  39514. };
  39515. return function (d, b) {
  39516. extendStatics(d, b);
  39517. function __() { this.constructor = d; }
  39518. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39519. };
  39520. })();
  39521. var transport_connection_TransportConnection = (function (_super) {
  39522. transport_connection_extends(TransportConnection, _super);
  39523. function TransportConnection(hooks, name, priority, key, options) {
  39524. var _this = _super.call(this) || this;
  39525. _this.initialize = runtime.transportConnectionInitializer;
  39526. _this.hooks = hooks;
  39527. _this.name = name;
  39528. _this.priority = priority;
  39529. _this.key = key;
  39530. _this.options = options;
  39531. _this.state = "new";
  39532. _this.timeline = options.timeline;
  39533. _this.activityTimeout = options.activityTimeout;
  39534. _this.id = _this.timeline.generateUniqueID();
  39535. return _this;
  39536. }
  39537. TransportConnection.prototype.handlesActivityChecks = function () {
  39538. return Boolean(this.hooks.handlesActivityChecks);
  39539. };
  39540. TransportConnection.prototype.supportsPing = function () {
  39541. return Boolean(this.hooks.supportsPing);
  39542. };
  39543. TransportConnection.prototype.connect = function () {
  39544. var _this = this;
  39545. if (this.socket || this.state !== "initialized") {
  39546. return false;
  39547. }
  39548. var url = this.hooks.urls.getInitial(this.key, this.options);
  39549. try {
  39550. this.socket = this.hooks.getSocket(url, this.options);
  39551. }
  39552. catch (e) {
  39553. util.defer(function () {
  39554. _this.onError(e);
  39555. _this.changeState("closed");
  39556. });
  39557. return false;
  39558. }
  39559. this.bindListeners();
  39560. logger.debug("Connecting", { transport: this.name, url: url });
  39561. this.changeState("connecting");
  39562. return true;
  39563. };
  39564. TransportConnection.prototype.close = function () {
  39565. if (this.socket) {
  39566. this.socket.close();
  39567. return true;
  39568. }
  39569. else {
  39570. return false;
  39571. }
  39572. };
  39573. TransportConnection.prototype.send = function (data) {
  39574. var _this = this;
  39575. if (this.state === "open") {
  39576. util.defer(function () {
  39577. if (_this.socket) {
  39578. _this.socket.send(data);
  39579. }
  39580. });
  39581. return true;
  39582. }
  39583. else {
  39584. return false;
  39585. }
  39586. };
  39587. TransportConnection.prototype.ping = function () {
  39588. if (this.state === "open" && this.supportsPing()) {
  39589. this.socket.ping();
  39590. }
  39591. };
  39592. TransportConnection.prototype.onOpen = function () {
  39593. if (this.hooks.beforeOpen) {
  39594. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39595. }
  39596. this.changeState("open");
  39597. this.socket.onopen = undefined;
  39598. };
  39599. TransportConnection.prototype.onError = function (error) {
  39600. this.emit("error", { type: 'WebSocketError', error: error });
  39601. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39602. };
  39603. TransportConnection.prototype.onClose = function (closeEvent) {
  39604. if (closeEvent) {
  39605. this.changeState("closed", {
  39606. code: closeEvent.code,
  39607. reason: closeEvent.reason,
  39608. wasClean: closeEvent.wasClean
  39609. });
  39610. }
  39611. else {
  39612. this.changeState("closed");
  39613. }
  39614. this.unbindListeners();
  39615. this.socket = undefined;
  39616. };
  39617. TransportConnection.prototype.onMessage = function (message) {
  39618. this.emit("message", message);
  39619. };
  39620. TransportConnection.prototype.onActivity = function () {
  39621. this.emit("activity");
  39622. };
  39623. TransportConnection.prototype.bindListeners = function () {
  39624. var _this = this;
  39625. this.socket.onopen = function () {
  39626. _this.onOpen();
  39627. };
  39628. this.socket.onerror = function (error) {
  39629. _this.onError(error);
  39630. };
  39631. this.socket.onclose = function (closeEvent) {
  39632. _this.onClose(closeEvent);
  39633. };
  39634. this.socket.onmessage = function (message) {
  39635. _this.onMessage(message);
  39636. };
  39637. if (this.supportsPing()) {
  39638. this.socket.onactivity = function () { _this.onActivity(); };
  39639. }
  39640. };
  39641. TransportConnection.prototype.unbindListeners = function () {
  39642. if (this.socket) {
  39643. this.socket.onopen = undefined;
  39644. this.socket.onerror = undefined;
  39645. this.socket.onclose = undefined;
  39646. this.socket.onmessage = undefined;
  39647. if (this.supportsPing()) {
  39648. this.socket.onactivity = undefined;
  39649. }
  39650. }
  39651. };
  39652. TransportConnection.prototype.changeState = function (state, params) {
  39653. this.state = state;
  39654. this.timeline.info(this.buildTimelineMessage({
  39655. state: state,
  39656. params: params
  39657. }));
  39658. this.emit(state, params);
  39659. };
  39660. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39661. return extend({ cid: this.id }, message);
  39662. };
  39663. return TransportConnection;
  39664. }(dispatcher));
  39665. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39666. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39667. var transport_Transport = (function () {
  39668. function Transport(hooks) {
  39669. this.hooks = hooks;
  39670. }
  39671. Transport.prototype.isSupported = function (environment) {
  39672. return this.hooks.isSupported(environment);
  39673. };
  39674. Transport.prototype.createConnection = function (name, priority, key, options) {
  39675. return new transport_connection(this.hooks, name, priority, key, options);
  39676. };
  39677. return Transport;
  39678. }());
  39679. /* harmony default export */ var transports_transport = (transport_Transport);
  39680. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39681. var WSTransport = new transports_transport({
  39682. urls: ws,
  39683. handlesActivityChecks: false,
  39684. supportsPing: false,
  39685. isInitialized: function () {
  39686. return Boolean(runtime.getWebSocketAPI());
  39687. },
  39688. isSupported: function () {
  39689. return Boolean(runtime.getWebSocketAPI());
  39690. },
  39691. getSocket: function (url) {
  39692. return runtime.createWebSocket(url);
  39693. }
  39694. });
  39695. var httpConfiguration = {
  39696. urls: http,
  39697. handlesActivityChecks: false,
  39698. supportsPing: true,
  39699. isInitialized: function () {
  39700. return true;
  39701. }
  39702. };
  39703. var streamingConfiguration = extend({ getSocket: function (url) {
  39704. return runtime.HTTPFactory.createStreamingSocket(url);
  39705. }
  39706. }, httpConfiguration);
  39707. var pollingConfiguration = extend({ getSocket: function (url) {
  39708. return runtime.HTTPFactory.createPollingSocket(url);
  39709. }
  39710. }, httpConfiguration);
  39711. var xhrConfiguration = {
  39712. isSupported: function () {
  39713. return runtime.isXHRSupported();
  39714. }
  39715. };
  39716. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39717. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39718. var Transports = {
  39719. ws: WSTransport,
  39720. xhr_streaming: XHRStreamingTransport,
  39721. xhr_polling: XHRPollingTransport
  39722. };
  39723. /* harmony default export */ var transports = (Transports);
  39724. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39725. var SockJSTransport = new transports_transport({
  39726. file: "sockjs",
  39727. urls: sockjs,
  39728. handlesActivityChecks: true,
  39729. supportsPing: false,
  39730. isSupported: function () {
  39731. return true;
  39732. },
  39733. isInitialized: function () {
  39734. return window.SockJS !== undefined;
  39735. },
  39736. getSocket: function (url, options) {
  39737. return new window.SockJS(url, null, {
  39738. js_path: Dependencies.getPath("sockjs", {
  39739. useTLS: options.useTLS
  39740. }),
  39741. ignore_null_origin: options.ignoreNullOrigin
  39742. });
  39743. },
  39744. beforeOpen: function (socket, path) {
  39745. socket.send(JSON.stringify({
  39746. path: path
  39747. }));
  39748. }
  39749. });
  39750. var xdrConfiguration = {
  39751. isSupported: function (environment) {
  39752. var yes = runtime.isXDRSupported(environment.useTLS);
  39753. return yes;
  39754. }
  39755. };
  39756. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39757. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39758. transports.xdr_streaming = XDRStreamingTransport;
  39759. transports.xdr_polling = XDRPollingTransport;
  39760. transports.sockjs = SockJSTransport;
  39761. /* harmony default export */ var transports_transports = (transports);
  39762. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39763. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39764. var extendStatics = function (d, b) {
  39765. extendStatics = Object.setPrototypeOf ||
  39766. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39767. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39768. return extendStatics(d, b);
  39769. };
  39770. return function (d, b) {
  39771. extendStatics(d, b);
  39772. function __() { this.constructor = d; }
  39773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39774. };
  39775. })();
  39776. var NetInfo = (function (_super) {
  39777. net_info_extends(NetInfo, _super);
  39778. function NetInfo() {
  39779. var _this = _super.call(this) || this;
  39780. var self = _this;
  39781. if (window.addEventListener !== undefined) {
  39782. window.addEventListener("online", function () {
  39783. self.emit('online');
  39784. }, false);
  39785. window.addEventListener("offline", function () {
  39786. self.emit('offline');
  39787. }, false);
  39788. }
  39789. return _this;
  39790. }
  39791. NetInfo.prototype.isOnline = function () {
  39792. if (window.navigator.onLine === undefined) {
  39793. return true;
  39794. }
  39795. else {
  39796. return window.navigator.onLine;
  39797. }
  39798. };
  39799. return NetInfo;
  39800. }(dispatcher));
  39801. var net_info_Network = new NetInfo();
  39802. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39803. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39804. function AssistantToTheTransportManager(manager, transport, options) {
  39805. this.manager = manager;
  39806. this.transport = transport;
  39807. this.minPingDelay = options.minPingDelay;
  39808. this.maxPingDelay = options.maxPingDelay;
  39809. this.pingDelay = undefined;
  39810. }
  39811. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39812. var _this = this;
  39813. options = extend({}, options, {
  39814. activityTimeout: this.pingDelay
  39815. });
  39816. var connection = this.transport.createConnection(name, priority, key, options);
  39817. var openTimestamp = null;
  39818. var onOpen = function () {
  39819. connection.unbind("open", onOpen);
  39820. connection.bind("closed", onClosed);
  39821. openTimestamp = util.now();
  39822. };
  39823. var onClosed = function (closeEvent) {
  39824. connection.unbind("closed", onClosed);
  39825. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39826. _this.manager.reportDeath();
  39827. }
  39828. else if (!closeEvent.wasClean && openTimestamp) {
  39829. var lifespan = util.now() - openTimestamp;
  39830. if (lifespan < 2 * _this.maxPingDelay) {
  39831. _this.manager.reportDeath();
  39832. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39833. }
  39834. }
  39835. };
  39836. connection.bind("open", onOpen);
  39837. return connection;
  39838. };
  39839. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39840. return this.manager.isAlive() && this.transport.isSupported(environment);
  39841. };
  39842. return AssistantToTheTransportManager;
  39843. }());
  39844. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39845. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39846. var Protocol = {
  39847. decodeMessage: function (messageEvent) {
  39848. try {
  39849. var messageData = JSON.parse(messageEvent.data);
  39850. var pusherEventData = messageData.data;
  39851. if (typeof pusherEventData === 'string') {
  39852. try {
  39853. pusherEventData = JSON.parse(messageData.data);
  39854. }
  39855. catch (e) { }
  39856. }
  39857. var pusherEvent = {
  39858. event: messageData.event,
  39859. channel: messageData.channel,
  39860. data: pusherEventData,
  39861. };
  39862. if (messageData.user_id) {
  39863. pusherEvent.user_id = messageData.user_id;
  39864. }
  39865. return pusherEvent;
  39866. }
  39867. catch (e) {
  39868. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39869. }
  39870. },
  39871. encodeMessage: function (event) {
  39872. return JSON.stringify(event);
  39873. },
  39874. processHandshake: function (messageEvent) {
  39875. var message = Protocol.decodeMessage(messageEvent);
  39876. if (message.event === "pusher:connection_established") {
  39877. if (!message.data.activity_timeout) {
  39878. throw "No activity timeout specified in handshake";
  39879. }
  39880. return {
  39881. action: "connected",
  39882. id: message.data.socket_id,
  39883. activityTimeout: message.data.activity_timeout * 1000
  39884. };
  39885. }
  39886. else if (message.event === "pusher:error") {
  39887. return {
  39888. action: this.getCloseAction(message.data),
  39889. error: this.getCloseError(message.data)
  39890. };
  39891. }
  39892. else {
  39893. throw "Invalid handshake";
  39894. }
  39895. },
  39896. getCloseAction: function (closeEvent) {
  39897. if (closeEvent.code < 4000) {
  39898. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39899. return "backoff";
  39900. }
  39901. else {
  39902. return null;
  39903. }
  39904. }
  39905. else if (closeEvent.code === 4000) {
  39906. return "tls_only";
  39907. }
  39908. else if (closeEvent.code < 4100) {
  39909. return "refused";
  39910. }
  39911. else if (closeEvent.code < 4200) {
  39912. return "backoff";
  39913. }
  39914. else if (closeEvent.code < 4300) {
  39915. return "retry";
  39916. }
  39917. else {
  39918. return "refused";
  39919. }
  39920. },
  39921. getCloseError: function (closeEvent) {
  39922. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39923. return {
  39924. type: 'PusherError',
  39925. data: {
  39926. code: closeEvent.code,
  39927. message: closeEvent.reason || closeEvent.message
  39928. }
  39929. };
  39930. }
  39931. else {
  39932. return null;
  39933. }
  39934. }
  39935. };
  39936. /* harmony default export */ var protocol_protocol = (Protocol);
  39937. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39938. var connection_extends = (undefined && undefined.__extends) || (function () {
  39939. var extendStatics = function (d, b) {
  39940. extendStatics = Object.setPrototypeOf ||
  39941. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39942. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39943. return extendStatics(d, b);
  39944. };
  39945. return function (d, b) {
  39946. extendStatics(d, b);
  39947. function __() { this.constructor = d; }
  39948. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39949. };
  39950. })();
  39951. var connection_Connection = (function (_super) {
  39952. connection_extends(Connection, _super);
  39953. function Connection(id, transport) {
  39954. var _this = _super.call(this) || this;
  39955. _this.id = id;
  39956. _this.transport = transport;
  39957. _this.activityTimeout = transport.activityTimeout;
  39958. _this.bindListeners();
  39959. return _this;
  39960. }
  39961. Connection.prototype.handlesActivityChecks = function () {
  39962. return this.transport.handlesActivityChecks();
  39963. };
  39964. Connection.prototype.send = function (data) {
  39965. return this.transport.send(data);
  39966. };
  39967. Connection.prototype.send_event = function (name, data, channel) {
  39968. var event = { event: name, data: data };
  39969. if (channel) {
  39970. event.channel = channel;
  39971. }
  39972. logger.debug('Event sent', event);
  39973. return this.send(protocol_protocol.encodeMessage(event));
  39974. };
  39975. Connection.prototype.ping = function () {
  39976. if (this.transport.supportsPing()) {
  39977. this.transport.ping();
  39978. }
  39979. else {
  39980. this.send_event('pusher:ping', {});
  39981. }
  39982. };
  39983. Connection.prototype.close = function () {
  39984. this.transport.close();
  39985. };
  39986. Connection.prototype.bindListeners = function () {
  39987. var _this = this;
  39988. var listeners = {
  39989. message: function (messageEvent) {
  39990. var pusherEvent;
  39991. try {
  39992. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39993. }
  39994. catch (e) {
  39995. _this.emit('error', {
  39996. type: 'MessageParseError',
  39997. error: e,
  39998. data: messageEvent.data
  39999. });
  40000. }
  40001. if (pusherEvent !== undefined) {
  40002. logger.debug('Event recd', pusherEvent);
  40003. switch (pusherEvent.event) {
  40004. case 'pusher:error':
  40005. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  40006. break;
  40007. case 'pusher:ping':
  40008. _this.emit("ping");
  40009. break;
  40010. case 'pusher:pong':
  40011. _this.emit("pong");
  40012. break;
  40013. }
  40014. _this.emit('message', pusherEvent);
  40015. }
  40016. },
  40017. activity: function () {
  40018. _this.emit("activity");
  40019. },
  40020. error: function (error) {
  40021. _this.emit("error", { type: "WebSocketError", error: error });
  40022. },
  40023. closed: function (closeEvent) {
  40024. unbindListeners();
  40025. if (closeEvent && closeEvent.code) {
  40026. _this.handleCloseEvent(closeEvent);
  40027. }
  40028. _this.transport = null;
  40029. _this.emit("closed");
  40030. }
  40031. };
  40032. var unbindListeners = function () {
  40033. objectApply(listeners, function (listener, event) {
  40034. _this.transport.unbind(event, listener);
  40035. });
  40036. };
  40037. objectApply(listeners, function (listener, event) {
  40038. _this.transport.bind(event, listener);
  40039. });
  40040. };
  40041. Connection.prototype.handleCloseEvent = function (closeEvent) {
  40042. var action = protocol_protocol.getCloseAction(closeEvent);
  40043. var error = protocol_protocol.getCloseError(closeEvent);
  40044. if (error) {
  40045. this.emit('error', error);
  40046. }
  40047. if (action) {
  40048. this.emit(action, { action: action, error: error });
  40049. }
  40050. };
  40051. return Connection;
  40052. }(dispatcher));
  40053. /* harmony default export */ var connection_connection = (connection_Connection);
  40054. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  40055. var handshake_Handshake = (function () {
  40056. function Handshake(transport, callback) {
  40057. this.transport = transport;
  40058. this.callback = callback;
  40059. this.bindListeners();
  40060. }
  40061. Handshake.prototype.close = function () {
  40062. this.unbindListeners();
  40063. this.transport.close();
  40064. };
  40065. Handshake.prototype.bindListeners = function () {
  40066. var _this = this;
  40067. this.onMessage = function (m) {
  40068. _this.unbindListeners();
  40069. var result;
  40070. try {
  40071. result = protocol_protocol.processHandshake(m);
  40072. }
  40073. catch (e) {
  40074. _this.finish("error", { error: e });
  40075. _this.transport.close();
  40076. return;
  40077. }
  40078. if (result.action === "connected") {
  40079. _this.finish("connected", {
  40080. connection: new connection_connection(result.id, _this.transport),
  40081. activityTimeout: result.activityTimeout
  40082. });
  40083. }
  40084. else {
  40085. _this.finish(result.action, { error: result.error });
  40086. _this.transport.close();
  40087. }
  40088. };
  40089. this.onClosed = function (closeEvent) {
  40090. _this.unbindListeners();
  40091. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  40092. var error = protocol_protocol.getCloseError(closeEvent);
  40093. _this.finish(action, { error: error });
  40094. };
  40095. this.transport.bind("message", this.onMessage);
  40096. this.transport.bind("closed", this.onClosed);
  40097. };
  40098. Handshake.prototype.unbindListeners = function () {
  40099. this.transport.unbind("message", this.onMessage);
  40100. this.transport.unbind("closed", this.onClosed);
  40101. };
  40102. Handshake.prototype.finish = function (action, params) {
  40103. this.callback(extend({ transport: this.transport, action: action }, params));
  40104. };
  40105. return Handshake;
  40106. }());
  40107. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  40108. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  40109. var pusher_authorizer_PusherAuthorizer = (function () {
  40110. function PusherAuthorizer(channel, options) {
  40111. this.channel = channel;
  40112. var authTransport = options.authTransport;
  40113. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  40114. throw "'" + authTransport + "' is not a recognized auth transport";
  40115. }
  40116. this.type = authTransport;
  40117. this.options = options;
  40118. this.authOptions = (options || {}).auth || {};
  40119. }
  40120. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  40121. var query = 'socket_id=' + encodeURIComponent(socketId) +
  40122. '&channel_name=' + encodeURIComponent(this.channel.name);
  40123. for (var i in this.authOptions.params) {
  40124. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  40125. }
  40126. return query;
  40127. };
  40128. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  40129. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  40130. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40131. };
  40132. return PusherAuthorizer;
  40133. }());
  40134. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40135. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40136. var timeline_sender_TimelineSender = (function () {
  40137. function TimelineSender(timeline, options) {
  40138. this.timeline = timeline;
  40139. this.options = options || {};
  40140. }
  40141. TimelineSender.prototype.send = function (useTLS, callback) {
  40142. if (this.timeline.isEmpty()) {
  40143. return;
  40144. }
  40145. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40146. };
  40147. return TimelineSender;
  40148. }());
  40149. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40150. // CONCATENATED MODULE: ./src/core/errors.ts
  40151. var errors_extends = (undefined && undefined.__extends) || (function () {
  40152. var extendStatics = function (d, b) {
  40153. extendStatics = Object.setPrototypeOf ||
  40154. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40155. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40156. return extendStatics(d, b);
  40157. };
  40158. return function (d, b) {
  40159. extendStatics(d, b);
  40160. function __() { this.constructor = d; }
  40161. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40162. };
  40163. })();
  40164. var BadEventName = (function (_super) {
  40165. errors_extends(BadEventName, _super);
  40166. function BadEventName(msg) {
  40167. var _newTarget = this.constructor;
  40168. var _this = _super.call(this, msg) || this;
  40169. Object.setPrototypeOf(_this, _newTarget.prototype);
  40170. return _this;
  40171. }
  40172. return BadEventName;
  40173. }(Error));
  40174. var RequestTimedOut = (function (_super) {
  40175. errors_extends(RequestTimedOut, _super);
  40176. function RequestTimedOut(msg) {
  40177. var _newTarget = this.constructor;
  40178. var _this = _super.call(this, msg) || this;
  40179. Object.setPrototypeOf(_this, _newTarget.prototype);
  40180. return _this;
  40181. }
  40182. return RequestTimedOut;
  40183. }(Error));
  40184. var TransportPriorityTooLow = (function (_super) {
  40185. errors_extends(TransportPriorityTooLow, _super);
  40186. function TransportPriorityTooLow(msg) {
  40187. var _newTarget = this.constructor;
  40188. var _this = _super.call(this, msg) || this;
  40189. Object.setPrototypeOf(_this, _newTarget.prototype);
  40190. return _this;
  40191. }
  40192. return TransportPriorityTooLow;
  40193. }(Error));
  40194. var TransportClosed = (function (_super) {
  40195. errors_extends(TransportClosed, _super);
  40196. function TransportClosed(msg) {
  40197. var _newTarget = this.constructor;
  40198. var _this = _super.call(this, msg) || this;
  40199. Object.setPrototypeOf(_this, _newTarget.prototype);
  40200. return _this;
  40201. }
  40202. return TransportClosed;
  40203. }(Error));
  40204. var UnsupportedFeature = (function (_super) {
  40205. errors_extends(UnsupportedFeature, _super);
  40206. function UnsupportedFeature(msg) {
  40207. var _newTarget = this.constructor;
  40208. var _this = _super.call(this, msg) || this;
  40209. Object.setPrototypeOf(_this, _newTarget.prototype);
  40210. return _this;
  40211. }
  40212. return UnsupportedFeature;
  40213. }(Error));
  40214. var UnsupportedTransport = (function (_super) {
  40215. errors_extends(UnsupportedTransport, _super);
  40216. function UnsupportedTransport(msg) {
  40217. var _newTarget = this.constructor;
  40218. var _this = _super.call(this, msg) || this;
  40219. Object.setPrototypeOf(_this, _newTarget.prototype);
  40220. return _this;
  40221. }
  40222. return UnsupportedTransport;
  40223. }(Error));
  40224. var UnsupportedStrategy = (function (_super) {
  40225. errors_extends(UnsupportedStrategy, _super);
  40226. function UnsupportedStrategy(msg) {
  40227. var _newTarget = this.constructor;
  40228. var _this = _super.call(this, msg) || this;
  40229. Object.setPrototypeOf(_this, _newTarget.prototype);
  40230. return _this;
  40231. }
  40232. return UnsupportedStrategy;
  40233. }(Error));
  40234. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40235. var channel_extends = (undefined && undefined.__extends) || (function () {
  40236. var extendStatics = function (d, b) {
  40237. extendStatics = Object.setPrototypeOf ||
  40238. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40239. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40240. return extendStatics(d, b);
  40241. };
  40242. return function (d, b) {
  40243. extendStatics(d, b);
  40244. function __() { this.constructor = d; }
  40245. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40246. };
  40247. })();
  40248. var channel_Channel = (function (_super) {
  40249. channel_extends(Channel, _super);
  40250. function Channel(name, pusher) {
  40251. var _this = _super.call(this, function (event, data) {
  40252. logger.debug('No callbacks on ' + name + ' for ' + event);
  40253. }) || this;
  40254. _this.name = name;
  40255. _this.pusher = pusher;
  40256. _this.subscribed = false;
  40257. _this.subscriptionPending = false;
  40258. _this.subscriptionCancelled = false;
  40259. return _this;
  40260. }
  40261. Channel.prototype.authorize = function (socketId, callback) {
  40262. return callback(false, {});
  40263. };
  40264. Channel.prototype.trigger = function (event, data) {
  40265. if (event.indexOf("client-") !== 0) {
  40266. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40267. }
  40268. if (!this.subscribed) {
  40269. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40270. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40271. }
  40272. return this.pusher.send_event(event, data, this.name);
  40273. };
  40274. Channel.prototype.disconnect = function () {
  40275. this.subscribed = false;
  40276. this.subscriptionPending = false;
  40277. };
  40278. Channel.prototype.handleEvent = function (event) {
  40279. var eventName = event.event;
  40280. var data = event.data;
  40281. if (eventName === "pusher_internal:subscription_succeeded") {
  40282. this.handleSubscriptionSucceededEvent(event);
  40283. }
  40284. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40285. var metadata = {};
  40286. this.emit(eventName, data, metadata);
  40287. }
  40288. };
  40289. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40290. this.subscriptionPending = false;
  40291. this.subscribed = true;
  40292. if (this.subscriptionCancelled) {
  40293. this.pusher.unsubscribe(this.name);
  40294. }
  40295. else {
  40296. this.emit("pusher:subscription_succeeded", event.data);
  40297. }
  40298. };
  40299. Channel.prototype.subscribe = function () {
  40300. var _this = this;
  40301. if (this.subscribed) {
  40302. return;
  40303. }
  40304. this.subscriptionPending = true;
  40305. this.subscriptionCancelled = false;
  40306. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40307. if (error) {
  40308. logger.error(data);
  40309. _this.emit('pusher:subscription_error', data);
  40310. }
  40311. else {
  40312. _this.pusher.send_event('pusher:subscribe', {
  40313. auth: data.auth,
  40314. channel_data: data.channel_data,
  40315. channel: _this.name
  40316. });
  40317. }
  40318. });
  40319. };
  40320. Channel.prototype.unsubscribe = function () {
  40321. this.subscribed = false;
  40322. this.pusher.send_event('pusher:unsubscribe', {
  40323. channel: this.name
  40324. });
  40325. };
  40326. Channel.prototype.cancelSubscription = function () {
  40327. this.subscriptionCancelled = true;
  40328. };
  40329. Channel.prototype.reinstateSubscription = function () {
  40330. this.subscriptionCancelled = false;
  40331. };
  40332. return Channel;
  40333. }(dispatcher));
  40334. /* harmony default export */ var channels_channel = (channel_Channel);
  40335. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40336. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40337. var extendStatics = function (d, b) {
  40338. extendStatics = Object.setPrototypeOf ||
  40339. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40340. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40341. return extendStatics(d, b);
  40342. };
  40343. return function (d, b) {
  40344. extendStatics(d, b);
  40345. function __() { this.constructor = d; }
  40346. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40347. };
  40348. })();
  40349. var private_channel_PrivateChannel = (function (_super) {
  40350. private_channel_extends(PrivateChannel, _super);
  40351. function PrivateChannel() {
  40352. return _super !== null && _super.apply(this, arguments) || this;
  40353. }
  40354. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40355. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40356. return authorizer.authorize(socketId, callback);
  40357. };
  40358. return PrivateChannel;
  40359. }(channels_channel));
  40360. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40361. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40362. var members_Members = (function () {
  40363. function Members() {
  40364. this.reset();
  40365. }
  40366. Members.prototype.get = function (id) {
  40367. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40368. return {
  40369. id: id,
  40370. info: this.members[id]
  40371. };
  40372. }
  40373. else {
  40374. return null;
  40375. }
  40376. };
  40377. Members.prototype.each = function (callback) {
  40378. var _this = this;
  40379. objectApply(this.members, function (member, id) {
  40380. callback(_this.get(id));
  40381. });
  40382. };
  40383. Members.prototype.setMyID = function (id) {
  40384. this.myID = id;
  40385. };
  40386. Members.prototype.onSubscription = function (subscriptionData) {
  40387. this.members = subscriptionData.presence.hash;
  40388. this.count = subscriptionData.presence.count;
  40389. this.me = this.get(this.myID);
  40390. };
  40391. Members.prototype.addMember = function (memberData) {
  40392. if (this.get(memberData.user_id) === null) {
  40393. this.count++;
  40394. }
  40395. this.members[memberData.user_id] = memberData.user_info;
  40396. return this.get(memberData.user_id);
  40397. };
  40398. Members.prototype.removeMember = function (memberData) {
  40399. var member = this.get(memberData.user_id);
  40400. if (member) {
  40401. delete this.members[memberData.user_id];
  40402. this.count--;
  40403. }
  40404. return member;
  40405. };
  40406. Members.prototype.reset = function () {
  40407. this.members = {};
  40408. this.count = 0;
  40409. this.myID = null;
  40410. this.me = null;
  40411. };
  40412. return Members;
  40413. }());
  40414. /* harmony default export */ var members = (members_Members);
  40415. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40416. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40417. var extendStatics = function (d, b) {
  40418. extendStatics = Object.setPrototypeOf ||
  40419. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40420. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40421. return extendStatics(d, b);
  40422. };
  40423. return function (d, b) {
  40424. extendStatics(d, b);
  40425. function __() { this.constructor = d; }
  40426. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40427. };
  40428. })();
  40429. var presence_channel_PresenceChannel = (function (_super) {
  40430. presence_channel_extends(PresenceChannel, _super);
  40431. function PresenceChannel(name, pusher) {
  40432. var _this = _super.call(this, name, pusher) || this;
  40433. _this.members = new members();
  40434. return _this;
  40435. }
  40436. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40437. var _this = this;
  40438. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40439. if (!error) {
  40440. if (authData.channel_data === undefined) {
  40441. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40442. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40443. ("expected 'channel_data' field. " + suffix));
  40444. callback("Invalid auth response");
  40445. return;
  40446. }
  40447. var channelData = JSON.parse(authData.channel_data);
  40448. _this.members.setMyID(channelData.user_id);
  40449. }
  40450. callback(error, authData);
  40451. });
  40452. };
  40453. PresenceChannel.prototype.handleEvent = function (event) {
  40454. var eventName = event.event;
  40455. if (eventName.indexOf("pusher_internal:") === 0) {
  40456. this.handleInternalEvent(event);
  40457. }
  40458. else {
  40459. var data = event.data;
  40460. var metadata = {};
  40461. if (event.user_id) {
  40462. metadata.user_id = event.user_id;
  40463. }
  40464. this.emit(eventName, data, metadata);
  40465. }
  40466. };
  40467. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40468. var eventName = event.event;
  40469. var data = event.data;
  40470. switch (eventName) {
  40471. case "pusher_internal:subscription_succeeded":
  40472. this.handleSubscriptionSucceededEvent(event);
  40473. break;
  40474. case "pusher_internal:member_added":
  40475. var addedMember = this.members.addMember(data);
  40476. this.emit('pusher:member_added', addedMember);
  40477. break;
  40478. case "pusher_internal:member_removed":
  40479. var removedMember = this.members.removeMember(data);
  40480. if (removedMember) {
  40481. this.emit('pusher:member_removed', removedMember);
  40482. }
  40483. break;
  40484. }
  40485. };
  40486. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40487. this.subscriptionPending = false;
  40488. this.subscribed = true;
  40489. if (this.subscriptionCancelled) {
  40490. this.pusher.unsubscribe(this.name);
  40491. }
  40492. else {
  40493. this.members.onSubscription(event.data);
  40494. this.emit("pusher:subscription_succeeded", this.members);
  40495. }
  40496. };
  40497. PresenceChannel.prototype.disconnect = function () {
  40498. this.members.reset();
  40499. _super.prototype.disconnect.call(this);
  40500. };
  40501. return PresenceChannel;
  40502. }(private_channel));
  40503. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40504. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40505. var nacl_fast = __webpack_require__(0);
  40506. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40507. var nacl_util = __webpack_require__(1);
  40508. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40509. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40510. var extendStatics = function (d, b) {
  40511. extendStatics = Object.setPrototypeOf ||
  40512. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40513. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40514. return extendStatics(d, b);
  40515. };
  40516. return function (d, b) {
  40517. extendStatics(d, b);
  40518. function __() { this.constructor = d; }
  40519. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40520. };
  40521. })();
  40522. var encrypted_channel_EncryptedChannel = (function (_super) {
  40523. encrypted_channel_extends(EncryptedChannel, _super);
  40524. function EncryptedChannel() {
  40525. var _this = _super !== null && _super.apply(this, arguments) || this;
  40526. _this.key = null;
  40527. return _this;
  40528. }
  40529. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40530. var _this = this;
  40531. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40532. if (error) {
  40533. callback(true, authData);
  40534. return;
  40535. }
  40536. var sharedSecret = authData["shared_secret"];
  40537. if (!sharedSecret) {
  40538. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40539. callback(true, errorMsg);
  40540. return;
  40541. }
  40542. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40543. delete authData["shared_secret"];
  40544. callback(false, authData);
  40545. });
  40546. };
  40547. EncryptedChannel.prototype.trigger = function (event, data) {
  40548. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40549. };
  40550. EncryptedChannel.prototype.handleEvent = function (event) {
  40551. var eventName = event.event;
  40552. var data = event.data;
  40553. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40554. _super.prototype.handleEvent.call(this, event);
  40555. return;
  40556. }
  40557. this.handleEncryptedEvent(eventName, data);
  40558. };
  40559. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40560. var _this = this;
  40561. if (!this.key) {
  40562. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40563. return;
  40564. }
  40565. if (!data.ciphertext || !data.nonce) {
  40566. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40567. return;
  40568. }
  40569. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40570. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40571. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40572. return;
  40573. }
  40574. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40575. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40576. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40577. return;
  40578. }
  40579. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40580. if (bytes === null) {
  40581. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40582. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40583. if (error) {
  40584. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40585. return;
  40586. }
  40587. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40588. if (bytes === null) {
  40589. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40590. return;
  40591. }
  40592. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40593. return;
  40594. });
  40595. return;
  40596. }
  40597. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40598. };
  40599. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40600. try {
  40601. this.emit(eventName, JSON.parse(data));
  40602. }
  40603. catch (e) {
  40604. this.emit(eventName, data);
  40605. }
  40606. return this;
  40607. };
  40608. return EncryptedChannel;
  40609. }(private_channel));
  40610. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40611. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40612. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40613. var extendStatics = function (d, b) {
  40614. extendStatics = Object.setPrototypeOf ||
  40615. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40616. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40617. return extendStatics(d, b);
  40618. };
  40619. return function (d, b) {
  40620. extendStatics(d, b);
  40621. function __() { this.constructor = d; }
  40622. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40623. };
  40624. })();
  40625. var connection_manager_ConnectionManager = (function (_super) {
  40626. connection_manager_extends(ConnectionManager, _super);
  40627. function ConnectionManager(key, options) {
  40628. var _this = _super.call(this) || this;
  40629. _this.key = key;
  40630. _this.options = options || {};
  40631. _this.state = "initialized";
  40632. _this.connection = null;
  40633. _this.usingTLS = !!options.useTLS;
  40634. _this.timeline = _this.options.timeline;
  40635. _this.errorCallbacks = _this.buildErrorCallbacks();
  40636. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40637. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40638. var Network = runtime.getNetwork();
  40639. Network.bind("online", function () {
  40640. _this.timeline.info({ netinfo: "online" });
  40641. if (_this.state === "connecting" || _this.state === "unavailable") {
  40642. _this.retryIn(0);
  40643. }
  40644. });
  40645. Network.bind("offline", function () {
  40646. _this.timeline.info({ netinfo: "offline" });
  40647. if (_this.connection) {
  40648. _this.sendActivityCheck();
  40649. }
  40650. });
  40651. _this.updateStrategy();
  40652. return _this;
  40653. }
  40654. ConnectionManager.prototype.connect = function () {
  40655. if (this.connection || this.runner) {
  40656. return;
  40657. }
  40658. if (!this.strategy.isSupported()) {
  40659. this.updateState("failed");
  40660. return;
  40661. }
  40662. this.updateState("connecting");
  40663. this.startConnecting();
  40664. this.setUnavailableTimer();
  40665. };
  40666. ;
  40667. ConnectionManager.prototype.send = function (data) {
  40668. if (this.connection) {
  40669. return this.connection.send(data);
  40670. }
  40671. else {
  40672. return false;
  40673. }
  40674. };
  40675. ;
  40676. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40677. if (this.connection) {
  40678. return this.connection.send_event(name, data, channel);
  40679. }
  40680. else {
  40681. return false;
  40682. }
  40683. };
  40684. ;
  40685. ConnectionManager.prototype.disconnect = function () {
  40686. this.disconnectInternally();
  40687. this.updateState("disconnected");
  40688. };
  40689. ;
  40690. ConnectionManager.prototype.isUsingTLS = function () {
  40691. return this.usingTLS;
  40692. };
  40693. ;
  40694. ConnectionManager.prototype.startConnecting = function () {
  40695. var _this = this;
  40696. var callback = function (error, handshake) {
  40697. if (error) {
  40698. _this.runner = _this.strategy.connect(0, callback);
  40699. }
  40700. else {
  40701. if (handshake.action === "error") {
  40702. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40703. _this.timeline.error({ handshakeError: handshake.error });
  40704. }
  40705. else {
  40706. _this.abortConnecting();
  40707. _this.handshakeCallbacks[handshake.action](handshake);
  40708. }
  40709. }
  40710. };
  40711. this.runner = this.strategy.connect(0, callback);
  40712. };
  40713. ;
  40714. ConnectionManager.prototype.abortConnecting = function () {
  40715. if (this.runner) {
  40716. this.runner.abort();
  40717. this.runner = null;
  40718. }
  40719. };
  40720. ;
  40721. ConnectionManager.prototype.disconnectInternally = function () {
  40722. this.abortConnecting();
  40723. this.clearRetryTimer();
  40724. this.clearUnavailableTimer();
  40725. if (this.connection) {
  40726. var connection = this.abandonConnection();
  40727. connection.close();
  40728. }
  40729. };
  40730. ;
  40731. ConnectionManager.prototype.updateStrategy = function () {
  40732. this.strategy = this.options.getStrategy({
  40733. key: this.key,
  40734. timeline: this.timeline,
  40735. useTLS: this.usingTLS
  40736. });
  40737. };
  40738. ;
  40739. ConnectionManager.prototype.retryIn = function (delay) {
  40740. var _this = this;
  40741. this.timeline.info({ action: "retry", delay: delay });
  40742. if (delay > 0) {
  40743. this.emit("connecting_in", Math.round(delay / 1000));
  40744. }
  40745. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40746. _this.disconnectInternally();
  40747. _this.connect();
  40748. });
  40749. };
  40750. ;
  40751. ConnectionManager.prototype.clearRetryTimer = function () {
  40752. if (this.retryTimer) {
  40753. this.retryTimer.ensureAborted();
  40754. this.retryTimer = null;
  40755. }
  40756. };
  40757. ;
  40758. ConnectionManager.prototype.setUnavailableTimer = function () {
  40759. var _this = this;
  40760. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40761. _this.updateState("unavailable");
  40762. });
  40763. };
  40764. ;
  40765. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40766. if (this.unavailableTimer) {
  40767. this.unavailableTimer.ensureAborted();
  40768. }
  40769. };
  40770. ;
  40771. ConnectionManager.prototype.sendActivityCheck = function () {
  40772. var _this = this;
  40773. this.stopActivityCheck();
  40774. this.connection.ping();
  40775. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40776. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40777. _this.retryIn(0);
  40778. });
  40779. };
  40780. ;
  40781. ConnectionManager.prototype.resetActivityCheck = function () {
  40782. var _this = this;
  40783. this.stopActivityCheck();
  40784. if (this.connection && !this.connection.handlesActivityChecks()) {
  40785. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40786. _this.sendActivityCheck();
  40787. });
  40788. }
  40789. };
  40790. ;
  40791. ConnectionManager.prototype.stopActivityCheck = function () {
  40792. if (this.activityTimer) {
  40793. this.activityTimer.ensureAborted();
  40794. }
  40795. };
  40796. ;
  40797. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40798. var _this = this;
  40799. return extend({}, errorCallbacks, {
  40800. message: function (message) {
  40801. _this.resetActivityCheck();
  40802. _this.emit('message', message);
  40803. },
  40804. ping: function () {
  40805. _this.send_event('pusher:pong', {});
  40806. },
  40807. activity: function () {
  40808. _this.resetActivityCheck();
  40809. },
  40810. error: function (error) {
  40811. _this.emit("error", { type: "WebSocketError", error: error });
  40812. },
  40813. closed: function () {
  40814. _this.abandonConnection();
  40815. if (_this.shouldRetry()) {
  40816. _this.retryIn(1000);
  40817. }
  40818. }
  40819. });
  40820. };
  40821. ;
  40822. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40823. var _this = this;
  40824. return extend({}, errorCallbacks, {
  40825. connected: function (handshake) {
  40826. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40827. _this.clearUnavailableTimer();
  40828. _this.setConnection(handshake.connection);
  40829. _this.socket_id = _this.connection.id;
  40830. _this.updateState("connected", { socket_id: _this.socket_id });
  40831. }
  40832. });
  40833. };
  40834. ;
  40835. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40836. var _this = this;
  40837. var withErrorEmitted = function (callback) {
  40838. return function (result) {
  40839. if (result.error) {
  40840. _this.emit("error", { type: "WebSocketError", error: result.error });
  40841. }
  40842. callback(result);
  40843. };
  40844. };
  40845. return {
  40846. tls_only: withErrorEmitted(function () {
  40847. _this.usingTLS = true;
  40848. _this.updateStrategy();
  40849. _this.retryIn(0);
  40850. }),
  40851. refused: withErrorEmitted(function () {
  40852. _this.disconnect();
  40853. }),
  40854. backoff: withErrorEmitted(function () {
  40855. _this.retryIn(1000);
  40856. }),
  40857. retry: withErrorEmitted(function () {
  40858. _this.retryIn(0);
  40859. })
  40860. };
  40861. };
  40862. ;
  40863. ConnectionManager.prototype.setConnection = function (connection) {
  40864. this.connection = connection;
  40865. for (var event in this.connectionCallbacks) {
  40866. this.connection.bind(event, this.connectionCallbacks[event]);
  40867. }
  40868. this.resetActivityCheck();
  40869. };
  40870. ;
  40871. ConnectionManager.prototype.abandonConnection = function () {
  40872. if (!this.connection) {
  40873. return;
  40874. }
  40875. this.stopActivityCheck();
  40876. for (var event in this.connectionCallbacks) {
  40877. this.connection.unbind(event, this.connectionCallbacks[event]);
  40878. }
  40879. var connection = this.connection;
  40880. this.connection = null;
  40881. return connection;
  40882. };
  40883. ConnectionManager.prototype.updateState = function (newState, data) {
  40884. var previousState = this.state;
  40885. this.state = newState;
  40886. if (previousState !== newState) {
  40887. var newStateDescription = newState;
  40888. if (newStateDescription === "connected") {
  40889. newStateDescription += " with new socket ID " + data.socket_id;
  40890. }
  40891. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40892. this.timeline.info({ state: newState, params: data });
  40893. this.emit('state_change', { previous: previousState, current: newState });
  40894. this.emit(newState, data);
  40895. }
  40896. };
  40897. ConnectionManager.prototype.shouldRetry = function () {
  40898. return this.state === "connecting" || this.state === "connected";
  40899. };
  40900. return ConnectionManager;
  40901. }(dispatcher));
  40902. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40903. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40904. var channels_Channels = (function () {
  40905. function Channels() {
  40906. this.channels = {};
  40907. }
  40908. Channels.prototype.add = function (name, pusher) {
  40909. if (!this.channels[name]) {
  40910. this.channels[name] = createChannel(name, pusher);
  40911. }
  40912. return this.channels[name];
  40913. };
  40914. Channels.prototype.all = function () {
  40915. return values(this.channels);
  40916. };
  40917. Channels.prototype.find = function (name) {
  40918. return this.channels[name];
  40919. };
  40920. Channels.prototype.remove = function (name) {
  40921. var channel = this.channels[name];
  40922. delete this.channels[name];
  40923. return channel;
  40924. };
  40925. Channels.prototype.disconnect = function () {
  40926. objectApply(this.channels, function (channel) {
  40927. channel.disconnect();
  40928. });
  40929. };
  40930. return Channels;
  40931. }());
  40932. /* harmony default export */ var channels = (channels_Channels);
  40933. function createChannel(name, pusher) {
  40934. if (name.indexOf('private-encrypted-') === 0) {
  40935. if (false) { var errorMsg; }
  40936. return factory.createEncryptedChannel(name, pusher);
  40937. }
  40938. else if (name.indexOf('private-') === 0) {
  40939. return factory.createPrivateChannel(name, pusher);
  40940. }
  40941. else if (name.indexOf('presence-') === 0) {
  40942. return factory.createPresenceChannel(name, pusher);
  40943. }
  40944. else {
  40945. return factory.createChannel(name, pusher);
  40946. }
  40947. }
  40948. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40949. var Factory = {
  40950. createChannels: function () {
  40951. return new channels();
  40952. },
  40953. createConnectionManager: function (key, options) {
  40954. return new connection_manager(key, options);
  40955. },
  40956. createChannel: function (name, pusher) {
  40957. return new channels_channel(name, pusher);
  40958. },
  40959. createPrivateChannel: function (name, pusher) {
  40960. return new private_channel(name, pusher);
  40961. },
  40962. createPresenceChannel: function (name, pusher) {
  40963. return new presence_channel(name, pusher);
  40964. },
  40965. createEncryptedChannel: function (name, pusher) {
  40966. return new encrypted_channel(name, pusher);
  40967. },
  40968. createTimelineSender: function (timeline, options) {
  40969. return new timeline_sender(timeline, options);
  40970. },
  40971. createAuthorizer: function (channel, options) {
  40972. if (options.authorizer) {
  40973. return options.authorizer(channel, options);
  40974. }
  40975. return new pusher_authorizer(channel, options);
  40976. },
  40977. createHandshake: function (transport, callback) {
  40978. return new connection_handshake(transport, callback);
  40979. },
  40980. createAssistantToTheTransportManager: function (manager, transport, options) {
  40981. return new assistant_to_the_transport_manager(manager, transport, options);
  40982. }
  40983. };
  40984. /* harmony default export */ var factory = (Factory);
  40985. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40986. var transport_manager_TransportManager = (function () {
  40987. function TransportManager(options) {
  40988. this.options = options || {};
  40989. this.livesLeft = this.options.lives || Infinity;
  40990. }
  40991. TransportManager.prototype.getAssistant = function (transport) {
  40992. return factory.createAssistantToTheTransportManager(this, transport, {
  40993. minPingDelay: this.options.minPingDelay,
  40994. maxPingDelay: this.options.maxPingDelay
  40995. });
  40996. };
  40997. TransportManager.prototype.isAlive = function () {
  40998. return this.livesLeft > 0;
  40999. };
  41000. TransportManager.prototype.reportDeath = function () {
  41001. this.livesLeft -= 1;
  41002. };
  41003. return TransportManager;
  41004. }());
  41005. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  41006. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  41007. var sequential_strategy_SequentialStrategy = (function () {
  41008. function SequentialStrategy(strategies, options) {
  41009. this.strategies = strategies;
  41010. this.loop = Boolean(options.loop);
  41011. this.failFast = Boolean(options.failFast);
  41012. this.timeout = options.timeout;
  41013. this.timeoutLimit = options.timeoutLimit;
  41014. }
  41015. SequentialStrategy.prototype.isSupported = function () {
  41016. return any(this.strategies, util.method("isSupported"));
  41017. };
  41018. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  41019. var _this = this;
  41020. var strategies = this.strategies;
  41021. var current = 0;
  41022. var timeout = this.timeout;
  41023. var runner = null;
  41024. var tryNextStrategy = function (error, handshake) {
  41025. if (handshake) {
  41026. callback(null, handshake);
  41027. }
  41028. else {
  41029. current = current + 1;
  41030. if (_this.loop) {
  41031. current = current % strategies.length;
  41032. }
  41033. if (current < strategies.length) {
  41034. if (timeout) {
  41035. timeout = timeout * 2;
  41036. if (_this.timeoutLimit) {
  41037. timeout = Math.min(timeout, _this.timeoutLimit);
  41038. }
  41039. }
  41040. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  41041. }
  41042. else {
  41043. callback(true);
  41044. }
  41045. }
  41046. };
  41047. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  41048. return {
  41049. abort: function () {
  41050. runner.abort();
  41051. },
  41052. forceMinPriority: function (p) {
  41053. minPriority = p;
  41054. if (runner) {
  41055. runner.forceMinPriority(p);
  41056. }
  41057. }
  41058. };
  41059. };
  41060. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  41061. var timer = null;
  41062. var runner = null;
  41063. if (options.timeout > 0) {
  41064. timer = new OneOffTimer(options.timeout, function () {
  41065. runner.abort();
  41066. callback(true);
  41067. });
  41068. }
  41069. runner = strategy.connect(minPriority, function (error, handshake) {
  41070. if (error && timer && timer.isRunning() && !options.failFast) {
  41071. return;
  41072. }
  41073. if (timer) {
  41074. timer.ensureAborted();
  41075. }
  41076. callback(error, handshake);
  41077. });
  41078. return {
  41079. abort: function () {
  41080. if (timer) {
  41081. timer.ensureAborted();
  41082. }
  41083. runner.abort();
  41084. },
  41085. forceMinPriority: function (p) {
  41086. runner.forceMinPriority(p);
  41087. }
  41088. };
  41089. };
  41090. return SequentialStrategy;
  41091. }());
  41092. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  41093. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  41094. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  41095. function BestConnectedEverStrategy(strategies) {
  41096. this.strategies = strategies;
  41097. }
  41098. BestConnectedEverStrategy.prototype.isSupported = function () {
  41099. return any(this.strategies, util.method("isSupported"));
  41100. };
  41101. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  41102. return connect(this.strategies, minPriority, function (i, runners) {
  41103. return function (error, handshake) {
  41104. runners[i].error = error;
  41105. if (error) {
  41106. if (allRunnersFailed(runners)) {
  41107. callback(true);
  41108. }
  41109. return;
  41110. }
  41111. apply(runners, function (runner) {
  41112. runner.forceMinPriority(handshake.transport.priority);
  41113. });
  41114. callback(null, handshake);
  41115. };
  41116. });
  41117. };
  41118. return BestConnectedEverStrategy;
  41119. }());
  41120. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  41121. function connect(strategies, minPriority, callbackBuilder) {
  41122. var runners = map(strategies, function (strategy, i, _, rs) {
  41123. return strategy.connect(minPriority, callbackBuilder(i, rs));
  41124. });
  41125. return {
  41126. abort: function () {
  41127. apply(runners, abortRunner);
  41128. },
  41129. forceMinPriority: function (p) {
  41130. apply(runners, function (runner) {
  41131. runner.forceMinPriority(p);
  41132. });
  41133. }
  41134. };
  41135. }
  41136. function allRunnersFailed(runners) {
  41137. return collections_all(runners, function (runner) {
  41138. return Boolean(runner.error);
  41139. });
  41140. }
  41141. function abortRunner(runner) {
  41142. if (!runner.error && !runner.aborted) {
  41143. runner.abort();
  41144. runner.aborted = true;
  41145. }
  41146. }
  41147. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41148. var cached_strategy_CachedStrategy = (function () {
  41149. function CachedStrategy(strategy, transports, options) {
  41150. this.strategy = strategy;
  41151. this.transports = transports;
  41152. this.ttl = options.ttl || 1800 * 1000;
  41153. this.usingTLS = options.useTLS;
  41154. this.timeline = options.timeline;
  41155. }
  41156. CachedStrategy.prototype.isSupported = function () {
  41157. return this.strategy.isSupported();
  41158. };
  41159. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41160. var usingTLS = this.usingTLS;
  41161. var info = fetchTransportCache(usingTLS);
  41162. var strategies = [this.strategy];
  41163. if (info && info.timestamp + this.ttl >= util.now()) {
  41164. var transport = this.transports[info.transport];
  41165. if (transport) {
  41166. this.timeline.info({
  41167. cached: true,
  41168. transport: info.transport,
  41169. latency: info.latency
  41170. });
  41171. strategies.push(new sequential_strategy([transport], {
  41172. timeout: info.latency * 2 + 1000,
  41173. failFast: true
  41174. }));
  41175. }
  41176. }
  41177. var startTimestamp = util.now();
  41178. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41179. if (error) {
  41180. flushTransportCache(usingTLS);
  41181. if (strategies.length > 0) {
  41182. startTimestamp = util.now();
  41183. runner = strategies.pop().connect(minPriority, cb);
  41184. }
  41185. else {
  41186. callback(error);
  41187. }
  41188. }
  41189. else {
  41190. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41191. callback(null, handshake);
  41192. }
  41193. });
  41194. return {
  41195. abort: function () {
  41196. runner.abort();
  41197. },
  41198. forceMinPriority: function (p) {
  41199. minPriority = p;
  41200. if (runner) {
  41201. runner.forceMinPriority(p);
  41202. }
  41203. }
  41204. };
  41205. };
  41206. return CachedStrategy;
  41207. }());
  41208. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41209. function getTransportCacheKey(usingTLS) {
  41210. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41211. }
  41212. function fetchTransportCache(usingTLS) {
  41213. var storage = runtime.getLocalStorage();
  41214. if (storage) {
  41215. try {
  41216. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41217. if (serializedCache) {
  41218. return JSON.parse(serializedCache);
  41219. }
  41220. }
  41221. catch (e) {
  41222. flushTransportCache(usingTLS);
  41223. }
  41224. }
  41225. return null;
  41226. }
  41227. function storeTransportCache(usingTLS, transport, latency) {
  41228. var storage = runtime.getLocalStorage();
  41229. if (storage) {
  41230. try {
  41231. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41232. timestamp: util.now(),
  41233. transport: transport,
  41234. latency: latency
  41235. });
  41236. }
  41237. catch (e) {
  41238. }
  41239. }
  41240. }
  41241. function flushTransportCache(usingTLS) {
  41242. var storage = runtime.getLocalStorage();
  41243. if (storage) {
  41244. try {
  41245. delete storage[getTransportCacheKey(usingTLS)];
  41246. }
  41247. catch (e) {
  41248. }
  41249. }
  41250. }
  41251. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41252. var delayed_strategy_DelayedStrategy = (function () {
  41253. function DelayedStrategy(strategy, _a) {
  41254. var number = _a.delay;
  41255. this.strategy = strategy;
  41256. this.options = { delay: number };
  41257. }
  41258. DelayedStrategy.prototype.isSupported = function () {
  41259. return this.strategy.isSupported();
  41260. };
  41261. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41262. var strategy = this.strategy;
  41263. var runner;
  41264. var timer = new OneOffTimer(this.options.delay, function () {
  41265. runner = strategy.connect(minPriority, callback);
  41266. });
  41267. return {
  41268. abort: function () {
  41269. timer.ensureAborted();
  41270. if (runner) {
  41271. runner.abort();
  41272. }
  41273. },
  41274. forceMinPriority: function (p) {
  41275. minPriority = p;
  41276. if (runner) {
  41277. runner.forceMinPriority(p);
  41278. }
  41279. }
  41280. };
  41281. };
  41282. return DelayedStrategy;
  41283. }());
  41284. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41285. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41286. var IfStrategy = (function () {
  41287. function IfStrategy(test, trueBranch, falseBranch) {
  41288. this.test = test;
  41289. this.trueBranch = trueBranch;
  41290. this.falseBranch = falseBranch;
  41291. }
  41292. IfStrategy.prototype.isSupported = function () {
  41293. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41294. return branch.isSupported();
  41295. };
  41296. IfStrategy.prototype.connect = function (minPriority, callback) {
  41297. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41298. return branch.connect(minPriority, callback);
  41299. };
  41300. return IfStrategy;
  41301. }());
  41302. /* harmony default export */ var if_strategy = (IfStrategy);
  41303. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41304. var FirstConnectedStrategy = (function () {
  41305. function FirstConnectedStrategy(strategy) {
  41306. this.strategy = strategy;
  41307. }
  41308. FirstConnectedStrategy.prototype.isSupported = function () {
  41309. return this.strategy.isSupported();
  41310. };
  41311. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41312. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41313. if (handshake) {
  41314. runner.abort();
  41315. }
  41316. callback(error, handshake);
  41317. });
  41318. return runner;
  41319. };
  41320. return FirstConnectedStrategy;
  41321. }());
  41322. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41323. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41324. function testSupportsStrategy(strategy) {
  41325. return function () {
  41326. return strategy.isSupported();
  41327. };
  41328. }
  41329. var getDefaultStrategy = function (config, defineTransport) {
  41330. var definedTransports = {};
  41331. function defineTransportStrategy(name, type, priority, options, manager) {
  41332. var transport = defineTransport(config, name, type, priority, options, manager);
  41333. definedTransports[name] = transport;
  41334. return transport;
  41335. }
  41336. var ws_options = {
  41337. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41338. hostTLS: config.wsHost + ":" + config.wssPort,
  41339. httpPath: config.wsPath
  41340. };
  41341. var wss_options = extend({}, ws_options, {
  41342. useTLS: true
  41343. });
  41344. var sockjs_options = {
  41345. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41346. hostTLS: config.httpHost + ":" + config.httpsPort,
  41347. httpPath: config.httpPath
  41348. };
  41349. var timeouts = {
  41350. loop: true,
  41351. timeout: 15000,
  41352. timeoutLimit: 60000
  41353. };
  41354. var ws_manager = new transport_manager({
  41355. lives: 2,
  41356. minPingDelay: 10000,
  41357. maxPingDelay: config.activity_timeout
  41358. });
  41359. var streaming_manager = new transport_manager({
  41360. lives: 2,
  41361. minPingDelay: 10000,
  41362. maxPingDelay: config.activity_timeout
  41363. });
  41364. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41365. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41366. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41367. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41368. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41369. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41370. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41371. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41372. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41373. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41374. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41375. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41376. 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);
  41377. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41378. var wsStrategy;
  41379. if (config.useTLS) {
  41380. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41381. }
  41382. else {
  41383. wsStrategy = new best_connected_ever_strategy([
  41384. ws_loop,
  41385. new delayed_strategy(wss_loop, { delay: 2000 }),
  41386. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41387. ]);
  41388. }
  41389. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41390. ttl: 1800000,
  41391. timeline: config.timeline,
  41392. useTLS: config.useTLS
  41393. });
  41394. };
  41395. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41396. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41397. /* harmony default export */ var transport_connection_initializer = (function () {
  41398. var self = this;
  41399. self.timeline.info(self.buildTimelineMessage({
  41400. transport: self.name + (self.options.useTLS ? "s" : "")
  41401. }));
  41402. if (self.hooks.isInitialized()) {
  41403. self.changeState("initialized");
  41404. }
  41405. else if (self.hooks.file) {
  41406. self.changeState("initializing");
  41407. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41408. if (self.hooks.isInitialized()) {
  41409. self.changeState("initialized");
  41410. callback(true);
  41411. }
  41412. else {
  41413. if (error) {
  41414. self.onError(error);
  41415. }
  41416. self.onClose();
  41417. callback(false);
  41418. }
  41419. });
  41420. }
  41421. else {
  41422. self.onClose();
  41423. }
  41424. });
  41425. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41426. var http_xdomain_request_hooks = {
  41427. getRequest: function (socket) {
  41428. var xdr = new window.XDomainRequest();
  41429. xdr.ontimeout = function () {
  41430. socket.emit("error", new RequestTimedOut());
  41431. socket.close();
  41432. };
  41433. xdr.onerror = function (e) {
  41434. socket.emit("error", e);
  41435. socket.close();
  41436. };
  41437. xdr.onprogress = function () {
  41438. if (xdr.responseText && xdr.responseText.length > 0) {
  41439. socket.onChunk(200, xdr.responseText);
  41440. }
  41441. };
  41442. xdr.onload = function () {
  41443. if (xdr.responseText && xdr.responseText.length > 0) {
  41444. socket.onChunk(200, xdr.responseText);
  41445. }
  41446. socket.emit("finished", 200);
  41447. socket.close();
  41448. };
  41449. return xdr;
  41450. },
  41451. abortRequest: function (xdr) {
  41452. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41453. xdr.abort();
  41454. }
  41455. };
  41456. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41457. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41458. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41459. var extendStatics = function (d, b) {
  41460. extendStatics = Object.setPrototypeOf ||
  41461. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41462. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41463. return extendStatics(d, b);
  41464. };
  41465. return function (d, b) {
  41466. extendStatics(d, b);
  41467. function __() { this.constructor = d; }
  41468. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41469. };
  41470. })();
  41471. var MAX_BUFFER_LENGTH = 256 * 1024;
  41472. var http_request_HTTPRequest = (function (_super) {
  41473. http_request_extends(HTTPRequest, _super);
  41474. function HTTPRequest(hooks, method, url) {
  41475. var _this = _super.call(this) || this;
  41476. _this.hooks = hooks;
  41477. _this.method = method;
  41478. _this.url = url;
  41479. return _this;
  41480. }
  41481. HTTPRequest.prototype.start = function (payload) {
  41482. var _this = this;
  41483. this.position = 0;
  41484. this.xhr = this.hooks.getRequest(this);
  41485. this.unloader = function () {
  41486. _this.close();
  41487. };
  41488. runtime.addUnloadListener(this.unloader);
  41489. this.xhr.open(this.method, this.url, true);
  41490. if (this.xhr.setRequestHeader) {
  41491. this.xhr.setRequestHeader("Content-Type", "application/json");
  41492. }
  41493. this.xhr.send(payload);
  41494. };
  41495. HTTPRequest.prototype.close = function () {
  41496. if (this.unloader) {
  41497. runtime.removeUnloadListener(this.unloader);
  41498. this.unloader = null;
  41499. }
  41500. if (this.xhr) {
  41501. this.hooks.abortRequest(this.xhr);
  41502. this.xhr = null;
  41503. }
  41504. };
  41505. HTTPRequest.prototype.onChunk = function (status, data) {
  41506. while (true) {
  41507. var chunk = this.advanceBuffer(data);
  41508. if (chunk) {
  41509. this.emit("chunk", { status: status, data: chunk });
  41510. }
  41511. else {
  41512. break;
  41513. }
  41514. }
  41515. if (this.isBufferTooLong(data)) {
  41516. this.emit("buffer_too_long");
  41517. }
  41518. };
  41519. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41520. var unreadData = buffer.slice(this.position);
  41521. var endOfLinePosition = unreadData.indexOf("\n");
  41522. if (endOfLinePosition !== -1) {
  41523. this.position += endOfLinePosition + 1;
  41524. return unreadData.slice(0, endOfLinePosition);
  41525. }
  41526. else {
  41527. return null;
  41528. }
  41529. };
  41530. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41531. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41532. };
  41533. return HTTPRequest;
  41534. }(dispatcher));
  41535. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41536. // CONCATENATED MODULE: ./src/core/http/state.ts
  41537. var State;
  41538. (function (State) {
  41539. State[State["CONNECTING"] = 0] = "CONNECTING";
  41540. State[State["OPEN"] = 1] = "OPEN";
  41541. State[State["CLOSED"] = 3] = "CLOSED";
  41542. })(State || (State = {}));
  41543. /* harmony default export */ var state = (State);
  41544. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41545. var autoIncrement = 1;
  41546. var http_socket_HTTPSocket = (function () {
  41547. function HTTPSocket(hooks, url) {
  41548. this.hooks = hooks;
  41549. this.session = randomNumber(1000) + "/" + randomString(8);
  41550. this.location = getLocation(url);
  41551. this.readyState = state.CONNECTING;
  41552. this.openStream();
  41553. }
  41554. HTTPSocket.prototype.send = function (payload) {
  41555. return this.sendRaw(JSON.stringify([payload]));
  41556. };
  41557. HTTPSocket.prototype.ping = function () {
  41558. this.hooks.sendHeartbeat(this);
  41559. };
  41560. HTTPSocket.prototype.close = function (code, reason) {
  41561. this.onClose(code, reason, true);
  41562. };
  41563. HTTPSocket.prototype.sendRaw = function (payload) {
  41564. if (this.readyState === state.OPEN) {
  41565. try {
  41566. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41567. return true;
  41568. }
  41569. catch (e) {
  41570. return false;
  41571. }
  41572. }
  41573. else {
  41574. return false;
  41575. }
  41576. };
  41577. HTTPSocket.prototype.reconnect = function () {
  41578. this.closeStream();
  41579. this.openStream();
  41580. };
  41581. ;
  41582. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41583. this.closeStream();
  41584. this.readyState = state.CLOSED;
  41585. if (this.onclose) {
  41586. this.onclose({
  41587. code: code,
  41588. reason: reason,
  41589. wasClean: wasClean
  41590. });
  41591. }
  41592. };
  41593. HTTPSocket.prototype.onChunk = function (chunk) {
  41594. if (chunk.status !== 200) {
  41595. return;
  41596. }
  41597. if (this.readyState === state.OPEN) {
  41598. this.onActivity();
  41599. }
  41600. var payload;
  41601. var type = chunk.data.slice(0, 1);
  41602. switch (type) {
  41603. case 'o':
  41604. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41605. this.onOpen(payload);
  41606. break;
  41607. case 'a':
  41608. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41609. for (var i = 0; i < payload.length; i++) {
  41610. this.onEvent(payload[i]);
  41611. }
  41612. break;
  41613. case 'm':
  41614. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41615. this.onEvent(payload);
  41616. break;
  41617. case 'h':
  41618. this.hooks.onHeartbeat(this);
  41619. break;
  41620. case 'c':
  41621. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41622. this.onClose(payload[0], payload[1], true);
  41623. break;
  41624. }
  41625. };
  41626. HTTPSocket.prototype.onOpen = function (options) {
  41627. if (this.readyState === state.CONNECTING) {
  41628. if (options && options.hostname) {
  41629. this.location.base = replaceHost(this.location.base, options.hostname);
  41630. }
  41631. this.readyState = state.OPEN;
  41632. if (this.onopen) {
  41633. this.onopen();
  41634. }
  41635. }
  41636. else {
  41637. this.onClose(1006, "Server lost session", true);
  41638. }
  41639. };
  41640. HTTPSocket.prototype.onEvent = function (event) {
  41641. if (this.readyState === state.OPEN && this.onmessage) {
  41642. this.onmessage({ data: event });
  41643. }
  41644. };
  41645. HTTPSocket.prototype.onActivity = function () {
  41646. if (this.onactivity) {
  41647. this.onactivity();
  41648. }
  41649. };
  41650. HTTPSocket.prototype.onError = function (error) {
  41651. if (this.onerror) {
  41652. this.onerror(error);
  41653. }
  41654. };
  41655. HTTPSocket.prototype.openStream = function () {
  41656. var _this = this;
  41657. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41658. this.stream.bind("chunk", function (chunk) {
  41659. _this.onChunk(chunk);
  41660. });
  41661. this.stream.bind("finished", function (status) {
  41662. _this.hooks.onFinished(_this, status);
  41663. });
  41664. this.stream.bind("buffer_too_long", function () {
  41665. _this.reconnect();
  41666. });
  41667. try {
  41668. this.stream.start();
  41669. }
  41670. catch (error) {
  41671. util.defer(function () {
  41672. _this.onError(error);
  41673. _this.onClose(1006, "Could not start streaming", false);
  41674. });
  41675. }
  41676. };
  41677. HTTPSocket.prototype.closeStream = function () {
  41678. if (this.stream) {
  41679. this.stream.unbind_all();
  41680. this.stream.close();
  41681. this.stream = null;
  41682. }
  41683. };
  41684. return HTTPSocket;
  41685. }());
  41686. function getLocation(url) {
  41687. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41688. return {
  41689. base: parts[1],
  41690. queryString: parts[2]
  41691. };
  41692. }
  41693. function getSendURL(url, session) {
  41694. return url.base + "/" + session + "/xhr_send";
  41695. }
  41696. function getUniqueURL(url) {
  41697. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41698. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41699. }
  41700. function replaceHost(url, hostname) {
  41701. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41702. return urlParts[1] + hostname + urlParts[3];
  41703. }
  41704. function randomNumber(max) {
  41705. return Math.floor(Math.random() * max);
  41706. }
  41707. function randomString(length) {
  41708. var result = [];
  41709. for (var i = 0; i < length; i++) {
  41710. result.push(randomNumber(32).toString(32));
  41711. }
  41712. return result.join('');
  41713. }
  41714. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41715. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41716. var http_streaming_socket_hooks = {
  41717. getReceiveURL: function (url, session) {
  41718. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41719. },
  41720. onHeartbeat: function (socket) {
  41721. socket.sendRaw("[]");
  41722. },
  41723. sendHeartbeat: function (socket) {
  41724. socket.sendRaw("[]");
  41725. },
  41726. onFinished: function (socket, status) {
  41727. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41728. }
  41729. };
  41730. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41731. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41732. var http_polling_socket_hooks = {
  41733. getReceiveURL: function (url, session) {
  41734. return url.base + "/" + session + "/xhr" + url.queryString;
  41735. },
  41736. onHeartbeat: function () {
  41737. },
  41738. sendHeartbeat: function (socket) {
  41739. socket.sendRaw("[]");
  41740. },
  41741. onFinished: function (socket, status) {
  41742. if (status === 200) {
  41743. socket.reconnect();
  41744. }
  41745. else {
  41746. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41747. }
  41748. }
  41749. };
  41750. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41751. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41752. var http_xhr_request_hooks = {
  41753. getRequest: function (socket) {
  41754. var Constructor = runtime.getXHRAPI();
  41755. var xhr = new Constructor();
  41756. xhr.onreadystatechange = xhr.onprogress = function () {
  41757. switch (xhr.readyState) {
  41758. case 3:
  41759. if (xhr.responseText && xhr.responseText.length > 0) {
  41760. socket.onChunk(xhr.status, xhr.responseText);
  41761. }
  41762. break;
  41763. case 4:
  41764. if (xhr.responseText && xhr.responseText.length > 0) {
  41765. socket.onChunk(xhr.status, xhr.responseText);
  41766. }
  41767. socket.emit("finished", xhr.status);
  41768. socket.close();
  41769. break;
  41770. }
  41771. };
  41772. return xhr;
  41773. },
  41774. abortRequest: function (xhr) {
  41775. xhr.onreadystatechange = null;
  41776. xhr.abort();
  41777. }
  41778. };
  41779. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41780. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41781. var HTTP = {
  41782. createStreamingSocket: function (url) {
  41783. return this.createSocket(http_streaming_socket, url);
  41784. },
  41785. createPollingSocket: function (url) {
  41786. return this.createSocket(http_polling_socket, url);
  41787. },
  41788. createSocket: function (hooks, url) {
  41789. return new http_socket(hooks, url);
  41790. },
  41791. createXHR: function (method, url) {
  41792. return this.createRequest(http_xhr_request, method, url);
  41793. },
  41794. createRequest: function (hooks, method, url) {
  41795. return new http_request(hooks, method, url);
  41796. }
  41797. };
  41798. /* harmony default export */ var http_http = (HTTP);
  41799. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41800. http_http.createXDR = function (method, url) {
  41801. return this.createRequest(http_xdomain_request, method, url);
  41802. };
  41803. /* harmony default export */ var web_http_http = (http_http);
  41804. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41805. var Runtime = {
  41806. nextAuthCallbackID: 1,
  41807. auth_callbacks: {},
  41808. ScriptReceivers: ScriptReceivers,
  41809. DependenciesReceivers: DependenciesReceivers,
  41810. getDefaultStrategy: default_strategy,
  41811. Transports: transports_transports,
  41812. transportConnectionInitializer: transport_connection_initializer,
  41813. HTTPFactory: web_http_http,
  41814. TimelineTransport: jsonp_timeline,
  41815. getXHRAPI: function () {
  41816. return window.XMLHttpRequest;
  41817. },
  41818. getWebSocketAPI: function () {
  41819. return window.WebSocket || window.MozWebSocket;
  41820. },
  41821. setup: function (PusherClass) {
  41822. var _this = this;
  41823. window.Pusher = PusherClass;
  41824. var initializeOnDocumentBody = function () {
  41825. _this.onDocumentBody(PusherClass.ready);
  41826. };
  41827. if (!window.JSON) {
  41828. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41829. }
  41830. else {
  41831. initializeOnDocumentBody();
  41832. }
  41833. },
  41834. getDocument: function () {
  41835. return document;
  41836. },
  41837. getProtocol: function () {
  41838. return this.getDocument().location.protocol;
  41839. },
  41840. getAuthorizers: function () {
  41841. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41842. },
  41843. onDocumentBody: function (callback) {
  41844. var _this = this;
  41845. if (document.body) {
  41846. callback();
  41847. }
  41848. else {
  41849. setTimeout(function () {
  41850. _this.onDocumentBody(callback);
  41851. }, 0);
  41852. }
  41853. },
  41854. createJSONPRequest: function (url, data) {
  41855. return new jsonp_request(url, data);
  41856. },
  41857. createScriptRequest: function (src) {
  41858. return new script_request(src);
  41859. },
  41860. getLocalStorage: function () {
  41861. try {
  41862. return window.localStorage;
  41863. }
  41864. catch (e) {
  41865. return undefined;
  41866. }
  41867. },
  41868. createXHR: function () {
  41869. if (this.getXHRAPI()) {
  41870. return this.createXMLHttpRequest();
  41871. }
  41872. else {
  41873. return this.createMicrosoftXHR();
  41874. }
  41875. },
  41876. createXMLHttpRequest: function () {
  41877. var Constructor = this.getXHRAPI();
  41878. return new Constructor();
  41879. },
  41880. createMicrosoftXHR: function () {
  41881. return new ActiveXObject("Microsoft.XMLHTTP");
  41882. },
  41883. getNetwork: function () {
  41884. return net_info_Network;
  41885. },
  41886. createWebSocket: function (url) {
  41887. var Constructor = this.getWebSocketAPI();
  41888. return new Constructor(url);
  41889. },
  41890. createSocketRequest: function (method, url) {
  41891. if (this.isXHRSupported()) {
  41892. return this.HTTPFactory.createXHR(method, url);
  41893. }
  41894. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41895. return this.HTTPFactory.createXDR(method, url);
  41896. }
  41897. else {
  41898. throw "Cross-origin HTTP requests are not supported";
  41899. }
  41900. },
  41901. isXHRSupported: function () {
  41902. var Constructor = this.getXHRAPI();
  41903. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41904. },
  41905. isXDRSupported: function (useTLS) {
  41906. var protocol = useTLS ? "https:" : "http:";
  41907. var documentProtocol = this.getProtocol();
  41908. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41909. },
  41910. addUnloadListener: function (listener) {
  41911. if (window.addEventListener !== undefined) {
  41912. window.addEventListener("unload", listener, false);
  41913. }
  41914. else if (window.attachEvent !== undefined) {
  41915. window.attachEvent("onunload", listener);
  41916. }
  41917. },
  41918. removeUnloadListener: function (listener) {
  41919. if (window.addEventListener !== undefined) {
  41920. window.removeEventListener("unload", listener, false);
  41921. }
  41922. else if (window.detachEvent !== undefined) {
  41923. window.detachEvent("onunload", listener);
  41924. }
  41925. }
  41926. };
  41927. /* harmony default export */ var runtime = (Runtime);
  41928. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41929. var TimelineLevel;
  41930. (function (TimelineLevel) {
  41931. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41932. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41933. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41934. })(TimelineLevel || (TimelineLevel = {}));
  41935. /* harmony default export */ var timeline_level = (TimelineLevel);
  41936. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41937. var timeline_Timeline = (function () {
  41938. function Timeline(key, session, options) {
  41939. this.key = key;
  41940. this.session = session;
  41941. this.events = [];
  41942. this.options = options || {};
  41943. this.sent = 0;
  41944. this.uniqueID = 0;
  41945. }
  41946. Timeline.prototype.log = function (level, event) {
  41947. if (level <= this.options.level) {
  41948. this.events.push(extend({}, event, { timestamp: util.now() }));
  41949. if (this.options.limit && this.events.length > this.options.limit) {
  41950. this.events.shift();
  41951. }
  41952. }
  41953. };
  41954. Timeline.prototype.error = function (event) {
  41955. this.log(timeline_level.ERROR, event);
  41956. };
  41957. Timeline.prototype.info = function (event) {
  41958. this.log(timeline_level.INFO, event);
  41959. };
  41960. Timeline.prototype.debug = function (event) {
  41961. this.log(timeline_level.DEBUG, event);
  41962. };
  41963. Timeline.prototype.isEmpty = function () {
  41964. return this.events.length === 0;
  41965. };
  41966. Timeline.prototype.send = function (sendfn, callback) {
  41967. var _this = this;
  41968. var data = extend({
  41969. session: this.session,
  41970. bundle: this.sent + 1,
  41971. key: this.key,
  41972. lib: "js",
  41973. version: this.options.version,
  41974. cluster: this.options.cluster,
  41975. features: this.options.features,
  41976. timeline: this.events
  41977. }, this.options.params);
  41978. this.events = [];
  41979. sendfn(data, function (error, result) {
  41980. if (!error) {
  41981. _this.sent++;
  41982. }
  41983. if (callback) {
  41984. callback(error, result);
  41985. }
  41986. });
  41987. return true;
  41988. };
  41989. Timeline.prototype.generateUniqueID = function () {
  41990. this.uniqueID++;
  41991. return this.uniqueID;
  41992. };
  41993. return Timeline;
  41994. }());
  41995. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41996. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41997. var transport_strategy_TransportStrategy = (function () {
  41998. function TransportStrategy(name, priority, transport, options) {
  41999. this.name = name;
  42000. this.priority = priority;
  42001. this.transport = transport;
  42002. this.options = options || {};
  42003. }
  42004. TransportStrategy.prototype.isSupported = function () {
  42005. return this.transport.isSupported({
  42006. useTLS: this.options.useTLS
  42007. });
  42008. };
  42009. TransportStrategy.prototype.connect = function (minPriority, callback) {
  42010. var _this = this;
  42011. if (!this.isSupported()) {
  42012. return failAttempt(new UnsupportedStrategy(), callback);
  42013. }
  42014. else if (this.priority < minPriority) {
  42015. return failAttempt(new TransportPriorityTooLow(), callback);
  42016. }
  42017. var connected = false;
  42018. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  42019. var handshake = null;
  42020. var onInitialized = function () {
  42021. transport.unbind("initialized", onInitialized);
  42022. transport.connect();
  42023. };
  42024. var onOpen = function () {
  42025. handshake = factory.createHandshake(transport, function (result) {
  42026. connected = true;
  42027. unbindListeners();
  42028. callback(null, result);
  42029. });
  42030. };
  42031. var onError = function (error) {
  42032. unbindListeners();
  42033. callback(error);
  42034. };
  42035. var onClosed = function () {
  42036. unbindListeners();
  42037. var serializedTransport;
  42038. serializedTransport = safeJSONStringify(transport);
  42039. callback(new TransportClosed(serializedTransport));
  42040. };
  42041. var unbindListeners = function () {
  42042. transport.unbind("initialized", onInitialized);
  42043. transport.unbind("open", onOpen);
  42044. transport.unbind("error", onError);
  42045. transport.unbind("closed", onClosed);
  42046. };
  42047. transport.bind("initialized", onInitialized);
  42048. transport.bind("open", onOpen);
  42049. transport.bind("error", onError);
  42050. transport.bind("closed", onClosed);
  42051. transport.initialize();
  42052. return {
  42053. abort: function () {
  42054. if (connected) {
  42055. return;
  42056. }
  42057. unbindListeners();
  42058. if (handshake) {
  42059. handshake.close();
  42060. }
  42061. else {
  42062. transport.close();
  42063. }
  42064. },
  42065. forceMinPriority: function (p) {
  42066. if (connected) {
  42067. return;
  42068. }
  42069. if (_this.priority < p) {
  42070. if (handshake) {
  42071. handshake.close();
  42072. }
  42073. else {
  42074. transport.close();
  42075. }
  42076. }
  42077. }
  42078. };
  42079. };
  42080. return TransportStrategy;
  42081. }());
  42082. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  42083. function failAttempt(error, callback) {
  42084. util.defer(function () {
  42085. callback(error);
  42086. });
  42087. return {
  42088. abort: function () { },
  42089. forceMinPriority: function () { }
  42090. };
  42091. }
  42092. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  42093. var strategy_builder_Transports = runtime.Transports;
  42094. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  42095. var transportClass = strategy_builder_Transports[type];
  42096. if (!transportClass) {
  42097. throw new UnsupportedTransport(type);
  42098. }
  42099. var enabled = (!config.enabledTransports ||
  42100. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  42101. (!config.disabledTransports ||
  42102. arrayIndexOf(config.disabledTransports, name) === -1);
  42103. var transport;
  42104. if (enabled) {
  42105. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  42106. key: config.key,
  42107. useTLS: config.useTLS,
  42108. timeline: config.timeline,
  42109. ignoreNullOrigin: config.ignoreNullOrigin
  42110. }, options));
  42111. }
  42112. else {
  42113. transport = strategy_builder_UnsupportedStrategy;
  42114. }
  42115. return transport;
  42116. };
  42117. var strategy_builder_UnsupportedStrategy = {
  42118. isSupported: function () {
  42119. return false;
  42120. },
  42121. connect: function (_, callback) {
  42122. var deferred = util.defer(function () {
  42123. callback(new UnsupportedStrategy());
  42124. });
  42125. return {
  42126. abort: function () {
  42127. deferred.ensureAborted();
  42128. },
  42129. forceMinPriority: function () { }
  42130. };
  42131. }
  42132. };
  42133. // CONCATENATED MODULE: ./src/core/config.ts
  42134. var getGlobalConfig = function () {
  42135. return {
  42136. wsHost: defaults.host,
  42137. wsPort: defaults.ws_port,
  42138. wssPort: defaults.wss_port,
  42139. wsPath: defaults.ws_path,
  42140. httpHost: defaults.sockjs_host,
  42141. httpPort: defaults.sockjs_http_port,
  42142. httpsPort: defaults.sockjs_https_port,
  42143. httpPath: defaults.sockjs_path,
  42144. statsHost: defaults.stats_host,
  42145. authEndpoint: defaults.channel_auth_endpoint,
  42146. authTransport: defaults.channel_auth_transport,
  42147. activity_timeout: defaults.activity_timeout,
  42148. pong_timeout: defaults.pong_timeout,
  42149. unavailable_timeout: defaults.unavailable_timeout
  42150. };
  42151. };
  42152. var getClusterConfig = function (clusterName) {
  42153. return {
  42154. wsHost: 'ws-' + clusterName + '.pusher.com',
  42155. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42156. };
  42157. };
  42158. // CONCATENATED MODULE: ./src/core/pusher.ts
  42159. var pusher_Pusher = (function () {
  42160. function Pusher(app_key, options) {
  42161. var _this = this;
  42162. checkAppKey(app_key);
  42163. options = options || {};
  42164. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42165. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42166. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42167. }
  42168. this.key = app_key;
  42169. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42170. this.channels = factory.createChannels();
  42171. this.global_emitter = new dispatcher();
  42172. this.sessionID = Math.floor(Math.random() * 1000000000);
  42173. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42174. cluster: this.config.cluster,
  42175. features: Pusher.getClientFeatures(),
  42176. params: this.config.timelineParams || {},
  42177. limit: 50,
  42178. level: timeline_level.INFO,
  42179. version: defaults.VERSION
  42180. });
  42181. if (!this.config.disableStats) {
  42182. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42183. host: this.config.statsHost,
  42184. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42185. });
  42186. }
  42187. var getStrategy = function (options) {
  42188. var config = extend({}, _this.config, options);
  42189. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42190. };
  42191. this.connection = factory.createConnectionManager(this.key, extend({
  42192. getStrategy: getStrategy,
  42193. timeline: this.timeline,
  42194. activityTimeout: this.config.activity_timeout,
  42195. pongTimeout: this.config.pong_timeout,
  42196. unavailableTimeout: this.config.unavailable_timeout
  42197. }, this.config, { useTLS: this.shouldUseTLS() }));
  42198. this.connection.bind('connected', function () {
  42199. _this.subscribeAll();
  42200. if (_this.timelineSender) {
  42201. _this.timelineSender.send(_this.connection.isUsingTLS());
  42202. }
  42203. });
  42204. this.connection.bind('message', function (event) {
  42205. var eventName = event.event;
  42206. var internal = eventName.indexOf('pusher_internal:') === 0;
  42207. if (event.channel) {
  42208. var channel = _this.channel(event.channel);
  42209. if (channel) {
  42210. channel.handleEvent(event);
  42211. }
  42212. }
  42213. if (!internal) {
  42214. _this.global_emitter.emit(event.event, event.data);
  42215. }
  42216. });
  42217. this.connection.bind('connecting', function () {
  42218. _this.channels.disconnect();
  42219. });
  42220. this.connection.bind('disconnected', function () {
  42221. _this.channels.disconnect();
  42222. });
  42223. this.connection.bind('error', function (err) {
  42224. logger.warn(err);
  42225. });
  42226. Pusher.instances.push(this);
  42227. this.timeline.info({ instances: Pusher.instances.length });
  42228. if (Pusher.isReady) {
  42229. this.connect();
  42230. }
  42231. }
  42232. Pusher.ready = function () {
  42233. Pusher.isReady = true;
  42234. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42235. Pusher.instances[i].connect();
  42236. }
  42237. };
  42238. Pusher.getClientFeatures = function () {
  42239. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42240. return t.isSupported({});
  42241. }));
  42242. };
  42243. Pusher.prototype.channel = function (name) {
  42244. return this.channels.find(name);
  42245. };
  42246. Pusher.prototype.allChannels = function () {
  42247. return this.channels.all();
  42248. };
  42249. Pusher.prototype.connect = function () {
  42250. this.connection.connect();
  42251. if (this.timelineSender) {
  42252. if (!this.timelineSenderTimer) {
  42253. var usingTLS = this.connection.isUsingTLS();
  42254. var timelineSender = this.timelineSender;
  42255. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42256. timelineSender.send(usingTLS);
  42257. });
  42258. }
  42259. }
  42260. };
  42261. Pusher.prototype.disconnect = function () {
  42262. this.connection.disconnect();
  42263. if (this.timelineSenderTimer) {
  42264. this.timelineSenderTimer.ensureAborted();
  42265. this.timelineSenderTimer = null;
  42266. }
  42267. };
  42268. Pusher.prototype.bind = function (event_name, callback, context) {
  42269. this.global_emitter.bind(event_name, callback, context);
  42270. return this;
  42271. };
  42272. Pusher.prototype.unbind = function (event_name, callback, context) {
  42273. this.global_emitter.unbind(event_name, callback, context);
  42274. return this;
  42275. };
  42276. Pusher.prototype.bind_global = function (callback) {
  42277. this.global_emitter.bind_global(callback);
  42278. return this;
  42279. };
  42280. Pusher.prototype.unbind_global = function (callback) {
  42281. this.global_emitter.unbind_global(callback);
  42282. return this;
  42283. };
  42284. Pusher.prototype.unbind_all = function (callback) {
  42285. this.global_emitter.unbind_all();
  42286. return this;
  42287. };
  42288. Pusher.prototype.subscribeAll = function () {
  42289. var channelName;
  42290. for (channelName in this.channels.channels) {
  42291. if (this.channels.channels.hasOwnProperty(channelName)) {
  42292. this.subscribe(channelName);
  42293. }
  42294. }
  42295. };
  42296. Pusher.prototype.subscribe = function (channel_name) {
  42297. var channel = this.channels.add(channel_name, this);
  42298. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42299. channel.reinstateSubscription();
  42300. }
  42301. else if (!channel.subscriptionPending &&
  42302. this.connection.state === 'connected') {
  42303. channel.subscribe();
  42304. }
  42305. return channel;
  42306. };
  42307. Pusher.prototype.unsubscribe = function (channel_name) {
  42308. var channel = this.channels.find(channel_name);
  42309. if (channel && channel.subscriptionPending) {
  42310. channel.cancelSubscription();
  42311. }
  42312. else {
  42313. channel = this.channels.remove(channel_name);
  42314. if (channel && this.connection.state === 'connected') {
  42315. channel.unsubscribe();
  42316. }
  42317. }
  42318. };
  42319. Pusher.prototype.send_event = function (event_name, data, channel) {
  42320. return this.connection.send_event(event_name, data, channel);
  42321. };
  42322. Pusher.prototype.shouldUseTLS = function () {
  42323. if (runtime.getProtocol() === 'https:') {
  42324. return true;
  42325. }
  42326. else if (this.config.forceTLS === true) {
  42327. return true;
  42328. }
  42329. else {
  42330. return Boolean(this.config.encrypted);
  42331. }
  42332. };
  42333. Pusher.instances = [];
  42334. Pusher.isReady = false;
  42335. Pusher.logToConsole = false;
  42336. Pusher.Runtime = runtime;
  42337. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42338. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42339. Pusher.auth_callbacks = runtime.auth_callbacks;
  42340. return Pusher;
  42341. }());
  42342. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42343. function checkAppKey(key) {
  42344. if (key === null || key === undefined) {
  42345. throw 'You must pass your app key when you instantiate Pusher.';
  42346. }
  42347. }
  42348. runtime.setup(pusher_Pusher);
  42349. /***/ })
  42350. /******/ ]);
  42351. });
  42352. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42353. /***/ }),
  42354. /***/ "./node_modules/setimmediate/setImmediate.js":
  42355. /*!***************************************************!*\
  42356. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42357. \***************************************************/
  42358. /*! no static exports found */
  42359. /***/ (function(module, exports, __webpack_require__) {
  42360. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42361. "use strict";
  42362. if (global.setImmediate) {
  42363. return;
  42364. }
  42365. var nextHandle = 1; // Spec says greater than zero
  42366. var tasksByHandle = {};
  42367. var currentlyRunningATask = false;
  42368. var doc = global.document;
  42369. var registerImmediate;
  42370. function setImmediate(callback) {
  42371. // Callback can either be a function or a string
  42372. if (typeof callback !== "function") {
  42373. callback = new Function("" + callback);
  42374. }
  42375. // Copy function arguments
  42376. var args = new Array(arguments.length - 1);
  42377. for (var i = 0; i < args.length; i++) {
  42378. args[i] = arguments[i + 1];
  42379. }
  42380. // Store and register the task
  42381. var task = { callback: callback, args: args };
  42382. tasksByHandle[nextHandle] = task;
  42383. registerImmediate(nextHandle);
  42384. return nextHandle++;
  42385. }
  42386. function clearImmediate(handle) {
  42387. delete tasksByHandle[handle];
  42388. }
  42389. function run(task) {
  42390. var callback = task.callback;
  42391. var args = task.args;
  42392. switch (args.length) {
  42393. case 0:
  42394. callback();
  42395. break;
  42396. case 1:
  42397. callback(args[0]);
  42398. break;
  42399. case 2:
  42400. callback(args[0], args[1]);
  42401. break;
  42402. case 3:
  42403. callback(args[0], args[1], args[2]);
  42404. break;
  42405. default:
  42406. callback.apply(undefined, args);
  42407. break;
  42408. }
  42409. }
  42410. function runIfPresent(handle) {
  42411. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42412. // So if we're currently running a task, we'll need to delay this invocation.
  42413. if (currentlyRunningATask) {
  42414. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42415. // "too much recursion" error.
  42416. setTimeout(runIfPresent, 0, handle);
  42417. } else {
  42418. var task = tasksByHandle[handle];
  42419. if (task) {
  42420. currentlyRunningATask = true;
  42421. try {
  42422. run(task);
  42423. } finally {
  42424. clearImmediate(handle);
  42425. currentlyRunningATask = false;
  42426. }
  42427. }
  42428. }
  42429. }
  42430. function installNextTickImplementation() {
  42431. registerImmediate = function(handle) {
  42432. process.nextTick(function () { runIfPresent(handle); });
  42433. };
  42434. }
  42435. function canUsePostMessage() {
  42436. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42437. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42438. if (global.postMessage && !global.importScripts) {
  42439. var postMessageIsAsynchronous = true;
  42440. var oldOnMessage = global.onmessage;
  42441. global.onmessage = function() {
  42442. postMessageIsAsynchronous = false;
  42443. };
  42444. global.postMessage("", "*");
  42445. global.onmessage = oldOnMessage;
  42446. return postMessageIsAsynchronous;
  42447. }
  42448. }
  42449. function installPostMessageImplementation() {
  42450. // Installs an event handler on `global` for the `message` event: see
  42451. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42452. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42453. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42454. var onGlobalMessage = function(event) {
  42455. if (event.source === global &&
  42456. typeof event.data === "string" &&
  42457. event.data.indexOf(messagePrefix) === 0) {
  42458. runIfPresent(+event.data.slice(messagePrefix.length));
  42459. }
  42460. };
  42461. if (global.addEventListener) {
  42462. global.addEventListener("message", onGlobalMessage, false);
  42463. } else {
  42464. global.attachEvent("onmessage", onGlobalMessage);
  42465. }
  42466. registerImmediate = function(handle) {
  42467. global.postMessage(messagePrefix + handle, "*");
  42468. };
  42469. }
  42470. function installMessageChannelImplementation() {
  42471. var channel = new MessageChannel();
  42472. channel.port1.onmessage = function(event) {
  42473. var handle = event.data;
  42474. runIfPresent(handle);
  42475. };
  42476. registerImmediate = function(handle) {
  42477. channel.port2.postMessage(handle);
  42478. };
  42479. }
  42480. function installReadyStateChangeImplementation() {
  42481. var html = doc.documentElement;
  42482. registerImmediate = function(handle) {
  42483. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42484. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42485. var script = doc.createElement("script");
  42486. script.onreadystatechange = function () {
  42487. runIfPresent(handle);
  42488. script.onreadystatechange = null;
  42489. html.removeChild(script);
  42490. script = null;
  42491. };
  42492. html.appendChild(script);
  42493. };
  42494. }
  42495. function installSetTimeoutImplementation() {
  42496. registerImmediate = function(handle) {
  42497. setTimeout(runIfPresent, 0, handle);
  42498. };
  42499. }
  42500. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42501. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42502. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42503. // Don't get fooled by e.g. browserify environments.
  42504. if ({}.toString.call(global.process) === "[object process]") {
  42505. // For Node.js before 0.9
  42506. installNextTickImplementation();
  42507. } else if (canUsePostMessage()) {
  42508. // For non-IE10 modern browsers
  42509. installPostMessageImplementation();
  42510. } else if (global.MessageChannel) {
  42511. // For web workers, where supported
  42512. installMessageChannelImplementation();
  42513. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42514. // For IE 6–8
  42515. installReadyStateChangeImplementation();
  42516. } else {
  42517. // For older browsers
  42518. installSetTimeoutImplementation();
  42519. }
  42520. attachTo.setImmediate = setImmediate;
  42521. attachTo.clearImmediate = clearImmediate;
  42522. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42523. /* 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")))
  42524. /***/ }),
  42525. /***/ "./node_modules/style-loader/index.js!./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  42526. /*!************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  42527. !*** ./node_modules/style-loader!./node_modules/css-loader??ref--6-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  42528. \************************************************************************************************************************************************************************************************************************************************************************************************************************/
  42529. /*! no static exports found */
  42530. /***/ (function(module, exports, __webpack_require__) {
  42531. var content = __webpack_require__(/*! !../../../node_modules/css-loader??ref--6-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src??ref--6-2!../../../node_modules/vue-loader/lib??vue-loader-options!./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  42532. if(typeof content === 'string') content = [[module.i, content, '']];
  42533. var transform;
  42534. var insertInto;
  42535. var options = {"hmr":true}
  42536. options.transform = transform
  42537. options.insertInto = undefined;
  42538. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "./node_modules/style-loader/lib/addStyles.js")(content, options);
  42539. if(content.locals) module.exports = content.locals;
  42540. if(false) {}
  42541. /***/ }),
  42542. /***/ "./node_modules/style-loader/lib/addStyles.js":
  42543. /*!****************************************************!*\
  42544. !*** ./node_modules/style-loader/lib/addStyles.js ***!
  42545. \****************************************************/
  42546. /*! no static exports found */
  42547. /***/ (function(module, exports, __webpack_require__) {
  42548. /*
  42549. MIT License http://www.opensource.org/licenses/mit-license.php
  42550. Author Tobias Koppers @sokra
  42551. */
  42552. var stylesInDom = {};
  42553. var memoize = function (fn) {
  42554. var memo;
  42555. return function () {
  42556. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  42557. return memo;
  42558. };
  42559. };
  42560. var isOldIE = memoize(function () {
  42561. // Test for IE <= 9 as proposed by Browserhacks
  42562. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  42563. // Tests for existence of standard globals is to allow style-loader
  42564. // to operate correctly into non-standard environments
  42565. // @see https://github.com/webpack-contrib/style-loader/issues/177
  42566. return window && document && document.all && !window.atob;
  42567. });
  42568. var getTarget = function (target, parent) {
  42569. if (parent){
  42570. return parent.querySelector(target);
  42571. }
  42572. return document.querySelector(target);
  42573. };
  42574. var getElement = (function (fn) {
  42575. var memo = {};
  42576. return function(target, parent) {
  42577. // If passing function in options, then use it for resolve "head" element.
  42578. // Useful for Shadow Root style i.e
  42579. // {
  42580. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  42581. // }
  42582. if (typeof target === 'function') {
  42583. return target();
  42584. }
  42585. if (typeof memo[target] === "undefined") {
  42586. var styleTarget = getTarget.call(this, target, parent);
  42587. // Special case to return head of iframe instead of iframe itself
  42588. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  42589. try {
  42590. // This will throw an exception if access to iframe is blocked
  42591. // due to cross-origin restrictions
  42592. styleTarget = styleTarget.contentDocument.head;
  42593. } catch(e) {
  42594. styleTarget = null;
  42595. }
  42596. }
  42597. memo[target] = styleTarget;
  42598. }
  42599. return memo[target]
  42600. };
  42601. })();
  42602. var singleton = null;
  42603. var singletonCounter = 0;
  42604. var stylesInsertedAtTop = [];
  42605. var fixUrls = __webpack_require__(/*! ./urls */ "./node_modules/style-loader/lib/urls.js");
  42606. module.exports = function(list, options) {
  42607. if (typeof DEBUG !== "undefined" && DEBUG) {
  42608. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  42609. }
  42610. options = options || {};
  42611. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  42612. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  42613. // tags it will allow on a page
  42614. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  42615. // By default, add <style> tags to the <head> element
  42616. if (!options.insertInto) options.insertInto = "head";
  42617. // By default, add <style> tags to the bottom of the target
  42618. if (!options.insertAt) options.insertAt = "bottom";
  42619. var styles = listToStyles(list, options);
  42620. addStylesToDom(styles, options);
  42621. return function update (newList) {
  42622. var mayRemove = [];
  42623. for (var i = 0; i < styles.length; i++) {
  42624. var item = styles[i];
  42625. var domStyle = stylesInDom[item.id];
  42626. domStyle.refs--;
  42627. mayRemove.push(domStyle);
  42628. }
  42629. if(newList) {
  42630. var newStyles = listToStyles(newList, options);
  42631. addStylesToDom(newStyles, options);
  42632. }
  42633. for (var i = 0; i < mayRemove.length; i++) {
  42634. var domStyle = mayRemove[i];
  42635. if(domStyle.refs === 0) {
  42636. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  42637. delete stylesInDom[domStyle.id];
  42638. }
  42639. }
  42640. };
  42641. };
  42642. function addStylesToDom (styles, options) {
  42643. for (var i = 0; i < styles.length; i++) {
  42644. var item = styles[i];
  42645. var domStyle = stylesInDom[item.id];
  42646. if(domStyle) {
  42647. domStyle.refs++;
  42648. for(var j = 0; j < domStyle.parts.length; j++) {
  42649. domStyle.parts[j](item.parts[j]);
  42650. }
  42651. for(; j < item.parts.length; j++) {
  42652. domStyle.parts.push(addStyle(item.parts[j], options));
  42653. }
  42654. } else {
  42655. var parts = [];
  42656. for(var j = 0; j < item.parts.length; j++) {
  42657. parts.push(addStyle(item.parts[j], options));
  42658. }
  42659. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  42660. }
  42661. }
  42662. }
  42663. function listToStyles (list, options) {
  42664. var styles = [];
  42665. var newStyles = {};
  42666. for (var i = 0; i < list.length; i++) {
  42667. var item = list[i];
  42668. var id = options.base ? item[0] + options.base : item[0];
  42669. var css = item[1];
  42670. var media = item[2];
  42671. var sourceMap = item[3];
  42672. var part = {css: css, media: media, sourceMap: sourceMap};
  42673. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  42674. else newStyles[id].parts.push(part);
  42675. }
  42676. return styles;
  42677. }
  42678. function insertStyleElement (options, style) {
  42679. var target = getElement(options.insertInto)
  42680. if (!target) {
  42681. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  42682. }
  42683. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  42684. if (options.insertAt === "top") {
  42685. if (!lastStyleElementInsertedAtTop) {
  42686. target.insertBefore(style, target.firstChild);
  42687. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  42688. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  42689. } else {
  42690. target.appendChild(style);
  42691. }
  42692. stylesInsertedAtTop.push(style);
  42693. } else if (options.insertAt === "bottom") {
  42694. target.appendChild(style);
  42695. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  42696. var nextSibling = getElement(options.insertAt.before, target);
  42697. target.insertBefore(style, nextSibling);
  42698. } else {
  42699. throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
  42700. }
  42701. }
  42702. function removeStyleElement (style) {
  42703. if (style.parentNode === null) return false;
  42704. style.parentNode.removeChild(style);
  42705. var idx = stylesInsertedAtTop.indexOf(style);
  42706. if(idx >= 0) {
  42707. stylesInsertedAtTop.splice(idx, 1);
  42708. }
  42709. }
  42710. function createStyleElement (options) {
  42711. var style = document.createElement("style");
  42712. if(options.attrs.type === undefined) {
  42713. options.attrs.type = "text/css";
  42714. }
  42715. if(options.attrs.nonce === undefined) {
  42716. var nonce = getNonce();
  42717. if (nonce) {
  42718. options.attrs.nonce = nonce;
  42719. }
  42720. }
  42721. addAttrs(style, options.attrs);
  42722. insertStyleElement(options, style);
  42723. return style;
  42724. }
  42725. function createLinkElement (options) {
  42726. var link = document.createElement("link");
  42727. if(options.attrs.type === undefined) {
  42728. options.attrs.type = "text/css";
  42729. }
  42730. options.attrs.rel = "stylesheet";
  42731. addAttrs(link, options.attrs);
  42732. insertStyleElement(options, link);
  42733. return link;
  42734. }
  42735. function addAttrs (el, attrs) {
  42736. Object.keys(attrs).forEach(function (key) {
  42737. el.setAttribute(key, attrs[key]);
  42738. });
  42739. }
  42740. function getNonce() {
  42741. if (false) {}
  42742. return __webpack_require__.nc;
  42743. }
  42744. function addStyle (obj, options) {
  42745. var style, update, remove, result;
  42746. // If a transform function was defined, run it on the css
  42747. if (options.transform && obj.css) {
  42748. result = typeof options.transform === 'function'
  42749. ? options.transform(obj.css)
  42750. : options.transform.default(obj.css);
  42751. if (result) {
  42752. // If transform returns a value, use that instead of the original css.
  42753. // This allows running runtime transformations on the css.
  42754. obj.css = result;
  42755. } else {
  42756. // If the transform function returns a falsy value, don't add this css.
  42757. // This allows conditional loading of css
  42758. return function() {
  42759. // noop
  42760. };
  42761. }
  42762. }
  42763. if (options.singleton) {
  42764. var styleIndex = singletonCounter++;
  42765. style = singleton || (singleton = createStyleElement(options));
  42766. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  42767. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  42768. } else if (
  42769. obj.sourceMap &&
  42770. typeof URL === "function" &&
  42771. typeof URL.createObjectURL === "function" &&
  42772. typeof URL.revokeObjectURL === "function" &&
  42773. typeof Blob === "function" &&
  42774. typeof btoa === "function"
  42775. ) {
  42776. style = createLinkElement(options);
  42777. update = updateLink.bind(null, style, options);
  42778. remove = function () {
  42779. removeStyleElement(style);
  42780. if(style.href) URL.revokeObjectURL(style.href);
  42781. };
  42782. } else {
  42783. style = createStyleElement(options);
  42784. update = applyToTag.bind(null, style);
  42785. remove = function () {
  42786. removeStyleElement(style);
  42787. };
  42788. }
  42789. update(obj);
  42790. return function updateStyle (newObj) {
  42791. if (newObj) {
  42792. if (
  42793. newObj.css === obj.css &&
  42794. newObj.media === obj.media &&
  42795. newObj.sourceMap === obj.sourceMap
  42796. ) {
  42797. return;
  42798. }
  42799. update(obj = newObj);
  42800. } else {
  42801. remove();
  42802. }
  42803. };
  42804. }
  42805. var replaceText = (function () {
  42806. var textStore = [];
  42807. return function (index, replacement) {
  42808. textStore[index] = replacement;
  42809. return textStore.filter(Boolean).join('\n');
  42810. };
  42811. })();
  42812. function applyToSingletonTag (style, index, remove, obj) {
  42813. var css = remove ? "" : obj.css;
  42814. if (style.styleSheet) {
  42815. style.styleSheet.cssText = replaceText(index, css);
  42816. } else {
  42817. var cssNode = document.createTextNode(css);
  42818. var childNodes = style.childNodes;
  42819. if (childNodes[index]) style.removeChild(childNodes[index]);
  42820. if (childNodes.length) {
  42821. style.insertBefore(cssNode, childNodes[index]);
  42822. } else {
  42823. style.appendChild(cssNode);
  42824. }
  42825. }
  42826. }
  42827. function applyToTag (style, obj) {
  42828. var css = obj.css;
  42829. var media = obj.media;
  42830. if(media) {
  42831. style.setAttribute("media", media)
  42832. }
  42833. if(style.styleSheet) {
  42834. style.styleSheet.cssText = css;
  42835. } else {
  42836. while(style.firstChild) {
  42837. style.removeChild(style.firstChild);
  42838. }
  42839. style.appendChild(document.createTextNode(css));
  42840. }
  42841. }
  42842. function updateLink (link, options, obj) {
  42843. var css = obj.css;
  42844. var sourceMap = obj.sourceMap;
  42845. /*
  42846. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  42847. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  42848. on by default. Otherwise default to the convertToAbsoluteUrls option
  42849. directly
  42850. */
  42851. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  42852. if (options.convertToAbsoluteUrls || autoFixUrls) {
  42853. css = fixUrls(css);
  42854. }
  42855. if (sourceMap) {
  42856. // http://stackoverflow.com/a/26603875
  42857. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  42858. }
  42859. var blob = new Blob([css], { type: "text/css" });
  42860. var oldSrc = link.href;
  42861. link.href = URL.createObjectURL(blob);
  42862. if(oldSrc) URL.revokeObjectURL(oldSrc);
  42863. }
  42864. /***/ }),
  42865. /***/ "./node_modules/style-loader/lib/urls.js":
  42866. /*!***********************************************!*\
  42867. !*** ./node_modules/style-loader/lib/urls.js ***!
  42868. \***********************************************/
  42869. /*! no static exports found */
  42870. /***/ (function(module, exports) {
  42871. /**
  42872. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  42873. * embed the css on the page. This breaks all relative urls because now they are relative to a
  42874. * bundle instead of the current page.
  42875. *
  42876. * One solution is to only use full urls, but that may be impossible.
  42877. *
  42878. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  42879. *
  42880. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  42881. *
  42882. */
  42883. module.exports = function (css) {
  42884. // get current location
  42885. var location = typeof window !== "undefined" && window.location;
  42886. if (!location) {
  42887. throw new Error("fixUrls requires window.location");
  42888. }
  42889. // blank or null?
  42890. if (!css || typeof css !== "string") {
  42891. return css;
  42892. }
  42893. var baseUrl = location.protocol + "//" + location.host;
  42894. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  42895. // convert each url(...)
  42896. /*
  42897. This regular expression is just a way to recursively match brackets within
  42898. a string.
  42899. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  42900. ( = Start a capturing group
  42901. (?: = Start a non-capturing group
  42902. [^)(] = Match anything that isn't a parentheses
  42903. | = OR
  42904. \( = Match a start parentheses
  42905. (?: = Start another non-capturing groups
  42906. [^)(]+ = Match anything that isn't a parentheses
  42907. | = OR
  42908. \( = Match a start parentheses
  42909. [^)(]* = Match anything that isn't a parentheses
  42910. \) = Match a end parentheses
  42911. ) = End Group
  42912. *\) = Match anything and then a close parens
  42913. ) = Close non-capturing group
  42914. * = Match anything
  42915. ) = Close capturing group
  42916. \) = Match a close parens
  42917. /gi = Get all matches, not the first. Be case insensitive.
  42918. */
  42919. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  42920. // strip quotes (if they exist)
  42921. var unquotedOrigUrl = origUrl
  42922. .trim()
  42923. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  42924. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  42925. // already a full url? no change
  42926. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  42927. return fullMatch;
  42928. }
  42929. // convert the url to a full url
  42930. var newUrl;
  42931. if (unquotedOrigUrl.indexOf("//") === 0) {
  42932. //TODO: should we add protocol?
  42933. newUrl = unquotedOrigUrl;
  42934. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  42935. // path should be relative to the base url
  42936. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  42937. } else {
  42938. // path should be relative to current directory
  42939. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  42940. }
  42941. // send back the fixed url(...)
  42942. return "url(" + JSON.stringify(newUrl) + ")";
  42943. });
  42944. // send back the fixed css
  42945. return fixedCss;
  42946. };
  42947. /***/ }),
  42948. /***/ "./node_modules/timers-browserify/main.js":
  42949. /*!************************************************!*\
  42950. !*** ./node_modules/timers-browserify/main.js ***!
  42951. \************************************************/
  42952. /*! no static exports found */
  42953. /***/ (function(module, exports, __webpack_require__) {
  42954. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42955. (typeof self !== "undefined" && self) ||
  42956. window;
  42957. var apply = Function.prototype.apply;
  42958. // DOM APIs, for completeness
  42959. exports.setTimeout = function() {
  42960. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42961. };
  42962. exports.setInterval = function() {
  42963. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42964. };
  42965. exports.clearTimeout =
  42966. exports.clearInterval = function(timeout) {
  42967. if (timeout) {
  42968. timeout.close();
  42969. }
  42970. };
  42971. function Timeout(id, clearFn) {
  42972. this._id = id;
  42973. this._clearFn = clearFn;
  42974. }
  42975. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42976. Timeout.prototype.close = function() {
  42977. this._clearFn.call(scope, this._id);
  42978. };
  42979. // Does not start the time, just sets up the members needed.
  42980. exports.enroll = function(item, msecs) {
  42981. clearTimeout(item._idleTimeoutId);
  42982. item._idleTimeout = msecs;
  42983. };
  42984. exports.unenroll = function(item) {
  42985. clearTimeout(item._idleTimeoutId);
  42986. item._idleTimeout = -1;
  42987. };
  42988. exports._unrefActive = exports.active = function(item) {
  42989. clearTimeout(item._idleTimeoutId);
  42990. var msecs = item._idleTimeout;
  42991. if (msecs >= 0) {
  42992. item._idleTimeoutId = setTimeout(function onTimeout() {
  42993. if (item._onTimeout)
  42994. item._onTimeout();
  42995. }, msecs);
  42996. }
  42997. };
  42998. // setimmediate attaches itself to the global object
  42999. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  43000. // On some exotic environments, it's not clear which object `setimmediate` was
  43001. // able to install onto. Search each possibility in the same order as the
  43002. // `setimmediate` library.
  43003. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  43004. (typeof global !== "undefined" && global.setImmediate) ||
  43005. (this && this.setImmediate);
  43006. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  43007. (typeof global !== "undefined" && global.clearImmediate) ||
  43008. (this && this.clearImmediate);
  43009. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  43010. /***/ }),
  43011. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&":
  43012. /*!*************************************************************************************************************************************************************************************************!*\
  43013. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c& ***!
  43014. \*************************************************************************************************************************************************************************************************/
  43015. /*! exports provided: render, staticRenderFns */
  43016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43017. "use strict";
  43018. __webpack_require__.r(__webpack_exports__);
  43019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43021. var render = function() {
  43022. var _vm = this
  43023. var _h = _vm.$createElement
  43024. var _c = _vm._self._c || _h
  43025. return _c("div", [
  43026. _c(
  43027. "nav",
  43028. {
  43029. staticClass:
  43030. "navbar navbar-expand navbar-dark bg-primary text-light shadow-sm"
  43031. },
  43032. [
  43033. _c(
  43034. "div",
  43035. { staticClass: "container-fluid" },
  43036. [
  43037. _c(
  43038. "router-link",
  43039. { staticClass: "navbar-brand", attrs: { to: { name: "home" } } },
  43040. [_vm._v("\n UPCCRT\n ")]
  43041. ),
  43042. _vm._v(" "),
  43043. _vm._m(0),
  43044. _vm._v(" "),
  43045. _c(
  43046. "div",
  43047. {
  43048. staticClass: "collapse navbar-collapse",
  43049. attrs: { id: "navbarSupportedContent" }
  43050. },
  43051. [
  43052. _vm._m(1),
  43053. _vm._v(" "),
  43054. _c(
  43055. "ul",
  43056. { staticClass: "navbar-nav ml-auto" },
  43057. [
  43058. !_vm.isLoggedIn
  43059. ? _c(
  43060. "router-link",
  43061. {
  43062. staticClass: "nav-link",
  43063. attrs: { to: { name: "login" } }
  43064. },
  43065. [_vm._v("Login")]
  43066. )
  43067. : _vm._e(),
  43068. _vm._v(" "),
  43069. _vm.isLoggedIn
  43070. ? _c("li", { staticClass: "nav-link" }, [
  43071. _vm._v(_vm._s(_vm.username))
  43072. ])
  43073. : _vm._e(),
  43074. _vm._v(" "),
  43075. _vm.isLoggedIn
  43076. ? _c(
  43077. "router-link",
  43078. {
  43079. staticClass: "nav-link",
  43080. attrs: { to: { name: "home" } }
  43081. },
  43082. [_vm._v("Home")]
  43083. )
  43084. : _vm._e()
  43085. ],
  43086. 1
  43087. )
  43088. ]
  43089. )
  43090. ],
  43091. 1
  43092. )
  43093. ]
  43094. ),
  43095. _vm._v(" "),
  43096. _c("main", { staticClass: "py-4" }, [_c("router-view")], 1)
  43097. ])
  43098. }
  43099. var staticRenderFns = [
  43100. function() {
  43101. var _vm = this
  43102. var _h = _vm.$createElement
  43103. var _c = _vm._self._c || _h
  43104. return _c(
  43105. "button",
  43106. {
  43107. staticClass: "navbar-toggler",
  43108. attrs: {
  43109. type: "button",
  43110. "data-toggle": "collapse",
  43111. "data-target": "#navbarSupportedContent",
  43112. "aria-controls": "navbarSupportedContent",
  43113. "aria-expanded": "false"
  43114. }
  43115. },
  43116. [_c("span", { staticClass: "navbar-toggler-icon" })]
  43117. )
  43118. },
  43119. function() {
  43120. var _vm = this
  43121. var _h = _vm.$createElement
  43122. var _c = _vm._self._c || _h
  43123. return _c("ul", { staticClass: "navbar-nav mr-auto text-center" }, [
  43124. _c("li", { staticClass: "nav-item" }, [
  43125. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43126. _c("i", { staticClass: "fas fa-sign-in-alt" }),
  43127. _vm._v(" "),
  43128. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43129. _vm._v("Check-In")
  43130. ])
  43131. ])
  43132. ]),
  43133. _vm._v(" "),
  43134. _c("li", { staticClass: "nav-item" }, [
  43135. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43136. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  43137. _vm._v(" "),
  43138. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43139. _vm._v("Check-Out")
  43140. ])
  43141. ])
  43142. ]),
  43143. _vm._v(" "),
  43144. _c("li", { staticClass: "nav-item" }, [
  43145. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43146. _c("i", { staticClass: "fas fa-tachometer-alt" }),
  43147. _vm._v(" "),
  43148. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43149. _vm._v("Dashboard")
  43150. ])
  43151. ])
  43152. ]),
  43153. _vm._v(" "),
  43154. _c("li", { staticClass: "nav-item" }, [
  43155. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43156. _c("i", { staticClass: "fas fa-chart-bar" }),
  43157. _vm._v(" "),
  43158. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43159. _vm._v("Reports")
  43160. ])
  43161. ])
  43162. ])
  43163. ])
  43164. }
  43165. ]
  43166. render._withStripped = true
  43167. /***/ }),
  43168. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Login.vue?vue&type=template&id=12f5395a&":
  43169. /*!***************************************************************************************************************************************************************************************************!*\
  43170. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Login.vue?vue&type=template&id=12f5395a& ***!
  43171. \***************************************************************************************************************************************************************************************************/
  43172. /*! exports provided: render, staticRenderFns */
  43173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43174. "use strict";
  43175. __webpack_require__.r(__webpack_exports__);
  43176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43178. var render = function() {
  43179. var _vm = this
  43180. var _h = _vm.$createElement
  43181. var _c = _vm._self._c || _h
  43182. return _c("div", { staticClass: "container" }, [
  43183. _c("div", { staticClass: "row justify-content-center" }, [
  43184. _c("div", { staticClass: "col-md-8" }, [
  43185. _c("div", { staticClass: "card card-default" }, [
  43186. _c("div", { staticClass: "card-header" }, [_vm._v("Login")]),
  43187. _vm._v(" "),
  43188. _c("div", { staticClass: "card-body" }, [
  43189. _c("form", { attrs: { method: "POST", action: "/login" } }, [
  43190. _c("div", { staticClass: "form-group row" }, [
  43191. _c(
  43192. "label",
  43193. {
  43194. staticClass: "col-sm-4 col-form-label text-md-right",
  43195. attrs: { for: "username" }
  43196. },
  43197. [_vm._v("Username")]
  43198. ),
  43199. _vm._v(" "),
  43200. _c("div", { staticClass: "col-md-6" }, [
  43201. _c("input", {
  43202. directives: [
  43203. {
  43204. name: "model",
  43205. rawName: "v-model",
  43206. value: _vm.username,
  43207. expression: "username"
  43208. }
  43209. ],
  43210. staticClass: "form-control",
  43211. attrs: {
  43212. id: "username",
  43213. type: "username",
  43214. required: "",
  43215. autofocus: ""
  43216. },
  43217. domProps: { value: _vm.username },
  43218. on: {
  43219. input: function($event) {
  43220. if ($event.target.composing) {
  43221. return
  43222. }
  43223. _vm.username = $event.target.value
  43224. }
  43225. }
  43226. })
  43227. ])
  43228. ]),
  43229. _vm._v(" "),
  43230. _c("div", { staticClass: "form-group row" }, [
  43231. _c(
  43232. "label",
  43233. {
  43234. staticClass: "col-md-4 col-form-label text-md-right",
  43235. attrs: { for: "password" }
  43236. },
  43237. [_vm._v("Password")]
  43238. ),
  43239. _vm._v(" "),
  43240. _c("div", { staticClass: "col-md-6" }, [
  43241. _c("input", {
  43242. directives: [
  43243. {
  43244. name: "model",
  43245. rawName: "v-model",
  43246. value: _vm.password,
  43247. expression: "password"
  43248. }
  43249. ],
  43250. staticClass: "form-control",
  43251. attrs: { id: "password", type: "password", required: "" },
  43252. domProps: { value: _vm.password },
  43253. on: {
  43254. input: function($event) {
  43255. if ($event.target.composing) {
  43256. return
  43257. }
  43258. _vm.password = $event.target.value
  43259. }
  43260. }
  43261. })
  43262. ])
  43263. ]),
  43264. _vm._v(" "),
  43265. _c("div", { staticClass: "form-group row mb-0" }, [
  43266. _c("div", { staticClass: "col-md-8 offset-md-4" }, [
  43267. _c(
  43268. "button",
  43269. {
  43270. staticClass: "btn btn-primary",
  43271. attrs: { type: "submit" },
  43272. on: { click: _vm.handleSubmit }
  43273. },
  43274. [
  43275. _vm._v(
  43276. "\n Login\n "
  43277. )
  43278. ]
  43279. )
  43280. ])
  43281. ])
  43282. ])
  43283. ])
  43284. ])
  43285. ])
  43286. ])
  43287. ])
  43288. }
  43289. var staticRenderFns = []
  43290. render._withStripped = true
  43291. /***/ }),
  43292. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&":
  43293. /*!*****************************************************************************************************************************************************************************************************************!*\
  43294. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& ***!
  43295. \*****************************************************************************************************************************************************************************************************************/
  43296. /*! exports provided: render, staticRenderFns */
  43297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43298. "use strict";
  43299. __webpack_require__.r(__webpack_exports__);
  43300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43302. var render = function() {
  43303. var _vm = this
  43304. var _h = _vm.$createElement
  43305. var _c = _vm._self._c || _h
  43306. return _vm._m(0)
  43307. }
  43308. var staticRenderFns = [
  43309. function() {
  43310. var _vm = this
  43311. var _h = _vm.$createElement
  43312. var _c = _vm._self._c || _h
  43313. return _c("div", { staticClass: "flex-center position-ref full-height" }, [
  43314. _c("div", { staticClass: "content" }, [
  43315. _c("div", { staticClass: "m-b-md" }, [
  43316. _c("h2", { staticClass: "title m-b-md" }, [
  43317. _vm._v("\n UPCCRT\n ")
  43318. ]),
  43319. _vm._v(" "),
  43320. _c("h3", [
  43321. _vm._v(
  43322. "\n University PC Care Repair Tracker\n "
  43323. )
  43324. ])
  43325. ])
  43326. ])
  43327. ])
  43328. }
  43329. ]
  43330. render._withStripped = true
  43331. /***/ }),
  43332. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  43333. /*!********************************************************************!*\
  43334. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  43335. \********************************************************************/
  43336. /*! exports provided: default */
  43337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43338. "use strict";
  43339. __webpack_require__.r(__webpack_exports__);
  43340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  43341. /* globals __VUE_SSR_CONTEXT__ */
  43342. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  43343. // This module is a runtime utility for cleaner component module output and will
  43344. // be included in the final webpack user bundle.
  43345. function normalizeComponent (
  43346. scriptExports,
  43347. render,
  43348. staticRenderFns,
  43349. functionalTemplate,
  43350. injectStyles,
  43351. scopeId,
  43352. moduleIdentifier, /* server only */
  43353. shadowMode /* vue-cli only */
  43354. ) {
  43355. // Vue.extend constructor export interop
  43356. var options = typeof scriptExports === 'function'
  43357. ? scriptExports.options
  43358. : scriptExports
  43359. // render functions
  43360. if (render) {
  43361. options.render = render
  43362. options.staticRenderFns = staticRenderFns
  43363. options._compiled = true
  43364. }
  43365. // functional template
  43366. if (functionalTemplate) {
  43367. options.functional = true
  43368. }
  43369. // scopedId
  43370. if (scopeId) {
  43371. options._scopeId = 'data-v-' + scopeId
  43372. }
  43373. var hook
  43374. if (moduleIdentifier) { // server build
  43375. hook = function (context) {
  43376. // 2.3 injection
  43377. context =
  43378. context || // cached call
  43379. (this.$vnode && this.$vnode.ssrContext) || // stateful
  43380. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  43381. // 2.2 with runInNewContext: true
  43382. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  43383. context = __VUE_SSR_CONTEXT__
  43384. }
  43385. // inject component styles
  43386. if (injectStyles) {
  43387. injectStyles.call(this, context)
  43388. }
  43389. // register component module identifier for async chunk inferrence
  43390. if (context && context._registeredComponents) {
  43391. context._registeredComponents.add(moduleIdentifier)
  43392. }
  43393. }
  43394. // used by ssr in case component is cached and beforeCreate
  43395. // never gets called
  43396. options._ssrRegister = hook
  43397. } else if (injectStyles) {
  43398. hook = shadowMode
  43399. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  43400. : injectStyles
  43401. }
  43402. if (hook) {
  43403. if (options.functional) {
  43404. // for template-only hot-reload because in that case the render fn doesn't
  43405. // go through the normalizer
  43406. options._injectStyles = hook
  43407. // register for functioal component in vue file
  43408. var originalRender = options.render
  43409. options.render = function renderWithStyleInjection (h, context) {
  43410. hook.call(context)
  43411. return originalRender(h, context)
  43412. }
  43413. } else {
  43414. // inject component registration as beforeCreate hook
  43415. var existing = options.beforeCreate
  43416. options.beforeCreate = existing
  43417. ? [].concat(existing, hook)
  43418. : [hook]
  43419. }
  43420. }
  43421. return {
  43422. exports: scriptExports,
  43423. options: options
  43424. }
  43425. }
  43426. /***/ }),
  43427. /***/ "./node_modules/vue-router/dist/vue-router.esm.js":
  43428. /*!********************************************************!*\
  43429. !*** ./node_modules/vue-router/dist/vue-router.esm.js ***!
  43430. \********************************************************/
  43431. /*! exports provided: default */
  43432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43433. "use strict";
  43434. __webpack_require__.r(__webpack_exports__);
  43435. /*!
  43436. * vue-router v3.1.6
  43437. * (c) 2020 Evan You
  43438. * @license MIT
  43439. */
  43440. /* */
  43441. function assert (condition, message) {
  43442. if (!condition) {
  43443. throw new Error(("[vue-router] " + message))
  43444. }
  43445. }
  43446. function warn (condition, message) {
  43447. if ( true && !condition) {
  43448. typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
  43449. }
  43450. }
  43451. function isError (err) {
  43452. return Object.prototype.toString.call(err).indexOf('Error') > -1
  43453. }
  43454. function isExtendedError (constructor, err) {
  43455. return (
  43456. err instanceof constructor ||
  43457. // _name is to support IE9 too
  43458. (err && (err.name === constructor.name || err._name === constructor._name))
  43459. )
  43460. }
  43461. function extend (a, b) {
  43462. for (var key in b) {
  43463. a[key] = b[key];
  43464. }
  43465. return a
  43466. }
  43467. var View = {
  43468. name: 'RouterView',
  43469. functional: true,
  43470. props: {
  43471. name: {
  43472. type: String,
  43473. default: 'default'
  43474. }
  43475. },
  43476. render: function render (_, ref) {
  43477. var props = ref.props;
  43478. var children = ref.children;
  43479. var parent = ref.parent;
  43480. var data = ref.data;
  43481. // used by devtools to display a router-view badge
  43482. data.routerView = true;
  43483. // directly use parent context's createElement() function
  43484. // so that components rendered by router-view can resolve named slots
  43485. var h = parent.$createElement;
  43486. var name = props.name;
  43487. var route = parent.$route;
  43488. var cache = parent._routerViewCache || (parent._routerViewCache = {});
  43489. // determine current view depth, also check to see if the tree
  43490. // has been toggled inactive but kept-alive.
  43491. var depth = 0;
  43492. var inactive = false;
  43493. while (parent && parent._routerRoot !== parent) {
  43494. var vnodeData = parent.$vnode ? parent.$vnode.data : {};
  43495. if (vnodeData.routerView) {
  43496. depth++;
  43497. }
  43498. if (vnodeData.keepAlive && parent._directInactive && parent._inactive) {
  43499. inactive = true;
  43500. }
  43501. parent = parent.$parent;
  43502. }
  43503. data.routerViewDepth = depth;
  43504. // render previous view if the tree is inactive and kept-alive
  43505. if (inactive) {
  43506. var cachedData = cache[name];
  43507. var cachedComponent = cachedData && cachedData.component;
  43508. if (cachedComponent) {
  43509. // #2301
  43510. // pass props
  43511. if (cachedData.configProps) {
  43512. fillPropsinData(cachedComponent, data, cachedData.route, cachedData.configProps);
  43513. }
  43514. return h(cachedComponent, data, children)
  43515. } else {
  43516. // render previous empty view
  43517. return h()
  43518. }
  43519. }
  43520. var matched = route.matched[depth];
  43521. var component = matched && matched.components[name];
  43522. // render empty node if no matched route or no config component
  43523. if (!matched || !component) {
  43524. cache[name] = null;
  43525. return h()
  43526. }
  43527. // cache component
  43528. cache[name] = { component: component };
  43529. // attach instance registration hook
  43530. // this will be called in the instance's injected lifecycle hooks
  43531. data.registerRouteInstance = function (vm, val) {
  43532. // val could be undefined for unregistration
  43533. var current = matched.instances[name];
  43534. if (
  43535. (val && current !== vm) ||
  43536. (!val && current === vm)
  43537. ) {
  43538. matched.instances[name] = val;
  43539. }
  43540. }
  43541. // also register instance in prepatch hook
  43542. // in case the same component instance is reused across different routes
  43543. ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) {
  43544. matched.instances[name] = vnode.componentInstance;
  43545. };
  43546. // register instance in init hook
  43547. // in case kept-alive component be actived when routes changed
  43548. data.hook.init = function (vnode) {
  43549. if (vnode.data.keepAlive &&
  43550. vnode.componentInstance &&
  43551. vnode.componentInstance !== matched.instances[name]
  43552. ) {
  43553. matched.instances[name] = vnode.componentInstance;
  43554. }
  43555. };
  43556. var configProps = matched.props && matched.props[name];
  43557. // save route and configProps in cachce
  43558. if (configProps) {
  43559. extend(cache[name], {
  43560. route: route,
  43561. configProps: configProps
  43562. });
  43563. fillPropsinData(component, data, route, configProps);
  43564. }
  43565. return h(component, data, children)
  43566. }
  43567. };
  43568. function fillPropsinData (component, data, route, configProps) {
  43569. // resolve props
  43570. var propsToPass = data.props = resolveProps(route, configProps);
  43571. if (propsToPass) {
  43572. // clone to prevent mutation
  43573. propsToPass = data.props = extend({}, propsToPass);
  43574. // pass non-declared props as attrs
  43575. var attrs = data.attrs = data.attrs || {};
  43576. for (var key in propsToPass) {
  43577. if (!component.props || !(key in component.props)) {
  43578. attrs[key] = propsToPass[key];
  43579. delete propsToPass[key];
  43580. }
  43581. }
  43582. }
  43583. }
  43584. function resolveProps (route, config) {
  43585. switch (typeof config) {
  43586. case 'undefined':
  43587. return
  43588. case 'object':
  43589. return config
  43590. case 'function':
  43591. return config(route)
  43592. case 'boolean':
  43593. return config ? route.params : undefined
  43594. default:
  43595. if (true) {
  43596. warn(
  43597. false,
  43598. "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " +
  43599. "expecting an object, function or boolean."
  43600. );
  43601. }
  43602. }
  43603. }
  43604. /* */
  43605. var encodeReserveRE = /[!'()*]/g;
  43606. var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
  43607. var commaRE = /%2C/g;
  43608. // fixed encodeURIComponent which is more conformant to RFC3986:
  43609. // - escapes [!'()*]
  43610. // - preserve commas
  43611. var encode = function (str) { return encodeURIComponent(str)
  43612. .replace(encodeReserveRE, encodeReserveReplacer)
  43613. .replace(commaRE, ','); };
  43614. var decode = decodeURIComponent;
  43615. function resolveQuery (
  43616. query,
  43617. extraQuery,
  43618. _parseQuery
  43619. ) {
  43620. if ( extraQuery === void 0 ) extraQuery = {};
  43621. var parse = _parseQuery || parseQuery;
  43622. var parsedQuery;
  43623. try {
  43624. parsedQuery = parse(query || '');
  43625. } catch (e) {
  43626. true && warn(false, e.message);
  43627. parsedQuery = {};
  43628. }
  43629. for (var key in extraQuery) {
  43630. parsedQuery[key] = extraQuery[key];
  43631. }
  43632. return parsedQuery
  43633. }
  43634. function parseQuery (query) {
  43635. var res = {};
  43636. query = query.trim().replace(/^(\?|#|&)/, '');
  43637. if (!query) {
  43638. return res
  43639. }
  43640. query.split('&').forEach(function (param) {
  43641. var parts = param.replace(/\+/g, ' ').split('=');
  43642. var key = decode(parts.shift());
  43643. var val = parts.length > 0
  43644. ? decode(parts.join('='))
  43645. : null;
  43646. if (res[key] === undefined) {
  43647. res[key] = val;
  43648. } else if (Array.isArray(res[key])) {
  43649. res[key].push(val);
  43650. } else {
  43651. res[key] = [res[key], val];
  43652. }
  43653. });
  43654. return res
  43655. }
  43656. function stringifyQuery (obj) {
  43657. var res = obj ? Object.keys(obj).map(function (key) {
  43658. var val = obj[key];
  43659. if (val === undefined) {
  43660. return ''
  43661. }
  43662. if (val === null) {
  43663. return encode(key)
  43664. }
  43665. if (Array.isArray(val)) {
  43666. var result = [];
  43667. val.forEach(function (val2) {
  43668. if (val2 === undefined) {
  43669. return
  43670. }
  43671. if (val2 === null) {
  43672. result.push(encode(key));
  43673. } else {
  43674. result.push(encode(key) + '=' + encode(val2));
  43675. }
  43676. });
  43677. return result.join('&')
  43678. }
  43679. return encode(key) + '=' + encode(val)
  43680. }).filter(function (x) { return x.length > 0; }).join('&') : null;
  43681. return res ? ("?" + res) : ''
  43682. }
  43683. /* */
  43684. var trailingSlashRE = /\/?$/;
  43685. function createRoute (
  43686. record,
  43687. location,
  43688. redirectedFrom,
  43689. router
  43690. ) {
  43691. var stringifyQuery = router && router.options.stringifyQuery;
  43692. var query = location.query || {};
  43693. try {
  43694. query = clone(query);
  43695. } catch (e) {}
  43696. var route = {
  43697. name: location.name || (record && record.name),
  43698. meta: (record && record.meta) || {},
  43699. path: location.path || '/',
  43700. hash: location.hash || '',
  43701. query: query,
  43702. params: location.params || {},
  43703. fullPath: getFullPath(location, stringifyQuery),
  43704. matched: record ? formatMatch(record) : []
  43705. };
  43706. if (redirectedFrom) {
  43707. route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery);
  43708. }
  43709. return Object.freeze(route)
  43710. }
  43711. function clone (value) {
  43712. if (Array.isArray(value)) {
  43713. return value.map(clone)
  43714. } else if (value && typeof value === 'object') {
  43715. var res = {};
  43716. for (var key in value) {
  43717. res[key] = clone(value[key]);
  43718. }
  43719. return res
  43720. } else {
  43721. return value
  43722. }
  43723. }
  43724. // the starting route that represents the initial state
  43725. var START = createRoute(null, {
  43726. path: '/'
  43727. });
  43728. function formatMatch (record) {
  43729. var res = [];
  43730. while (record) {
  43731. res.unshift(record);
  43732. record = record.parent;
  43733. }
  43734. return res
  43735. }
  43736. function getFullPath (
  43737. ref,
  43738. _stringifyQuery
  43739. ) {
  43740. var path = ref.path;
  43741. var query = ref.query; if ( query === void 0 ) query = {};
  43742. var hash = ref.hash; if ( hash === void 0 ) hash = '';
  43743. var stringify = _stringifyQuery || stringifyQuery;
  43744. return (path || '/') + stringify(query) + hash
  43745. }
  43746. function isSameRoute (a, b) {
  43747. if (b === START) {
  43748. return a === b
  43749. } else if (!b) {
  43750. return false
  43751. } else if (a.path && b.path) {
  43752. return (
  43753. a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
  43754. a.hash === b.hash &&
  43755. isObjectEqual(a.query, b.query)
  43756. )
  43757. } else if (a.name && b.name) {
  43758. return (
  43759. a.name === b.name &&
  43760. a.hash === b.hash &&
  43761. isObjectEqual(a.query, b.query) &&
  43762. isObjectEqual(a.params, b.params)
  43763. )
  43764. } else {
  43765. return false
  43766. }
  43767. }
  43768. function isObjectEqual (a, b) {
  43769. if ( a === void 0 ) a = {};
  43770. if ( b === void 0 ) b = {};
  43771. // handle null value #1566
  43772. if (!a || !b) { return a === b }
  43773. var aKeys = Object.keys(a);
  43774. var bKeys = Object.keys(b);
  43775. if (aKeys.length !== bKeys.length) {
  43776. return false
  43777. }
  43778. return aKeys.every(function (key) {
  43779. var aVal = a[key];
  43780. var bVal = b[key];
  43781. // check nested equality
  43782. if (typeof aVal === 'object' && typeof bVal === 'object') {
  43783. return isObjectEqual(aVal, bVal)
  43784. }
  43785. return String(aVal) === String(bVal)
  43786. })
  43787. }
  43788. function isIncludedRoute (current, target) {
  43789. return (
  43790. current.path.replace(trailingSlashRE, '/').indexOf(
  43791. target.path.replace(trailingSlashRE, '/')
  43792. ) === 0 &&
  43793. (!target.hash || current.hash === target.hash) &&
  43794. queryIncludes(current.query, target.query)
  43795. )
  43796. }
  43797. function queryIncludes (current, target) {
  43798. for (var key in target) {
  43799. if (!(key in current)) {
  43800. return false
  43801. }
  43802. }
  43803. return true
  43804. }
  43805. /* */
  43806. function resolvePath (
  43807. relative,
  43808. base,
  43809. append
  43810. ) {
  43811. var firstChar = relative.charAt(0);
  43812. if (firstChar === '/') {
  43813. return relative
  43814. }
  43815. if (firstChar === '?' || firstChar === '#') {
  43816. return base + relative
  43817. }
  43818. var stack = base.split('/');
  43819. // remove trailing segment if:
  43820. // - not appending
  43821. // - appending to trailing slash (last segment is empty)
  43822. if (!append || !stack[stack.length - 1]) {
  43823. stack.pop();
  43824. }
  43825. // resolve relative path
  43826. var segments = relative.replace(/^\//, '').split('/');
  43827. for (var i = 0; i < segments.length; i++) {
  43828. var segment = segments[i];
  43829. if (segment === '..') {
  43830. stack.pop();
  43831. } else if (segment !== '.') {
  43832. stack.push(segment);
  43833. }
  43834. }
  43835. // ensure leading slash
  43836. if (stack[0] !== '') {
  43837. stack.unshift('');
  43838. }
  43839. return stack.join('/')
  43840. }
  43841. function parsePath (path) {
  43842. var hash = '';
  43843. var query = '';
  43844. var hashIndex = path.indexOf('#');
  43845. if (hashIndex >= 0) {
  43846. hash = path.slice(hashIndex);
  43847. path = path.slice(0, hashIndex);
  43848. }
  43849. var queryIndex = path.indexOf('?');
  43850. if (queryIndex >= 0) {
  43851. query = path.slice(queryIndex + 1);
  43852. path = path.slice(0, queryIndex);
  43853. }
  43854. return {
  43855. path: path,
  43856. query: query,
  43857. hash: hash
  43858. }
  43859. }
  43860. function cleanPath (path) {
  43861. return path.replace(/\/\//g, '/')
  43862. }
  43863. var isarray = Array.isArray || function (arr) {
  43864. return Object.prototype.toString.call(arr) == '[object Array]';
  43865. };
  43866. /**
  43867. * Expose `pathToRegexp`.
  43868. */
  43869. var pathToRegexp_1 = pathToRegexp;
  43870. var parse_1 = parse;
  43871. var compile_1 = compile;
  43872. var tokensToFunction_1 = tokensToFunction;
  43873. var tokensToRegExp_1 = tokensToRegExp;
  43874. /**
  43875. * The main path matching regexp utility.
  43876. *
  43877. * @type {RegExp}
  43878. */
  43879. var PATH_REGEXP = new RegExp([
  43880. // Match escaped characters that would otherwise appear in future matches.
  43881. // This allows the user to escape special characters that won't transform.
  43882. '(\\\\.)',
  43883. // Match Express-style parameters and un-named parameters with a prefix
  43884. // and optional suffixes. Matches appear as:
  43885. //
  43886. // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
  43887. // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
  43888. // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
  43889. '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
  43890. ].join('|'), 'g');
  43891. /**
  43892. * Parse a string for the raw tokens.
  43893. *
  43894. * @param {string} str
  43895. * @param {Object=} options
  43896. * @return {!Array}
  43897. */
  43898. function parse (str, options) {
  43899. var tokens = [];
  43900. var key = 0;
  43901. var index = 0;
  43902. var path = '';
  43903. var defaultDelimiter = options && options.delimiter || '/';
  43904. var res;
  43905. while ((res = PATH_REGEXP.exec(str)) != null) {
  43906. var m = res[0];
  43907. var escaped = res[1];
  43908. var offset = res.index;
  43909. path += str.slice(index, offset);
  43910. index = offset + m.length;
  43911. // Ignore already escaped sequences.
  43912. if (escaped) {
  43913. path += escaped[1];
  43914. continue
  43915. }
  43916. var next = str[index];
  43917. var prefix = res[2];
  43918. var name = res[3];
  43919. var capture = res[4];
  43920. var group = res[5];
  43921. var modifier = res[6];
  43922. var asterisk = res[7];
  43923. // Push the current path onto the tokens.
  43924. if (path) {
  43925. tokens.push(path);
  43926. path = '';
  43927. }
  43928. var partial = prefix != null && next != null && next !== prefix;
  43929. var repeat = modifier === '+' || modifier === '*';
  43930. var optional = modifier === '?' || modifier === '*';
  43931. var delimiter = res[2] || defaultDelimiter;
  43932. var pattern = capture || group;
  43933. tokens.push({
  43934. name: name || key++,
  43935. prefix: prefix || '',
  43936. delimiter: delimiter,
  43937. optional: optional,
  43938. repeat: repeat,
  43939. partial: partial,
  43940. asterisk: !!asterisk,
  43941. pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
  43942. });
  43943. }
  43944. // Match any characters still remaining.
  43945. if (index < str.length) {
  43946. path += str.substr(index);
  43947. }
  43948. // If the path exists, push it onto the end.
  43949. if (path) {
  43950. tokens.push(path);
  43951. }
  43952. return tokens
  43953. }
  43954. /**
  43955. * Compile a string to a template function for the path.
  43956. *
  43957. * @param {string} str
  43958. * @param {Object=} options
  43959. * @return {!function(Object=, Object=)}
  43960. */
  43961. function compile (str, options) {
  43962. return tokensToFunction(parse(str, options))
  43963. }
  43964. /**
  43965. * Prettier encoding of URI path segments.
  43966. *
  43967. * @param {string}
  43968. * @return {string}
  43969. */
  43970. function encodeURIComponentPretty (str) {
  43971. return encodeURI(str).replace(/[\/?#]/g, function (c) {
  43972. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  43973. })
  43974. }
  43975. /**
  43976. * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
  43977. *
  43978. * @param {string}
  43979. * @return {string}
  43980. */
  43981. function encodeAsterisk (str) {
  43982. return encodeURI(str).replace(/[?#]/g, function (c) {
  43983. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  43984. })
  43985. }
  43986. /**
  43987. * Expose a method for transforming tokens into the path function.
  43988. */
  43989. function tokensToFunction (tokens) {
  43990. // Compile all the tokens into regexps.
  43991. var matches = new Array(tokens.length);
  43992. // Compile all the patterns before compilation.
  43993. for (var i = 0; i < tokens.length; i++) {
  43994. if (typeof tokens[i] === 'object') {
  43995. matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
  43996. }
  43997. }
  43998. return function (obj, opts) {
  43999. var path = '';
  44000. var data = obj || {};
  44001. var options = opts || {};
  44002. var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
  44003. for (var i = 0; i < tokens.length; i++) {
  44004. var token = tokens[i];
  44005. if (typeof token === 'string') {
  44006. path += token;
  44007. continue
  44008. }
  44009. var value = data[token.name];
  44010. var segment;
  44011. if (value == null) {
  44012. if (token.optional) {
  44013. // Prepend partial segment prefixes.
  44014. if (token.partial) {
  44015. path += token.prefix;
  44016. }
  44017. continue
  44018. } else {
  44019. throw new TypeError('Expected "' + token.name + '" to be defined')
  44020. }
  44021. }
  44022. if (isarray(value)) {
  44023. if (!token.repeat) {
  44024. throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
  44025. }
  44026. if (value.length === 0) {
  44027. if (token.optional) {
  44028. continue
  44029. } else {
  44030. throw new TypeError('Expected "' + token.name + '" to not be empty')
  44031. }
  44032. }
  44033. for (var j = 0; j < value.length; j++) {
  44034. segment = encode(value[j]);
  44035. if (!matches[i].test(segment)) {
  44036. throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
  44037. }
  44038. path += (j === 0 ? token.prefix : token.delimiter) + segment;
  44039. }
  44040. continue
  44041. }
  44042. segment = token.asterisk ? encodeAsterisk(value) : encode(value);
  44043. if (!matches[i].test(segment)) {
  44044. throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
  44045. }
  44046. path += token.prefix + segment;
  44047. }
  44048. return path
  44049. }
  44050. }
  44051. /**
  44052. * Escape a regular expression string.
  44053. *
  44054. * @param {string} str
  44055. * @return {string}
  44056. */
  44057. function escapeString (str) {
  44058. return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
  44059. }
  44060. /**
  44061. * Escape the capturing group by escaping special characters and meaning.
  44062. *
  44063. * @param {string} group
  44064. * @return {string}
  44065. */
  44066. function escapeGroup (group) {
  44067. return group.replace(/([=!:$\/()])/g, '\\$1')
  44068. }
  44069. /**
  44070. * Attach the keys as a property of the regexp.
  44071. *
  44072. * @param {!RegExp} re
  44073. * @param {Array} keys
  44074. * @return {!RegExp}
  44075. */
  44076. function attachKeys (re, keys) {
  44077. re.keys = keys;
  44078. return re
  44079. }
  44080. /**
  44081. * Get the flags for a regexp from the options.
  44082. *
  44083. * @param {Object} options
  44084. * @return {string}
  44085. */
  44086. function flags (options) {
  44087. return options.sensitive ? '' : 'i'
  44088. }
  44089. /**
  44090. * Pull out keys from a regexp.
  44091. *
  44092. * @param {!RegExp} path
  44093. * @param {!Array} keys
  44094. * @return {!RegExp}
  44095. */
  44096. function regexpToRegexp (path, keys) {
  44097. // Use a negative lookahead to match only capturing groups.
  44098. var groups = path.source.match(/\((?!\?)/g);
  44099. if (groups) {
  44100. for (var i = 0; i < groups.length; i++) {
  44101. keys.push({
  44102. name: i,
  44103. prefix: null,
  44104. delimiter: null,
  44105. optional: false,
  44106. repeat: false,
  44107. partial: false,
  44108. asterisk: false,
  44109. pattern: null
  44110. });
  44111. }
  44112. }
  44113. return attachKeys(path, keys)
  44114. }
  44115. /**
  44116. * Transform an array into a regexp.
  44117. *
  44118. * @param {!Array} path
  44119. * @param {Array} keys
  44120. * @param {!Object} options
  44121. * @return {!RegExp}
  44122. */
  44123. function arrayToRegexp (path, keys, options) {
  44124. var parts = [];
  44125. for (var i = 0; i < path.length; i++) {
  44126. parts.push(pathToRegexp(path[i], keys, options).source);
  44127. }
  44128. var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
  44129. return attachKeys(regexp, keys)
  44130. }
  44131. /**
  44132. * Create a path regexp from string input.
  44133. *
  44134. * @param {string} path
  44135. * @param {!Array} keys
  44136. * @param {!Object} options
  44137. * @return {!RegExp}
  44138. */
  44139. function stringToRegexp (path, keys, options) {
  44140. return tokensToRegExp(parse(path, options), keys, options)
  44141. }
  44142. /**
  44143. * Expose a function for taking tokens and returning a RegExp.
  44144. *
  44145. * @param {!Array} tokens
  44146. * @param {(Array|Object)=} keys
  44147. * @param {Object=} options
  44148. * @return {!RegExp}
  44149. */
  44150. function tokensToRegExp (tokens, keys, options) {
  44151. if (!isarray(keys)) {
  44152. options = /** @type {!Object} */ (keys || options);
  44153. keys = [];
  44154. }
  44155. options = options || {};
  44156. var strict = options.strict;
  44157. var end = options.end !== false;
  44158. var route = '';
  44159. // Iterate over the tokens and create our regexp string.
  44160. for (var i = 0; i < tokens.length; i++) {
  44161. var token = tokens[i];
  44162. if (typeof token === 'string') {
  44163. route += escapeString(token);
  44164. } else {
  44165. var prefix = escapeString(token.prefix);
  44166. var capture = '(?:' + token.pattern + ')';
  44167. keys.push(token);
  44168. if (token.repeat) {
  44169. capture += '(?:' + prefix + capture + ')*';
  44170. }
  44171. if (token.optional) {
  44172. if (!token.partial) {
  44173. capture = '(?:' + prefix + '(' + capture + '))?';
  44174. } else {
  44175. capture = prefix + '(' + capture + ')?';
  44176. }
  44177. } else {
  44178. capture = prefix + '(' + capture + ')';
  44179. }
  44180. route += capture;
  44181. }
  44182. }
  44183. var delimiter = escapeString(options.delimiter || '/');
  44184. var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
  44185. // In non-strict mode we allow a slash at the end of match. If the path to
  44186. // match already ends with a slash, we remove it for consistency. The slash
  44187. // is valid at the end of a path match, not in the middle. This is important
  44188. // in non-ending mode, where "/test/" shouldn't match "/test//route".
  44189. if (!strict) {
  44190. route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
  44191. }
  44192. if (end) {
  44193. route += '$';
  44194. } else {
  44195. // In non-ending mode, we need the capturing groups to match as much as
  44196. // possible by using a positive lookahead to the end or next path segment.
  44197. route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
  44198. }
  44199. return attachKeys(new RegExp('^' + route, flags(options)), keys)
  44200. }
  44201. /**
  44202. * Normalize the given path string, returning a regular expression.
  44203. *
  44204. * An empty array can be passed in for the keys, which will hold the
  44205. * placeholder key descriptions. For example, using `/user/:id`, `keys` will
  44206. * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
  44207. *
  44208. * @param {(string|RegExp|Array)} path
  44209. * @param {(Array|Object)=} keys
  44210. * @param {Object=} options
  44211. * @return {!RegExp}
  44212. */
  44213. function pathToRegexp (path, keys, options) {
  44214. if (!isarray(keys)) {
  44215. options = /** @type {!Object} */ (keys || options);
  44216. keys = [];
  44217. }
  44218. options = options || {};
  44219. if (path instanceof RegExp) {
  44220. return regexpToRegexp(path, /** @type {!Array} */ (keys))
  44221. }
  44222. if (isarray(path)) {
  44223. return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
  44224. }
  44225. return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
  44226. }
  44227. pathToRegexp_1.parse = parse_1;
  44228. pathToRegexp_1.compile = compile_1;
  44229. pathToRegexp_1.tokensToFunction = tokensToFunction_1;
  44230. pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
  44231. /* */
  44232. // $flow-disable-line
  44233. var regexpCompileCache = Object.create(null);
  44234. function fillParams (
  44235. path,
  44236. params,
  44237. routeMsg
  44238. ) {
  44239. params = params || {};
  44240. try {
  44241. var filler =
  44242. regexpCompileCache[path] ||
  44243. (regexpCompileCache[path] = pathToRegexp_1.compile(path));
  44244. // Fix #2505 resolving asterisk routes { name: 'not-found', params: { pathMatch: '/not-found' }}
  44245. // and fix #3106 so that you can work with location descriptor object having params.pathMatch equal to empty string
  44246. if (typeof params.pathMatch === 'string') { params[0] = params.pathMatch; }
  44247. return filler(params, { pretty: true })
  44248. } catch (e) {
  44249. if (true) {
  44250. // Fix #3072 no warn if `pathMatch` is string
  44251. warn(typeof params.pathMatch === 'string', ("missing param for " + routeMsg + ": " + (e.message)));
  44252. }
  44253. return ''
  44254. } finally {
  44255. // delete the 0 if it was added
  44256. delete params[0];
  44257. }
  44258. }
  44259. /* */
  44260. function normalizeLocation (
  44261. raw,
  44262. current,
  44263. append,
  44264. router
  44265. ) {
  44266. var next = typeof raw === 'string' ? { path: raw } : raw;
  44267. // named target
  44268. if (next._normalized) {
  44269. return next
  44270. } else if (next.name) {
  44271. next = extend({}, raw);
  44272. var params = next.params;
  44273. if (params && typeof params === 'object') {
  44274. next.params = extend({}, params);
  44275. }
  44276. return next
  44277. }
  44278. // relative params
  44279. if (!next.path && next.params && current) {
  44280. next = extend({}, next);
  44281. next._normalized = true;
  44282. var params$1 = extend(extend({}, current.params), next.params);
  44283. if (current.name) {
  44284. next.name = current.name;
  44285. next.params = params$1;
  44286. } else if (current.matched.length) {
  44287. var rawPath = current.matched[current.matched.length - 1].path;
  44288. next.path = fillParams(rawPath, params$1, ("path " + (current.path)));
  44289. } else if (true) {
  44290. warn(false, "relative params navigation requires a current route.");
  44291. }
  44292. return next
  44293. }
  44294. var parsedPath = parsePath(next.path || '');
  44295. var basePath = (current && current.path) || '/';
  44296. var path = parsedPath.path
  44297. ? resolvePath(parsedPath.path, basePath, append || next.append)
  44298. : basePath;
  44299. var query = resolveQuery(
  44300. parsedPath.query,
  44301. next.query,
  44302. router && router.options.parseQuery
  44303. );
  44304. var hash = next.hash || parsedPath.hash;
  44305. if (hash && hash.charAt(0) !== '#') {
  44306. hash = "#" + hash;
  44307. }
  44308. return {
  44309. _normalized: true,
  44310. path: path,
  44311. query: query,
  44312. hash: hash
  44313. }
  44314. }
  44315. /* */
  44316. // work around weird flow bug
  44317. var toTypes = [String, Object];
  44318. var eventTypes = [String, Array];
  44319. var noop = function () {};
  44320. var Link = {
  44321. name: 'RouterLink',
  44322. props: {
  44323. to: {
  44324. type: toTypes,
  44325. required: true
  44326. },
  44327. tag: {
  44328. type: String,
  44329. default: 'a'
  44330. },
  44331. exact: Boolean,
  44332. append: Boolean,
  44333. replace: Boolean,
  44334. activeClass: String,
  44335. exactActiveClass: String,
  44336. event: {
  44337. type: eventTypes,
  44338. default: 'click'
  44339. }
  44340. },
  44341. render: function render (h) {
  44342. var this$1 = this;
  44343. var router = this.$router;
  44344. var current = this.$route;
  44345. var ref = router.resolve(
  44346. this.to,
  44347. current,
  44348. this.append
  44349. );
  44350. var location = ref.location;
  44351. var route = ref.route;
  44352. var href = ref.href;
  44353. var classes = {};
  44354. var globalActiveClass = router.options.linkActiveClass;
  44355. var globalExactActiveClass = router.options.linkExactActiveClass;
  44356. // Support global empty active class
  44357. var activeClassFallback =
  44358. globalActiveClass == null ? 'router-link-active' : globalActiveClass;
  44359. var exactActiveClassFallback =
  44360. globalExactActiveClass == null
  44361. ? 'router-link-exact-active'
  44362. : globalExactActiveClass;
  44363. var activeClass =
  44364. this.activeClass == null ? activeClassFallback : this.activeClass;
  44365. var exactActiveClass =
  44366. this.exactActiveClass == null
  44367. ? exactActiveClassFallback
  44368. : this.exactActiveClass;
  44369. var compareTarget = route.redirectedFrom
  44370. ? createRoute(null, normalizeLocation(route.redirectedFrom), null, router)
  44371. : route;
  44372. classes[exactActiveClass] = isSameRoute(current, compareTarget);
  44373. classes[activeClass] = this.exact
  44374. ? classes[exactActiveClass]
  44375. : isIncludedRoute(current, compareTarget);
  44376. var handler = function (e) {
  44377. if (guardEvent(e)) {
  44378. if (this$1.replace) {
  44379. router.replace(location, noop);
  44380. } else {
  44381. router.push(location, noop);
  44382. }
  44383. }
  44384. };
  44385. var on = { click: guardEvent };
  44386. if (Array.isArray(this.event)) {
  44387. this.event.forEach(function (e) {
  44388. on[e] = handler;
  44389. });
  44390. } else {
  44391. on[this.event] = handler;
  44392. }
  44393. var data = { class: classes };
  44394. var scopedSlot =
  44395. !this.$scopedSlots.$hasNormal &&
  44396. this.$scopedSlots.default &&
  44397. this.$scopedSlots.default({
  44398. href: href,
  44399. route: route,
  44400. navigate: handler,
  44401. isActive: classes[activeClass],
  44402. isExactActive: classes[exactActiveClass]
  44403. });
  44404. if (scopedSlot) {
  44405. if (scopedSlot.length === 1) {
  44406. return scopedSlot[0]
  44407. } else if (scopedSlot.length > 1 || !scopedSlot.length) {
  44408. if (true) {
  44409. warn(
  44410. false,
  44411. ("RouterLink with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.")
  44412. );
  44413. }
  44414. return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot)
  44415. }
  44416. }
  44417. if (this.tag === 'a') {
  44418. data.on = on;
  44419. data.attrs = { href: href };
  44420. } else {
  44421. // find the first <a> child and apply listener and href
  44422. var a = findAnchor(this.$slots.default);
  44423. if (a) {
  44424. // in case the <a> is a static node
  44425. a.isStatic = false;
  44426. var aData = (a.data = extend({}, a.data));
  44427. aData.on = aData.on || {};
  44428. // transform existing events in both objects into arrays so we can push later
  44429. for (var event in aData.on) {
  44430. var handler$1 = aData.on[event];
  44431. if (event in on) {
  44432. aData.on[event] = Array.isArray(handler$1) ? handler$1 : [handler$1];
  44433. }
  44434. }
  44435. // append new listeners for router-link
  44436. for (var event$1 in on) {
  44437. if (event$1 in aData.on) {
  44438. // on[event] is always a function
  44439. aData.on[event$1].push(on[event$1]);
  44440. } else {
  44441. aData.on[event$1] = handler;
  44442. }
  44443. }
  44444. var aAttrs = (a.data.attrs = extend({}, a.data.attrs));
  44445. aAttrs.href = href;
  44446. } else {
  44447. // doesn't have <a> child, apply listener to self
  44448. data.on = on;
  44449. }
  44450. }
  44451. return h(this.tag, data, this.$slots.default)
  44452. }
  44453. };
  44454. function guardEvent (e) {
  44455. // don't redirect with control keys
  44456. if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return }
  44457. // don't redirect when preventDefault called
  44458. if (e.defaultPrevented) { return }
  44459. // don't redirect on right click
  44460. if (e.button !== undefined && e.button !== 0) { return }
  44461. // don't redirect if `target="_blank"`
  44462. if (e.currentTarget && e.currentTarget.getAttribute) {
  44463. var target = e.currentTarget.getAttribute('target');
  44464. if (/\b_blank\b/i.test(target)) { return }
  44465. }
  44466. // this may be a Weex event which doesn't have this method
  44467. if (e.preventDefault) {
  44468. e.preventDefault();
  44469. }
  44470. return true
  44471. }
  44472. function findAnchor (children) {
  44473. if (children) {
  44474. var child;
  44475. for (var i = 0; i < children.length; i++) {
  44476. child = children[i];
  44477. if (child.tag === 'a') {
  44478. return child
  44479. }
  44480. if (child.children && (child = findAnchor(child.children))) {
  44481. return child
  44482. }
  44483. }
  44484. }
  44485. }
  44486. var _Vue;
  44487. function install (Vue) {
  44488. if (install.installed && _Vue === Vue) { return }
  44489. install.installed = true;
  44490. _Vue = Vue;
  44491. var isDef = function (v) { return v !== undefined; };
  44492. var registerInstance = function (vm, callVal) {
  44493. var i = vm.$options._parentVnode;
  44494. if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {
  44495. i(vm, callVal);
  44496. }
  44497. };
  44498. Vue.mixin({
  44499. beforeCreate: function beforeCreate () {
  44500. if (isDef(this.$options.router)) {
  44501. this._routerRoot = this;
  44502. this._router = this.$options.router;
  44503. this._router.init(this);
  44504. Vue.util.defineReactive(this, '_route', this._router.history.current);
  44505. } else {
  44506. this._routerRoot = (this.$parent && this.$parent._routerRoot) || this;
  44507. }
  44508. registerInstance(this, this);
  44509. },
  44510. destroyed: function destroyed () {
  44511. registerInstance(this);
  44512. }
  44513. });
  44514. Object.defineProperty(Vue.prototype, '$router', {
  44515. get: function get () { return this._routerRoot._router }
  44516. });
  44517. Object.defineProperty(Vue.prototype, '$route', {
  44518. get: function get () { return this._routerRoot._route }
  44519. });
  44520. Vue.component('RouterView', View);
  44521. Vue.component('RouterLink', Link);
  44522. var strats = Vue.config.optionMergeStrategies;
  44523. // use the same hook merging strategy for route hooks
  44524. strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created;
  44525. }
  44526. /* */
  44527. var inBrowser = typeof window !== 'undefined';
  44528. /* */
  44529. function createRouteMap (
  44530. routes,
  44531. oldPathList,
  44532. oldPathMap,
  44533. oldNameMap
  44534. ) {
  44535. // the path list is used to control path matching priority
  44536. var pathList = oldPathList || [];
  44537. // $flow-disable-line
  44538. var pathMap = oldPathMap || Object.create(null);
  44539. // $flow-disable-line
  44540. var nameMap = oldNameMap || Object.create(null);
  44541. routes.forEach(function (route) {
  44542. addRouteRecord(pathList, pathMap, nameMap, route);
  44543. });
  44544. // ensure wildcard routes are always at the end
  44545. for (var i = 0, l = pathList.length; i < l; i++) {
  44546. if (pathList[i] === '*') {
  44547. pathList.push(pathList.splice(i, 1)[0]);
  44548. l--;
  44549. i--;
  44550. }
  44551. }
  44552. if (true) {
  44553. // warn if routes do not include leading slashes
  44554. var found = pathList
  44555. // check for missing leading slash
  44556. .filter(function (path) { return path && path.charAt(0) !== '*' && path.charAt(0) !== '/'; });
  44557. if (found.length > 0) {
  44558. var pathNames = found.map(function (path) { return ("- " + path); }).join('\n');
  44559. warn(false, ("Non-nested routes must include a leading slash character. Fix the following routes: \n" + pathNames));
  44560. }
  44561. }
  44562. return {
  44563. pathList: pathList,
  44564. pathMap: pathMap,
  44565. nameMap: nameMap
  44566. }
  44567. }
  44568. function addRouteRecord (
  44569. pathList,
  44570. pathMap,
  44571. nameMap,
  44572. route,
  44573. parent,
  44574. matchAs
  44575. ) {
  44576. var path = route.path;
  44577. var name = route.name;
  44578. if (true) {
  44579. assert(path != null, "\"path\" is required in a route configuration.");
  44580. assert(
  44581. typeof route.component !== 'string',
  44582. "route config \"component\" for path: " + (String(
  44583. path || name
  44584. )) + " cannot be a " + "string id. Use an actual component instead."
  44585. );
  44586. }
  44587. var pathToRegexpOptions =
  44588. route.pathToRegexpOptions || {};
  44589. var normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict);
  44590. if (typeof route.caseSensitive === 'boolean') {
  44591. pathToRegexpOptions.sensitive = route.caseSensitive;
  44592. }
  44593. var record = {
  44594. path: normalizedPath,
  44595. regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
  44596. components: route.components || { default: route.component },
  44597. instances: {},
  44598. name: name,
  44599. parent: parent,
  44600. matchAs: matchAs,
  44601. redirect: route.redirect,
  44602. beforeEnter: route.beforeEnter,
  44603. meta: route.meta || {},
  44604. props:
  44605. route.props == null
  44606. ? {}
  44607. : route.components
  44608. ? route.props
  44609. : { default: route.props }
  44610. };
  44611. if (route.children) {
  44612. // Warn if route is named, does not redirect and has a default child route.
  44613. // If users navigate to this route by name, the default child will
  44614. // not be rendered (GH Issue #629)
  44615. if (true) {
  44616. if (
  44617. route.name &&
  44618. !route.redirect &&
  44619. route.children.some(function (child) { return /^\/?$/.test(child.path); })
  44620. ) {
  44621. warn(
  44622. false,
  44623. "Named Route '" + (route.name) + "' has a default child route. " +
  44624. "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
  44625. "the default child route will not be rendered. Remove the name from " +
  44626. "this route and use the name of the default child route for named " +
  44627. "links instead."
  44628. );
  44629. }
  44630. }
  44631. route.children.forEach(function (child) {
  44632. var childMatchAs = matchAs
  44633. ? cleanPath((matchAs + "/" + (child.path)))
  44634. : undefined;
  44635. addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs);
  44636. });
  44637. }
  44638. if (!pathMap[record.path]) {
  44639. pathList.push(record.path);
  44640. pathMap[record.path] = record;
  44641. }
  44642. if (route.alias !== undefined) {
  44643. var aliases = Array.isArray(route.alias) ? route.alias : [route.alias];
  44644. for (var i = 0; i < aliases.length; ++i) {
  44645. var alias = aliases[i];
  44646. if ( true && alias === path) {
  44647. warn(
  44648. false,
  44649. ("Found an alias with the same value as the path: \"" + path + "\". You have to remove that alias. It will be ignored in development.")
  44650. );
  44651. // skip in dev to make it work
  44652. continue
  44653. }
  44654. var aliasRoute = {
  44655. path: alias,
  44656. children: route.children
  44657. };
  44658. addRouteRecord(
  44659. pathList,
  44660. pathMap,
  44661. nameMap,
  44662. aliasRoute,
  44663. parent,
  44664. record.path || '/' // matchAs
  44665. );
  44666. }
  44667. }
  44668. if (name) {
  44669. if (!nameMap[name]) {
  44670. nameMap[name] = record;
  44671. } else if ( true && !matchAs) {
  44672. warn(
  44673. false,
  44674. "Duplicate named routes definition: " +
  44675. "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
  44676. );
  44677. }
  44678. }
  44679. }
  44680. function compileRouteRegex (
  44681. path,
  44682. pathToRegexpOptions
  44683. ) {
  44684. var regex = pathToRegexp_1(path, [], pathToRegexpOptions);
  44685. if (true) {
  44686. var keys = Object.create(null);
  44687. regex.keys.forEach(function (key) {
  44688. warn(
  44689. !keys[key.name],
  44690. ("Duplicate param keys in route with path: \"" + path + "\"")
  44691. );
  44692. keys[key.name] = true;
  44693. });
  44694. }
  44695. return regex
  44696. }
  44697. function normalizePath (
  44698. path,
  44699. parent,
  44700. strict
  44701. ) {
  44702. if (!strict) { path = path.replace(/\/$/, ''); }
  44703. if (path[0] === '/') { return path }
  44704. if (parent == null) { return path }
  44705. return cleanPath(((parent.path) + "/" + path))
  44706. }
  44707. /* */
  44708. function createMatcher (
  44709. routes,
  44710. router
  44711. ) {
  44712. var ref = createRouteMap(routes);
  44713. var pathList = ref.pathList;
  44714. var pathMap = ref.pathMap;
  44715. var nameMap = ref.nameMap;
  44716. function addRoutes (routes) {
  44717. createRouteMap(routes, pathList, pathMap, nameMap);
  44718. }
  44719. function match (
  44720. raw,
  44721. currentRoute,
  44722. redirectedFrom
  44723. ) {
  44724. var location = normalizeLocation(raw, currentRoute, false, router);
  44725. var name = location.name;
  44726. if (name) {
  44727. var record = nameMap[name];
  44728. if (true) {
  44729. warn(record, ("Route with name '" + name + "' does not exist"));
  44730. }
  44731. if (!record) { return _createRoute(null, location) }
  44732. var paramNames = record.regex.keys
  44733. .filter(function (key) { return !key.optional; })
  44734. .map(function (key) { return key.name; });
  44735. if (typeof location.params !== 'object') {
  44736. location.params = {};
  44737. }
  44738. if (currentRoute && typeof currentRoute.params === 'object') {
  44739. for (var key in currentRoute.params) {
  44740. if (!(key in location.params) && paramNames.indexOf(key) > -1) {
  44741. location.params[key] = currentRoute.params[key];
  44742. }
  44743. }
  44744. }
  44745. location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""));
  44746. return _createRoute(record, location, redirectedFrom)
  44747. } else if (location.path) {
  44748. location.params = {};
  44749. for (var i = 0; i < pathList.length; i++) {
  44750. var path = pathList[i];
  44751. var record$1 = pathMap[path];
  44752. if (matchRoute(record$1.regex, location.path, location.params)) {
  44753. return _createRoute(record$1, location, redirectedFrom)
  44754. }
  44755. }
  44756. }
  44757. // no match
  44758. return _createRoute(null, location)
  44759. }
  44760. function redirect (
  44761. record,
  44762. location
  44763. ) {
  44764. var originalRedirect = record.redirect;
  44765. var redirect = typeof originalRedirect === 'function'
  44766. ? originalRedirect(createRoute(record, location, null, router))
  44767. : originalRedirect;
  44768. if (typeof redirect === 'string') {
  44769. redirect = { path: redirect };
  44770. }
  44771. if (!redirect || typeof redirect !== 'object') {
  44772. if (true) {
  44773. warn(
  44774. false, ("invalid redirect option: " + (JSON.stringify(redirect)))
  44775. );
  44776. }
  44777. return _createRoute(null, location)
  44778. }
  44779. var re = redirect;
  44780. var name = re.name;
  44781. var path = re.path;
  44782. var query = location.query;
  44783. var hash = location.hash;
  44784. var params = location.params;
  44785. query = re.hasOwnProperty('query') ? re.query : query;
  44786. hash = re.hasOwnProperty('hash') ? re.hash : hash;
  44787. params = re.hasOwnProperty('params') ? re.params : params;
  44788. if (name) {
  44789. // resolved named direct
  44790. var targetRecord = nameMap[name];
  44791. if (true) {
  44792. assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."));
  44793. }
  44794. return match({
  44795. _normalized: true,
  44796. name: name,
  44797. query: query,
  44798. hash: hash,
  44799. params: params
  44800. }, undefined, location)
  44801. } else if (path) {
  44802. // 1. resolve relative redirect
  44803. var rawPath = resolveRecordPath(path, record);
  44804. // 2. resolve params
  44805. var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""));
  44806. // 3. rematch with existing query and hash
  44807. return match({
  44808. _normalized: true,
  44809. path: resolvedPath,
  44810. query: query,
  44811. hash: hash
  44812. }, undefined, location)
  44813. } else {
  44814. if (true) {
  44815. warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
  44816. }
  44817. return _createRoute(null, location)
  44818. }
  44819. }
  44820. function alias (
  44821. record,
  44822. location,
  44823. matchAs
  44824. ) {
  44825. var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""));
  44826. var aliasedMatch = match({
  44827. _normalized: true,
  44828. path: aliasedPath
  44829. });
  44830. if (aliasedMatch) {
  44831. var matched = aliasedMatch.matched;
  44832. var aliasedRecord = matched[matched.length - 1];
  44833. location.params = aliasedMatch.params;
  44834. return _createRoute(aliasedRecord, location)
  44835. }
  44836. return _createRoute(null, location)
  44837. }
  44838. function _createRoute (
  44839. record,
  44840. location,
  44841. redirectedFrom
  44842. ) {
  44843. if (record && record.redirect) {
  44844. return redirect(record, redirectedFrom || location)
  44845. }
  44846. if (record && record.matchAs) {
  44847. return alias(record, location, record.matchAs)
  44848. }
  44849. return createRoute(record, location, redirectedFrom, router)
  44850. }
  44851. return {
  44852. match: match,
  44853. addRoutes: addRoutes
  44854. }
  44855. }
  44856. function matchRoute (
  44857. regex,
  44858. path,
  44859. params
  44860. ) {
  44861. var m = path.match(regex);
  44862. if (!m) {
  44863. return false
  44864. } else if (!params) {
  44865. return true
  44866. }
  44867. for (var i = 1, len = m.length; i < len; ++i) {
  44868. var key = regex.keys[i - 1];
  44869. var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
  44870. if (key) {
  44871. // Fix #1994: using * with props: true generates a param named 0
  44872. params[key.name || 'pathMatch'] = val;
  44873. }
  44874. }
  44875. return true
  44876. }
  44877. function resolveRecordPath (path, record) {
  44878. return resolvePath(path, record.parent ? record.parent.path : '/', true)
  44879. }
  44880. /* */
  44881. // use User Timing api (if present) for more accurate key precision
  44882. var Time =
  44883. inBrowser && window.performance && window.performance.now
  44884. ? window.performance
  44885. : Date;
  44886. function genStateKey () {
  44887. return Time.now().toFixed(3)
  44888. }
  44889. var _key = genStateKey();
  44890. function getStateKey () {
  44891. return _key
  44892. }
  44893. function setStateKey (key) {
  44894. return (_key = key)
  44895. }
  44896. /* */
  44897. var positionStore = Object.create(null);
  44898. function setupScroll () {
  44899. // Fix for #1585 for Firefox
  44900. // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
  44901. // Fix for #2774 Support for apps loaded from Windows file shares not mapped to network drives: replaced location.origin with
  44902. // window.location.protocol + '//' + window.location.host
  44903. // location.host contains the port and location.hostname doesn't
  44904. var protocolAndPath = window.location.protocol + '//' + window.location.host;
  44905. var absolutePath = window.location.href.replace(protocolAndPath, '');
  44906. // preserve existing history state as it could be overriden by the user
  44907. var stateCopy = extend({}, window.history.state);
  44908. stateCopy.key = getStateKey();
  44909. window.history.replaceState(stateCopy, '', absolutePath);
  44910. window.addEventListener('popstate', function (e) {
  44911. saveScrollPosition();
  44912. if (e.state && e.state.key) {
  44913. setStateKey(e.state.key);
  44914. }
  44915. });
  44916. }
  44917. function handleScroll (
  44918. router,
  44919. to,
  44920. from,
  44921. isPop
  44922. ) {
  44923. if (!router.app) {
  44924. return
  44925. }
  44926. var behavior = router.options.scrollBehavior;
  44927. if (!behavior) {
  44928. return
  44929. }
  44930. if (true) {
  44931. assert(typeof behavior === 'function', "scrollBehavior must be a function");
  44932. }
  44933. // wait until re-render finishes before scrolling
  44934. router.app.$nextTick(function () {
  44935. var position = getScrollPosition();
  44936. var shouldScroll = behavior.call(
  44937. router,
  44938. to,
  44939. from,
  44940. isPop ? position : null
  44941. );
  44942. if (!shouldScroll) {
  44943. return
  44944. }
  44945. if (typeof shouldScroll.then === 'function') {
  44946. shouldScroll
  44947. .then(function (shouldScroll) {
  44948. scrollToPosition((shouldScroll), position);
  44949. })
  44950. .catch(function (err) {
  44951. if (true) {
  44952. assert(false, err.toString());
  44953. }
  44954. });
  44955. } else {
  44956. scrollToPosition(shouldScroll, position);
  44957. }
  44958. });
  44959. }
  44960. function saveScrollPosition () {
  44961. var key = getStateKey();
  44962. if (key) {
  44963. positionStore[key] = {
  44964. x: window.pageXOffset,
  44965. y: window.pageYOffset
  44966. };
  44967. }
  44968. }
  44969. function getScrollPosition () {
  44970. var key = getStateKey();
  44971. if (key) {
  44972. return positionStore[key]
  44973. }
  44974. }
  44975. function getElementPosition (el, offset) {
  44976. var docEl = document.documentElement;
  44977. var docRect = docEl.getBoundingClientRect();
  44978. var elRect = el.getBoundingClientRect();
  44979. return {
  44980. x: elRect.left - docRect.left - offset.x,
  44981. y: elRect.top - docRect.top - offset.y
  44982. }
  44983. }
  44984. function isValidPosition (obj) {
  44985. return isNumber(obj.x) || isNumber(obj.y)
  44986. }
  44987. function normalizePosition (obj) {
  44988. return {
  44989. x: isNumber(obj.x) ? obj.x : window.pageXOffset,
  44990. y: isNumber(obj.y) ? obj.y : window.pageYOffset
  44991. }
  44992. }
  44993. function normalizeOffset (obj) {
  44994. return {
  44995. x: isNumber(obj.x) ? obj.x : 0,
  44996. y: isNumber(obj.y) ? obj.y : 0
  44997. }
  44998. }
  44999. function isNumber (v) {
  45000. return typeof v === 'number'
  45001. }
  45002. var hashStartsWithNumberRE = /^#\d/;
  45003. function scrollToPosition (shouldScroll, position) {
  45004. var isObject = typeof shouldScroll === 'object';
  45005. if (isObject && typeof shouldScroll.selector === 'string') {
  45006. // getElementById would still fail if the selector contains a more complicated query like #main[data-attr]
  45007. // but at the same time, it doesn't make much sense to select an element with an id and an extra selector
  45008. var el = hashStartsWithNumberRE.test(shouldScroll.selector) // $flow-disable-line
  45009. ? document.getElementById(shouldScroll.selector.slice(1)) // $flow-disable-line
  45010. : document.querySelector(shouldScroll.selector);
  45011. if (el) {
  45012. var offset =
  45013. shouldScroll.offset && typeof shouldScroll.offset === 'object'
  45014. ? shouldScroll.offset
  45015. : {};
  45016. offset = normalizeOffset(offset);
  45017. position = getElementPosition(el, offset);
  45018. } else if (isValidPosition(shouldScroll)) {
  45019. position = normalizePosition(shouldScroll);
  45020. }
  45021. } else if (isObject && isValidPosition(shouldScroll)) {
  45022. position = normalizePosition(shouldScroll);
  45023. }
  45024. if (position) {
  45025. window.scrollTo(position.x, position.y);
  45026. }
  45027. }
  45028. /* */
  45029. var supportsPushState =
  45030. inBrowser &&
  45031. (function () {
  45032. var ua = window.navigator.userAgent;
  45033. if (
  45034. (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
  45035. ua.indexOf('Mobile Safari') !== -1 &&
  45036. ua.indexOf('Chrome') === -1 &&
  45037. ua.indexOf('Windows Phone') === -1
  45038. ) {
  45039. return false
  45040. }
  45041. return window.history && 'pushState' in window.history
  45042. })();
  45043. function pushState (url, replace) {
  45044. saveScrollPosition();
  45045. // try...catch the pushState call to get around Safari
  45046. // DOM Exception 18 where it limits to 100 pushState calls
  45047. var history = window.history;
  45048. try {
  45049. if (replace) {
  45050. // preserve existing history state as it could be overriden by the user
  45051. var stateCopy = extend({}, history.state);
  45052. stateCopy.key = getStateKey();
  45053. history.replaceState(stateCopy, '', url);
  45054. } else {
  45055. history.pushState({ key: setStateKey(genStateKey()) }, '', url);
  45056. }
  45057. } catch (e) {
  45058. window.location[replace ? 'replace' : 'assign'](url);
  45059. }
  45060. }
  45061. function replaceState (url) {
  45062. pushState(url, true);
  45063. }
  45064. /* */
  45065. function runQueue (queue, fn, cb) {
  45066. var step = function (index) {
  45067. if (index >= queue.length) {
  45068. cb();
  45069. } else {
  45070. if (queue[index]) {
  45071. fn(queue[index], function () {
  45072. step(index + 1);
  45073. });
  45074. } else {
  45075. step(index + 1);
  45076. }
  45077. }
  45078. };
  45079. step(0);
  45080. }
  45081. /* */
  45082. function resolveAsyncComponents (matched) {
  45083. return function (to, from, next) {
  45084. var hasAsync = false;
  45085. var pending = 0;
  45086. var error = null;
  45087. flatMapComponents(matched, function (def, _, match, key) {
  45088. // if it's a function and doesn't have cid attached,
  45089. // assume it's an async component resolve function.
  45090. // we are not using Vue's default async resolving mechanism because
  45091. // we want to halt the navigation until the incoming component has been
  45092. // resolved.
  45093. if (typeof def === 'function' && def.cid === undefined) {
  45094. hasAsync = true;
  45095. pending++;
  45096. var resolve = once(function (resolvedDef) {
  45097. if (isESModule(resolvedDef)) {
  45098. resolvedDef = resolvedDef.default;
  45099. }
  45100. // save resolved on async factory in case it's used elsewhere
  45101. def.resolved = typeof resolvedDef === 'function'
  45102. ? resolvedDef
  45103. : _Vue.extend(resolvedDef);
  45104. match.components[key] = resolvedDef;
  45105. pending--;
  45106. if (pending <= 0) {
  45107. next();
  45108. }
  45109. });
  45110. var reject = once(function (reason) {
  45111. var msg = "Failed to resolve async component " + key + ": " + reason;
  45112. true && warn(false, msg);
  45113. if (!error) {
  45114. error = isError(reason)
  45115. ? reason
  45116. : new Error(msg);
  45117. next(error);
  45118. }
  45119. });
  45120. var res;
  45121. try {
  45122. res = def(resolve, reject);
  45123. } catch (e) {
  45124. reject(e);
  45125. }
  45126. if (res) {
  45127. if (typeof res.then === 'function') {
  45128. res.then(resolve, reject);
  45129. } else {
  45130. // new syntax in Vue 2.3
  45131. var comp = res.component;
  45132. if (comp && typeof comp.then === 'function') {
  45133. comp.then(resolve, reject);
  45134. }
  45135. }
  45136. }
  45137. }
  45138. });
  45139. if (!hasAsync) { next(); }
  45140. }
  45141. }
  45142. function flatMapComponents (
  45143. matched,
  45144. fn
  45145. ) {
  45146. return flatten(matched.map(function (m) {
  45147. return Object.keys(m.components).map(function (key) { return fn(
  45148. m.components[key],
  45149. m.instances[key],
  45150. m, key
  45151. ); })
  45152. }))
  45153. }
  45154. function flatten (arr) {
  45155. return Array.prototype.concat.apply([], arr)
  45156. }
  45157. var hasSymbol =
  45158. typeof Symbol === 'function' &&
  45159. typeof Symbol.toStringTag === 'symbol';
  45160. function isESModule (obj) {
  45161. return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module')
  45162. }
  45163. // in Webpack 2, require.ensure now also returns a Promise
  45164. // so the resolve/reject functions may get called an extra time
  45165. // if the user uses an arrow function shorthand that happens to
  45166. // return that Promise.
  45167. function once (fn) {
  45168. var called = false;
  45169. return function () {
  45170. var args = [], len = arguments.length;
  45171. while ( len-- ) args[ len ] = arguments[ len ];
  45172. if (called) { return }
  45173. called = true;
  45174. return fn.apply(this, args)
  45175. }
  45176. }
  45177. var NavigationDuplicated = /*@__PURE__*/(function (Error) {
  45178. function NavigationDuplicated (normalizedLocation) {
  45179. Error.call(this);
  45180. this.name = this._name = 'NavigationDuplicated';
  45181. // passing the message to super() doesn't seem to work in the transpiled version
  45182. this.message = "Navigating to current location (\"" + (normalizedLocation.fullPath) + "\") is not allowed";
  45183. // add a stack property so services like Sentry can correctly display it
  45184. Object.defineProperty(this, 'stack', {
  45185. value: new Error().stack,
  45186. writable: true,
  45187. configurable: true
  45188. });
  45189. // we could also have used
  45190. // Error.captureStackTrace(this, this.constructor)
  45191. // but it only exists on node and chrome
  45192. }
  45193. if ( Error ) NavigationDuplicated.__proto__ = Error;
  45194. NavigationDuplicated.prototype = Object.create( Error && Error.prototype );
  45195. NavigationDuplicated.prototype.constructor = NavigationDuplicated;
  45196. return NavigationDuplicated;
  45197. }(Error));
  45198. // support IE9
  45199. NavigationDuplicated._name = 'NavigationDuplicated';
  45200. /* */
  45201. var History = function History (router, base) {
  45202. this.router = router;
  45203. this.base = normalizeBase(base);
  45204. // start with a route object that stands for "nowhere"
  45205. this.current = START;
  45206. this.pending = null;
  45207. this.ready = false;
  45208. this.readyCbs = [];
  45209. this.readyErrorCbs = [];
  45210. this.errorCbs = [];
  45211. };
  45212. History.prototype.listen = function listen (cb) {
  45213. this.cb = cb;
  45214. };
  45215. History.prototype.onReady = function onReady (cb, errorCb) {
  45216. if (this.ready) {
  45217. cb();
  45218. } else {
  45219. this.readyCbs.push(cb);
  45220. if (errorCb) {
  45221. this.readyErrorCbs.push(errorCb);
  45222. }
  45223. }
  45224. };
  45225. History.prototype.onError = function onError (errorCb) {
  45226. this.errorCbs.push(errorCb);
  45227. };
  45228. History.prototype.transitionTo = function transitionTo (
  45229. location,
  45230. onComplete,
  45231. onAbort
  45232. ) {
  45233. var this$1 = this;
  45234. var route = this.router.match(location, this.current);
  45235. this.confirmTransition(
  45236. route,
  45237. function () {
  45238. this$1.updateRoute(route);
  45239. onComplete && onComplete(route);
  45240. this$1.ensureURL();
  45241. // fire ready cbs once
  45242. if (!this$1.ready) {
  45243. this$1.ready = true;
  45244. this$1.readyCbs.forEach(function (cb) {
  45245. cb(route);
  45246. });
  45247. }
  45248. },
  45249. function (err) {
  45250. if (onAbort) {
  45251. onAbort(err);
  45252. }
  45253. if (err && !this$1.ready) {
  45254. this$1.ready = true;
  45255. this$1.readyErrorCbs.forEach(function (cb) {
  45256. cb(err);
  45257. });
  45258. }
  45259. }
  45260. );
  45261. };
  45262. History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
  45263. var this$1 = this;
  45264. var current = this.current;
  45265. var abort = function (err) {
  45266. // after merging https://github.com/vuejs/vue-router/pull/2771 we
  45267. // When the user navigates through history through back/forward buttons
  45268. // we do not want to throw the error. We only throw it if directly calling
  45269. // push/replace. That's why it's not included in isError
  45270. if (!isExtendedError(NavigationDuplicated, err) && isError(err)) {
  45271. if (this$1.errorCbs.length) {
  45272. this$1.errorCbs.forEach(function (cb) {
  45273. cb(err);
  45274. });
  45275. } else {
  45276. warn(false, 'uncaught error during route navigation:');
  45277. console.error(err);
  45278. }
  45279. }
  45280. onAbort && onAbort(err);
  45281. };
  45282. if (
  45283. isSameRoute(route, current) &&
  45284. // in the case the route map has been dynamically appended to
  45285. route.matched.length === current.matched.length
  45286. ) {
  45287. this.ensureURL();
  45288. return abort(new NavigationDuplicated(route))
  45289. }
  45290. var ref = resolveQueue(
  45291. this.current.matched,
  45292. route.matched
  45293. );
  45294. var updated = ref.updated;
  45295. var deactivated = ref.deactivated;
  45296. var activated = ref.activated;
  45297. var queue = [].concat(
  45298. // in-component leave guards
  45299. extractLeaveGuards(deactivated),
  45300. // global before hooks
  45301. this.router.beforeHooks,
  45302. // in-component update hooks
  45303. extractUpdateHooks(updated),
  45304. // in-config enter guards
  45305. activated.map(function (m) { return m.beforeEnter; }),
  45306. // async components
  45307. resolveAsyncComponents(activated)
  45308. );
  45309. this.pending = route;
  45310. var iterator = function (hook, next) {
  45311. if (this$1.pending !== route) {
  45312. return abort()
  45313. }
  45314. try {
  45315. hook(route, current, function (to) {
  45316. if (to === false || isError(to)) {
  45317. // next(false) -> abort navigation, ensure current URL
  45318. this$1.ensureURL(true);
  45319. abort(to);
  45320. } else if (
  45321. typeof to === 'string' ||
  45322. (typeof to === 'object' &&
  45323. (typeof to.path === 'string' || typeof to.name === 'string'))
  45324. ) {
  45325. // next('/') or next({ path: '/' }) -> redirect
  45326. abort();
  45327. if (typeof to === 'object' && to.replace) {
  45328. this$1.replace(to);
  45329. } else {
  45330. this$1.push(to);
  45331. }
  45332. } else {
  45333. // confirm transition and pass on the value
  45334. next(to);
  45335. }
  45336. });
  45337. } catch (e) {
  45338. abort(e);
  45339. }
  45340. };
  45341. runQueue(queue, iterator, function () {
  45342. var postEnterCbs = [];
  45343. var isValid = function () { return this$1.current === route; };
  45344. // wait until async components are resolved before
  45345. // extracting in-component enter guards
  45346. var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
  45347. var queue = enterGuards.concat(this$1.router.resolveHooks);
  45348. runQueue(queue, iterator, function () {
  45349. if (this$1.pending !== route) {
  45350. return abort()
  45351. }
  45352. this$1.pending = null;
  45353. onComplete(route);
  45354. if (this$1.router.app) {
  45355. this$1.router.app.$nextTick(function () {
  45356. postEnterCbs.forEach(function (cb) {
  45357. cb();
  45358. });
  45359. });
  45360. }
  45361. });
  45362. });
  45363. };
  45364. History.prototype.updateRoute = function updateRoute (route) {
  45365. var prev = this.current;
  45366. this.current = route;
  45367. this.cb && this.cb(route);
  45368. this.router.afterHooks.forEach(function (hook) {
  45369. hook && hook(route, prev);
  45370. });
  45371. };
  45372. function normalizeBase (base) {
  45373. if (!base) {
  45374. if (inBrowser) {
  45375. // respect <base> tag
  45376. var baseEl = document.querySelector('base');
  45377. base = (baseEl && baseEl.getAttribute('href')) || '/';
  45378. // strip full URL origin
  45379. base = base.replace(/^https?:\/\/[^\/]+/, '');
  45380. } else {
  45381. base = '/';
  45382. }
  45383. }
  45384. // make sure there's the starting slash
  45385. if (base.charAt(0) !== '/') {
  45386. base = '/' + base;
  45387. }
  45388. // remove trailing slash
  45389. return base.replace(/\/$/, '')
  45390. }
  45391. function resolveQueue (
  45392. current,
  45393. next
  45394. ) {
  45395. var i;
  45396. var max = Math.max(current.length, next.length);
  45397. for (i = 0; i < max; i++) {
  45398. if (current[i] !== next[i]) {
  45399. break
  45400. }
  45401. }
  45402. return {
  45403. updated: next.slice(0, i),
  45404. activated: next.slice(i),
  45405. deactivated: current.slice(i)
  45406. }
  45407. }
  45408. function extractGuards (
  45409. records,
  45410. name,
  45411. bind,
  45412. reverse
  45413. ) {
  45414. var guards = flatMapComponents(records, function (def, instance, match, key) {
  45415. var guard = extractGuard(def, name);
  45416. if (guard) {
  45417. return Array.isArray(guard)
  45418. ? guard.map(function (guard) { return bind(guard, instance, match, key); })
  45419. : bind(guard, instance, match, key)
  45420. }
  45421. });
  45422. return flatten(reverse ? guards.reverse() : guards)
  45423. }
  45424. function extractGuard (
  45425. def,
  45426. key
  45427. ) {
  45428. if (typeof def !== 'function') {
  45429. // extend now so that global mixins are applied.
  45430. def = _Vue.extend(def);
  45431. }
  45432. return def.options[key]
  45433. }
  45434. function extractLeaveGuards (deactivated) {
  45435. return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true)
  45436. }
  45437. function extractUpdateHooks (updated) {
  45438. return extractGuards(updated, 'beforeRouteUpdate', bindGuard)
  45439. }
  45440. function bindGuard (guard, instance) {
  45441. if (instance) {
  45442. return function boundRouteGuard () {
  45443. return guard.apply(instance, arguments)
  45444. }
  45445. }
  45446. }
  45447. function extractEnterGuards (
  45448. activated,
  45449. cbs,
  45450. isValid
  45451. ) {
  45452. return extractGuards(
  45453. activated,
  45454. 'beforeRouteEnter',
  45455. function (guard, _, match, key) {
  45456. return bindEnterGuard(guard, match, key, cbs, isValid)
  45457. }
  45458. )
  45459. }
  45460. function bindEnterGuard (
  45461. guard,
  45462. match,
  45463. key,
  45464. cbs,
  45465. isValid
  45466. ) {
  45467. return function routeEnterGuard (to, from, next) {
  45468. return guard(to, from, function (cb) {
  45469. if (typeof cb === 'function') {
  45470. cbs.push(function () {
  45471. // #750
  45472. // if a router-view is wrapped with an out-in transition,
  45473. // the instance may not have been registered at this time.
  45474. // we will need to poll for registration until current route
  45475. // is no longer valid.
  45476. poll(cb, match.instances, key, isValid);
  45477. });
  45478. }
  45479. next(cb);
  45480. })
  45481. }
  45482. }
  45483. function poll (
  45484. cb, // somehow flow cannot infer this is a function
  45485. instances,
  45486. key,
  45487. isValid
  45488. ) {
  45489. if (
  45490. instances[key] &&
  45491. !instances[key]._isBeingDestroyed // do not reuse being destroyed instance
  45492. ) {
  45493. cb(instances[key]);
  45494. } else if (isValid()) {
  45495. setTimeout(function () {
  45496. poll(cb, instances, key, isValid);
  45497. }, 16);
  45498. }
  45499. }
  45500. /* */
  45501. var HTML5History = /*@__PURE__*/(function (History) {
  45502. function HTML5History (router, base) {
  45503. var this$1 = this;
  45504. History.call(this, router, base);
  45505. var expectScroll = router.options.scrollBehavior;
  45506. var supportsScroll = supportsPushState && expectScroll;
  45507. if (supportsScroll) {
  45508. setupScroll();
  45509. }
  45510. var initLocation = getLocation(this.base);
  45511. window.addEventListener('popstate', function (e) {
  45512. var current = this$1.current;
  45513. // Avoiding first `popstate` event dispatched in some browsers but first
  45514. // history route not updated since async guard at the same time.
  45515. var location = getLocation(this$1.base);
  45516. if (this$1.current === START && location === initLocation) {
  45517. return
  45518. }
  45519. this$1.transitionTo(location, function (route) {
  45520. if (supportsScroll) {
  45521. handleScroll(router, route, current, true);
  45522. }
  45523. });
  45524. });
  45525. }
  45526. if ( History ) HTML5History.__proto__ = History;
  45527. HTML5History.prototype = Object.create( History && History.prototype );
  45528. HTML5History.prototype.constructor = HTML5History;
  45529. HTML5History.prototype.go = function go (n) {
  45530. window.history.go(n);
  45531. };
  45532. HTML5History.prototype.push = function push (location, onComplete, onAbort) {
  45533. var this$1 = this;
  45534. var ref = this;
  45535. var fromRoute = ref.current;
  45536. this.transitionTo(location, function (route) {
  45537. pushState(cleanPath(this$1.base + route.fullPath));
  45538. handleScroll(this$1.router, route, fromRoute, false);
  45539. onComplete && onComplete(route);
  45540. }, onAbort);
  45541. };
  45542. HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
  45543. var this$1 = this;
  45544. var ref = this;
  45545. var fromRoute = ref.current;
  45546. this.transitionTo(location, function (route) {
  45547. replaceState(cleanPath(this$1.base + route.fullPath));
  45548. handleScroll(this$1.router, route, fromRoute, false);
  45549. onComplete && onComplete(route);
  45550. }, onAbort);
  45551. };
  45552. HTML5History.prototype.ensureURL = function ensureURL (push) {
  45553. if (getLocation(this.base) !== this.current.fullPath) {
  45554. var current = cleanPath(this.base + this.current.fullPath);
  45555. push ? pushState(current) : replaceState(current);
  45556. }
  45557. };
  45558. HTML5History.prototype.getCurrentLocation = function getCurrentLocation () {
  45559. return getLocation(this.base)
  45560. };
  45561. return HTML5History;
  45562. }(History));
  45563. function getLocation (base) {
  45564. var path = decodeURI(window.location.pathname);
  45565. if (base && path.indexOf(base) === 0) {
  45566. path = path.slice(base.length);
  45567. }
  45568. return (path || '/') + window.location.search + window.location.hash
  45569. }
  45570. /* */
  45571. var HashHistory = /*@__PURE__*/(function (History) {
  45572. function HashHistory (router, base, fallback) {
  45573. History.call(this, router, base);
  45574. // check history fallback deeplinking
  45575. if (fallback && checkFallback(this.base)) {
  45576. return
  45577. }
  45578. ensureSlash();
  45579. }
  45580. if ( History ) HashHistory.__proto__ = History;
  45581. HashHistory.prototype = Object.create( History && History.prototype );
  45582. HashHistory.prototype.constructor = HashHistory;
  45583. // this is delayed until the app mounts
  45584. // to avoid the hashchange listener being fired too early
  45585. HashHistory.prototype.setupListeners = function setupListeners () {
  45586. var this$1 = this;
  45587. var router = this.router;
  45588. var expectScroll = router.options.scrollBehavior;
  45589. var supportsScroll = supportsPushState && expectScroll;
  45590. if (supportsScroll) {
  45591. setupScroll();
  45592. }
  45593. window.addEventListener(
  45594. supportsPushState ? 'popstate' : 'hashchange',
  45595. function () {
  45596. var current = this$1.current;
  45597. if (!ensureSlash()) {
  45598. return
  45599. }
  45600. this$1.transitionTo(getHash(), function (route) {
  45601. if (supportsScroll) {
  45602. handleScroll(this$1.router, route, current, true);
  45603. }
  45604. if (!supportsPushState) {
  45605. replaceHash(route.fullPath);
  45606. }
  45607. });
  45608. }
  45609. );
  45610. };
  45611. HashHistory.prototype.push = function push (location, onComplete, onAbort) {
  45612. var this$1 = this;
  45613. var ref = this;
  45614. var fromRoute = ref.current;
  45615. this.transitionTo(
  45616. location,
  45617. function (route) {
  45618. pushHash(route.fullPath);
  45619. handleScroll(this$1.router, route, fromRoute, false);
  45620. onComplete && onComplete(route);
  45621. },
  45622. onAbort
  45623. );
  45624. };
  45625. HashHistory.prototype.replace = function replace (location, onComplete, onAbort) {
  45626. var this$1 = this;
  45627. var ref = this;
  45628. var fromRoute = ref.current;
  45629. this.transitionTo(
  45630. location,
  45631. function (route) {
  45632. replaceHash(route.fullPath);
  45633. handleScroll(this$1.router, route, fromRoute, false);
  45634. onComplete && onComplete(route);
  45635. },
  45636. onAbort
  45637. );
  45638. };
  45639. HashHistory.prototype.go = function go (n) {
  45640. window.history.go(n);
  45641. };
  45642. HashHistory.prototype.ensureURL = function ensureURL (push) {
  45643. var current = this.current.fullPath;
  45644. if (getHash() !== current) {
  45645. push ? pushHash(current) : replaceHash(current);
  45646. }
  45647. };
  45648. HashHistory.prototype.getCurrentLocation = function getCurrentLocation () {
  45649. return getHash()
  45650. };
  45651. return HashHistory;
  45652. }(History));
  45653. function checkFallback (base) {
  45654. var location = getLocation(base);
  45655. if (!/^\/#/.test(location)) {
  45656. window.location.replace(cleanPath(base + '/#' + location));
  45657. return true
  45658. }
  45659. }
  45660. function ensureSlash () {
  45661. var path = getHash();
  45662. if (path.charAt(0) === '/') {
  45663. return true
  45664. }
  45665. replaceHash('/' + path);
  45666. return false
  45667. }
  45668. function getHash () {
  45669. // We can't use window.location.hash here because it's not
  45670. // consistent across browsers - Firefox will pre-decode it!
  45671. var href = window.location.href;
  45672. var index = href.indexOf('#');
  45673. // empty path
  45674. if (index < 0) { return '' }
  45675. href = href.slice(index + 1);
  45676. // decode the hash but not the search or hash
  45677. // as search(query) is already decoded
  45678. // https://github.com/vuejs/vue-router/issues/2708
  45679. var searchIndex = href.indexOf('?');
  45680. if (searchIndex < 0) {
  45681. var hashIndex = href.indexOf('#');
  45682. if (hashIndex > -1) {
  45683. href = decodeURI(href.slice(0, hashIndex)) + href.slice(hashIndex);
  45684. } else { href = decodeURI(href); }
  45685. } else {
  45686. href = decodeURI(href.slice(0, searchIndex)) + href.slice(searchIndex);
  45687. }
  45688. return href
  45689. }
  45690. function getUrl (path) {
  45691. var href = window.location.href;
  45692. var i = href.indexOf('#');
  45693. var base = i >= 0 ? href.slice(0, i) : href;
  45694. return (base + "#" + path)
  45695. }
  45696. function pushHash (path) {
  45697. if (supportsPushState) {
  45698. pushState(getUrl(path));
  45699. } else {
  45700. window.location.hash = path;
  45701. }
  45702. }
  45703. function replaceHash (path) {
  45704. if (supportsPushState) {
  45705. replaceState(getUrl(path));
  45706. } else {
  45707. window.location.replace(getUrl(path));
  45708. }
  45709. }
  45710. /* */
  45711. var AbstractHistory = /*@__PURE__*/(function (History) {
  45712. function AbstractHistory (router, base) {
  45713. History.call(this, router, base);
  45714. this.stack = [];
  45715. this.index = -1;
  45716. }
  45717. if ( History ) AbstractHistory.__proto__ = History;
  45718. AbstractHistory.prototype = Object.create( History && History.prototype );
  45719. AbstractHistory.prototype.constructor = AbstractHistory;
  45720. AbstractHistory.prototype.push = function push (location, onComplete, onAbort) {
  45721. var this$1 = this;
  45722. this.transitionTo(
  45723. location,
  45724. function (route) {
  45725. this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
  45726. this$1.index++;
  45727. onComplete && onComplete(route);
  45728. },
  45729. onAbort
  45730. );
  45731. };
  45732. AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) {
  45733. var this$1 = this;
  45734. this.transitionTo(
  45735. location,
  45736. function (route) {
  45737. this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
  45738. onComplete && onComplete(route);
  45739. },
  45740. onAbort
  45741. );
  45742. };
  45743. AbstractHistory.prototype.go = function go (n) {
  45744. var this$1 = this;
  45745. var targetIndex = this.index + n;
  45746. if (targetIndex < 0 || targetIndex >= this.stack.length) {
  45747. return
  45748. }
  45749. var route = this.stack[targetIndex];
  45750. this.confirmTransition(
  45751. route,
  45752. function () {
  45753. this$1.index = targetIndex;
  45754. this$1.updateRoute(route);
  45755. },
  45756. function (err) {
  45757. if (isExtendedError(NavigationDuplicated, err)) {
  45758. this$1.index = targetIndex;
  45759. }
  45760. }
  45761. );
  45762. };
  45763. AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () {
  45764. var current = this.stack[this.stack.length - 1];
  45765. return current ? current.fullPath : '/'
  45766. };
  45767. AbstractHistory.prototype.ensureURL = function ensureURL () {
  45768. // noop
  45769. };
  45770. return AbstractHistory;
  45771. }(History));
  45772. /* */
  45773. var VueRouter = function VueRouter (options) {
  45774. if ( options === void 0 ) options = {};
  45775. this.app = null;
  45776. this.apps = [];
  45777. this.options = options;
  45778. this.beforeHooks = [];
  45779. this.resolveHooks = [];
  45780. this.afterHooks = [];
  45781. this.matcher = createMatcher(options.routes || [], this);
  45782. var mode = options.mode || 'hash';
  45783. this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
  45784. if (this.fallback) {
  45785. mode = 'hash';
  45786. }
  45787. if (!inBrowser) {
  45788. mode = 'abstract';
  45789. }
  45790. this.mode = mode;
  45791. switch (mode) {
  45792. case 'history':
  45793. this.history = new HTML5History(this, options.base);
  45794. break
  45795. case 'hash':
  45796. this.history = new HashHistory(this, options.base, this.fallback);
  45797. break
  45798. case 'abstract':
  45799. this.history = new AbstractHistory(this, options.base);
  45800. break
  45801. default:
  45802. if (true) {
  45803. assert(false, ("invalid mode: " + mode));
  45804. }
  45805. }
  45806. };
  45807. var prototypeAccessors = { currentRoute: { configurable: true } };
  45808. VueRouter.prototype.match = function match (
  45809. raw,
  45810. current,
  45811. redirectedFrom
  45812. ) {
  45813. return this.matcher.match(raw, current, redirectedFrom)
  45814. };
  45815. prototypeAccessors.currentRoute.get = function () {
  45816. return this.history && this.history.current
  45817. };
  45818. VueRouter.prototype.init = function init (app /* Vue component instance */) {
  45819. var this$1 = this;
  45820. true && assert(
  45821. install.installed,
  45822. "not installed. Make sure to call `Vue.use(VueRouter)` " +
  45823. "before creating root instance."
  45824. );
  45825. this.apps.push(app);
  45826. // set up app destroyed handler
  45827. // https://github.com/vuejs/vue-router/issues/2639
  45828. app.$once('hook:destroyed', function () {
  45829. // clean out app from this.apps array once destroyed
  45830. var index = this$1.apps.indexOf(app);
  45831. if (index > -1) { this$1.apps.splice(index, 1); }
  45832. // ensure we still have a main app or null if no apps
  45833. // we do not release the router so it can be reused
  45834. if (this$1.app === app) { this$1.app = this$1.apps[0] || null; }
  45835. });
  45836. // main app previously initialized
  45837. // return as we don't need to set up new history listener
  45838. if (this.app) {
  45839. return
  45840. }
  45841. this.app = app;
  45842. var history = this.history;
  45843. if (history instanceof HTML5History) {
  45844. history.transitionTo(history.getCurrentLocation());
  45845. } else if (history instanceof HashHistory) {
  45846. var setupHashListener = function () {
  45847. history.setupListeners();
  45848. };
  45849. history.transitionTo(
  45850. history.getCurrentLocation(),
  45851. setupHashListener,
  45852. setupHashListener
  45853. );
  45854. }
  45855. history.listen(function (route) {
  45856. this$1.apps.forEach(function (app) {
  45857. app._route = route;
  45858. });
  45859. });
  45860. };
  45861. VueRouter.prototype.beforeEach = function beforeEach (fn) {
  45862. return registerHook(this.beforeHooks, fn)
  45863. };
  45864. VueRouter.prototype.beforeResolve = function beforeResolve (fn) {
  45865. return registerHook(this.resolveHooks, fn)
  45866. };
  45867. VueRouter.prototype.afterEach = function afterEach (fn) {
  45868. return registerHook(this.afterHooks, fn)
  45869. };
  45870. VueRouter.prototype.onReady = function onReady (cb, errorCb) {
  45871. this.history.onReady(cb, errorCb);
  45872. };
  45873. VueRouter.prototype.onError = function onError (errorCb) {
  45874. this.history.onError(errorCb);
  45875. };
  45876. VueRouter.prototype.push = function push (location, onComplete, onAbort) {
  45877. var this$1 = this;
  45878. // $flow-disable-line
  45879. if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
  45880. return new Promise(function (resolve, reject) {
  45881. this$1.history.push(location, resolve, reject);
  45882. })
  45883. } else {
  45884. this.history.push(location, onComplete, onAbort);
  45885. }
  45886. };
  45887. VueRouter.prototype.replace = function replace (location, onComplete, onAbort) {
  45888. var this$1 = this;
  45889. // $flow-disable-line
  45890. if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
  45891. return new Promise(function (resolve, reject) {
  45892. this$1.history.replace(location, resolve, reject);
  45893. })
  45894. } else {
  45895. this.history.replace(location, onComplete, onAbort);
  45896. }
  45897. };
  45898. VueRouter.prototype.go = function go (n) {
  45899. this.history.go(n);
  45900. };
  45901. VueRouter.prototype.back = function back () {
  45902. this.go(-1);
  45903. };
  45904. VueRouter.prototype.forward = function forward () {
  45905. this.go(1);
  45906. };
  45907. VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
  45908. var route = to
  45909. ? to.matched
  45910. ? to
  45911. : this.resolve(to).route
  45912. : this.currentRoute;
  45913. if (!route) {
  45914. return []
  45915. }
  45916. return [].concat.apply([], route.matched.map(function (m) {
  45917. return Object.keys(m.components).map(function (key) {
  45918. return m.components[key]
  45919. })
  45920. }))
  45921. };
  45922. VueRouter.prototype.resolve = function resolve (
  45923. to,
  45924. current,
  45925. append
  45926. ) {
  45927. current = current || this.history.current;
  45928. var location = normalizeLocation(
  45929. to,
  45930. current,
  45931. append,
  45932. this
  45933. );
  45934. var route = this.match(location, current);
  45935. var fullPath = route.redirectedFrom || route.fullPath;
  45936. var base = this.history.base;
  45937. var href = createHref(base, fullPath, this.mode);
  45938. return {
  45939. location: location,
  45940. route: route,
  45941. href: href,
  45942. // for backwards compat
  45943. normalizedTo: location,
  45944. resolved: route
  45945. }
  45946. };
  45947. VueRouter.prototype.addRoutes = function addRoutes (routes) {
  45948. this.matcher.addRoutes(routes);
  45949. if (this.history.current !== START) {
  45950. this.history.transitionTo(this.history.getCurrentLocation());
  45951. }
  45952. };
  45953. Object.defineProperties( VueRouter.prototype, prototypeAccessors );
  45954. function registerHook (list, fn) {
  45955. list.push(fn);
  45956. return function () {
  45957. var i = list.indexOf(fn);
  45958. if (i > -1) { list.splice(i, 1); }
  45959. }
  45960. }
  45961. function createHref (base, fullPath, mode) {
  45962. var path = mode === 'hash' ? '#' + fullPath : fullPath;
  45963. return base ? cleanPath(base + '/' + path) : path
  45964. }
  45965. VueRouter.install = install;
  45966. VueRouter.version = '3.1.6';
  45967. if (inBrowser && window.Vue) {
  45968. window.Vue.use(VueRouter);
  45969. }
  45970. /* harmony default export */ __webpack_exports__["default"] = (VueRouter);
  45971. /***/ }),
  45972. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  45973. /*!*************************************************!*\
  45974. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  45975. \*************************************************/
  45976. /*! no static exports found */
  45977. /***/ (function(module, exports, __webpack_require__) {
  45978. "use strict";
  45979. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  45980. * Vue.js v2.6.11
  45981. * (c) 2014-2019 Evan You
  45982. * Released under the MIT License.
  45983. */
  45984. /* */
  45985. var emptyObject = Object.freeze({});
  45986. // These helpers produce better VM code in JS engines due to their
  45987. // explicitness and function inlining.
  45988. function isUndef (v) {
  45989. return v === undefined || v === null
  45990. }
  45991. function isDef (v) {
  45992. return v !== undefined && v !== null
  45993. }
  45994. function isTrue (v) {
  45995. return v === true
  45996. }
  45997. function isFalse (v) {
  45998. return v === false
  45999. }
  46000. /**
  46001. * Check if value is primitive.
  46002. */
  46003. function isPrimitive (value) {
  46004. return (
  46005. typeof value === 'string' ||
  46006. typeof value === 'number' ||
  46007. // $flow-disable-line
  46008. typeof value === 'symbol' ||
  46009. typeof value === 'boolean'
  46010. )
  46011. }
  46012. /**
  46013. * Quick object check - this is primarily used to tell
  46014. * Objects from primitive values when we know the value
  46015. * is a JSON-compliant type.
  46016. */
  46017. function isObject (obj) {
  46018. return obj !== null && typeof obj === 'object'
  46019. }
  46020. /**
  46021. * Get the raw type string of a value, e.g., [object Object].
  46022. */
  46023. var _toString = Object.prototype.toString;
  46024. function toRawType (value) {
  46025. return _toString.call(value).slice(8, -1)
  46026. }
  46027. /**
  46028. * Strict object type check. Only returns true
  46029. * for plain JavaScript objects.
  46030. */
  46031. function isPlainObject (obj) {
  46032. return _toString.call(obj) === '[object Object]'
  46033. }
  46034. function isRegExp (v) {
  46035. return _toString.call(v) === '[object RegExp]'
  46036. }
  46037. /**
  46038. * Check if val is a valid array index.
  46039. */
  46040. function isValidArrayIndex (val) {
  46041. var n = parseFloat(String(val));
  46042. return n >= 0 && Math.floor(n) === n && isFinite(val)
  46043. }
  46044. function isPromise (val) {
  46045. return (
  46046. isDef(val) &&
  46047. typeof val.then === 'function' &&
  46048. typeof val.catch === 'function'
  46049. )
  46050. }
  46051. /**
  46052. * Convert a value to a string that is actually rendered.
  46053. */
  46054. function toString (val) {
  46055. return val == null
  46056. ? ''
  46057. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  46058. ? JSON.stringify(val, null, 2)
  46059. : String(val)
  46060. }
  46061. /**
  46062. * Convert an input value to a number for persistence.
  46063. * If the conversion fails, return original string.
  46064. */
  46065. function toNumber (val) {
  46066. var n = parseFloat(val);
  46067. return isNaN(n) ? val : n
  46068. }
  46069. /**
  46070. * Make a map and return a function for checking if a key
  46071. * is in that map.
  46072. */
  46073. function makeMap (
  46074. str,
  46075. expectsLowerCase
  46076. ) {
  46077. var map = Object.create(null);
  46078. var list = str.split(',');
  46079. for (var i = 0; i < list.length; i++) {
  46080. map[list[i]] = true;
  46081. }
  46082. return expectsLowerCase
  46083. ? function (val) { return map[val.toLowerCase()]; }
  46084. : function (val) { return map[val]; }
  46085. }
  46086. /**
  46087. * Check if a tag is a built-in tag.
  46088. */
  46089. var isBuiltInTag = makeMap('slot,component', true);
  46090. /**
  46091. * Check if an attribute is a reserved attribute.
  46092. */
  46093. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  46094. /**
  46095. * Remove an item from an array.
  46096. */
  46097. function remove (arr, item) {
  46098. if (arr.length) {
  46099. var index = arr.indexOf(item);
  46100. if (index > -1) {
  46101. return arr.splice(index, 1)
  46102. }
  46103. }
  46104. }
  46105. /**
  46106. * Check whether an object has the property.
  46107. */
  46108. var hasOwnProperty = Object.prototype.hasOwnProperty;
  46109. function hasOwn (obj, key) {
  46110. return hasOwnProperty.call(obj, key)
  46111. }
  46112. /**
  46113. * Create a cached version of a pure function.
  46114. */
  46115. function cached (fn) {
  46116. var cache = Object.create(null);
  46117. return (function cachedFn (str) {
  46118. var hit = cache[str];
  46119. return hit || (cache[str] = fn(str))
  46120. })
  46121. }
  46122. /**
  46123. * Camelize a hyphen-delimited string.
  46124. */
  46125. var camelizeRE = /-(\w)/g;
  46126. var camelize = cached(function (str) {
  46127. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  46128. });
  46129. /**
  46130. * Capitalize a string.
  46131. */
  46132. var capitalize = cached(function (str) {
  46133. return str.charAt(0).toUpperCase() + str.slice(1)
  46134. });
  46135. /**
  46136. * Hyphenate a camelCase string.
  46137. */
  46138. var hyphenateRE = /\B([A-Z])/g;
  46139. var hyphenate = cached(function (str) {
  46140. return str.replace(hyphenateRE, '-$1').toLowerCase()
  46141. });
  46142. /**
  46143. * Simple bind polyfill for environments that do not support it,
  46144. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  46145. * since native bind is now performant enough in most browsers.
  46146. * But removing it would mean breaking code that was able to run in
  46147. * PhantomJS 1.x, so this must be kept for backward compatibility.
  46148. */
  46149. /* istanbul ignore next */
  46150. function polyfillBind (fn, ctx) {
  46151. function boundFn (a) {
  46152. var l = arguments.length;
  46153. return l
  46154. ? l > 1
  46155. ? fn.apply(ctx, arguments)
  46156. : fn.call(ctx, a)
  46157. : fn.call(ctx)
  46158. }
  46159. boundFn._length = fn.length;
  46160. return boundFn
  46161. }
  46162. function nativeBind (fn, ctx) {
  46163. return fn.bind(ctx)
  46164. }
  46165. var bind = Function.prototype.bind
  46166. ? nativeBind
  46167. : polyfillBind;
  46168. /**
  46169. * Convert an Array-like object to a real Array.
  46170. */
  46171. function toArray (list, start) {
  46172. start = start || 0;
  46173. var i = list.length - start;
  46174. var ret = new Array(i);
  46175. while (i--) {
  46176. ret[i] = list[i + start];
  46177. }
  46178. return ret
  46179. }
  46180. /**
  46181. * Mix properties into target object.
  46182. */
  46183. function extend (to, _from) {
  46184. for (var key in _from) {
  46185. to[key] = _from[key];
  46186. }
  46187. return to
  46188. }
  46189. /**
  46190. * Merge an Array of Objects into a single Object.
  46191. */
  46192. function toObject (arr) {
  46193. var res = {};
  46194. for (var i = 0; i < arr.length; i++) {
  46195. if (arr[i]) {
  46196. extend(res, arr[i]);
  46197. }
  46198. }
  46199. return res
  46200. }
  46201. /* eslint-disable no-unused-vars */
  46202. /**
  46203. * Perform no operation.
  46204. * Stubbing args to make Flow happy without leaving useless transpiled code
  46205. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  46206. */
  46207. function noop (a, b, c) {}
  46208. /**
  46209. * Always return false.
  46210. */
  46211. var no = function (a, b, c) { return false; };
  46212. /* eslint-enable no-unused-vars */
  46213. /**
  46214. * Return the same value.
  46215. */
  46216. var identity = function (_) { return _; };
  46217. /**
  46218. * Generate a string containing static keys from compiler modules.
  46219. */
  46220. function genStaticKeys (modules) {
  46221. return modules.reduce(function (keys, m) {
  46222. return keys.concat(m.staticKeys || [])
  46223. }, []).join(',')
  46224. }
  46225. /**
  46226. * Check if two values are loosely equal - that is,
  46227. * if they are plain objects, do they have the same shape?
  46228. */
  46229. function looseEqual (a, b) {
  46230. if (a === b) { return true }
  46231. var isObjectA = isObject(a);
  46232. var isObjectB = isObject(b);
  46233. if (isObjectA && isObjectB) {
  46234. try {
  46235. var isArrayA = Array.isArray(a);
  46236. var isArrayB = Array.isArray(b);
  46237. if (isArrayA && isArrayB) {
  46238. return a.length === b.length && a.every(function (e, i) {
  46239. return looseEqual(e, b[i])
  46240. })
  46241. } else if (a instanceof Date && b instanceof Date) {
  46242. return a.getTime() === b.getTime()
  46243. } else if (!isArrayA && !isArrayB) {
  46244. var keysA = Object.keys(a);
  46245. var keysB = Object.keys(b);
  46246. return keysA.length === keysB.length && keysA.every(function (key) {
  46247. return looseEqual(a[key], b[key])
  46248. })
  46249. } else {
  46250. /* istanbul ignore next */
  46251. return false
  46252. }
  46253. } catch (e) {
  46254. /* istanbul ignore next */
  46255. return false
  46256. }
  46257. } else if (!isObjectA && !isObjectB) {
  46258. return String(a) === String(b)
  46259. } else {
  46260. return false
  46261. }
  46262. }
  46263. /**
  46264. * Return the first index at which a loosely equal value can be
  46265. * found in the array (if value is a plain object, the array must
  46266. * contain an object of the same shape), or -1 if it is not present.
  46267. */
  46268. function looseIndexOf (arr, val) {
  46269. for (var i = 0; i < arr.length; i++) {
  46270. if (looseEqual(arr[i], val)) { return i }
  46271. }
  46272. return -1
  46273. }
  46274. /**
  46275. * Ensure a function is called only once.
  46276. */
  46277. function once (fn) {
  46278. var called = false;
  46279. return function () {
  46280. if (!called) {
  46281. called = true;
  46282. fn.apply(this, arguments);
  46283. }
  46284. }
  46285. }
  46286. var SSR_ATTR = 'data-server-rendered';
  46287. var ASSET_TYPES = [
  46288. 'component',
  46289. 'directive',
  46290. 'filter'
  46291. ];
  46292. var LIFECYCLE_HOOKS = [
  46293. 'beforeCreate',
  46294. 'created',
  46295. 'beforeMount',
  46296. 'mounted',
  46297. 'beforeUpdate',
  46298. 'updated',
  46299. 'beforeDestroy',
  46300. 'destroyed',
  46301. 'activated',
  46302. 'deactivated',
  46303. 'errorCaptured',
  46304. 'serverPrefetch'
  46305. ];
  46306. /* */
  46307. var config = ({
  46308. /**
  46309. * Option merge strategies (used in core/util/options)
  46310. */
  46311. // $flow-disable-line
  46312. optionMergeStrategies: Object.create(null),
  46313. /**
  46314. * Whether to suppress warnings.
  46315. */
  46316. silent: false,
  46317. /**
  46318. * Show production mode tip message on boot?
  46319. */
  46320. productionTip: "development" !== 'production',
  46321. /**
  46322. * Whether to enable devtools
  46323. */
  46324. devtools: "development" !== 'production',
  46325. /**
  46326. * Whether to record perf
  46327. */
  46328. performance: false,
  46329. /**
  46330. * Error handler for watcher errors
  46331. */
  46332. errorHandler: null,
  46333. /**
  46334. * Warn handler for watcher warns
  46335. */
  46336. warnHandler: null,
  46337. /**
  46338. * Ignore certain custom elements
  46339. */
  46340. ignoredElements: [],
  46341. /**
  46342. * Custom user key aliases for v-on
  46343. */
  46344. // $flow-disable-line
  46345. keyCodes: Object.create(null),
  46346. /**
  46347. * Check if a tag is reserved so that it cannot be registered as a
  46348. * component. This is platform-dependent and may be overwritten.
  46349. */
  46350. isReservedTag: no,
  46351. /**
  46352. * Check if an attribute is reserved so that it cannot be used as a component
  46353. * prop. This is platform-dependent and may be overwritten.
  46354. */
  46355. isReservedAttr: no,
  46356. /**
  46357. * Check if a tag is an unknown element.
  46358. * Platform-dependent.
  46359. */
  46360. isUnknownElement: no,
  46361. /**
  46362. * Get the namespace of an element
  46363. */
  46364. getTagNamespace: noop,
  46365. /**
  46366. * Parse the real tag name for the specific platform.
  46367. */
  46368. parsePlatformTagName: identity,
  46369. /**
  46370. * Check if an attribute must be bound using property, e.g. value
  46371. * Platform-dependent.
  46372. */
  46373. mustUseProp: no,
  46374. /**
  46375. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  46376. * This will significantly reduce performance if set to false.
  46377. */
  46378. async: true,
  46379. /**
  46380. * Exposed for legacy reasons
  46381. */
  46382. _lifecycleHooks: LIFECYCLE_HOOKS
  46383. });
  46384. /* */
  46385. /**
  46386. * unicode letters used for parsing html tags, component names and property paths.
  46387. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  46388. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  46389. */
  46390. 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/;
  46391. /**
  46392. * Check if a string starts with $ or _
  46393. */
  46394. function isReserved (str) {
  46395. var c = (str + '').charCodeAt(0);
  46396. return c === 0x24 || c === 0x5F
  46397. }
  46398. /**
  46399. * Define a property.
  46400. */
  46401. function def (obj, key, val, enumerable) {
  46402. Object.defineProperty(obj, key, {
  46403. value: val,
  46404. enumerable: !!enumerable,
  46405. writable: true,
  46406. configurable: true
  46407. });
  46408. }
  46409. /**
  46410. * Parse simple path.
  46411. */
  46412. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  46413. function parsePath (path) {
  46414. if (bailRE.test(path)) {
  46415. return
  46416. }
  46417. var segments = path.split('.');
  46418. return function (obj) {
  46419. for (var i = 0; i < segments.length; i++) {
  46420. if (!obj) { return }
  46421. obj = obj[segments[i]];
  46422. }
  46423. return obj
  46424. }
  46425. }
  46426. /* */
  46427. // can we use __proto__?
  46428. var hasProto = '__proto__' in {};
  46429. // Browser environment sniffing
  46430. var inBrowser = typeof window !== 'undefined';
  46431. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  46432. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  46433. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  46434. var isIE = UA && /msie|trident/.test(UA);
  46435. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  46436. var isEdge = UA && UA.indexOf('edge/') > 0;
  46437. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  46438. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  46439. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  46440. var isPhantomJS = UA && /phantomjs/.test(UA);
  46441. var isFF = UA && UA.match(/firefox\/(\d+)/);
  46442. // Firefox has a "watch" function on Object.prototype...
  46443. var nativeWatch = ({}).watch;
  46444. var supportsPassive = false;
  46445. if (inBrowser) {
  46446. try {
  46447. var opts = {};
  46448. Object.defineProperty(opts, 'passive', ({
  46449. get: function get () {
  46450. /* istanbul ignore next */
  46451. supportsPassive = true;
  46452. }
  46453. })); // https://github.com/facebook/flow/issues/285
  46454. window.addEventListener('test-passive', null, opts);
  46455. } catch (e) {}
  46456. }
  46457. // this needs to be lazy-evaled because vue may be required before
  46458. // vue-server-renderer can set VUE_ENV
  46459. var _isServer;
  46460. var isServerRendering = function () {
  46461. if (_isServer === undefined) {
  46462. /* istanbul ignore if */
  46463. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  46464. // detect presence of vue-server-renderer and avoid
  46465. // Webpack shimming the process
  46466. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  46467. } else {
  46468. _isServer = false;
  46469. }
  46470. }
  46471. return _isServer
  46472. };
  46473. // detect devtools
  46474. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  46475. /* istanbul ignore next */
  46476. function isNative (Ctor) {
  46477. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  46478. }
  46479. var hasSymbol =
  46480. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  46481. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  46482. var _Set;
  46483. /* istanbul ignore if */ // $flow-disable-line
  46484. if (typeof Set !== 'undefined' && isNative(Set)) {
  46485. // use native Set when available.
  46486. _Set = Set;
  46487. } else {
  46488. // a non-standard Set polyfill that only works with primitive keys.
  46489. _Set = /*@__PURE__*/(function () {
  46490. function Set () {
  46491. this.set = Object.create(null);
  46492. }
  46493. Set.prototype.has = function has (key) {
  46494. return this.set[key] === true
  46495. };
  46496. Set.prototype.add = function add (key) {
  46497. this.set[key] = true;
  46498. };
  46499. Set.prototype.clear = function clear () {
  46500. this.set = Object.create(null);
  46501. };
  46502. return Set;
  46503. }());
  46504. }
  46505. /* */
  46506. var warn = noop;
  46507. var tip = noop;
  46508. var generateComponentTrace = (noop); // work around flow check
  46509. var formatComponentName = (noop);
  46510. {
  46511. var hasConsole = typeof console !== 'undefined';
  46512. var classifyRE = /(?:^|[-_])(\w)/g;
  46513. var classify = function (str) { return str
  46514. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  46515. .replace(/[-_]/g, ''); };
  46516. warn = function (msg, vm) {
  46517. var trace = vm ? generateComponentTrace(vm) : '';
  46518. if (config.warnHandler) {
  46519. config.warnHandler.call(null, msg, vm, trace);
  46520. } else if (hasConsole && (!config.silent)) {
  46521. console.error(("[Vue warn]: " + msg + trace));
  46522. }
  46523. };
  46524. tip = function (msg, vm) {
  46525. if (hasConsole && (!config.silent)) {
  46526. console.warn("[Vue tip]: " + msg + (
  46527. vm ? generateComponentTrace(vm) : ''
  46528. ));
  46529. }
  46530. };
  46531. formatComponentName = function (vm, includeFile) {
  46532. if (vm.$root === vm) {
  46533. return '<Root>'
  46534. }
  46535. var options = typeof vm === 'function' && vm.cid != null
  46536. ? vm.options
  46537. : vm._isVue
  46538. ? vm.$options || vm.constructor.options
  46539. : vm;
  46540. var name = options.name || options._componentTag;
  46541. var file = options.__file;
  46542. if (!name && file) {
  46543. var match = file.match(/([^/\\]+)\.vue$/);
  46544. name = match && match[1];
  46545. }
  46546. return (
  46547. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  46548. (file && includeFile !== false ? (" at " + file) : '')
  46549. )
  46550. };
  46551. var repeat = function (str, n) {
  46552. var res = '';
  46553. while (n) {
  46554. if (n % 2 === 1) { res += str; }
  46555. if (n > 1) { str += str; }
  46556. n >>= 1;
  46557. }
  46558. return res
  46559. };
  46560. generateComponentTrace = function (vm) {
  46561. if (vm._isVue && vm.$parent) {
  46562. var tree = [];
  46563. var currentRecursiveSequence = 0;
  46564. while (vm) {
  46565. if (tree.length > 0) {
  46566. var last = tree[tree.length - 1];
  46567. if (last.constructor === vm.constructor) {
  46568. currentRecursiveSequence++;
  46569. vm = vm.$parent;
  46570. continue
  46571. } else if (currentRecursiveSequence > 0) {
  46572. tree[tree.length - 1] = [last, currentRecursiveSequence];
  46573. currentRecursiveSequence = 0;
  46574. }
  46575. }
  46576. tree.push(vm);
  46577. vm = vm.$parent;
  46578. }
  46579. return '\n\nfound in\n\n' + tree
  46580. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  46581. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  46582. : formatComponentName(vm))); })
  46583. .join('\n')
  46584. } else {
  46585. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  46586. }
  46587. };
  46588. }
  46589. /* */
  46590. var uid = 0;
  46591. /**
  46592. * A dep is an observable that can have multiple
  46593. * directives subscribing to it.
  46594. */
  46595. var Dep = function Dep () {
  46596. this.id = uid++;
  46597. this.subs = [];
  46598. };
  46599. Dep.prototype.addSub = function addSub (sub) {
  46600. this.subs.push(sub);
  46601. };
  46602. Dep.prototype.removeSub = function removeSub (sub) {
  46603. remove(this.subs, sub);
  46604. };
  46605. Dep.prototype.depend = function depend () {
  46606. if (Dep.target) {
  46607. Dep.target.addDep(this);
  46608. }
  46609. };
  46610. Dep.prototype.notify = function notify () {
  46611. // stabilize the subscriber list first
  46612. var subs = this.subs.slice();
  46613. if (!config.async) {
  46614. // subs aren't sorted in scheduler if not running async
  46615. // we need to sort them now to make sure they fire in correct
  46616. // order
  46617. subs.sort(function (a, b) { return a.id - b.id; });
  46618. }
  46619. for (var i = 0, l = subs.length; i < l; i++) {
  46620. subs[i].update();
  46621. }
  46622. };
  46623. // The current target watcher being evaluated.
  46624. // This is globally unique because only one watcher
  46625. // can be evaluated at a time.
  46626. Dep.target = null;
  46627. var targetStack = [];
  46628. function pushTarget (target) {
  46629. targetStack.push(target);
  46630. Dep.target = target;
  46631. }
  46632. function popTarget () {
  46633. targetStack.pop();
  46634. Dep.target = targetStack[targetStack.length - 1];
  46635. }
  46636. /* */
  46637. var VNode = function VNode (
  46638. tag,
  46639. data,
  46640. children,
  46641. text,
  46642. elm,
  46643. context,
  46644. componentOptions,
  46645. asyncFactory
  46646. ) {
  46647. this.tag = tag;
  46648. this.data = data;
  46649. this.children = children;
  46650. this.text = text;
  46651. this.elm = elm;
  46652. this.ns = undefined;
  46653. this.context = context;
  46654. this.fnContext = undefined;
  46655. this.fnOptions = undefined;
  46656. this.fnScopeId = undefined;
  46657. this.key = data && data.key;
  46658. this.componentOptions = componentOptions;
  46659. this.componentInstance = undefined;
  46660. this.parent = undefined;
  46661. this.raw = false;
  46662. this.isStatic = false;
  46663. this.isRootInsert = true;
  46664. this.isComment = false;
  46665. this.isCloned = false;
  46666. this.isOnce = false;
  46667. this.asyncFactory = asyncFactory;
  46668. this.asyncMeta = undefined;
  46669. this.isAsyncPlaceholder = false;
  46670. };
  46671. var prototypeAccessors = { child: { configurable: true } };
  46672. // DEPRECATED: alias for componentInstance for backwards compat.
  46673. /* istanbul ignore next */
  46674. prototypeAccessors.child.get = function () {
  46675. return this.componentInstance
  46676. };
  46677. Object.defineProperties( VNode.prototype, prototypeAccessors );
  46678. var createEmptyVNode = function (text) {
  46679. if ( text === void 0 ) text = '';
  46680. var node = new VNode();
  46681. node.text = text;
  46682. node.isComment = true;
  46683. return node
  46684. };
  46685. function createTextVNode (val) {
  46686. return new VNode(undefined, undefined, undefined, String(val))
  46687. }
  46688. // optimized shallow clone
  46689. // used for static nodes and slot nodes because they may be reused across
  46690. // multiple renders, cloning them avoids errors when DOM manipulations rely
  46691. // on their elm reference.
  46692. function cloneVNode (vnode) {
  46693. var cloned = new VNode(
  46694. vnode.tag,
  46695. vnode.data,
  46696. // #7975
  46697. // clone children array to avoid mutating original in case of cloning
  46698. // a child.
  46699. vnode.children && vnode.children.slice(),
  46700. vnode.text,
  46701. vnode.elm,
  46702. vnode.context,
  46703. vnode.componentOptions,
  46704. vnode.asyncFactory
  46705. );
  46706. cloned.ns = vnode.ns;
  46707. cloned.isStatic = vnode.isStatic;
  46708. cloned.key = vnode.key;
  46709. cloned.isComment = vnode.isComment;
  46710. cloned.fnContext = vnode.fnContext;
  46711. cloned.fnOptions = vnode.fnOptions;
  46712. cloned.fnScopeId = vnode.fnScopeId;
  46713. cloned.asyncMeta = vnode.asyncMeta;
  46714. cloned.isCloned = true;
  46715. return cloned
  46716. }
  46717. /*
  46718. * not type checking this file because flow doesn't play well with
  46719. * dynamically accessing methods on Array prototype
  46720. */
  46721. var arrayProto = Array.prototype;
  46722. var arrayMethods = Object.create(arrayProto);
  46723. var methodsToPatch = [
  46724. 'push',
  46725. 'pop',
  46726. 'shift',
  46727. 'unshift',
  46728. 'splice',
  46729. 'sort',
  46730. 'reverse'
  46731. ];
  46732. /**
  46733. * Intercept mutating methods and emit events
  46734. */
  46735. methodsToPatch.forEach(function (method) {
  46736. // cache original method
  46737. var original = arrayProto[method];
  46738. def(arrayMethods, method, function mutator () {
  46739. var args = [], len = arguments.length;
  46740. while ( len-- ) args[ len ] = arguments[ len ];
  46741. var result = original.apply(this, args);
  46742. var ob = this.__ob__;
  46743. var inserted;
  46744. switch (method) {
  46745. case 'push':
  46746. case 'unshift':
  46747. inserted = args;
  46748. break
  46749. case 'splice':
  46750. inserted = args.slice(2);
  46751. break
  46752. }
  46753. if (inserted) { ob.observeArray(inserted); }
  46754. // notify change
  46755. ob.dep.notify();
  46756. return result
  46757. });
  46758. });
  46759. /* */
  46760. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  46761. /**
  46762. * In some cases we may want to disable observation inside a component's
  46763. * update computation.
  46764. */
  46765. var shouldObserve = true;
  46766. function toggleObserving (value) {
  46767. shouldObserve = value;
  46768. }
  46769. /**
  46770. * Observer class that is attached to each observed
  46771. * object. Once attached, the observer converts the target
  46772. * object's property keys into getter/setters that
  46773. * collect dependencies and dispatch updates.
  46774. */
  46775. var Observer = function Observer (value) {
  46776. this.value = value;
  46777. this.dep = new Dep();
  46778. this.vmCount = 0;
  46779. def(value, '__ob__', this);
  46780. if (Array.isArray(value)) {
  46781. if (hasProto) {
  46782. protoAugment(value, arrayMethods);
  46783. } else {
  46784. copyAugment(value, arrayMethods, arrayKeys);
  46785. }
  46786. this.observeArray(value);
  46787. } else {
  46788. this.walk(value);
  46789. }
  46790. };
  46791. /**
  46792. * Walk through all properties and convert them into
  46793. * getter/setters. This method should only be called when
  46794. * value type is Object.
  46795. */
  46796. Observer.prototype.walk = function walk (obj) {
  46797. var keys = Object.keys(obj);
  46798. for (var i = 0; i < keys.length; i++) {
  46799. defineReactive$$1(obj, keys[i]);
  46800. }
  46801. };
  46802. /**
  46803. * Observe a list of Array items.
  46804. */
  46805. Observer.prototype.observeArray = function observeArray (items) {
  46806. for (var i = 0, l = items.length; i < l; i++) {
  46807. observe(items[i]);
  46808. }
  46809. };
  46810. // helpers
  46811. /**
  46812. * Augment a target Object or Array by intercepting
  46813. * the prototype chain using __proto__
  46814. */
  46815. function protoAugment (target, src) {
  46816. /* eslint-disable no-proto */
  46817. target.__proto__ = src;
  46818. /* eslint-enable no-proto */
  46819. }
  46820. /**
  46821. * Augment a target Object or Array by defining
  46822. * hidden properties.
  46823. */
  46824. /* istanbul ignore next */
  46825. function copyAugment (target, src, keys) {
  46826. for (var i = 0, l = keys.length; i < l; i++) {
  46827. var key = keys[i];
  46828. def(target, key, src[key]);
  46829. }
  46830. }
  46831. /**
  46832. * Attempt to create an observer instance for a value,
  46833. * returns the new observer if successfully observed,
  46834. * or the existing observer if the value already has one.
  46835. */
  46836. function observe (value, asRootData) {
  46837. if (!isObject(value) || value instanceof VNode) {
  46838. return
  46839. }
  46840. var ob;
  46841. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  46842. ob = value.__ob__;
  46843. } else if (
  46844. shouldObserve &&
  46845. !isServerRendering() &&
  46846. (Array.isArray(value) || isPlainObject(value)) &&
  46847. Object.isExtensible(value) &&
  46848. !value._isVue
  46849. ) {
  46850. ob = new Observer(value);
  46851. }
  46852. if (asRootData && ob) {
  46853. ob.vmCount++;
  46854. }
  46855. return ob
  46856. }
  46857. /**
  46858. * Define a reactive property on an Object.
  46859. */
  46860. function defineReactive$$1 (
  46861. obj,
  46862. key,
  46863. val,
  46864. customSetter,
  46865. shallow
  46866. ) {
  46867. var dep = new Dep();
  46868. var property = Object.getOwnPropertyDescriptor(obj, key);
  46869. if (property && property.configurable === false) {
  46870. return
  46871. }
  46872. // cater for pre-defined getter/setters
  46873. var getter = property && property.get;
  46874. var setter = property && property.set;
  46875. if ((!getter || setter) && arguments.length === 2) {
  46876. val = obj[key];
  46877. }
  46878. var childOb = !shallow && observe(val);
  46879. Object.defineProperty(obj, key, {
  46880. enumerable: true,
  46881. configurable: true,
  46882. get: function reactiveGetter () {
  46883. var value = getter ? getter.call(obj) : val;
  46884. if (Dep.target) {
  46885. dep.depend();
  46886. if (childOb) {
  46887. childOb.dep.depend();
  46888. if (Array.isArray(value)) {
  46889. dependArray(value);
  46890. }
  46891. }
  46892. }
  46893. return value
  46894. },
  46895. set: function reactiveSetter (newVal) {
  46896. var value = getter ? getter.call(obj) : val;
  46897. /* eslint-disable no-self-compare */
  46898. if (newVal === value || (newVal !== newVal && value !== value)) {
  46899. return
  46900. }
  46901. /* eslint-enable no-self-compare */
  46902. if (customSetter) {
  46903. customSetter();
  46904. }
  46905. // #7981: for accessor properties without setter
  46906. if (getter && !setter) { return }
  46907. if (setter) {
  46908. setter.call(obj, newVal);
  46909. } else {
  46910. val = newVal;
  46911. }
  46912. childOb = !shallow && observe(newVal);
  46913. dep.notify();
  46914. }
  46915. });
  46916. }
  46917. /**
  46918. * Set a property on an object. Adds the new property and
  46919. * triggers change notification if the property doesn't
  46920. * already exist.
  46921. */
  46922. function set (target, key, val) {
  46923. if (isUndef(target) || isPrimitive(target)
  46924. ) {
  46925. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  46926. }
  46927. if (Array.isArray(target) && isValidArrayIndex(key)) {
  46928. target.length = Math.max(target.length, key);
  46929. target.splice(key, 1, val);
  46930. return val
  46931. }
  46932. if (key in target && !(key in Object.prototype)) {
  46933. target[key] = val;
  46934. return val
  46935. }
  46936. var ob = (target).__ob__;
  46937. if (target._isVue || (ob && ob.vmCount)) {
  46938. warn(
  46939. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  46940. 'at runtime - declare it upfront in the data option.'
  46941. );
  46942. return val
  46943. }
  46944. if (!ob) {
  46945. target[key] = val;
  46946. return val
  46947. }
  46948. defineReactive$$1(ob.value, key, val);
  46949. ob.dep.notify();
  46950. return val
  46951. }
  46952. /**
  46953. * Delete a property and trigger change if necessary.
  46954. */
  46955. function del (target, key) {
  46956. if (isUndef(target) || isPrimitive(target)
  46957. ) {
  46958. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  46959. }
  46960. if (Array.isArray(target) && isValidArrayIndex(key)) {
  46961. target.splice(key, 1);
  46962. return
  46963. }
  46964. var ob = (target).__ob__;
  46965. if (target._isVue || (ob && ob.vmCount)) {
  46966. warn(
  46967. 'Avoid deleting properties on a Vue instance or its root $data ' +
  46968. '- just set it to null.'
  46969. );
  46970. return
  46971. }
  46972. if (!hasOwn(target, key)) {
  46973. return
  46974. }
  46975. delete target[key];
  46976. if (!ob) {
  46977. return
  46978. }
  46979. ob.dep.notify();
  46980. }
  46981. /**
  46982. * Collect dependencies on array elements when the array is touched, since
  46983. * we cannot intercept array element access like property getters.
  46984. */
  46985. function dependArray (value) {
  46986. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  46987. e = value[i];
  46988. e && e.__ob__ && e.__ob__.dep.depend();
  46989. if (Array.isArray(e)) {
  46990. dependArray(e);
  46991. }
  46992. }
  46993. }
  46994. /* */
  46995. /**
  46996. * Option overwriting strategies are functions that handle
  46997. * how to merge a parent option value and a child option
  46998. * value into the final value.
  46999. */
  47000. var strats = config.optionMergeStrategies;
  47001. /**
  47002. * Options with restrictions
  47003. */
  47004. {
  47005. strats.el = strats.propsData = function (parent, child, vm, key) {
  47006. if (!vm) {
  47007. warn(
  47008. "option \"" + key + "\" can only be used during instance " +
  47009. 'creation with the `new` keyword.'
  47010. );
  47011. }
  47012. return defaultStrat(parent, child)
  47013. };
  47014. }
  47015. /**
  47016. * Helper that recursively merges two data objects together.
  47017. */
  47018. function mergeData (to, from) {
  47019. if (!from) { return to }
  47020. var key, toVal, fromVal;
  47021. var keys = hasSymbol
  47022. ? Reflect.ownKeys(from)
  47023. : Object.keys(from);
  47024. for (var i = 0; i < keys.length; i++) {
  47025. key = keys[i];
  47026. // in case the object is already observed...
  47027. if (key === '__ob__') { continue }
  47028. toVal = to[key];
  47029. fromVal = from[key];
  47030. if (!hasOwn(to, key)) {
  47031. set(to, key, fromVal);
  47032. } else if (
  47033. toVal !== fromVal &&
  47034. isPlainObject(toVal) &&
  47035. isPlainObject(fromVal)
  47036. ) {
  47037. mergeData(toVal, fromVal);
  47038. }
  47039. }
  47040. return to
  47041. }
  47042. /**
  47043. * Data
  47044. */
  47045. function mergeDataOrFn (
  47046. parentVal,
  47047. childVal,
  47048. vm
  47049. ) {
  47050. if (!vm) {
  47051. // in a Vue.extend merge, both should be functions
  47052. if (!childVal) {
  47053. return parentVal
  47054. }
  47055. if (!parentVal) {
  47056. return childVal
  47057. }
  47058. // when parentVal & childVal are both present,
  47059. // we need to return a function that returns the
  47060. // merged result of both functions... no need to
  47061. // check if parentVal is a function here because
  47062. // it has to be a function to pass previous merges.
  47063. return function mergedDataFn () {
  47064. return mergeData(
  47065. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  47066. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  47067. )
  47068. }
  47069. } else {
  47070. return function mergedInstanceDataFn () {
  47071. // instance merge
  47072. var instanceData = typeof childVal === 'function'
  47073. ? childVal.call(vm, vm)
  47074. : childVal;
  47075. var defaultData = typeof parentVal === 'function'
  47076. ? parentVal.call(vm, vm)
  47077. : parentVal;
  47078. if (instanceData) {
  47079. return mergeData(instanceData, defaultData)
  47080. } else {
  47081. return defaultData
  47082. }
  47083. }
  47084. }
  47085. }
  47086. strats.data = function (
  47087. parentVal,
  47088. childVal,
  47089. vm
  47090. ) {
  47091. if (!vm) {
  47092. if (childVal && typeof childVal !== 'function') {
  47093. warn(
  47094. 'The "data" option should be a function ' +
  47095. 'that returns a per-instance value in component ' +
  47096. 'definitions.',
  47097. vm
  47098. );
  47099. return parentVal
  47100. }
  47101. return mergeDataOrFn(parentVal, childVal)
  47102. }
  47103. return mergeDataOrFn(parentVal, childVal, vm)
  47104. };
  47105. /**
  47106. * Hooks and props are merged as arrays.
  47107. */
  47108. function mergeHook (
  47109. parentVal,
  47110. childVal
  47111. ) {
  47112. var res = childVal
  47113. ? parentVal
  47114. ? parentVal.concat(childVal)
  47115. : Array.isArray(childVal)
  47116. ? childVal
  47117. : [childVal]
  47118. : parentVal;
  47119. return res
  47120. ? dedupeHooks(res)
  47121. : res
  47122. }
  47123. function dedupeHooks (hooks) {
  47124. var res = [];
  47125. for (var i = 0; i < hooks.length; i++) {
  47126. if (res.indexOf(hooks[i]) === -1) {
  47127. res.push(hooks[i]);
  47128. }
  47129. }
  47130. return res
  47131. }
  47132. LIFECYCLE_HOOKS.forEach(function (hook) {
  47133. strats[hook] = mergeHook;
  47134. });
  47135. /**
  47136. * Assets
  47137. *
  47138. * When a vm is present (instance creation), we need to do
  47139. * a three-way merge between constructor options, instance
  47140. * options and parent options.
  47141. */
  47142. function mergeAssets (
  47143. parentVal,
  47144. childVal,
  47145. vm,
  47146. key
  47147. ) {
  47148. var res = Object.create(parentVal || null);
  47149. if (childVal) {
  47150. assertObjectType(key, childVal, vm);
  47151. return extend(res, childVal)
  47152. } else {
  47153. return res
  47154. }
  47155. }
  47156. ASSET_TYPES.forEach(function (type) {
  47157. strats[type + 's'] = mergeAssets;
  47158. });
  47159. /**
  47160. * Watchers.
  47161. *
  47162. * Watchers hashes should not overwrite one
  47163. * another, so we merge them as arrays.
  47164. */
  47165. strats.watch = function (
  47166. parentVal,
  47167. childVal,
  47168. vm,
  47169. key
  47170. ) {
  47171. // work around Firefox's Object.prototype.watch...
  47172. if (parentVal === nativeWatch) { parentVal = undefined; }
  47173. if (childVal === nativeWatch) { childVal = undefined; }
  47174. /* istanbul ignore if */
  47175. if (!childVal) { return Object.create(parentVal || null) }
  47176. {
  47177. assertObjectType(key, childVal, vm);
  47178. }
  47179. if (!parentVal) { return childVal }
  47180. var ret = {};
  47181. extend(ret, parentVal);
  47182. for (var key$1 in childVal) {
  47183. var parent = ret[key$1];
  47184. var child = childVal[key$1];
  47185. if (parent && !Array.isArray(parent)) {
  47186. parent = [parent];
  47187. }
  47188. ret[key$1] = parent
  47189. ? parent.concat(child)
  47190. : Array.isArray(child) ? child : [child];
  47191. }
  47192. return ret
  47193. };
  47194. /**
  47195. * Other object hashes.
  47196. */
  47197. strats.props =
  47198. strats.methods =
  47199. strats.inject =
  47200. strats.computed = function (
  47201. parentVal,
  47202. childVal,
  47203. vm,
  47204. key
  47205. ) {
  47206. if (childVal && "development" !== 'production') {
  47207. assertObjectType(key, childVal, vm);
  47208. }
  47209. if (!parentVal) { return childVal }
  47210. var ret = Object.create(null);
  47211. extend(ret, parentVal);
  47212. if (childVal) { extend(ret, childVal); }
  47213. return ret
  47214. };
  47215. strats.provide = mergeDataOrFn;
  47216. /**
  47217. * Default strategy.
  47218. */
  47219. var defaultStrat = function (parentVal, childVal) {
  47220. return childVal === undefined
  47221. ? parentVal
  47222. : childVal
  47223. };
  47224. /**
  47225. * Validate component names
  47226. */
  47227. function checkComponents (options) {
  47228. for (var key in options.components) {
  47229. validateComponentName(key);
  47230. }
  47231. }
  47232. function validateComponentName (name) {
  47233. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  47234. warn(
  47235. 'Invalid component name: "' + name + '". Component names ' +
  47236. 'should conform to valid custom element name in html5 specification.'
  47237. );
  47238. }
  47239. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  47240. warn(
  47241. 'Do not use built-in or reserved HTML elements as component ' +
  47242. 'id: ' + name
  47243. );
  47244. }
  47245. }
  47246. /**
  47247. * Ensure all props option syntax are normalized into the
  47248. * Object-based format.
  47249. */
  47250. function normalizeProps (options, vm) {
  47251. var props = options.props;
  47252. if (!props) { return }
  47253. var res = {};
  47254. var i, val, name;
  47255. if (Array.isArray(props)) {
  47256. i = props.length;
  47257. while (i--) {
  47258. val = props[i];
  47259. if (typeof val === 'string') {
  47260. name = camelize(val);
  47261. res[name] = { type: null };
  47262. } else {
  47263. warn('props must be strings when using array syntax.');
  47264. }
  47265. }
  47266. } else if (isPlainObject(props)) {
  47267. for (var key in props) {
  47268. val = props[key];
  47269. name = camelize(key);
  47270. res[name] = isPlainObject(val)
  47271. ? val
  47272. : { type: val };
  47273. }
  47274. } else {
  47275. warn(
  47276. "Invalid value for option \"props\": expected an Array or an Object, " +
  47277. "but got " + (toRawType(props)) + ".",
  47278. vm
  47279. );
  47280. }
  47281. options.props = res;
  47282. }
  47283. /**
  47284. * Normalize all injections into Object-based format
  47285. */
  47286. function normalizeInject (options, vm) {
  47287. var inject = options.inject;
  47288. if (!inject) { return }
  47289. var normalized = options.inject = {};
  47290. if (Array.isArray(inject)) {
  47291. for (var i = 0; i < inject.length; i++) {
  47292. normalized[inject[i]] = { from: inject[i] };
  47293. }
  47294. } else if (isPlainObject(inject)) {
  47295. for (var key in inject) {
  47296. var val = inject[key];
  47297. normalized[key] = isPlainObject(val)
  47298. ? extend({ from: key }, val)
  47299. : { from: val };
  47300. }
  47301. } else {
  47302. warn(
  47303. "Invalid value for option \"inject\": expected an Array or an Object, " +
  47304. "but got " + (toRawType(inject)) + ".",
  47305. vm
  47306. );
  47307. }
  47308. }
  47309. /**
  47310. * Normalize raw function directives into object format.
  47311. */
  47312. function normalizeDirectives (options) {
  47313. var dirs = options.directives;
  47314. if (dirs) {
  47315. for (var key in dirs) {
  47316. var def$$1 = dirs[key];
  47317. if (typeof def$$1 === 'function') {
  47318. dirs[key] = { bind: def$$1, update: def$$1 };
  47319. }
  47320. }
  47321. }
  47322. }
  47323. function assertObjectType (name, value, vm) {
  47324. if (!isPlainObject(value)) {
  47325. warn(
  47326. "Invalid value for option \"" + name + "\": expected an Object, " +
  47327. "but got " + (toRawType(value)) + ".",
  47328. vm
  47329. );
  47330. }
  47331. }
  47332. /**
  47333. * Merge two option objects into a new one.
  47334. * Core utility used in both instantiation and inheritance.
  47335. */
  47336. function mergeOptions (
  47337. parent,
  47338. child,
  47339. vm
  47340. ) {
  47341. {
  47342. checkComponents(child);
  47343. }
  47344. if (typeof child === 'function') {
  47345. child = child.options;
  47346. }
  47347. normalizeProps(child, vm);
  47348. normalizeInject(child, vm);
  47349. normalizeDirectives(child);
  47350. // Apply extends and mixins on the child options,
  47351. // but only if it is a raw options object that isn't
  47352. // the result of another mergeOptions call.
  47353. // Only merged options has the _base property.
  47354. if (!child._base) {
  47355. if (child.extends) {
  47356. parent = mergeOptions(parent, child.extends, vm);
  47357. }
  47358. if (child.mixins) {
  47359. for (var i = 0, l = child.mixins.length; i < l; i++) {
  47360. parent = mergeOptions(parent, child.mixins[i], vm);
  47361. }
  47362. }
  47363. }
  47364. var options = {};
  47365. var key;
  47366. for (key in parent) {
  47367. mergeField(key);
  47368. }
  47369. for (key in child) {
  47370. if (!hasOwn(parent, key)) {
  47371. mergeField(key);
  47372. }
  47373. }
  47374. function mergeField (key) {
  47375. var strat = strats[key] || defaultStrat;
  47376. options[key] = strat(parent[key], child[key], vm, key);
  47377. }
  47378. return options
  47379. }
  47380. /**
  47381. * Resolve an asset.
  47382. * This function is used because child instances need access
  47383. * to assets defined in its ancestor chain.
  47384. */
  47385. function resolveAsset (
  47386. options,
  47387. type,
  47388. id,
  47389. warnMissing
  47390. ) {
  47391. /* istanbul ignore if */
  47392. if (typeof id !== 'string') {
  47393. return
  47394. }
  47395. var assets = options[type];
  47396. // check local registration variations first
  47397. if (hasOwn(assets, id)) { return assets[id] }
  47398. var camelizedId = camelize(id);
  47399. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  47400. var PascalCaseId = capitalize(camelizedId);
  47401. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  47402. // fallback to prototype chain
  47403. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  47404. if (warnMissing && !res) {
  47405. warn(
  47406. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  47407. options
  47408. );
  47409. }
  47410. return res
  47411. }
  47412. /* */
  47413. function validateProp (
  47414. key,
  47415. propOptions,
  47416. propsData,
  47417. vm
  47418. ) {
  47419. var prop = propOptions[key];
  47420. var absent = !hasOwn(propsData, key);
  47421. var value = propsData[key];
  47422. // boolean casting
  47423. var booleanIndex = getTypeIndex(Boolean, prop.type);
  47424. if (booleanIndex > -1) {
  47425. if (absent && !hasOwn(prop, 'default')) {
  47426. value = false;
  47427. } else if (value === '' || value === hyphenate(key)) {
  47428. // only cast empty string / same name to boolean if
  47429. // boolean has higher priority
  47430. var stringIndex = getTypeIndex(String, prop.type);
  47431. if (stringIndex < 0 || booleanIndex < stringIndex) {
  47432. value = true;
  47433. }
  47434. }
  47435. }
  47436. // check default value
  47437. if (value === undefined) {
  47438. value = getPropDefaultValue(vm, prop, key);
  47439. // since the default value is a fresh copy,
  47440. // make sure to observe it.
  47441. var prevShouldObserve = shouldObserve;
  47442. toggleObserving(true);
  47443. observe(value);
  47444. toggleObserving(prevShouldObserve);
  47445. }
  47446. {
  47447. assertProp(prop, key, value, vm, absent);
  47448. }
  47449. return value
  47450. }
  47451. /**
  47452. * Get the default value of a prop.
  47453. */
  47454. function getPropDefaultValue (vm, prop, key) {
  47455. // no default, return undefined
  47456. if (!hasOwn(prop, 'default')) {
  47457. return undefined
  47458. }
  47459. var def = prop.default;
  47460. // warn against non-factory defaults for Object & Array
  47461. if (isObject(def)) {
  47462. warn(
  47463. 'Invalid default value for prop "' + key + '": ' +
  47464. 'Props with type Object/Array must use a factory function ' +
  47465. 'to return the default value.',
  47466. vm
  47467. );
  47468. }
  47469. // the raw prop value was also undefined from previous render,
  47470. // return previous default value to avoid unnecessary watcher trigger
  47471. if (vm && vm.$options.propsData &&
  47472. vm.$options.propsData[key] === undefined &&
  47473. vm._props[key] !== undefined
  47474. ) {
  47475. return vm._props[key]
  47476. }
  47477. // call factory function for non-Function types
  47478. // a value is Function if its prototype is function even across different execution context
  47479. return typeof def === 'function' && getType(prop.type) !== 'Function'
  47480. ? def.call(vm)
  47481. : def
  47482. }
  47483. /**
  47484. * Assert whether a prop is valid.
  47485. */
  47486. function assertProp (
  47487. prop,
  47488. name,
  47489. value,
  47490. vm,
  47491. absent
  47492. ) {
  47493. if (prop.required && absent) {
  47494. warn(
  47495. 'Missing required prop: "' + name + '"',
  47496. vm
  47497. );
  47498. return
  47499. }
  47500. if (value == null && !prop.required) {
  47501. return
  47502. }
  47503. var type = prop.type;
  47504. var valid = !type || type === true;
  47505. var expectedTypes = [];
  47506. if (type) {
  47507. if (!Array.isArray(type)) {
  47508. type = [type];
  47509. }
  47510. for (var i = 0; i < type.length && !valid; i++) {
  47511. var assertedType = assertType(value, type[i]);
  47512. expectedTypes.push(assertedType.expectedType || '');
  47513. valid = assertedType.valid;
  47514. }
  47515. }
  47516. if (!valid) {
  47517. warn(
  47518. getInvalidTypeMessage(name, value, expectedTypes),
  47519. vm
  47520. );
  47521. return
  47522. }
  47523. var validator = prop.validator;
  47524. if (validator) {
  47525. if (!validator(value)) {
  47526. warn(
  47527. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  47528. vm
  47529. );
  47530. }
  47531. }
  47532. }
  47533. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  47534. function assertType (value, type) {
  47535. var valid;
  47536. var expectedType = getType(type);
  47537. if (simpleCheckRE.test(expectedType)) {
  47538. var t = typeof value;
  47539. valid = t === expectedType.toLowerCase();
  47540. // for primitive wrapper objects
  47541. if (!valid && t === 'object') {
  47542. valid = value instanceof type;
  47543. }
  47544. } else if (expectedType === 'Object') {
  47545. valid = isPlainObject(value);
  47546. } else if (expectedType === 'Array') {
  47547. valid = Array.isArray(value);
  47548. } else {
  47549. valid = value instanceof type;
  47550. }
  47551. return {
  47552. valid: valid,
  47553. expectedType: expectedType
  47554. }
  47555. }
  47556. /**
  47557. * Use function string name to check built-in types,
  47558. * because a simple equality check will fail when running
  47559. * across different vms / iframes.
  47560. */
  47561. function getType (fn) {
  47562. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  47563. return match ? match[1] : ''
  47564. }
  47565. function isSameType (a, b) {
  47566. return getType(a) === getType(b)
  47567. }
  47568. function getTypeIndex (type, expectedTypes) {
  47569. if (!Array.isArray(expectedTypes)) {
  47570. return isSameType(expectedTypes, type) ? 0 : -1
  47571. }
  47572. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  47573. if (isSameType(expectedTypes[i], type)) {
  47574. return i
  47575. }
  47576. }
  47577. return -1
  47578. }
  47579. function getInvalidTypeMessage (name, value, expectedTypes) {
  47580. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  47581. " Expected " + (expectedTypes.map(capitalize).join(', '));
  47582. var expectedType = expectedTypes[0];
  47583. var receivedType = toRawType(value);
  47584. var expectedValue = styleValue(value, expectedType);
  47585. var receivedValue = styleValue(value, receivedType);
  47586. // check if we need to specify expected value
  47587. if (expectedTypes.length === 1 &&
  47588. isExplicable(expectedType) &&
  47589. !isBoolean(expectedType, receivedType)) {
  47590. message += " with value " + expectedValue;
  47591. }
  47592. message += ", got " + receivedType + " ";
  47593. // check if we need to specify received value
  47594. if (isExplicable(receivedType)) {
  47595. message += "with value " + receivedValue + ".";
  47596. }
  47597. return message
  47598. }
  47599. function styleValue (value, type) {
  47600. if (type === 'String') {
  47601. return ("\"" + value + "\"")
  47602. } else if (type === 'Number') {
  47603. return ("" + (Number(value)))
  47604. } else {
  47605. return ("" + value)
  47606. }
  47607. }
  47608. function isExplicable (value) {
  47609. var explicitTypes = ['string', 'number', 'boolean'];
  47610. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  47611. }
  47612. function isBoolean () {
  47613. var args = [], len = arguments.length;
  47614. while ( len-- ) args[ len ] = arguments[ len ];
  47615. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  47616. }
  47617. /* */
  47618. function handleError (err, vm, info) {
  47619. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  47620. // See: https://github.com/vuejs/vuex/issues/1505
  47621. pushTarget();
  47622. try {
  47623. if (vm) {
  47624. var cur = vm;
  47625. while ((cur = cur.$parent)) {
  47626. var hooks = cur.$options.errorCaptured;
  47627. if (hooks) {
  47628. for (var i = 0; i < hooks.length; i++) {
  47629. try {
  47630. var capture = hooks[i].call(cur, err, vm, info) === false;
  47631. if (capture) { return }
  47632. } catch (e) {
  47633. globalHandleError(e, cur, 'errorCaptured hook');
  47634. }
  47635. }
  47636. }
  47637. }
  47638. }
  47639. globalHandleError(err, vm, info);
  47640. } finally {
  47641. popTarget();
  47642. }
  47643. }
  47644. function invokeWithErrorHandling (
  47645. handler,
  47646. context,
  47647. args,
  47648. vm,
  47649. info
  47650. ) {
  47651. var res;
  47652. try {
  47653. res = args ? handler.apply(context, args) : handler.call(context);
  47654. if (res && !res._isVue && isPromise(res) && !res._handled) {
  47655. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  47656. // issue #9511
  47657. // avoid catch triggering multiple times when nested calls
  47658. res._handled = true;
  47659. }
  47660. } catch (e) {
  47661. handleError(e, vm, info);
  47662. }
  47663. return res
  47664. }
  47665. function globalHandleError (err, vm, info) {
  47666. if (config.errorHandler) {
  47667. try {
  47668. return config.errorHandler.call(null, err, vm, info)
  47669. } catch (e) {
  47670. // if the user intentionally throws the original error in the handler,
  47671. // do not log it twice
  47672. if (e !== err) {
  47673. logError(e, null, 'config.errorHandler');
  47674. }
  47675. }
  47676. }
  47677. logError(err, vm, info);
  47678. }
  47679. function logError (err, vm, info) {
  47680. {
  47681. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  47682. }
  47683. /* istanbul ignore else */
  47684. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  47685. console.error(err);
  47686. } else {
  47687. throw err
  47688. }
  47689. }
  47690. /* */
  47691. var isUsingMicroTask = false;
  47692. var callbacks = [];
  47693. var pending = false;
  47694. function flushCallbacks () {
  47695. pending = false;
  47696. var copies = callbacks.slice(0);
  47697. callbacks.length = 0;
  47698. for (var i = 0; i < copies.length; i++) {
  47699. copies[i]();
  47700. }
  47701. }
  47702. // Here we have async deferring wrappers using microtasks.
  47703. // In 2.5 we used (macro) tasks (in combination with microtasks).
  47704. // However, it has subtle problems when state is changed right before repaint
  47705. // (e.g. #6813, out-in transitions).
  47706. // Also, using (macro) tasks in event handler would cause some weird behaviors
  47707. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  47708. // So we now use microtasks everywhere, again.
  47709. // A major drawback of this tradeoff is that there are some scenarios
  47710. // where microtasks have too high a priority and fire in between supposedly
  47711. // sequential events (e.g. #4521, #6690, which have workarounds)
  47712. // or even between bubbling of the same event (#6566).
  47713. var timerFunc;
  47714. // The nextTick behavior leverages the microtask queue, which can be accessed
  47715. // via either native Promise.then or MutationObserver.
  47716. // MutationObserver has wider support, however it is seriously bugged in
  47717. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  47718. // completely stops working after triggering a few times... so, if native
  47719. // Promise is available, we will use it:
  47720. /* istanbul ignore next, $flow-disable-line */
  47721. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  47722. var p = Promise.resolve();
  47723. timerFunc = function () {
  47724. p.then(flushCallbacks);
  47725. // In problematic UIWebViews, Promise.then doesn't completely break, but
  47726. // it can get stuck in a weird state where callbacks are pushed into the
  47727. // microtask queue but the queue isn't being flushed, until the browser
  47728. // needs to do some other work, e.g. handle a timer. Therefore we can
  47729. // "force" the microtask queue to be flushed by adding an empty timer.
  47730. if (isIOS) { setTimeout(noop); }
  47731. };
  47732. isUsingMicroTask = true;
  47733. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  47734. isNative(MutationObserver) ||
  47735. // PhantomJS and iOS 7.x
  47736. MutationObserver.toString() === '[object MutationObserverConstructor]'
  47737. )) {
  47738. // Use MutationObserver where native Promise is not available,
  47739. // e.g. PhantomJS, iOS7, Android 4.4
  47740. // (#6466 MutationObserver is unreliable in IE11)
  47741. var counter = 1;
  47742. var observer = new MutationObserver(flushCallbacks);
  47743. var textNode = document.createTextNode(String(counter));
  47744. observer.observe(textNode, {
  47745. characterData: true
  47746. });
  47747. timerFunc = function () {
  47748. counter = (counter + 1) % 2;
  47749. textNode.data = String(counter);
  47750. };
  47751. isUsingMicroTask = true;
  47752. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  47753. // Fallback to setImmediate.
  47754. // Technically it leverages the (macro) task queue,
  47755. // but it is still a better choice than setTimeout.
  47756. timerFunc = function () {
  47757. setImmediate(flushCallbacks);
  47758. };
  47759. } else {
  47760. // Fallback to setTimeout.
  47761. timerFunc = function () {
  47762. setTimeout(flushCallbacks, 0);
  47763. };
  47764. }
  47765. function nextTick (cb, ctx) {
  47766. var _resolve;
  47767. callbacks.push(function () {
  47768. if (cb) {
  47769. try {
  47770. cb.call(ctx);
  47771. } catch (e) {
  47772. handleError(e, ctx, 'nextTick');
  47773. }
  47774. } else if (_resolve) {
  47775. _resolve(ctx);
  47776. }
  47777. });
  47778. if (!pending) {
  47779. pending = true;
  47780. timerFunc();
  47781. }
  47782. // $flow-disable-line
  47783. if (!cb && typeof Promise !== 'undefined') {
  47784. return new Promise(function (resolve) {
  47785. _resolve = resolve;
  47786. })
  47787. }
  47788. }
  47789. /* */
  47790. var mark;
  47791. var measure;
  47792. {
  47793. var perf = inBrowser && window.performance;
  47794. /* istanbul ignore if */
  47795. if (
  47796. perf &&
  47797. perf.mark &&
  47798. perf.measure &&
  47799. perf.clearMarks &&
  47800. perf.clearMeasures
  47801. ) {
  47802. mark = function (tag) { return perf.mark(tag); };
  47803. measure = function (name, startTag, endTag) {
  47804. perf.measure(name, startTag, endTag);
  47805. perf.clearMarks(startTag);
  47806. perf.clearMarks(endTag);
  47807. // perf.clearMeasures(name)
  47808. };
  47809. }
  47810. }
  47811. /* not type checking this file because flow doesn't play well with Proxy */
  47812. var initProxy;
  47813. {
  47814. var allowedGlobals = makeMap(
  47815. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  47816. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  47817. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  47818. 'require' // for Webpack/Browserify
  47819. );
  47820. var warnNonPresent = function (target, key) {
  47821. warn(
  47822. "Property or method \"" + key + "\" is not defined on the instance but " +
  47823. 'referenced during render. Make sure that this property is reactive, ' +
  47824. 'either in the data option, or for class-based components, by ' +
  47825. 'initializing the property. ' +
  47826. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  47827. target
  47828. );
  47829. };
  47830. var warnReservedPrefix = function (target, key) {
  47831. warn(
  47832. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  47833. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  47834. 'prevent conflicts with Vue internals. ' +
  47835. 'See: https://vuejs.org/v2/api/#data',
  47836. target
  47837. );
  47838. };
  47839. var hasProxy =
  47840. typeof Proxy !== 'undefined' && isNative(Proxy);
  47841. if (hasProxy) {
  47842. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  47843. config.keyCodes = new Proxy(config.keyCodes, {
  47844. set: function set (target, key, value) {
  47845. if (isBuiltInModifier(key)) {
  47846. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  47847. return false
  47848. } else {
  47849. target[key] = value;
  47850. return true
  47851. }
  47852. }
  47853. });
  47854. }
  47855. var hasHandler = {
  47856. has: function has (target, key) {
  47857. var has = key in target;
  47858. var isAllowed = allowedGlobals(key) ||
  47859. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  47860. if (!has && !isAllowed) {
  47861. if (key in target.$data) { warnReservedPrefix(target, key); }
  47862. else { warnNonPresent(target, key); }
  47863. }
  47864. return has || !isAllowed
  47865. }
  47866. };
  47867. var getHandler = {
  47868. get: function get (target, key) {
  47869. if (typeof key === 'string' && !(key in target)) {
  47870. if (key in target.$data) { warnReservedPrefix(target, key); }
  47871. else { warnNonPresent(target, key); }
  47872. }
  47873. return target[key]
  47874. }
  47875. };
  47876. initProxy = function initProxy (vm) {
  47877. if (hasProxy) {
  47878. // determine which proxy handler to use
  47879. var options = vm.$options;
  47880. var handlers = options.render && options.render._withStripped
  47881. ? getHandler
  47882. : hasHandler;
  47883. vm._renderProxy = new Proxy(vm, handlers);
  47884. } else {
  47885. vm._renderProxy = vm;
  47886. }
  47887. };
  47888. }
  47889. /* */
  47890. var seenObjects = new _Set();
  47891. /**
  47892. * Recursively traverse an object to evoke all converted
  47893. * getters, so that every nested property inside the object
  47894. * is collected as a "deep" dependency.
  47895. */
  47896. function traverse (val) {
  47897. _traverse(val, seenObjects);
  47898. seenObjects.clear();
  47899. }
  47900. function _traverse (val, seen) {
  47901. var i, keys;
  47902. var isA = Array.isArray(val);
  47903. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  47904. return
  47905. }
  47906. if (val.__ob__) {
  47907. var depId = val.__ob__.dep.id;
  47908. if (seen.has(depId)) {
  47909. return
  47910. }
  47911. seen.add(depId);
  47912. }
  47913. if (isA) {
  47914. i = val.length;
  47915. while (i--) { _traverse(val[i], seen); }
  47916. } else {
  47917. keys = Object.keys(val);
  47918. i = keys.length;
  47919. while (i--) { _traverse(val[keys[i]], seen); }
  47920. }
  47921. }
  47922. /* */
  47923. var normalizeEvent = cached(function (name) {
  47924. var passive = name.charAt(0) === '&';
  47925. name = passive ? name.slice(1) : name;
  47926. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  47927. name = once$$1 ? name.slice(1) : name;
  47928. var capture = name.charAt(0) === '!';
  47929. name = capture ? name.slice(1) : name;
  47930. return {
  47931. name: name,
  47932. once: once$$1,
  47933. capture: capture,
  47934. passive: passive
  47935. }
  47936. });
  47937. function createFnInvoker (fns, vm) {
  47938. function invoker () {
  47939. var arguments$1 = arguments;
  47940. var fns = invoker.fns;
  47941. if (Array.isArray(fns)) {
  47942. var cloned = fns.slice();
  47943. for (var i = 0; i < cloned.length; i++) {
  47944. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  47945. }
  47946. } else {
  47947. // return handler return value for single handlers
  47948. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  47949. }
  47950. }
  47951. invoker.fns = fns;
  47952. return invoker
  47953. }
  47954. function updateListeners (
  47955. on,
  47956. oldOn,
  47957. add,
  47958. remove$$1,
  47959. createOnceHandler,
  47960. vm
  47961. ) {
  47962. var name, def$$1, cur, old, event;
  47963. for (name in on) {
  47964. def$$1 = cur = on[name];
  47965. old = oldOn[name];
  47966. event = normalizeEvent(name);
  47967. if (isUndef(cur)) {
  47968. warn(
  47969. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  47970. vm
  47971. );
  47972. } else if (isUndef(old)) {
  47973. if (isUndef(cur.fns)) {
  47974. cur = on[name] = createFnInvoker(cur, vm);
  47975. }
  47976. if (isTrue(event.once)) {
  47977. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  47978. }
  47979. add(event.name, cur, event.capture, event.passive, event.params);
  47980. } else if (cur !== old) {
  47981. old.fns = cur;
  47982. on[name] = old;
  47983. }
  47984. }
  47985. for (name in oldOn) {
  47986. if (isUndef(on[name])) {
  47987. event = normalizeEvent(name);
  47988. remove$$1(event.name, oldOn[name], event.capture);
  47989. }
  47990. }
  47991. }
  47992. /* */
  47993. function mergeVNodeHook (def, hookKey, hook) {
  47994. if (def instanceof VNode) {
  47995. def = def.data.hook || (def.data.hook = {});
  47996. }
  47997. var invoker;
  47998. var oldHook = def[hookKey];
  47999. function wrappedHook () {
  48000. hook.apply(this, arguments);
  48001. // important: remove merged hook to ensure it's called only once
  48002. // and prevent memory leak
  48003. remove(invoker.fns, wrappedHook);
  48004. }
  48005. if (isUndef(oldHook)) {
  48006. // no existing hook
  48007. invoker = createFnInvoker([wrappedHook]);
  48008. } else {
  48009. /* istanbul ignore if */
  48010. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  48011. // already a merged invoker
  48012. invoker = oldHook;
  48013. invoker.fns.push(wrappedHook);
  48014. } else {
  48015. // existing plain hook
  48016. invoker = createFnInvoker([oldHook, wrappedHook]);
  48017. }
  48018. }
  48019. invoker.merged = true;
  48020. def[hookKey] = invoker;
  48021. }
  48022. /* */
  48023. function extractPropsFromVNodeData (
  48024. data,
  48025. Ctor,
  48026. tag
  48027. ) {
  48028. // we are only extracting raw values here.
  48029. // validation and default values are handled in the child
  48030. // component itself.
  48031. var propOptions = Ctor.options.props;
  48032. if (isUndef(propOptions)) {
  48033. return
  48034. }
  48035. var res = {};
  48036. var attrs = data.attrs;
  48037. var props = data.props;
  48038. if (isDef(attrs) || isDef(props)) {
  48039. for (var key in propOptions) {
  48040. var altKey = hyphenate(key);
  48041. {
  48042. var keyInLowerCase = key.toLowerCase();
  48043. if (
  48044. key !== keyInLowerCase &&
  48045. attrs && hasOwn(attrs, keyInLowerCase)
  48046. ) {
  48047. tip(
  48048. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  48049. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  48050. " \"" + key + "\". " +
  48051. "Note that HTML attributes are case-insensitive and camelCased " +
  48052. "props need to use their kebab-case equivalents when using in-DOM " +
  48053. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  48054. );
  48055. }
  48056. }
  48057. checkProp(res, props, key, altKey, true) ||
  48058. checkProp(res, attrs, key, altKey, false);
  48059. }
  48060. }
  48061. return res
  48062. }
  48063. function checkProp (
  48064. res,
  48065. hash,
  48066. key,
  48067. altKey,
  48068. preserve
  48069. ) {
  48070. if (isDef(hash)) {
  48071. if (hasOwn(hash, key)) {
  48072. res[key] = hash[key];
  48073. if (!preserve) {
  48074. delete hash[key];
  48075. }
  48076. return true
  48077. } else if (hasOwn(hash, altKey)) {
  48078. res[key] = hash[altKey];
  48079. if (!preserve) {
  48080. delete hash[altKey];
  48081. }
  48082. return true
  48083. }
  48084. }
  48085. return false
  48086. }
  48087. /* */
  48088. // The template compiler attempts to minimize the need for normalization by
  48089. // statically analyzing the template at compile time.
  48090. //
  48091. // For plain HTML markup, normalization can be completely skipped because the
  48092. // generated render function is guaranteed to return Array<VNode>. There are
  48093. // two cases where extra normalization is needed:
  48094. // 1. When the children contains components - because a functional component
  48095. // may return an Array instead of a single root. In this case, just a simple
  48096. // normalization is needed - if any child is an Array, we flatten the whole
  48097. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  48098. // because functional components already normalize their own children.
  48099. function simpleNormalizeChildren (children) {
  48100. for (var i = 0; i < children.length; i++) {
  48101. if (Array.isArray(children[i])) {
  48102. return Array.prototype.concat.apply([], children)
  48103. }
  48104. }
  48105. return children
  48106. }
  48107. // 2. When the children contains constructs that always generated nested Arrays,
  48108. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  48109. // with hand-written render functions / JSX. In such cases a full normalization
  48110. // is needed to cater to all possible types of children values.
  48111. function normalizeChildren (children) {
  48112. return isPrimitive(children)
  48113. ? [createTextVNode(children)]
  48114. : Array.isArray(children)
  48115. ? normalizeArrayChildren(children)
  48116. : undefined
  48117. }
  48118. function isTextNode (node) {
  48119. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  48120. }
  48121. function normalizeArrayChildren (children, nestedIndex) {
  48122. var res = [];
  48123. var i, c, lastIndex, last;
  48124. for (i = 0; i < children.length; i++) {
  48125. c = children[i];
  48126. if (isUndef(c) || typeof c === 'boolean') { continue }
  48127. lastIndex = res.length - 1;
  48128. last = res[lastIndex];
  48129. // nested
  48130. if (Array.isArray(c)) {
  48131. if (c.length > 0) {
  48132. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  48133. // merge adjacent text nodes
  48134. if (isTextNode(c[0]) && isTextNode(last)) {
  48135. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  48136. c.shift();
  48137. }
  48138. res.push.apply(res, c);
  48139. }
  48140. } else if (isPrimitive(c)) {
  48141. if (isTextNode(last)) {
  48142. // merge adjacent text nodes
  48143. // this is necessary for SSR hydration because text nodes are
  48144. // essentially merged when rendered to HTML strings
  48145. res[lastIndex] = createTextVNode(last.text + c);
  48146. } else if (c !== '') {
  48147. // convert primitive to vnode
  48148. res.push(createTextVNode(c));
  48149. }
  48150. } else {
  48151. if (isTextNode(c) && isTextNode(last)) {
  48152. // merge adjacent text nodes
  48153. res[lastIndex] = createTextVNode(last.text + c.text);
  48154. } else {
  48155. // default key for nested array children (likely generated by v-for)
  48156. if (isTrue(children._isVList) &&
  48157. isDef(c.tag) &&
  48158. isUndef(c.key) &&
  48159. isDef(nestedIndex)) {
  48160. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  48161. }
  48162. res.push(c);
  48163. }
  48164. }
  48165. }
  48166. return res
  48167. }
  48168. /* */
  48169. function initProvide (vm) {
  48170. var provide = vm.$options.provide;
  48171. if (provide) {
  48172. vm._provided = typeof provide === 'function'
  48173. ? provide.call(vm)
  48174. : provide;
  48175. }
  48176. }
  48177. function initInjections (vm) {
  48178. var result = resolveInject(vm.$options.inject, vm);
  48179. if (result) {
  48180. toggleObserving(false);
  48181. Object.keys(result).forEach(function (key) {
  48182. /* istanbul ignore else */
  48183. {
  48184. defineReactive$$1(vm, key, result[key], function () {
  48185. warn(
  48186. "Avoid mutating an injected value directly since the changes will be " +
  48187. "overwritten whenever the provided component re-renders. " +
  48188. "injection being mutated: \"" + key + "\"",
  48189. vm
  48190. );
  48191. });
  48192. }
  48193. });
  48194. toggleObserving(true);
  48195. }
  48196. }
  48197. function resolveInject (inject, vm) {
  48198. if (inject) {
  48199. // inject is :any because flow is not smart enough to figure out cached
  48200. var result = Object.create(null);
  48201. var keys = hasSymbol
  48202. ? Reflect.ownKeys(inject)
  48203. : Object.keys(inject);
  48204. for (var i = 0; i < keys.length; i++) {
  48205. var key = keys[i];
  48206. // #6574 in case the inject object is observed...
  48207. if (key === '__ob__') { continue }
  48208. var provideKey = inject[key].from;
  48209. var source = vm;
  48210. while (source) {
  48211. if (source._provided && hasOwn(source._provided, provideKey)) {
  48212. result[key] = source._provided[provideKey];
  48213. break
  48214. }
  48215. source = source.$parent;
  48216. }
  48217. if (!source) {
  48218. if ('default' in inject[key]) {
  48219. var provideDefault = inject[key].default;
  48220. result[key] = typeof provideDefault === 'function'
  48221. ? provideDefault.call(vm)
  48222. : provideDefault;
  48223. } else {
  48224. warn(("Injection \"" + key + "\" not found"), vm);
  48225. }
  48226. }
  48227. }
  48228. return result
  48229. }
  48230. }
  48231. /* */
  48232. /**
  48233. * Runtime helper for resolving raw children VNodes into a slot object.
  48234. */
  48235. function resolveSlots (
  48236. children,
  48237. context
  48238. ) {
  48239. if (!children || !children.length) {
  48240. return {}
  48241. }
  48242. var slots = {};
  48243. for (var i = 0, l = children.length; i < l; i++) {
  48244. var child = children[i];
  48245. var data = child.data;
  48246. // remove slot attribute if the node is resolved as a Vue slot node
  48247. if (data && data.attrs && data.attrs.slot) {
  48248. delete data.attrs.slot;
  48249. }
  48250. // named slots should only be respected if the vnode was rendered in the
  48251. // same context.
  48252. if ((child.context === context || child.fnContext === context) &&
  48253. data && data.slot != null
  48254. ) {
  48255. var name = data.slot;
  48256. var slot = (slots[name] || (slots[name] = []));
  48257. if (child.tag === 'template') {
  48258. slot.push.apply(slot, child.children || []);
  48259. } else {
  48260. slot.push(child);
  48261. }
  48262. } else {
  48263. (slots.default || (slots.default = [])).push(child);
  48264. }
  48265. }
  48266. // ignore slots that contains only whitespace
  48267. for (var name$1 in slots) {
  48268. if (slots[name$1].every(isWhitespace)) {
  48269. delete slots[name$1];
  48270. }
  48271. }
  48272. return slots
  48273. }
  48274. function isWhitespace (node) {
  48275. return (node.isComment && !node.asyncFactory) || node.text === ' '
  48276. }
  48277. /* */
  48278. function normalizeScopedSlots (
  48279. slots,
  48280. normalSlots,
  48281. prevSlots
  48282. ) {
  48283. var res;
  48284. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  48285. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  48286. var key = slots && slots.$key;
  48287. if (!slots) {
  48288. res = {};
  48289. } else if (slots._normalized) {
  48290. // fast path 1: child component re-render only, parent did not change
  48291. return slots._normalized
  48292. } else if (
  48293. isStable &&
  48294. prevSlots &&
  48295. prevSlots !== emptyObject &&
  48296. key === prevSlots.$key &&
  48297. !hasNormalSlots &&
  48298. !prevSlots.$hasNormal
  48299. ) {
  48300. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  48301. // only need to normalize once
  48302. return prevSlots
  48303. } else {
  48304. res = {};
  48305. for (var key$1 in slots) {
  48306. if (slots[key$1] && key$1[0] !== '$') {
  48307. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  48308. }
  48309. }
  48310. }
  48311. // expose normal slots on scopedSlots
  48312. for (var key$2 in normalSlots) {
  48313. if (!(key$2 in res)) {
  48314. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  48315. }
  48316. }
  48317. // avoriaz seems to mock a non-extensible $scopedSlots object
  48318. // and when that is passed down this would cause an error
  48319. if (slots && Object.isExtensible(slots)) {
  48320. (slots)._normalized = res;
  48321. }
  48322. def(res, '$stable', isStable);
  48323. def(res, '$key', key);
  48324. def(res, '$hasNormal', hasNormalSlots);
  48325. return res
  48326. }
  48327. function normalizeScopedSlot(normalSlots, key, fn) {
  48328. var normalized = function () {
  48329. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  48330. res = res && typeof res === 'object' && !Array.isArray(res)
  48331. ? [res] // single vnode
  48332. : normalizeChildren(res);
  48333. return res && (
  48334. res.length === 0 ||
  48335. (res.length === 1 && res[0].isComment) // #9658
  48336. ) ? undefined
  48337. : res
  48338. };
  48339. // this is a slot using the new v-slot syntax without scope. although it is
  48340. // compiled as a scoped slot, render fn users would expect it to be present
  48341. // on this.$slots because the usage is semantically a normal slot.
  48342. if (fn.proxy) {
  48343. Object.defineProperty(normalSlots, key, {
  48344. get: normalized,
  48345. enumerable: true,
  48346. configurable: true
  48347. });
  48348. }
  48349. return normalized
  48350. }
  48351. function proxyNormalSlot(slots, key) {
  48352. return function () { return slots[key]; }
  48353. }
  48354. /* */
  48355. /**
  48356. * Runtime helper for rendering v-for lists.
  48357. */
  48358. function renderList (
  48359. val,
  48360. render
  48361. ) {
  48362. var ret, i, l, keys, key;
  48363. if (Array.isArray(val) || typeof val === 'string') {
  48364. ret = new Array(val.length);
  48365. for (i = 0, l = val.length; i < l; i++) {
  48366. ret[i] = render(val[i], i);
  48367. }
  48368. } else if (typeof val === 'number') {
  48369. ret = new Array(val);
  48370. for (i = 0; i < val; i++) {
  48371. ret[i] = render(i + 1, i);
  48372. }
  48373. } else if (isObject(val)) {
  48374. if (hasSymbol && val[Symbol.iterator]) {
  48375. ret = [];
  48376. var iterator = val[Symbol.iterator]();
  48377. var result = iterator.next();
  48378. while (!result.done) {
  48379. ret.push(render(result.value, ret.length));
  48380. result = iterator.next();
  48381. }
  48382. } else {
  48383. keys = Object.keys(val);
  48384. ret = new Array(keys.length);
  48385. for (i = 0, l = keys.length; i < l; i++) {
  48386. key = keys[i];
  48387. ret[i] = render(val[key], key, i);
  48388. }
  48389. }
  48390. }
  48391. if (!isDef(ret)) {
  48392. ret = [];
  48393. }
  48394. (ret)._isVList = true;
  48395. return ret
  48396. }
  48397. /* */
  48398. /**
  48399. * Runtime helper for rendering <slot>
  48400. */
  48401. function renderSlot (
  48402. name,
  48403. fallback,
  48404. props,
  48405. bindObject
  48406. ) {
  48407. var scopedSlotFn = this.$scopedSlots[name];
  48408. var nodes;
  48409. if (scopedSlotFn) { // scoped slot
  48410. props = props || {};
  48411. if (bindObject) {
  48412. if (!isObject(bindObject)) {
  48413. warn(
  48414. 'slot v-bind without argument expects an Object',
  48415. this
  48416. );
  48417. }
  48418. props = extend(extend({}, bindObject), props);
  48419. }
  48420. nodes = scopedSlotFn(props) || fallback;
  48421. } else {
  48422. nodes = this.$slots[name] || fallback;
  48423. }
  48424. var target = props && props.slot;
  48425. if (target) {
  48426. return this.$createElement('template', { slot: target }, nodes)
  48427. } else {
  48428. return nodes
  48429. }
  48430. }
  48431. /* */
  48432. /**
  48433. * Runtime helper for resolving filters
  48434. */
  48435. function resolveFilter (id) {
  48436. return resolveAsset(this.$options, 'filters', id, true) || identity
  48437. }
  48438. /* */
  48439. function isKeyNotMatch (expect, actual) {
  48440. if (Array.isArray(expect)) {
  48441. return expect.indexOf(actual) === -1
  48442. } else {
  48443. return expect !== actual
  48444. }
  48445. }
  48446. /**
  48447. * Runtime helper for checking keyCodes from config.
  48448. * exposed as Vue.prototype._k
  48449. * passing in eventKeyName as last argument separately for backwards compat
  48450. */
  48451. function checkKeyCodes (
  48452. eventKeyCode,
  48453. key,
  48454. builtInKeyCode,
  48455. eventKeyName,
  48456. builtInKeyName
  48457. ) {
  48458. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  48459. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  48460. return isKeyNotMatch(builtInKeyName, eventKeyName)
  48461. } else if (mappedKeyCode) {
  48462. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  48463. } else if (eventKeyName) {
  48464. return hyphenate(eventKeyName) !== key
  48465. }
  48466. }
  48467. /* */
  48468. /**
  48469. * Runtime helper for merging v-bind="object" into a VNode's data.
  48470. */
  48471. function bindObjectProps (
  48472. data,
  48473. tag,
  48474. value,
  48475. asProp,
  48476. isSync
  48477. ) {
  48478. if (value) {
  48479. if (!isObject(value)) {
  48480. warn(
  48481. 'v-bind without argument expects an Object or Array value',
  48482. this
  48483. );
  48484. } else {
  48485. if (Array.isArray(value)) {
  48486. value = toObject(value);
  48487. }
  48488. var hash;
  48489. var loop = function ( key ) {
  48490. if (
  48491. key === 'class' ||
  48492. key === 'style' ||
  48493. isReservedAttribute(key)
  48494. ) {
  48495. hash = data;
  48496. } else {
  48497. var type = data.attrs && data.attrs.type;
  48498. hash = asProp || config.mustUseProp(tag, type, key)
  48499. ? data.domProps || (data.domProps = {})
  48500. : data.attrs || (data.attrs = {});
  48501. }
  48502. var camelizedKey = camelize(key);
  48503. var hyphenatedKey = hyphenate(key);
  48504. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  48505. hash[key] = value[key];
  48506. if (isSync) {
  48507. var on = data.on || (data.on = {});
  48508. on[("update:" + key)] = function ($event) {
  48509. value[key] = $event;
  48510. };
  48511. }
  48512. }
  48513. };
  48514. for (var key in value) loop( key );
  48515. }
  48516. }
  48517. return data
  48518. }
  48519. /* */
  48520. /**
  48521. * Runtime helper for rendering static trees.
  48522. */
  48523. function renderStatic (
  48524. index,
  48525. isInFor
  48526. ) {
  48527. var cached = this._staticTrees || (this._staticTrees = []);
  48528. var tree = cached[index];
  48529. // if has already-rendered static tree and not inside v-for,
  48530. // we can reuse the same tree.
  48531. if (tree && !isInFor) {
  48532. return tree
  48533. }
  48534. // otherwise, render a fresh tree.
  48535. tree = cached[index] = this.$options.staticRenderFns[index].call(
  48536. this._renderProxy,
  48537. null,
  48538. this // for render fns generated for functional component templates
  48539. );
  48540. markStatic(tree, ("__static__" + index), false);
  48541. return tree
  48542. }
  48543. /**
  48544. * Runtime helper for v-once.
  48545. * Effectively it means marking the node as static with a unique key.
  48546. */
  48547. function markOnce (
  48548. tree,
  48549. index,
  48550. key
  48551. ) {
  48552. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  48553. return tree
  48554. }
  48555. function markStatic (
  48556. tree,
  48557. key,
  48558. isOnce
  48559. ) {
  48560. if (Array.isArray(tree)) {
  48561. for (var i = 0; i < tree.length; i++) {
  48562. if (tree[i] && typeof tree[i] !== 'string') {
  48563. markStaticNode(tree[i], (key + "_" + i), isOnce);
  48564. }
  48565. }
  48566. } else {
  48567. markStaticNode(tree, key, isOnce);
  48568. }
  48569. }
  48570. function markStaticNode (node, key, isOnce) {
  48571. node.isStatic = true;
  48572. node.key = key;
  48573. node.isOnce = isOnce;
  48574. }
  48575. /* */
  48576. function bindObjectListeners (data, value) {
  48577. if (value) {
  48578. if (!isPlainObject(value)) {
  48579. warn(
  48580. 'v-on without argument expects an Object value',
  48581. this
  48582. );
  48583. } else {
  48584. var on = data.on = data.on ? extend({}, data.on) : {};
  48585. for (var key in value) {
  48586. var existing = on[key];
  48587. var ours = value[key];
  48588. on[key] = existing ? [].concat(existing, ours) : ours;
  48589. }
  48590. }
  48591. }
  48592. return data
  48593. }
  48594. /* */
  48595. function resolveScopedSlots (
  48596. fns, // see flow/vnode
  48597. res,
  48598. // the following are added in 2.6
  48599. hasDynamicKeys,
  48600. contentHashKey
  48601. ) {
  48602. res = res || { $stable: !hasDynamicKeys };
  48603. for (var i = 0; i < fns.length; i++) {
  48604. var slot = fns[i];
  48605. if (Array.isArray(slot)) {
  48606. resolveScopedSlots(slot, res, hasDynamicKeys);
  48607. } else if (slot) {
  48608. // marker for reverse proxying v-slot without scope on this.$slots
  48609. if (slot.proxy) {
  48610. slot.fn.proxy = true;
  48611. }
  48612. res[slot.key] = slot.fn;
  48613. }
  48614. }
  48615. if (contentHashKey) {
  48616. (res).$key = contentHashKey;
  48617. }
  48618. return res
  48619. }
  48620. /* */
  48621. function bindDynamicKeys (baseObj, values) {
  48622. for (var i = 0; i < values.length; i += 2) {
  48623. var key = values[i];
  48624. if (typeof key === 'string' && key) {
  48625. baseObj[values[i]] = values[i + 1];
  48626. } else if (key !== '' && key !== null) {
  48627. // null is a special value for explicitly removing a binding
  48628. warn(
  48629. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  48630. this
  48631. );
  48632. }
  48633. }
  48634. return baseObj
  48635. }
  48636. // helper to dynamically append modifier runtime markers to event names.
  48637. // ensure only append when value is already string, otherwise it will be cast
  48638. // to string and cause the type check to miss.
  48639. function prependModifier (value, symbol) {
  48640. return typeof value === 'string' ? symbol + value : value
  48641. }
  48642. /* */
  48643. function installRenderHelpers (target) {
  48644. target._o = markOnce;
  48645. target._n = toNumber;
  48646. target._s = toString;
  48647. target._l = renderList;
  48648. target._t = renderSlot;
  48649. target._q = looseEqual;
  48650. target._i = looseIndexOf;
  48651. target._m = renderStatic;
  48652. target._f = resolveFilter;
  48653. target._k = checkKeyCodes;
  48654. target._b = bindObjectProps;
  48655. target._v = createTextVNode;
  48656. target._e = createEmptyVNode;
  48657. target._u = resolveScopedSlots;
  48658. target._g = bindObjectListeners;
  48659. target._d = bindDynamicKeys;
  48660. target._p = prependModifier;
  48661. }
  48662. /* */
  48663. function FunctionalRenderContext (
  48664. data,
  48665. props,
  48666. children,
  48667. parent,
  48668. Ctor
  48669. ) {
  48670. var this$1 = this;
  48671. var options = Ctor.options;
  48672. // ensure the createElement function in functional components
  48673. // gets a unique context - this is necessary for correct named slot check
  48674. var contextVm;
  48675. if (hasOwn(parent, '_uid')) {
  48676. contextVm = Object.create(parent);
  48677. // $flow-disable-line
  48678. contextVm._original = parent;
  48679. } else {
  48680. // the context vm passed in is a functional context as well.
  48681. // in this case we want to make sure we are able to get a hold to the
  48682. // real context instance.
  48683. contextVm = parent;
  48684. // $flow-disable-line
  48685. parent = parent._original;
  48686. }
  48687. var isCompiled = isTrue(options._compiled);
  48688. var needNormalization = !isCompiled;
  48689. this.data = data;
  48690. this.props = props;
  48691. this.children = children;
  48692. this.parent = parent;
  48693. this.listeners = data.on || emptyObject;
  48694. this.injections = resolveInject(options.inject, parent);
  48695. this.slots = function () {
  48696. if (!this$1.$slots) {
  48697. normalizeScopedSlots(
  48698. data.scopedSlots,
  48699. this$1.$slots = resolveSlots(children, parent)
  48700. );
  48701. }
  48702. return this$1.$slots
  48703. };
  48704. Object.defineProperty(this, 'scopedSlots', ({
  48705. enumerable: true,
  48706. get: function get () {
  48707. return normalizeScopedSlots(data.scopedSlots, this.slots())
  48708. }
  48709. }));
  48710. // support for compiled functional template
  48711. if (isCompiled) {
  48712. // exposing $options for renderStatic()
  48713. this.$options = options;
  48714. // pre-resolve slots for renderSlot()
  48715. this.$slots = this.slots();
  48716. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  48717. }
  48718. if (options._scopeId) {
  48719. this._c = function (a, b, c, d) {
  48720. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  48721. if (vnode && !Array.isArray(vnode)) {
  48722. vnode.fnScopeId = options._scopeId;
  48723. vnode.fnContext = parent;
  48724. }
  48725. return vnode
  48726. };
  48727. } else {
  48728. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  48729. }
  48730. }
  48731. installRenderHelpers(FunctionalRenderContext.prototype);
  48732. function createFunctionalComponent (
  48733. Ctor,
  48734. propsData,
  48735. data,
  48736. contextVm,
  48737. children
  48738. ) {
  48739. var options = Ctor.options;
  48740. var props = {};
  48741. var propOptions = options.props;
  48742. if (isDef(propOptions)) {
  48743. for (var key in propOptions) {
  48744. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  48745. }
  48746. } else {
  48747. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  48748. if (isDef(data.props)) { mergeProps(props, data.props); }
  48749. }
  48750. var renderContext = new FunctionalRenderContext(
  48751. data,
  48752. props,
  48753. children,
  48754. contextVm,
  48755. Ctor
  48756. );
  48757. var vnode = options.render.call(null, renderContext._c, renderContext);
  48758. if (vnode instanceof VNode) {
  48759. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  48760. } else if (Array.isArray(vnode)) {
  48761. var vnodes = normalizeChildren(vnode) || [];
  48762. var res = new Array(vnodes.length);
  48763. for (var i = 0; i < vnodes.length; i++) {
  48764. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  48765. }
  48766. return res
  48767. }
  48768. }
  48769. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  48770. // #7817 clone node before setting fnContext, otherwise if the node is reused
  48771. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  48772. // that should not be matched to match.
  48773. var clone = cloneVNode(vnode);
  48774. clone.fnContext = contextVm;
  48775. clone.fnOptions = options;
  48776. {
  48777. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  48778. }
  48779. if (data.slot) {
  48780. (clone.data || (clone.data = {})).slot = data.slot;
  48781. }
  48782. return clone
  48783. }
  48784. function mergeProps (to, from) {
  48785. for (var key in from) {
  48786. to[camelize(key)] = from[key];
  48787. }
  48788. }
  48789. /* */
  48790. /* */
  48791. /* */
  48792. /* */
  48793. // inline hooks to be invoked on component VNodes during patch
  48794. var componentVNodeHooks = {
  48795. init: function init (vnode, hydrating) {
  48796. if (
  48797. vnode.componentInstance &&
  48798. !vnode.componentInstance._isDestroyed &&
  48799. vnode.data.keepAlive
  48800. ) {
  48801. // kept-alive components, treat as a patch
  48802. var mountedNode = vnode; // work around flow
  48803. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  48804. } else {
  48805. var child = vnode.componentInstance = createComponentInstanceForVnode(
  48806. vnode,
  48807. activeInstance
  48808. );
  48809. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  48810. }
  48811. },
  48812. prepatch: function prepatch (oldVnode, vnode) {
  48813. var options = vnode.componentOptions;
  48814. var child = vnode.componentInstance = oldVnode.componentInstance;
  48815. updateChildComponent(
  48816. child,
  48817. options.propsData, // updated props
  48818. options.listeners, // updated listeners
  48819. vnode, // new parent vnode
  48820. options.children // new children
  48821. );
  48822. },
  48823. insert: function insert (vnode) {
  48824. var context = vnode.context;
  48825. var componentInstance = vnode.componentInstance;
  48826. if (!componentInstance._isMounted) {
  48827. componentInstance._isMounted = true;
  48828. callHook(componentInstance, 'mounted');
  48829. }
  48830. if (vnode.data.keepAlive) {
  48831. if (context._isMounted) {
  48832. // vue-router#1212
  48833. // During updates, a kept-alive component's child components may
  48834. // change, so directly walking the tree here may call activated hooks
  48835. // on incorrect children. Instead we push them into a queue which will
  48836. // be processed after the whole patch process ended.
  48837. queueActivatedComponent(componentInstance);
  48838. } else {
  48839. activateChildComponent(componentInstance, true /* direct */);
  48840. }
  48841. }
  48842. },
  48843. destroy: function destroy (vnode) {
  48844. var componentInstance = vnode.componentInstance;
  48845. if (!componentInstance._isDestroyed) {
  48846. if (!vnode.data.keepAlive) {
  48847. componentInstance.$destroy();
  48848. } else {
  48849. deactivateChildComponent(componentInstance, true /* direct */);
  48850. }
  48851. }
  48852. }
  48853. };
  48854. var hooksToMerge = Object.keys(componentVNodeHooks);
  48855. function createComponent (
  48856. Ctor,
  48857. data,
  48858. context,
  48859. children,
  48860. tag
  48861. ) {
  48862. if (isUndef(Ctor)) {
  48863. return
  48864. }
  48865. var baseCtor = context.$options._base;
  48866. // plain options object: turn it into a constructor
  48867. if (isObject(Ctor)) {
  48868. Ctor = baseCtor.extend(Ctor);
  48869. }
  48870. // if at this stage it's not a constructor or an async component factory,
  48871. // reject.
  48872. if (typeof Ctor !== 'function') {
  48873. {
  48874. warn(("Invalid Component definition: " + (String(Ctor))), context);
  48875. }
  48876. return
  48877. }
  48878. // async component
  48879. var asyncFactory;
  48880. if (isUndef(Ctor.cid)) {
  48881. asyncFactory = Ctor;
  48882. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  48883. if (Ctor === undefined) {
  48884. // return a placeholder node for async component, which is rendered
  48885. // as a comment node but preserves all the raw information for the node.
  48886. // the information will be used for async server-rendering and hydration.
  48887. return createAsyncPlaceholder(
  48888. asyncFactory,
  48889. data,
  48890. context,
  48891. children,
  48892. tag
  48893. )
  48894. }
  48895. }
  48896. data = data || {};
  48897. // resolve constructor options in case global mixins are applied after
  48898. // component constructor creation
  48899. resolveConstructorOptions(Ctor);
  48900. // transform component v-model data into props & events
  48901. if (isDef(data.model)) {
  48902. transformModel(Ctor.options, data);
  48903. }
  48904. // extract props
  48905. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  48906. // functional component
  48907. if (isTrue(Ctor.options.functional)) {
  48908. return createFunctionalComponent(Ctor, propsData, data, context, children)
  48909. }
  48910. // extract listeners, since these needs to be treated as
  48911. // child component listeners instead of DOM listeners
  48912. var listeners = data.on;
  48913. // replace with listeners with .native modifier
  48914. // so it gets processed during parent component patch.
  48915. data.on = data.nativeOn;
  48916. if (isTrue(Ctor.options.abstract)) {
  48917. // abstract components do not keep anything
  48918. // other than props & listeners & slot
  48919. // work around flow
  48920. var slot = data.slot;
  48921. data = {};
  48922. if (slot) {
  48923. data.slot = slot;
  48924. }
  48925. }
  48926. // install component management hooks onto the placeholder node
  48927. installComponentHooks(data);
  48928. // return a placeholder vnode
  48929. var name = Ctor.options.name || tag;
  48930. var vnode = new VNode(
  48931. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  48932. data, undefined, undefined, undefined, context,
  48933. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  48934. asyncFactory
  48935. );
  48936. return vnode
  48937. }
  48938. function createComponentInstanceForVnode (
  48939. vnode, // we know it's MountedComponentVNode but flow doesn't
  48940. parent // activeInstance in lifecycle state
  48941. ) {
  48942. var options = {
  48943. _isComponent: true,
  48944. _parentVnode: vnode,
  48945. parent: parent
  48946. };
  48947. // check inline-template render functions
  48948. var inlineTemplate = vnode.data.inlineTemplate;
  48949. if (isDef(inlineTemplate)) {
  48950. options.render = inlineTemplate.render;
  48951. options.staticRenderFns = inlineTemplate.staticRenderFns;
  48952. }
  48953. return new vnode.componentOptions.Ctor(options)
  48954. }
  48955. function installComponentHooks (data) {
  48956. var hooks = data.hook || (data.hook = {});
  48957. for (var i = 0; i < hooksToMerge.length; i++) {
  48958. var key = hooksToMerge[i];
  48959. var existing = hooks[key];
  48960. var toMerge = componentVNodeHooks[key];
  48961. if (existing !== toMerge && !(existing && existing._merged)) {
  48962. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  48963. }
  48964. }
  48965. }
  48966. function mergeHook$1 (f1, f2) {
  48967. var merged = function (a, b) {
  48968. // flow complains about extra args which is why we use any
  48969. f1(a, b);
  48970. f2(a, b);
  48971. };
  48972. merged._merged = true;
  48973. return merged
  48974. }
  48975. // transform component v-model info (value and callback) into
  48976. // prop and event handler respectively.
  48977. function transformModel (options, data) {
  48978. var prop = (options.model && options.model.prop) || 'value';
  48979. var event = (options.model && options.model.event) || 'input'
  48980. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  48981. var on = data.on || (data.on = {});
  48982. var existing = on[event];
  48983. var callback = data.model.callback;
  48984. if (isDef(existing)) {
  48985. if (
  48986. Array.isArray(existing)
  48987. ? existing.indexOf(callback) === -1
  48988. : existing !== callback
  48989. ) {
  48990. on[event] = [callback].concat(existing);
  48991. }
  48992. } else {
  48993. on[event] = callback;
  48994. }
  48995. }
  48996. /* */
  48997. var SIMPLE_NORMALIZE = 1;
  48998. var ALWAYS_NORMALIZE = 2;
  48999. // wrapper function for providing a more flexible interface
  49000. // without getting yelled at by flow
  49001. function createElement (
  49002. context,
  49003. tag,
  49004. data,
  49005. children,
  49006. normalizationType,
  49007. alwaysNormalize
  49008. ) {
  49009. if (Array.isArray(data) || isPrimitive(data)) {
  49010. normalizationType = children;
  49011. children = data;
  49012. data = undefined;
  49013. }
  49014. if (isTrue(alwaysNormalize)) {
  49015. normalizationType = ALWAYS_NORMALIZE;
  49016. }
  49017. return _createElement(context, tag, data, children, normalizationType)
  49018. }
  49019. function _createElement (
  49020. context,
  49021. tag,
  49022. data,
  49023. children,
  49024. normalizationType
  49025. ) {
  49026. if (isDef(data) && isDef((data).__ob__)) {
  49027. warn(
  49028. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  49029. 'Always create fresh vnode data objects in each render!',
  49030. context
  49031. );
  49032. return createEmptyVNode()
  49033. }
  49034. // object syntax in v-bind
  49035. if (isDef(data) && isDef(data.is)) {
  49036. tag = data.is;
  49037. }
  49038. if (!tag) {
  49039. // in case of component :is set to falsy value
  49040. return createEmptyVNode()
  49041. }
  49042. // warn against non-primitive key
  49043. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  49044. ) {
  49045. {
  49046. warn(
  49047. 'Avoid using non-primitive value as key, ' +
  49048. 'use string/number value instead.',
  49049. context
  49050. );
  49051. }
  49052. }
  49053. // support single function children as default scoped slot
  49054. if (Array.isArray(children) &&
  49055. typeof children[0] === 'function'
  49056. ) {
  49057. data = data || {};
  49058. data.scopedSlots = { default: children[0] };
  49059. children.length = 0;
  49060. }
  49061. if (normalizationType === ALWAYS_NORMALIZE) {
  49062. children = normalizeChildren(children);
  49063. } else if (normalizationType === SIMPLE_NORMALIZE) {
  49064. children = simpleNormalizeChildren(children);
  49065. }
  49066. var vnode, ns;
  49067. if (typeof tag === 'string') {
  49068. var Ctor;
  49069. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  49070. if (config.isReservedTag(tag)) {
  49071. // platform built-in elements
  49072. if (isDef(data) && isDef(data.nativeOn)) {
  49073. warn(
  49074. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  49075. context
  49076. );
  49077. }
  49078. vnode = new VNode(
  49079. config.parsePlatformTagName(tag), data, children,
  49080. undefined, undefined, context
  49081. );
  49082. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  49083. // component
  49084. vnode = createComponent(Ctor, data, context, children, tag);
  49085. } else {
  49086. // unknown or unlisted namespaced elements
  49087. // check at runtime because it may get assigned a namespace when its
  49088. // parent normalizes children
  49089. vnode = new VNode(
  49090. tag, data, children,
  49091. undefined, undefined, context
  49092. );
  49093. }
  49094. } else {
  49095. // direct component options / constructor
  49096. vnode = createComponent(tag, data, context, children);
  49097. }
  49098. if (Array.isArray(vnode)) {
  49099. return vnode
  49100. } else if (isDef(vnode)) {
  49101. if (isDef(ns)) { applyNS(vnode, ns); }
  49102. if (isDef(data)) { registerDeepBindings(data); }
  49103. return vnode
  49104. } else {
  49105. return createEmptyVNode()
  49106. }
  49107. }
  49108. function applyNS (vnode, ns, force) {
  49109. vnode.ns = ns;
  49110. if (vnode.tag === 'foreignObject') {
  49111. // use default namespace inside foreignObject
  49112. ns = undefined;
  49113. force = true;
  49114. }
  49115. if (isDef(vnode.children)) {
  49116. for (var i = 0, l = vnode.children.length; i < l; i++) {
  49117. var child = vnode.children[i];
  49118. if (isDef(child.tag) && (
  49119. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  49120. applyNS(child, ns, force);
  49121. }
  49122. }
  49123. }
  49124. }
  49125. // ref #5318
  49126. // necessary to ensure parent re-render when deep bindings like :style and
  49127. // :class are used on slot nodes
  49128. function registerDeepBindings (data) {
  49129. if (isObject(data.style)) {
  49130. traverse(data.style);
  49131. }
  49132. if (isObject(data.class)) {
  49133. traverse(data.class);
  49134. }
  49135. }
  49136. /* */
  49137. function initRender (vm) {
  49138. vm._vnode = null; // the root of the child tree
  49139. vm._staticTrees = null; // v-once cached trees
  49140. var options = vm.$options;
  49141. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  49142. var renderContext = parentVnode && parentVnode.context;
  49143. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  49144. vm.$scopedSlots = emptyObject;
  49145. // bind the createElement fn to this instance
  49146. // so that we get proper render context inside it.
  49147. // args order: tag, data, children, normalizationType, alwaysNormalize
  49148. // internal version is used by render functions compiled from templates
  49149. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  49150. // normalization is always applied for the public version, used in
  49151. // user-written render functions.
  49152. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  49153. // $attrs & $listeners are exposed for easier HOC creation.
  49154. // they need to be reactive so that HOCs using them are always updated
  49155. var parentData = parentVnode && parentVnode.data;
  49156. /* istanbul ignore else */
  49157. {
  49158. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  49159. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  49160. }, true);
  49161. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  49162. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  49163. }, true);
  49164. }
  49165. }
  49166. var currentRenderingInstance = null;
  49167. function renderMixin (Vue) {
  49168. // install runtime convenience helpers
  49169. installRenderHelpers(Vue.prototype);
  49170. Vue.prototype.$nextTick = function (fn) {
  49171. return nextTick(fn, this)
  49172. };
  49173. Vue.prototype._render = function () {
  49174. var vm = this;
  49175. var ref = vm.$options;
  49176. var render = ref.render;
  49177. var _parentVnode = ref._parentVnode;
  49178. if (_parentVnode) {
  49179. vm.$scopedSlots = normalizeScopedSlots(
  49180. _parentVnode.data.scopedSlots,
  49181. vm.$slots,
  49182. vm.$scopedSlots
  49183. );
  49184. }
  49185. // set parent vnode. this allows render functions to have access
  49186. // to the data on the placeholder node.
  49187. vm.$vnode = _parentVnode;
  49188. // render self
  49189. var vnode;
  49190. try {
  49191. // There's no need to maintain a stack because all render fns are called
  49192. // separately from one another. Nested component's render fns are called
  49193. // when parent component is patched.
  49194. currentRenderingInstance = vm;
  49195. vnode = render.call(vm._renderProxy, vm.$createElement);
  49196. } catch (e) {
  49197. handleError(e, vm, "render");
  49198. // return error render result,
  49199. // or previous vnode to prevent render error causing blank component
  49200. /* istanbul ignore else */
  49201. if (vm.$options.renderError) {
  49202. try {
  49203. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  49204. } catch (e) {
  49205. handleError(e, vm, "renderError");
  49206. vnode = vm._vnode;
  49207. }
  49208. } else {
  49209. vnode = vm._vnode;
  49210. }
  49211. } finally {
  49212. currentRenderingInstance = null;
  49213. }
  49214. // if the returned array contains only a single node, allow it
  49215. if (Array.isArray(vnode) && vnode.length === 1) {
  49216. vnode = vnode[0];
  49217. }
  49218. // return empty vnode in case the render function errored out
  49219. if (!(vnode instanceof VNode)) {
  49220. if (Array.isArray(vnode)) {
  49221. warn(
  49222. 'Multiple root nodes returned from render function. Render function ' +
  49223. 'should return a single root node.',
  49224. vm
  49225. );
  49226. }
  49227. vnode = createEmptyVNode();
  49228. }
  49229. // set parent
  49230. vnode.parent = _parentVnode;
  49231. return vnode
  49232. };
  49233. }
  49234. /* */
  49235. function ensureCtor (comp, base) {
  49236. if (
  49237. comp.__esModule ||
  49238. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  49239. ) {
  49240. comp = comp.default;
  49241. }
  49242. return isObject(comp)
  49243. ? base.extend(comp)
  49244. : comp
  49245. }
  49246. function createAsyncPlaceholder (
  49247. factory,
  49248. data,
  49249. context,
  49250. children,
  49251. tag
  49252. ) {
  49253. var node = createEmptyVNode();
  49254. node.asyncFactory = factory;
  49255. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  49256. return node
  49257. }
  49258. function resolveAsyncComponent (
  49259. factory,
  49260. baseCtor
  49261. ) {
  49262. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  49263. return factory.errorComp
  49264. }
  49265. if (isDef(factory.resolved)) {
  49266. return factory.resolved
  49267. }
  49268. var owner = currentRenderingInstance;
  49269. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  49270. // already pending
  49271. factory.owners.push(owner);
  49272. }
  49273. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  49274. return factory.loadingComp
  49275. }
  49276. if (owner && !isDef(factory.owners)) {
  49277. var owners = factory.owners = [owner];
  49278. var sync = true;
  49279. var timerLoading = null;
  49280. var timerTimeout = null
  49281. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  49282. var forceRender = function (renderCompleted) {
  49283. for (var i = 0, l = owners.length; i < l; i++) {
  49284. (owners[i]).$forceUpdate();
  49285. }
  49286. if (renderCompleted) {
  49287. owners.length = 0;
  49288. if (timerLoading !== null) {
  49289. clearTimeout(timerLoading);
  49290. timerLoading = null;
  49291. }
  49292. if (timerTimeout !== null) {
  49293. clearTimeout(timerTimeout);
  49294. timerTimeout = null;
  49295. }
  49296. }
  49297. };
  49298. var resolve = once(function (res) {
  49299. // cache resolved
  49300. factory.resolved = ensureCtor(res, baseCtor);
  49301. // invoke callbacks only if this is not a synchronous resolve
  49302. // (async resolves are shimmed as synchronous during SSR)
  49303. if (!sync) {
  49304. forceRender(true);
  49305. } else {
  49306. owners.length = 0;
  49307. }
  49308. });
  49309. var reject = once(function (reason) {
  49310. warn(
  49311. "Failed to resolve async component: " + (String(factory)) +
  49312. (reason ? ("\nReason: " + reason) : '')
  49313. );
  49314. if (isDef(factory.errorComp)) {
  49315. factory.error = true;
  49316. forceRender(true);
  49317. }
  49318. });
  49319. var res = factory(resolve, reject);
  49320. if (isObject(res)) {
  49321. if (isPromise(res)) {
  49322. // () => Promise
  49323. if (isUndef(factory.resolved)) {
  49324. res.then(resolve, reject);
  49325. }
  49326. } else if (isPromise(res.component)) {
  49327. res.component.then(resolve, reject);
  49328. if (isDef(res.error)) {
  49329. factory.errorComp = ensureCtor(res.error, baseCtor);
  49330. }
  49331. if (isDef(res.loading)) {
  49332. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  49333. if (res.delay === 0) {
  49334. factory.loading = true;
  49335. } else {
  49336. timerLoading = setTimeout(function () {
  49337. timerLoading = null;
  49338. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  49339. factory.loading = true;
  49340. forceRender(false);
  49341. }
  49342. }, res.delay || 200);
  49343. }
  49344. }
  49345. if (isDef(res.timeout)) {
  49346. timerTimeout = setTimeout(function () {
  49347. timerTimeout = null;
  49348. if (isUndef(factory.resolved)) {
  49349. reject(
  49350. "timeout (" + (res.timeout) + "ms)"
  49351. );
  49352. }
  49353. }, res.timeout);
  49354. }
  49355. }
  49356. }
  49357. sync = false;
  49358. // return in case resolved synchronously
  49359. return factory.loading
  49360. ? factory.loadingComp
  49361. : factory.resolved
  49362. }
  49363. }
  49364. /* */
  49365. function isAsyncPlaceholder (node) {
  49366. return node.isComment && node.asyncFactory
  49367. }
  49368. /* */
  49369. function getFirstComponentChild (children) {
  49370. if (Array.isArray(children)) {
  49371. for (var i = 0; i < children.length; i++) {
  49372. var c = children[i];
  49373. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  49374. return c
  49375. }
  49376. }
  49377. }
  49378. }
  49379. /* */
  49380. /* */
  49381. function initEvents (vm) {
  49382. vm._events = Object.create(null);
  49383. vm._hasHookEvent = false;
  49384. // init parent attached events
  49385. var listeners = vm.$options._parentListeners;
  49386. if (listeners) {
  49387. updateComponentListeners(vm, listeners);
  49388. }
  49389. }
  49390. var target;
  49391. function add (event, fn) {
  49392. target.$on(event, fn);
  49393. }
  49394. function remove$1 (event, fn) {
  49395. target.$off(event, fn);
  49396. }
  49397. function createOnceHandler (event, fn) {
  49398. var _target = target;
  49399. return function onceHandler () {
  49400. var res = fn.apply(null, arguments);
  49401. if (res !== null) {
  49402. _target.$off(event, onceHandler);
  49403. }
  49404. }
  49405. }
  49406. function updateComponentListeners (
  49407. vm,
  49408. listeners,
  49409. oldListeners
  49410. ) {
  49411. target = vm;
  49412. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  49413. target = undefined;
  49414. }
  49415. function eventsMixin (Vue) {
  49416. var hookRE = /^hook:/;
  49417. Vue.prototype.$on = function (event, fn) {
  49418. var vm = this;
  49419. if (Array.isArray(event)) {
  49420. for (var i = 0, l = event.length; i < l; i++) {
  49421. vm.$on(event[i], fn);
  49422. }
  49423. } else {
  49424. (vm._events[event] || (vm._events[event] = [])).push(fn);
  49425. // optimize hook:event cost by using a boolean flag marked at registration
  49426. // instead of a hash lookup
  49427. if (hookRE.test(event)) {
  49428. vm._hasHookEvent = true;
  49429. }
  49430. }
  49431. return vm
  49432. };
  49433. Vue.prototype.$once = function (event, fn) {
  49434. var vm = this;
  49435. function on () {
  49436. vm.$off(event, on);
  49437. fn.apply(vm, arguments);
  49438. }
  49439. on.fn = fn;
  49440. vm.$on(event, on);
  49441. return vm
  49442. };
  49443. Vue.prototype.$off = function (event, fn) {
  49444. var vm = this;
  49445. // all
  49446. if (!arguments.length) {
  49447. vm._events = Object.create(null);
  49448. return vm
  49449. }
  49450. // array of events
  49451. if (Array.isArray(event)) {
  49452. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  49453. vm.$off(event[i$1], fn);
  49454. }
  49455. return vm
  49456. }
  49457. // specific event
  49458. var cbs = vm._events[event];
  49459. if (!cbs) {
  49460. return vm
  49461. }
  49462. if (!fn) {
  49463. vm._events[event] = null;
  49464. return vm
  49465. }
  49466. // specific handler
  49467. var cb;
  49468. var i = cbs.length;
  49469. while (i--) {
  49470. cb = cbs[i];
  49471. if (cb === fn || cb.fn === fn) {
  49472. cbs.splice(i, 1);
  49473. break
  49474. }
  49475. }
  49476. return vm
  49477. };
  49478. Vue.prototype.$emit = function (event) {
  49479. var vm = this;
  49480. {
  49481. var lowerCaseEvent = event.toLowerCase();
  49482. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  49483. tip(
  49484. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  49485. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  49486. "Note that HTML attributes are case-insensitive and you cannot use " +
  49487. "v-on to listen to camelCase events when using in-DOM templates. " +
  49488. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  49489. );
  49490. }
  49491. }
  49492. var cbs = vm._events[event];
  49493. if (cbs) {
  49494. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  49495. var args = toArray(arguments, 1);
  49496. var info = "event handler for \"" + event + "\"";
  49497. for (var i = 0, l = cbs.length; i < l; i++) {
  49498. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  49499. }
  49500. }
  49501. return vm
  49502. };
  49503. }
  49504. /* */
  49505. var activeInstance = null;
  49506. var isUpdatingChildComponent = false;
  49507. function setActiveInstance(vm) {
  49508. var prevActiveInstance = activeInstance;
  49509. activeInstance = vm;
  49510. return function () {
  49511. activeInstance = prevActiveInstance;
  49512. }
  49513. }
  49514. function initLifecycle (vm) {
  49515. var options = vm.$options;
  49516. // locate first non-abstract parent
  49517. var parent = options.parent;
  49518. if (parent && !options.abstract) {
  49519. while (parent.$options.abstract && parent.$parent) {
  49520. parent = parent.$parent;
  49521. }
  49522. parent.$children.push(vm);
  49523. }
  49524. vm.$parent = parent;
  49525. vm.$root = parent ? parent.$root : vm;
  49526. vm.$children = [];
  49527. vm.$refs = {};
  49528. vm._watcher = null;
  49529. vm._inactive = null;
  49530. vm._directInactive = false;
  49531. vm._isMounted = false;
  49532. vm._isDestroyed = false;
  49533. vm._isBeingDestroyed = false;
  49534. }
  49535. function lifecycleMixin (Vue) {
  49536. Vue.prototype._update = function (vnode, hydrating) {
  49537. var vm = this;
  49538. var prevEl = vm.$el;
  49539. var prevVnode = vm._vnode;
  49540. var restoreActiveInstance = setActiveInstance(vm);
  49541. vm._vnode = vnode;
  49542. // Vue.prototype.__patch__ is injected in entry points
  49543. // based on the rendering backend used.
  49544. if (!prevVnode) {
  49545. // initial render
  49546. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  49547. } else {
  49548. // updates
  49549. vm.$el = vm.__patch__(prevVnode, vnode);
  49550. }
  49551. restoreActiveInstance();
  49552. // update __vue__ reference
  49553. if (prevEl) {
  49554. prevEl.__vue__ = null;
  49555. }
  49556. if (vm.$el) {
  49557. vm.$el.__vue__ = vm;
  49558. }
  49559. // if parent is an HOC, update its $el as well
  49560. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  49561. vm.$parent.$el = vm.$el;
  49562. }
  49563. // updated hook is called by the scheduler to ensure that children are
  49564. // updated in a parent's updated hook.
  49565. };
  49566. Vue.prototype.$forceUpdate = function () {
  49567. var vm = this;
  49568. if (vm._watcher) {
  49569. vm._watcher.update();
  49570. }
  49571. };
  49572. Vue.prototype.$destroy = function () {
  49573. var vm = this;
  49574. if (vm._isBeingDestroyed) {
  49575. return
  49576. }
  49577. callHook(vm, 'beforeDestroy');
  49578. vm._isBeingDestroyed = true;
  49579. // remove self from parent
  49580. var parent = vm.$parent;
  49581. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  49582. remove(parent.$children, vm);
  49583. }
  49584. // teardown watchers
  49585. if (vm._watcher) {
  49586. vm._watcher.teardown();
  49587. }
  49588. var i = vm._watchers.length;
  49589. while (i--) {
  49590. vm._watchers[i].teardown();
  49591. }
  49592. // remove reference from data ob
  49593. // frozen object may not have observer.
  49594. if (vm._data.__ob__) {
  49595. vm._data.__ob__.vmCount--;
  49596. }
  49597. // call the last hook...
  49598. vm._isDestroyed = true;
  49599. // invoke destroy hooks on current rendered tree
  49600. vm.__patch__(vm._vnode, null);
  49601. // fire destroyed hook
  49602. callHook(vm, 'destroyed');
  49603. // turn off all instance listeners.
  49604. vm.$off();
  49605. // remove __vue__ reference
  49606. if (vm.$el) {
  49607. vm.$el.__vue__ = null;
  49608. }
  49609. // release circular reference (#6759)
  49610. if (vm.$vnode) {
  49611. vm.$vnode.parent = null;
  49612. }
  49613. };
  49614. }
  49615. function mountComponent (
  49616. vm,
  49617. el,
  49618. hydrating
  49619. ) {
  49620. vm.$el = el;
  49621. if (!vm.$options.render) {
  49622. vm.$options.render = createEmptyVNode;
  49623. {
  49624. /* istanbul ignore if */
  49625. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  49626. vm.$options.el || el) {
  49627. warn(
  49628. 'You are using the runtime-only build of Vue where the template ' +
  49629. 'compiler is not available. Either pre-compile the templates into ' +
  49630. 'render functions, or use the compiler-included build.',
  49631. vm
  49632. );
  49633. } else {
  49634. warn(
  49635. 'Failed to mount component: template or render function not defined.',
  49636. vm
  49637. );
  49638. }
  49639. }
  49640. }
  49641. callHook(vm, 'beforeMount');
  49642. var updateComponent;
  49643. /* istanbul ignore if */
  49644. if (config.performance && mark) {
  49645. updateComponent = function () {
  49646. var name = vm._name;
  49647. var id = vm._uid;
  49648. var startTag = "vue-perf-start:" + id;
  49649. var endTag = "vue-perf-end:" + id;
  49650. mark(startTag);
  49651. var vnode = vm._render();
  49652. mark(endTag);
  49653. measure(("vue " + name + " render"), startTag, endTag);
  49654. mark(startTag);
  49655. vm._update(vnode, hydrating);
  49656. mark(endTag);
  49657. measure(("vue " + name + " patch"), startTag, endTag);
  49658. };
  49659. } else {
  49660. updateComponent = function () {
  49661. vm._update(vm._render(), hydrating);
  49662. };
  49663. }
  49664. // we set this to vm._watcher inside the watcher's constructor
  49665. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  49666. // component's mounted hook), which relies on vm._watcher being already defined
  49667. new Watcher(vm, updateComponent, noop, {
  49668. before: function before () {
  49669. if (vm._isMounted && !vm._isDestroyed) {
  49670. callHook(vm, 'beforeUpdate');
  49671. }
  49672. }
  49673. }, true /* isRenderWatcher */);
  49674. hydrating = false;
  49675. // manually mounted instance, call mounted on self
  49676. // mounted is called for render-created child components in its inserted hook
  49677. if (vm.$vnode == null) {
  49678. vm._isMounted = true;
  49679. callHook(vm, 'mounted');
  49680. }
  49681. return vm
  49682. }
  49683. function updateChildComponent (
  49684. vm,
  49685. propsData,
  49686. listeners,
  49687. parentVnode,
  49688. renderChildren
  49689. ) {
  49690. {
  49691. isUpdatingChildComponent = true;
  49692. }
  49693. // determine whether component has slot children
  49694. // we need to do this before overwriting $options._renderChildren.
  49695. // check if there are dynamic scopedSlots (hand-written or compiled but with
  49696. // dynamic slot names). Static scoped slots compiled from template has the
  49697. // "$stable" marker.
  49698. var newScopedSlots = parentVnode.data.scopedSlots;
  49699. var oldScopedSlots = vm.$scopedSlots;
  49700. var hasDynamicScopedSlot = !!(
  49701. (newScopedSlots && !newScopedSlots.$stable) ||
  49702. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  49703. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  49704. );
  49705. // Any static slot children from the parent may have changed during parent's
  49706. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  49707. // update is necessary to ensure correctness.
  49708. var needsForceUpdate = !!(
  49709. renderChildren || // has new static slots
  49710. vm.$options._renderChildren || // has old static slots
  49711. hasDynamicScopedSlot
  49712. );
  49713. vm.$options._parentVnode = parentVnode;
  49714. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  49715. if (vm._vnode) { // update child tree's parent
  49716. vm._vnode.parent = parentVnode;
  49717. }
  49718. vm.$options._renderChildren = renderChildren;
  49719. // update $attrs and $listeners hash
  49720. // these are also reactive so they may trigger child update if the child
  49721. // used them during render
  49722. vm.$attrs = parentVnode.data.attrs || emptyObject;
  49723. vm.$listeners = listeners || emptyObject;
  49724. // update props
  49725. if (propsData && vm.$options.props) {
  49726. toggleObserving(false);
  49727. var props = vm._props;
  49728. var propKeys = vm.$options._propKeys || [];
  49729. for (var i = 0; i < propKeys.length; i++) {
  49730. var key = propKeys[i];
  49731. var propOptions = vm.$options.props; // wtf flow?
  49732. props[key] = validateProp(key, propOptions, propsData, vm);
  49733. }
  49734. toggleObserving(true);
  49735. // keep a copy of raw propsData
  49736. vm.$options.propsData = propsData;
  49737. }
  49738. // update listeners
  49739. listeners = listeners || emptyObject;
  49740. var oldListeners = vm.$options._parentListeners;
  49741. vm.$options._parentListeners = listeners;
  49742. updateComponentListeners(vm, listeners, oldListeners);
  49743. // resolve slots + force update if has children
  49744. if (needsForceUpdate) {
  49745. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  49746. vm.$forceUpdate();
  49747. }
  49748. {
  49749. isUpdatingChildComponent = false;
  49750. }
  49751. }
  49752. function isInInactiveTree (vm) {
  49753. while (vm && (vm = vm.$parent)) {
  49754. if (vm._inactive) { return true }
  49755. }
  49756. return false
  49757. }
  49758. function activateChildComponent (vm, direct) {
  49759. if (direct) {
  49760. vm._directInactive = false;
  49761. if (isInInactiveTree(vm)) {
  49762. return
  49763. }
  49764. } else if (vm._directInactive) {
  49765. return
  49766. }
  49767. if (vm._inactive || vm._inactive === null) {
  49768. vm._inactive = false;
  49769. for (var i = 0; i < vm.$children.length; i++) {
  49770. activateChildComponent(vm.$children[i]);
  49771. }
  49772. callHook(vm, 'activated');
  49773. }
  49774. }
  49775. function deactivateChildComponent (vm, direct) {
  49776. if (direct) {
  49777. vm._directInactive = true;
  49778. if (isInInactiveTree(vm)) {
  49779. return
  49780. }
  49781. }
  49782. if (!vm._inactive) {
  49783. vm._inactive = true;
  49784. for (var i = 0; i < vm.$children.length; i++) {
  49785. deactivateChildComponent(vm.$children[i]);
  49786. }
  49787. callHook(vm, 'deactivated');
  49788. }
  49789. }
  49790. function callHook (vm, hook) {
  49791. // #7573 disable dep collection when invoking lifecycle hooks
  49792. pushTarget();
  49793. var handlers = vm.$options[hook];
  49794. var info = hook + " hook";
  49795. if (handlers) {
  49796. for (var i = 0, j = handlers.length; i < j; i++) {
  49797. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  49798. }
  49799. }
  49800. if (vm._hasHookEvent) {
  49801. vm.$emit('hook:' + hook);
  49802. }
  49803. popTarget();
  49804. }
  49805. /* */
  49806. var MAX_UPDATE_COUNT = 100;
  49807. var queue = [];
  49808. var activatedChildren = [];
  49809. var has = {};
  49810. var circular = {};
  49811. var waiting = false;
  49812. var flushing = false;
  49813. var index = 0;
  49814. /**
  49815. * Reset the scheduler's state.
  49816. */
  49817. function resetSchedulerState () {
  49818. index = queue.length = activatedChildren.length = 0;
  49819. has = {};
  49820. {
  49821. circular = {};
  49822. }
  49823. waiting = flushing = false;
  49824. }
  49825. // Async edge case #6566 requires saving the timestamp when event listeners are
  49826. // attached. However, calling performance.now() has a perf overhead especially
  49827. // if the page has thousands of event listeners. Instead, we take a timestamp
  49828. // every time the scheduler flushes and use that for all event listeners
  49829. // attached during that flush.
  49830. var currentFlushTimestamp = 0;
  49831. // Async edge case fix requires storing an event listener's attach timestamp.
  49832. var getNow = Date.now;
  49833. // Determine what event timestamp the browser is using. Annoyingly, the
  49834. // timestamp can either be hi-res (relative to page load) or low-res
  49835. // (relative to UNIX epoch), so in order to compare time we have to use the
  49836. // same timestamp type when saving the flush timestamp.
  49837. // All IE versions use low-res event timestamps, and have problematic clock
  49838. // implementations (#9632)
  49839. if (inBrowser && !isIE) {
  49840. var performance = window.performance;
  49841. if (
  49842. performance &&
  49843. typeof performance.now === 'function' &&
  49844. getNow() > document.createEvent('Event').timeStamp
  49845. ) {
  49846. // if the event timestamp, although evaluated AFTER the Date.now(), is
  49847. // smaller than it, it means the event is using a hi-res timestamp,
  49848. // and we need to use the hi-res version for event listener timestamps as
  49849. // well.
  49850. getNow = function () { return performance.now(); };
  49851. }
  49852. }
  49853. /**
  49854. * Flush both queues and run the watchers.
  49855. */
  49856. function flushSchedulerQueue () {
  49857. currentFlushTimestamp = getNow();
  49858. flushing = true;
  49859. var watcher, id;
  49860. // Sort queue before flush.
  49861. // This ensures that:
  49862. // 1. Components are updated from parent to child. (because parent is always
  49863. // created before the child)
  49864. // 2. A component's user watchers are run before its render watcher (because
  49865. // user watchers are created before the render watcher)
  49866. // 3. If a component is destroyed during a parent component's watcher run,
  49867. // its watchers can be skipped.
  49868. queue.sort(function (a, b) { return a.id - b.id; });
  49869. // do not cache length because more watchers might be pushed
  49870. // as we run existing watchers
  49871. for (index = 0; index < queue.length; index++) {
  49872. watcher = queue[index];
  49873. if (watcher.before) {
  49874. watcher.before();
  49875. }
  49876. id = watcher.id;
  49877. has[id] = null;
  49878. watcher.run();
  49879. // in dev build, check and stop circular updates.
  49880. if (has[id] != null) {
  49881. circular[id] = (circular[id] || 0) + 1;
  49882. if (circular[id] > MAX_UPDATE_COUNT) {
  49883. warn(
  49884. 'You may have an infinite update loop ' + (
  49885. watcher.user
  49886. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  49887. : "in a component render function."
  49888. ),
  49889. watcher.vm
  49890. );
  49891. break
  49892. }
  49893. }
  49894. }
  49895. // keep copies of post queues before resetting state
  49896. var activatedQueue = activatedChildren.slice();
  49897. var updatedQueue = queue.slice();
  49898. resetSchedulerState();
  49899. // call component updated and activated hooks
  49900. callActivatedHooks(activatedQueue);
  49901. callUpdatedHooks(updatedQueue);
  49902. // devtool hook
  49903. /* istanbul ignore if */
  49904. if (devtools && config.devtools) {
  49905. devtools.emit('flush');
  49906. }
  49907. }
  49908. function callUpdatedHooks (queue) {
  49909. var i = queue.length;
  49910. while (i--) {
  49911. var watcher = queue[i];
  49912. var vm = watcher.vm;
  49913. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  49914. callHook(vm, 'updated');
  49915. }
  49916. }
  49917. }
  49918. /**
  49919. * Queue a kept-alive component that was activated during patch.
  49920. * The queue will be processed after the entire tree has been patched.
  49921. */
  49922. function queueActivatedComponent (vm) {
  49923. // setting _inactive to false here so that a render function can
  49924. // rely on checking whether it's in an inactive tree (e.g. router-view)
  49925. vm._inactive = false;
  49926. activatedChildren.push(vm);
  49927. }
  49928. function callActivatedHooks (queue) {
  49929. for (var i = 0; i < queue.length; i++) {
  49930. queue[i]._inactive = true;
  49931. activateChildComponent(queue[i], true /* true */);
  49932. }
  49933. }
  49934. /**
  49935. * Push a watcher into the watcher queue.
  49936. * Jobs with duplicate IDs will be skipped unless it's
  49937. * pushed when the queue is being flushed.
  49938. */
  49939. function queueWatcher (watcher) {
  49940. var id = watcher.id;
  49941. if (has[id] == null) {
  49942. has[id] = true;
  49943. if (!flushing) {
  49944. queue.push(watcher);
  49945. } else {
  49946. // if already flushing, splice the watcher based on its id
  49947. // if already past its id, it will be run next immediately.
  49948. var i = queue.length - 1;
  49949. while (i > index && queue[i].id > watcher.id) {
  49950. i--;
  49951. }
  49952. queue.splice(i + 1, 0, watcher);
  49953. }
  49954. // queue the flush
  49955. if (!waiting) {
  49956. waiting = true;
  49957. if (!config.async) {
  49958. flushSchedulerQueue();
  49959. return
  49960. }
  49961. nextTick(flushSchedulerQueue);
  49962. }
  49963. }
  49964. }
  49965. /* */
  49966. var uid$2 = 0;
  49967. /**
  49968. * A watcher parses an expression, collects dependencies,
  49969. * and fires callback when the expression value changes.
  49970. * This is used for both the $watch() api and directives.
  49971. */
  49972. var Watcher = function Watcher (
  49973. vm,
  49974. expOrFn,
  49975. cb,
  49976. options,
  49977. isRenderWatcher
  49978. ) {
  49979. this.vm = vm;
  49980. if (isRenderWatcher) {
  49981. vm._watcher = this;
  49982. }
  49983. vm._watchers.push(this);
  49984. // options
  49985. if (options) {
  49986. this.deep = !!options.deep;
  49987. this.user = !!options.user;
  49988. this.lazy = !!options.lazy;
  49989. this.sync = !!options.sync;
  49990. this.before = options.before;
  49991. } else {
  49992. this.deep = this.user = this.lazy = this.sync = false;
  49993. }
  49994. this.cb = cb;
  49995. this.id = ++uid$2; // uid for batching
  49996. this.active = true;
  49997. this.dirty = this.lazy; // for lazy watchers
  49998. this.deps = [];
  49999. this.newDeps = [];
  50000. this.depIds = new _Set();
  50001. this.newDepIds = new _Set();
  50002. this.expression = expOrFn.toString();
  50003. // parse expression for getter
  50004. if (typeof expOrFn === 'function') {
  50005. this.getter = expOrFn;
  50006. } else {
  50007. this.getter = parsePath(expOrFn);
  50008. if (!this.getter) {
  50009. this.getter = noop;
  50010. warn(
  50011. "Failed watching path: \"" + expOrFn + "\" " +
  50012. 'Watcher only accepts simple dot-delimited paths. ' +
  50013. 'For full control, use a function instead.',
  50014. vm
  50015. );
  50016. }
  50017. }
  50018. this.value = this.lazy
  50019. ? undefined
  50020. : this.get();
  50021. };
  50022. /**
  50023. * Evaluate the getter, and re-collect dependencies.
  50024. */
  50025. Watcher.prototype.get = function get () {
  50026. pushTarget(this);
  50027. var value;
  50028. var vm = this.vm;
  50029. try {
  50030. value = this.getter.call(vm, vm);
  50031. } catch (e) {
  50032. if (this.user) {
  50033. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  50034. } else {
  50035. throw e
  50036. }
  50037. } finally {
  50038. // "touch" every property so they are all tracked as
  50039. // dependencies for deep watching
  50040. if (this.deep) {
  50041. traverse(value);
  50042. }
  50043. popTarget();
  50044. this.cleanupDeps();
  50045. }
  50046. return value
  50047. };
  50048. /**
  50049. * Add a dependency to this directive.
  50050. */
  50051. Watcher.prototype.addDep = function addDep (dep) {
  50052. var id = dep.id;
  50053. if (!this.newDepIds.has(id)) {
  50054. this.newDepIds.add(id);
  50055. this.newDeps.push(dep);
  50056. if (!this.depIds.has(id)) {
  50057. dep.addSub(this);
  50058. }
  50059. }
  50060. };
  50061. /**
  50062. * Clean up for dependency collection.
  50063. */
  50064. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  50065. var i = this.deps.length;
  50066. while (i--) {
  50067. var dep = this.deps[i];
  50068. if (!this.newDepIds.has(dep.id)) {
  50069. dep.removeSub(this);
  50070. }
  50071. }
  50072. var tmp = this.depIds;
  50073. this.depIds = this.newDepIds;
  50074. this.newDepIds = tmp;
  50075. this.newDepIds.clear();
  50076. tmp = this.deps;
  50077. this.deps = this.newDeps;
  50078. this.newDeps = tmp;
  50079. this.newDeps.length = 0;
  50080. };
  50081. /**
  50082. * Subscriber interface.
  50083. * Will be called when a dependency changes.
  50084. */
  50085. Watcher.prototype.update = function update () {
  50086. /* istanbul ignore else */
  50087. if (this.lazy) {
  50088. this.dirty = true;
  50089. } else if (this.sync) {
  50090. this.run();
  50091. } else {
  50092. queueWatcher(this);
  50093. }
  50094. };
  50095. /**
  50096. * Scheduler job interface.
  50097. * Will be called by the scheduler.
  50098. */
  50099. Watcher.prototype.run = function run () {
  50100. if (this.active) {
  50101. var value = this.get();
  50102. if (
  50103. value !== this.value ||
  50104. // Deep watchers and watchers on Object/Arrays should fire even
  50105. // when the value is the same, because the value may
  50106. // have mutated.
  50107. isObject(value) ||
  50108. this.deep
  50109. ) {
  50110. // set new value
  50111. var oldValue = this.value;
  50112. this.value = value;
  50113. if (this.user) {
  50114. try {
  50115. this.cb.call(this.vm, value, oldValue);
  50116. } catch (e) {
  50117. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  50118. }
  50119. } else {
  50120. this.cb.call(this.vm, value, oldValue);
  50121. }
  50122. }
  50123. }
  50124. };
  50125. /**
  50126. * Evaluate the value of the watcher.
  50127. * This only gets called for lazy watchers.
  50128. */
  50129. Watcher.prototype.evaluate = function evaluate () {
  50130. this.value = this.get();
  50131. this.dirty = false;
  50132. };
  50133. /**
  50134. * Depend on all deps collected by this watcher.
  50135. */
  50136. Watcher.prototype.depend = function depend () {
  50137. var i = this.deps.length;
  50138. while (i--) {
  50139. this.deps[i].depend();
  50140. }
  50141. };
  50142. /**
  50143. * Remove self from all dependencies' subscriber list.
  50144. */
  50145. Watcher.prototype.teardown = function teardown () {
  50146. if (this.active) {
  50147. // remove self from vm's watcher list
  50148. // this is a somewhat expensive operation so we skip it
  50149. // if the vm is being destroyed.
  50150. if (!this.vm._isBeingDestroyed) {
  50151. remove(this.vm._watchers, this);
  50152. }
  50153. var i = this.deps.length;
  50154. while (i--) {
  50155. this.deps[i].removeSub(this);
  50156. }
  50157. this.active = false;
  50158. }
  50159. };
  50160. /* */
  50161. var sharedPropertyDefinition = {
  50162. enumerable: true,
  50163. configurable: true,
  50164. get: noop,
  50165. set: noop
  50166. };
  50167. function proxy (target, sourceKey, key) {
  50168. sharedPropertyDefinition.get = function proxyGetter () {
  50169. return this[sourceKey][key]
  50170. };
  50171. sharedPropertyDefinition.set = function proxySetter (val) {
  50172. this[sourceKey][key] = val;
  50173. };
  50174. Object.defineProperty(target, key, sharedPropertyDefinition);
  50175. }
  50176. function initState (vm) {
  50177. vm._watchers = [];
  50178. var opts = vm.$options;
  50179. if (opts.props) { initProps(vm, opts.props); }
  50180. if (opts.methods) { initMethods(vm, opts.methods); }
  50181. if (opts.data) {
  50182. initData(vm);
  50183. } else {
  50184. observe(vm._data = {}, true /* asRootData */);
  50185. }
  50186. if (opts.computed) { initComputed(vm, opts.computed); }
  50187. if (opts.watch && opts.watch !== nativeWatch) {
  50188. initWatch(vm, opts.watch);
  50189. }
  50190. }
  50191. function initProps (vm, propsOptions) {
  50192. var propsData = vm.$options.propsData || {};
  50193. var props = vm._props = {};
  50194. // cache prop keys so that future props updates can iterate using Array
  50195. // instead of dynamic object key enumeration.
  50196. var keys = vm.$options._propKeys = [];
  50197. var isRoot = !vm.$parent;
  50198. // root instance props should be converted
  50199. if (!isRoot) {
  50200. toggleObserving(false);
  50201. }
  50202. var loop = function ( key ) {
  50203. keys.push(key);
  50204. var value = validateProp(key, propsOptions, propsData, vm);
  50205. /* istanbul ignore else */
  50206. {
  50207. var hyphenatedKey = hyphenate(key);
  50208. if (isReservedAttribute(hyphenatedKey) ||
  50209. config.isReservedAttr(hyphenatedKey)) {
  50210. warn(
  50211. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  50212. vm
  50213. );
  50214. }
  50215. defineReactive$$1(props, key, value, function () {
  50216. if (!isRoot && !isUpdatingChildComponent) {
  50217. warn(
  50218. "Avoid mutating a prop directly since the value will be " +
  50219. "overwritten whenever the parent component re-renders. " +
  50220. "Instead, use a data or computed property based on the prop's " +
  50221. "value. Prop being mutated: \"" + key + "\"",
  50222. vm
  50223. );
  50224. }
  50225. });
  50226. }
  50227. // static props are already proxied on the component's prototype
  50228. // during Vue.extend(). We only need to proxy props defined at
  50229. // instantiation here.
  50230. if (!(key in vm)) {
  50231. proxy(vm, "_props", key);
  50232. }
  50233. };
  50234. for (var key in propsOptions) loop( key );
  50235. toggleObserving(true);
  50236. }
  50237. function initData (vm) {
  50238. var data = vm.$options.data;
  50239. data = vm._data = typeof data === 'function'
  50240. ? getData(data, vm)
  50241. : data || {};
  50242. if (!isPlainObject(data)) {
  50243. data = {};
  50244. warn(
  50245. 'data functions should return an object:\n' +
  50246. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  50247. vm
  50248. );
  50249. }
  50250. // proxy data on instance
  50251. var keys = Object.keys(data);
  50252. var props = vm.$options.props;
  50253. var methods = vm.$options.methods;
  50254. var i = keys.length;
  50255. while (i--) {
  50256. var key = keys[i];
  50257. {
  50258. if (methods && hasOwn(methods, key)) {
  50259. warn(
  50260. ("Method \"" + key + "\" has already been defined as a data property."),
  50261. vm
  50262. );
  50263. }
  50264. }
  50265. if (props && hasOwn(props, key)) {
  50266. warn(
  50267. "The data property \"" + key + "\" is already declared as a prop. " +
  50268. "Use prop default value instead.",
  50269. vm
  50270. );
  50271. } else if (!isReserved(key)) {
  50272. proxy(vm, "_data", key);
  50273. }
  50274. }
  50275. // observe data
  50276. observe(data, true /* asRootData */);
  50277. }
  50278. function getData (data, vm) {
  50279. // #7573 disable dep collection when invoking data getters
  50280. pushTarget();
  50281. try {
  50282. return data.call(vm, vm)
  50283. } catch (e) {
  50284. handleError(e, vm, "data()");
  50285. return {}
  50286. } finally {
  50287. popTarget();
  50288. }
  50289. }
  50290. var computedWatcherOptions = { lazy: true };
  50291. function initComputed (vm, computed) {
  50292. // $flow-disable-line
  50293. var watchers = vm._computedWatchers = Object.create(null);
  50294. // computed properties are just getters during SSR
  50295. var isSSR = isServerRendering();
  50296. for (var key in computed) {
  50297. var userDef = computed[key];
  50298. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  50299. if (getter == null) {
  50300. warn(
  50301. ("Getter is missing for computed property \"" + key + "\"."),
  50302. vm
  50303. );
  50304. }
  50305. if (!isSSR) {
  50306. // create internal watcher for the computed property.
  50307. watchers[key] = new Watcher(
  50308. vm,
  50309. getter || noop,
  50310. noop,
  50311. computedWatcherOptions
  50312. );
  50313. }
  50314. // component-defined computed properties are already defined on the
  50315. // component prototype. We only need to define computed properties defined
  50316. // at instantiation here.
  50317. if (!(key in vm)) {
  50318. defineComputed(vm, key, userDef);
  50319. } else {
  50320. if (key in vm.$data) {
  50321. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  50322. } else if (vm.$options.props && key in vm.$options.props) {
  50323. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  50324. }
  50325. }
  50326. }
  50327. }
  50328. function defineComputed (
  50329. target,
  50330. key,
  50331. userDef
  50332. ) {
  50333. var shouldCache = !isServerRendering();
  50334. if (typeof userDef === 'function') {
  50335. sharedPropertyDefinition.get = shouldCache
  50336. ? createComputedGetter(key)
  50337. : createGetterInvoker(userDef);
  50338. sharedPropertyDefinition.set = noop;
  50339. } else {
  50340. sharedPropertyDefinition.get = userDef.get
  50341. ? shouldCache && userDef.cache !== false
  50342. ? createComputedGetter(key)
  50343. : createGetterInvoker(userDef.get)
  50344. : noop;
  50345. sharedPropertyDefinition.set = userDef.set || noop;
  50346. }
  50347. if (sharedPropertyDefinition.set === noop) {
  50348. sharedPropertyDefinition.set = function () {
  50349. warn(
  50350. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  50351. this
  50352. );
  50353. };
  50354. }
  50355. Object.defineProperty(target, key, sharedPropertyDefinition);
  50356. }
  50357. function createComputedGetter (key) {
  50358. return function computedGetter () {
  50359. var watcher = this._computedWatchers && this._computedWatchers[key];
  50360. if (watcher) {
  50361. if (watcher.dirty) {
  50362. watcher.evaluate();
  50363. }
  50364. if (Dep.target) {
  50365. watcher.depend();
  50366. }
  50367. return watcher.value
  50368. }
  50369. }
  50370. }
  50371. function createGetterInvoker(fn) {
  50372. return function computedGetter () {
  50373. return fn.call(this, this)
  50374. }
  50375. }
  50376. function initMethods (vm, methods) {
  50377. var props = vm.$options.props;
  50378. for (var key in methods) {
  50379. {
  50380. if (typeof methods[key] !== 'function') {
  50381. warn(
  50382. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  50383. "Did you reference the function correctly?",
  50384. vm
  50385. );
  50386. }
  50387. if (props && hasOwn(props, key)) {
  50388. warn(
  50389. ("Method \"" + key + "\" has already been defined as a prop."),
  50390. vm
  50391. );
  50392. }
  50393. if ((key in vm) && isReserved(key)) {
  50394. warn(
  50395. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  50396. "Avoid defining component methods that start with _ or $."
  50397. );
  50398. }
  50399. }
  50400. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  50401. }
  50402. }
  50403. function initWatch (vm, watch) {
  50404. for (var key in watch) {
  50405. var handler = watch[key];
  50406. if (Array.isArray(handler)) {
  50407. for (var i = 0; i < handler.length; i++) {
  50408. createWatcher(vm, key, handler[i]);
  50409. }
  50410. } else {
  50411. createWatcher(vm, key, handler);
  50412. }
  50413. }
  50414. }
  50415. function createWatcher (
  50416. vm,
  50417. expOrFn,
  50418. handler,
  50419. options
  50420. ) {
  50421. if (isPlainObject(handler)) {
  50422. options = handler;
  50423. handler = handler.handler;
  50424. }
  50425. if (typeof handler === 'string') {
  50426. handler = vm[handler];
  50427. }
  50428. return vm.$watch(expOrFn, handler, options)
  50429. }
  50430. function stateMixin (Vue) {
  50431. // flow somehow has problems with directly declared definition object
  50432. // when using Object.defineProperty, so we have to procedurally build up
  50433. // the object here.
  50434. var dataDef = {};
  50435. dataDef.get = function () { return this._data };
  50436. var propsDef = {};
  50437. propsDef.get = function () { return this._props };
  50438. {
  50439. dataDef.set = function () {
  50440. warn(
  50441. 'Avoid replacing instance root $data. ' +
  50442. 'Use nested data properties instead.',
  50443. this
  50444. );
  50445. };
  50446. propsDef.set = function () {
  50447. warn("$props is readonly.", this);
  50448. };
  50449. }
  50450. Object.defineProperty(Vue.prototype, '$data', dataDef);
  50451. Object.defineProperty(Vue.prototype, '$props', propsDef);
  50452. Vue.prototype.$set = set;
  50453. Vue.prototype.$delete = del;
  50454. Vue.prototype.$watch = function (
  50455. expOrFn,
  50456. cb,
  50457. options
  50458. ) {
  50459. var vm = this;
  50460. if (isPlainObject(cb)) {
  50461. return createWatcher(vm, expOrFn, cb, options)
  50462. }
  50463. options = options || {};
  50464. options.user = true;
  50465. var watcher = new Watcher(vm, expOrFn, cb, options);
  50466. if (options.immediate) {
  50467. try {
  50468. cb.call(vm, watcher.value);
  50469. } catch (error) {
  50470. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  50471. }
  50472. }
  50473. return function unwatchFn () {
  50474. watcher.teardown();
  50475. }
  50476. };
  50477. }
  50478. /* */
  50479. var uid$3 = 0;
  50480. function initMixin (Vue) {
  50481. Vue.prototype._init = function (options) {
  50482. var vm = this;
  50483. // a uid
  50484. vm._uid = uid$3++;
  50485. var startTag, endTag;
  50486. /* istanbul ignore if */
  50487. if (config.performance && mark) {
  50488. startTag = "vue-perf-start:" + (vm._uid);
  50489. endTag = "vue-perf-end:" + (vm._uid);
  50490. mark(startTag);
  50491. }
  50492. // a flag to avoid this being observed
  50493. vm._isVue = true;
  50494. // merge options
  50495. if (options && options._isComponent) {
  50496. // optimize internal component instantiation
  50497. // since dynamic options merging is pretty slow, and none of the
  50498. // internal component options needs special treatment.
  50499. initInternalComponent(vm, options);
  50500. } else {
  50501. vm.$options = mergeOptions(
  50502. resolveConstructorOptions(vm.constructor),
  50503. options || {},
  50504. vm
  50505. );
  50506. }
  50507. /* istanbul ignore else */
  50508. {
  50509. initProxy(vm);
  50510. }
  50511. // expose real self
  50512. vm._self = vm;
  50513. initLifecycle(vm);
  50514. initEvents(vm);
  50515. initRender(vm);
  50516. callHook(vm, 'beforeCreate');
  50517. initInjections(vm); // resolve injections before data/props
  50518. initState(vm);
  50519. initProvide(vm); // resolve provide after data/props
  50520. callHook(vm, 'created');
  50521. /* istanbul ignore if */
  50522. if (config.performance && mark) {
  50523. vm._name = formatComponentName(vm, false);
  50524. mark(endTag);
  50525. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  50526. }
  50527. if (vm.$options.el) {
  50528. vm.$mount(vm.$options.el);
  50529. }
  50530. };
  50531. }
  50532. function initInternalComponent (vm, options) {
  50533. var opts = vm.$options = Object.create(vm.constructor.options);
  50534. // doing this because it's faster than dynamic enumeration.
  50535. var parentVnode = options._parentVnode;
  50536. opts.parent = options.parent;
  50537. opts._parentVnode = parentVnode;
  50538. var vnodeComponentOptions = parentVnode.componentOptions;
  50539. opts.propsData = vnodeComponentOptions.propsData;
  50540. opts._parentListeners = vnodeComponentOptions.listeners;
  50541. opts._renderChildren = vnodeComponentOptions.children;
  50542. opts._componentTag = vnodeComponentOptions.tag;
  50543. if (options.render) {
  50544. opts.render = options.render;
  50545. opts.staticRenderFns = options.staticRenderFns;
  50546. }
  50547. }
  50548. function resolveConstructorOptions (Ctor) {
  50549. var options = Ctor.options;
  50550. if (Ctor.super) {
  50551. var superOptions = resolveConstructorOptions(Ctor.super);
  50552. var cachedSuperOptions = Ctor.superOptions;
  50553. if (superOptions !== cachedSuperOptions) {
  50554. // super option changed,
  50555. // need to resolve new options.
  50556. Ctor.superOptions = superOptions;
  50557. // check if there are any late-modified/attached options (#4976)
  50558. var modifiedOptions = resolveModifiedOptions(Ctor);
  50559. // update base extend options
  50560. if (modifiedOptions) {
  50561. extend(Ctor.extendOptions, modifiedOptions);
  50562. }
  50563. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  50564. if (options.name) {
  50565. options.components[options.name] = Ctor;
  50566. }
  50567. }
  50568. }
  50569. return options
  50570. }
  50571. function resolveModifiedOptions (Ctor) {
  50572. var modified;
  50573. var latest = Ctor.options;
  50574. var sealed = Ctor.sealedOptions;
  50575. for (var key in latest) {
  50576. if (latest[key] !== sealed[key]) {
  50577. if (!modified) { modified = {}; }
  50578. modified[key] = latest[key];
  50579. }
  50580. }
  50581. return modified
  50582. }
  50583. function Vue (options) {
  50584. if (!(this instanceof Vue)
  50585. ) {
  50586. warn('Vue is a constructor and should be called with the `new` keyword');
  50587. }
  50588. this._init(options);
  50589. }
  50590. initMixin(Vue);
  50591. stateMixin(Vue);
  50592. eventsMixin(Vue);
  50593. lifecycleMixin(Vue);
  50594. renderMixin(Vue);
  50595. /* */
  50596. function initUse (Vue) {
  50597. Vue.use = function (plugin) {
  50598. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  50599. if (installedPlugins.indexOf(plugin) > -1) {
  50600. return this
  50601. }
  50602. // additional parameters
  50603. var args = toArray(arguments, 1);
  50604. args.unshift(this);
  50605. if (typeof plugin.install === 'function') {
  50606. plugin.install.apply(plugin, args);
  50607. } else if (typeof plugin === 'function') {
  50608. plugin.apply(null, args);
  50609. }
  50610. installedPlugins.push(plugin);
  50611. return this
  50612. };
  50613. }
  50614. /* */
  50615. function initMixin$1 (Vue) {
  50616. Vue.mixin = function (mixin) {
  50617. this.options = mergeOptions(this.options, mixin);
  50618. return this
  50619. };
  50620. }
  50621. /* */
  50622. function initExtend (Vue) {
  50623. /**
  50624. * Each instance constructor, including Vue, has a unique
  50625. * cid. This enables us to create wrapped "child
  50626. * constructors" for prototypal inheritance and cache them.
  50627. */
  50628. Vue.cid = 0;
  50629. var cid = 1;
  50630. /**
  50631. * Class inheritance
  50632. */
  50633. Vue.extend = function (extendOptions) {
  50634. extendOptions = extendOptions || {};
  50635. var Super = this;
  50636. var SuperId = Super.cid;
  50637. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  50638. if (cachedCtors[SuperId]) {
  50639. return cachedCtors[SuperId]
  50640. }
  50641. var name = extendOptions.name || Super.options.name;
  50642. if (name) {
  50643. validateComponentName(name);
  50644. }
  50645. var Sub = function VueComponent (options) {
  50646. this._init(options);
  50647. };
  50648. Sub.prototype = Object.create(Super.prototype);
  50649. Sub.prototype.constructor = Sub;
  50650. Sub.cid = cid++;
  50651. Sub.options = mergeOptions(
  50652. Super.options,
  50653. extendOptions
  50654. );
  50655. Sub['super'] = Super;
  50656. // For props and computed properties, we define the proxy getters on
  50657. // the Vue instances at extension time, on the extended prototype. This
  50658. // avoids Object.defineProperty calls for each instance created.
  50659. if (Sub.options.props) {
  50660. initProps$1(Sub);
  50661. }
  50662. if (Sub.options.computed) {
  50663. initComputed$1(Sub);
  50664. }
  50665. // allow further extension/mixin/plugin usage
  50666. Sub.extend = Super.extend;
  50667. Sub.mixin = Super.mixin;
  50668. Sub.use = Super.use;
  50669. // create asset registers, so extended classes
  50670. // can have their private assets too.
  50671. ASSET_TYPES.forEach(function (type) {
  50672. Sub[type] = Super[type];
  50673. });
  50674. // enable recursive self-lookup
  50675. if (name) {
  50676. Sub.options.components[name] = Sub;
  50677. }
  50678. // keep a reference to the super options at extension time.
  50679. // later at instantiation we can check if Super's options have
  50680. // been updated.
  50681. Sub.superOptions = Super.options;
  50682. Sub.extendOptions = extendOptions;
  50683. Sub.sealedOptions = extend({}, Sub.options);
  50684. // cache constructor
  50685. cachedCtors[SuperId] = Sub;
  50686. return Sub
  50687. };
  50688. }
  50689. function initProps$1 (Comp) {
  50690. var props = Comp.options.props;
  50691. for (var key in props) {
  50692. proxy(Comp.prototype, "_props", key);
  50693. }
  50694. }
  50695. function initComputed$1 (Comp) {
  50696. var computed = Comp.options.computed;
  50697. for (var key in computed) {
  50698. defineComputed(Comp.prototype, key, computed[key]);
  50699. }
  50700. }
  50701. /* */
  50702. function initAssetRegisters (Vue) {
  50703. /**
  50704. * Create asset registration methods.
  50705. */
  50706. ASSET_TYPES.forEach(function (type) {
  50707. Vue[type] = function (
  50708. id,
  50709. definition
  50710. ) {
  50711. if (!definition) {
  50712. return this.options[type + 's'][id]
  50713. } else {
  50714. /* istanbul ignore if */
  50715. if (type === 'component') {
  50716. validateComponentName(id);
  50717. }
  50718. if (type === 'component' && isPlainObject(definition)) {
  50719. definition.name = definition.name || id;
  50720. definition = this.options._base.extend(definition);
  50721. }
  50722. if (type === 'directive' && typeof definition === 'function') {
  50723. definition = { bind: definition, update: definition };
  50724. }
  50725. this.options[type + 's'][id] = definition;
  50726. return definition
  50727. }
  50728. };
  50729. });
  50730. }
  50731. /* */
  50732. function getComponentName (opts) {
  50733. return opts && (opts.Ctor.options.name || opts.tag)
  50734. }
  50735. function matches (pattern, name) {
  50736. if (Array.isArray(pattern)) {
  50737. return pattern.indexOf(name) > -1
  50738. } else if (typeof pattern === 'string') {
  50739. return pattern.split(',').indexOf(name) > -1
  50740. } else if (isRegExp(pattern)) {
  50741. return pattern.test(name)
  50742. }
  50743. /* istanbul ignore next */
  50744. return false
  50745. }
  50746. function pruneCache (keepAliveInstance, filter) {
  50747. var cache = keepAliveInstance.cache;
  50748. var keys = keepAliveInstance.keys;
  50749. var _vnode = keepAliveInstance._vnode;
  50750. for (var key in cache) {
  50751. var cachedNode = cache[key];
  50752. if (cachedNode) {
  50753. var name = getComponentName(cachedNode.componentOptions);
  50754. if (name && !filter(name)) {
  50755. pruneCacheEntry(cache, key, keys, _vnode);
  50756. }
  50757. }
  50758. }
  50759. }
  50760. function pruneCacheEntry (
  50761. cache,
  50762. key,
  50763. keys,
  50764. current
  50765. ) {
  50766. var cached$$1 = cache[key];
  50767. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  50768. cached$$1.componentInstance.$destroy();
  50769. }
  50770. cache[key] = null;
  50771. remove(keys, key);
  50772. }
  50773. var patternTypes = [String, RegExp, Array];
  50774. var KeepAlive = {
  50775. name: 'keep-alive',
  50776. abstract: true,
  50777. props: {
  50778. include: patternTypes,
  50779. exclude: patternTypes,
  50780. max: [String, Number]
  50781. },
  50782. created: function created () {
  50783. this.cache = Object.create(null);
  50784. this.keys = [];
  50785. },
  50786. destroyed: function destroyed () {
  50787. for (var key in this.cache) {
  50788. pruneCacheEntry(this.cache, key, this.keys);
  50789. }
  50790. },
  50791. mounted: function mounted () {
  50792. var this$1 = this;
  50793. this.$watch('include', function (val) {
  50794. pruneCache(this$1, function (name) { return matches(val, name); });
  50795. });
  50796. this.$watch('exclude', function (val) {
  50797. pruneCache(this$1, function (name) { return !matches(val, name); });
  50798. });
  50799. },
  50800. render: function render () {
  50801. var slot = this.$slots.default;
  50802. var vnode = getFirstComponentChild(slot);
  50803. var componentOptions = vnode && vnode.componentOptions;
  50804. if (componentOptions) {
  50805. // check pattern
  50806. var name = getComponentName(componentOptions);
  50807. var ref = this;
  50808. var include = ref.include;
  50809. var exclude = ref.exclude;
  50810. if (
  50811. // not included
  50812. (include && (!name || !matches(include, name))) ||
  50813. // excluded
  50814. (exclude && name && matches(exclude, name))
  50815. ) {
  50816. return vnode
  50817. }
  50818. var ref$1 = this;
  50819. var cache = ref$1.cache;
  50820. var keys = ref$1.keys;
  50821. var key = vnode.key == null
  50822. // same constructor may get registered as different local components
  50823. // so cid alone is not enough (#3269)
  50824. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  50825. : vnode.key;
  50826. if (cache[key]) {
  50827. vnode.componentInstance = cache[key].componentInstance;
  50828. // make current key freshest
  50829. remove(keys, key);
  50830. keys.push(key);
  50831. } else {
  50832. cache[key] = vnode;
  50833. keys.push(key);
  50834. // prune oldest entry
  50835. if (this.max && keys.length > parseInt(this.max)) {
  50836. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  50837. }
  50838. }
  50839. vnode.data.keepAlive = true;
  50840. }
  50841. return vnode || (slot && slot[0])
  50842. }
  50843. };
  50844. var builtInComponents = {
  50845. KeepAlive: KeepAlive
  50846. };
  50847. /* */
  50848. function initGlobalAPI (Vue) {
  50849. // config
  50850. var configDef = {};
  50851. configDef.get = function () { return config; };
  50852. {
  50853. configDef.set = function () {
  50854. warn(
  50855. 'Do not replace the Vue.config object, set individual fields instead.'
  50856. );
  50857. };
  50858. }
  50859. Object.defineProperty(Vue, 'config', configDef);
  50860. // exposed util methods.
  50861. // NOTE: these are not considered part of the public API - avoid relying on
  50862. // them unless you are aware of the risk.
  50863. Vue.util = {
  50864. warn: warn,
  50865. extend: extend,
  50866. mergeOptions: mergeOptions,
  50867. defineReactive: defineReactive$$1
  50868. };
  50869. Vue.set = set;
  50870. Vue.delete = del;
  50871. Vue.nextTick = nextTick;
  50872. // 2.6 explicit observable API
  50873. Vue.observable = function (obj) {
  50874. observe(obj);
  50875. return obj
  50876. };
  50877. Vue.options = Object.create(null);
  50878. ASSET_TYPES.forEach(function (type) {
  50879. Vue.options[type + 's'] = Object.create(null);
  50880. });
  50881. // this is used to identify the "base" constructor to extend all plain-object
  50882. // components with in Weex's multi-instance scenarios.
  50883. Vue.options._base = Vue;
  50884. extend(Vue.options.components, builtInComponents);
  50885. initUse(Vue);
  50886. initMixin$1(Vue);
  50887. initExtend(Vue);
  50888. initAssetRegisters(Vue);
  50889. }
  50890. initGlobalAPI(Vue);
  50891. Object.defineProperty(Vue.prototype, '$isServer', {
  50892. get: isServerRendering
  50893. });
  50894. Object.defineProperty(Vue.prototype, '$ssrContext', {
  50895. get: function get () {
  50896. /* istanbul ignore next */
  50897. return this.$vnode && this.$vnode.ssrContext
  50898. }
  50899. });
  50900. // expose FunctionalRenderContext for ssr runtime helper installation
  50901. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  50902. value: FunctionalRenderContext
  50903. });
  50904. Vue.version = '2.6.11';
  50905. /* */
  50906. // these are reserved for web because they are directly compiled away
  50907. // during template compilation
  50908. var isReservedAttr = makeMap('style,class');
  50909. // attributes that should be using props for binding
  50910. var acceptValue = makeMap('input,textarea,option,select,progress');
  50911. var mustUseProp = function (tag, type, attr) {
  50912. return (
  50913. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  50914. (attr === 'selected' && tag === 'option') ||
  50915. (attr === 'checked' && tag === 'input') ||
  50916. (attr === 'muted' && tag === 'video')
  50917. )
  50918. };
  50919. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  50920. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  50921. var convertEnumeratedValue = function (key, value) {
  50922. return isFalsyAttrValue(value) || value === 'false'
  50923. ? 'false'
  50924. // allow arbitrary string value for contenteditable
  50925. : key === 'contenteditable' && isValidContentEditableValue(value)
  50926. ? value
  50927. : 'true'
  50928. };
  50929. var isBooleanAttr = makeMap(
  50930. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  50931. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  50932. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  50933. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  50934. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  50935. 'truespeed,typemustmatch,visible'
  50936. );
  50937. var xlinkNS = 'http://www.w3.org/1999/xlink';
  50938. var isXlink = function (name) {
  50939. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  50940. };
  50941. var getXlinkProp = function (name) {
  50942. return isXlink(name) ? name.slice(6, name.length) : ''
  50943. };
  50944. var isFalsyAttrValue = function (val) {
  50945. return val == null || val === false
  50946. };
  50947. /* */
  50948. function genClassForVnode (vnode) {
  50949. var data = vnode.data;
  50950. var parentNode = vnode;
  50951. var childNode = vnode;
  50952. while (isDef(childNode.componentInstance)) {
  50953. childNode = childNode.componentInstance._vnode;
  50954. if (childNode && childNode.data) {
  50955. data = mergeClassData(childNode.data, data);
  50956. }
  50957. }
  50958. while (isDef(parentNode = parentNode.parent)) {
  50959. if (parentNode && parentNode.data) {
  50960. data = mergeClassData(data, parentNode.data);
  50961. }
  50962. }
  50963. return renderClass(data.staticClass, data.class)
  50964. }
  50965. function mergeClassData (child, parent) {
  50966. return {
  50967. staticClass: concat(child.staticClass, parent.staticClass),
  50968. class: isDef(child.class)
  50969. ? [child.class, parent.class]
  50970. : parent.class
  50971. }
  50972. }
  50973. function renderClass (
  50974. staticClass,
  50975. dynamicClass
  50976. ) {
  50977. if (isDef(staticClass) || isDef(dynamicClass)) {
  50978. return concat(staticClass, stringifyClass(dynamicClass))
  50979. }
  50980. /* istanbul ignore next */
  50981. return ''
  50982. }
  50983. function concat (a, b) {
  50984. return a ? b ? (a + ' ' + b) : a : (b || '')
  50985. }
  50986. function stringifyClass (value) {
  50987. if (Array.isArray(value)) {
  50988. return stringifyArray(value)
  50989. }
  50990. if (isObject(value)) {
  50991. return stringifyObject(value)
  50992. }
  50993. if (typeof value === 'string') {
  50994. return value
  50995. }
  50996. /* istanbul ignore next */
  50997. return ''
  50998. }
  50999. function stringifyArray (value) {
  51000. var res = '';
  51001. var stringified;
  51002. for (var i = 0, l = value.length; i < l; i++) {
  51003. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  51004. if (res) { res += ' '; }
  51005. res += stringified;
  51006. }
  51007. }
  51008. return res
  51009. }
  51010. function stringifyObject (value) {
  51011. var res = '';
  51012. for (var key in value) {
  51013. if (value[key]) {
  51014. if (res) { res += ' '; }
  51015. res += key;
  51016. }
  51017. }
  51018. return res
  51019. }
  51020. /* */
  51021. var namespaceMap = {
  51022. svg: 'http://www.w3.org/2000/svg',
  51023. math: 'http://www.w3.org/1998/Math/MathML'
  51024. };
  51025. var isHTMLTag = makeMap(
  51026. 'html,body,base,head,link,meta,style,title,' +
  51027. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  51028. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  51029. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  51030. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  51031. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  51032. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  51033. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  51034. 'output,progress,select,textarea,' +
  51035. 'details,dialog,menu,menuitem,summary,' +
  51036. 'content,element,shadow,template,blockquote,iframe,tfoot'
  51037. );
  51038. // this map is intentionally selective, only covering SVG elements that may
  51039. // contain child elements.
  51040. var isSVG = makeMap(
  51041. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  51042. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  51043. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  51044. true
  51045. );
  51046. var isPreTag = function (tag) { return tag === 'pre'; };
  51047. var isReservedTag = function (tag) {
  51048. return isHTMLTag(tag) || isSVG(tag)
  51049. };
  51050. function getTagNamespace (tag) {
  51051. if (isSVG(tag)) {
  51052. return 'svg'
  51053. }
  51054. // basic support for MathML
  51055. // note it doesn't support other MathML elements being component roots
  51056. if (tag === 'math') {
  51057. return 'math'
  51058. }
  51059. }
  51060. var unknownElementCache = Object.create(null);
  51061. function isUnknownElement (tag) {
  51062. /* istanbul ignore if */
  51063. if (!inBrowser) {
  51064. return true
  51065. }
  51066. if (isReservedTag(tag)) {
  51067. return false
  51068. }
  51069. tag = tag.toLowerCase();
  51070. /* istanbul ignore if */
  51071. if (unknownElementCache[tag] != null) {
  51072. return unknownElementCache[tag]
  51073. }
  51074. var el = document.createElement(tag);
  51075. if (tag.indexOf('-') > -1) {
  51076. // http://stackoverflow.com/a/28210364/1070244
  51077. return (unknownElementCache[tag] = (
  51078. el.constructor === window.HTMLUnknownElement ||
  51079. el.constructor === window.HTMLElement
  51080. ))
  51081. } else {
  51082. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  51083. }
  51084. }
  51085. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  51086. /* */
  51087. /**
  51088. * Query an element selector if it's not an element already.
  51089. */
  51090. function query (el) {
  51091. if (typeof el === 'string') {
  51092. var selected = document.querySelector(el);
  51093. if (!selected) {
  51094. warn(
  51095. 'Cannot find element: ' + el
  51096. );
  51097. return document.createElement('div')
  51098. }
  51099. return selected
  51100. } else {
  51101. return el
  51102. }
  51103. }
  51104. /* */
  51105. function createElement$1 (tagName, vnode) {
  51106. var elm = document.createElement(tagName);
  51107. if (tagName !== 'select') {
  51108. return elm
  51109. }
  51110. // false or null will remove the attribute but undefined will not
  51111. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  51112. elm.setAttribute('multiple', 'multiple');
  51113. }
  51114. return elm
  51115. }
  51116. function createElementNS (namespace, tagName) {
  51117. return document.createElementNS(namespaceMap[namespace], tagName)
  51118. }
  51119. function createTextNode (text) {
  51120. return document.createTextNode(text)
  51121. }
  51122. function createComment (text) {
  51123. return document.createComment(text)
  51124. }
  51125. function insertBefore (parentNode, newNode, referenceNode) {
  51126. parentNode.insertBefore(newNode, referenceNode);
  51127. }
  51128. function removeChild (node, child) {
  51129. node.removeChild(child);
  51130. }
  51131. function appendChild (node, child) {
  51132. node.appendChild(child);
  51133. }
  51134. function parentNode (node) {
  51135. return node.parentNode
  51136. }
  51137. function nextSibling (node) {
  51138. return node.nextSibling
  51139. }
  51140. function tagName (node) {
  51141. return node.tagName
  51142. }
  51143. function setTextContent (node, text) {
  51144. node.textContent = text;
  51145. }
  51146. function setStyleScope (node, scopeId) {
  51147. node.setAttribute(scopeId, '');
  51148. }
  51149. var nodeOps = /*#__PURE__*/Object.freeze({
  51150. createElement: createElement$1,
  51151. createElementNS: createElementNS,
  51152. createTextNode: createTextNode,
  51153. createComment: createComment,
  51154. insertBefore: insertBefore,
  51155. removeChild: removeChild,
  51156. appendChild: appendChild,
  51157. parentNode: parentNode,
  51158. nextSibling: nextSibling,
  51159. tagName: tagName,
  51160. setTextContent: setTextContent,
  51161. setStyleScope: setStyleScope
  51162. });
  51163. /* */
  51164. var ref = {
  51165. create: function create (_, vnode) {
  51166. registerRef(vnode);
  51167. },
  51168. update: function update (oldVnode, vnode) {
  51169. if (oldVnode.data.ref !== vnode.data.ref) {
  51170. registerRef(oldVnode, true);
  51171. registerRef(vnode);
  51172. }
  51173. },
  51174. destroy: function destroy (vnode) {
  51175. registerRef(vnode, true);
  51176. }
  51177. };
  51178. function registerRef (vnode, isRemoval) {
  51179. var key = vnode.data.ref;
  51180. if (!isDef(key)) { return }
  51181. var vm = vnode.context;
  51182. var ref = vnode.componentInstance || vnode.elm;
  51183. var refs = vm.$refs;
  51184. if (isRemoval) {
  51185. if (Array.isArray(refs[key])) {
  51186. remove(refs[key], ref);
  51187. } else if (refs[key] === ref) {
  51188. refs[key] = undefined;
  51189. }
  51190. } else {
  51191. if (vnode.data.refInFor) {
  51192. if (!Array.isArray(refs[key])) {
  51193. refs[key] = [ref];
  51194. } else if (refs[key].indexOf(ref) < 0) {
  51195. // $flow-disable-line
  51196. refs[key].push(ref);
  51197. }
  51198. } else {
  51199. refs[key] = ref;
  51200. }
  51201. }
  51202. }
  51203. /**
  51204. * Virtual DOM patching algorithm based on Snabbdom by
  51205. * Simon Friis Vindum (@paldepind)
  51206. * Licensed under the MIT License
  51207. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  51208. *
  51209. * modified by Evan You (@yyx990803)
  51210. *
  51211. * Not type-checking this because this file is perf-critical and the cost
  51212. * of making flow understand it is not worth it.
  51213. */
  51214. var emptyNode = new VNode('', {}, []);
  51215. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  51216. function sameVnode (a, b) {
  51217. return (
  51218. a.key === b.key && (
  51219. (
  51220. a.tag === b.tag &&
  51221. a.isComment === b.isComment &&
  51222. isDef(a.data) === isDef(b.data) &&
  51223. sameInputType(a, b)
  51224. ) || (
  51225. isTrue(a.isAsyncPlaceholder) &&
  51226. a.asyncFactory === b.asyncFactory &&
  51227. isUndef(b.asyncFactory.error)
  51228. )
  51229. )
  51230. )
  51231. }
  51232. function sameInputType (a, b) {
  51233. if (a.tag !== 'input') { return true }
  51234. var i;
  51235. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  51236. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  51237. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  51238. }
  51239. function createKeyToOldIdx (children, beginIdx, endIdx) {
  51240. var i, key;
  51241. var map = {};
  51242. for (i = beginIdx; i <= endIdx; ++i) {
  51243. key = children[i].key;
  51244. if (isDef(key)) { map[key] = i; }
  51245. }
  51246. return map
  51247. }
  51248. function createPatchFunction (backend) {
  51249. var i, j;
  51250. var cbs = {};
  51251. var modules = backend.modules;
  51252. var nodeOps = backend.nodeOps;
  51253. for (i = 0; i < hooks.length; ++i) {
  51254. cbs[hooks[i]] = [];
  51255. for (j = 0; j < modules.length; ++j) {
  51256. if (isDef(modules[j][hooks[i]])) {
  51257. cbs[hooks[i]].push(modules[j][hooks[i]]);
  51258. }
  51259. }
  51260. }
  51261. function emptyNodeAt (elm) {
  51262. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  51263. }
  51264. function createRmCb (childElm, listeners) {
  51265. function remove$$1 () {
  51266. if (--remove$$1.listeners === 0) {
  51267. removeNode(childElm);
  51268. }
  51269. }
  51270. remove$$1.listeners = listeners;
  51271. return remove$$1
  51272. }
  51273. function removeNode (el) {
  51274. var parent = nodeOps.parentNode(el);
  51275. // element may have already been removed due to v-html / v-text
  51276. if (isDef(parent)) {
  51277. nodeOps.removeChild(parent, el);
  51278. }
  51279. }
  51280. function isUnknownElement$$1 (vnode, inVPre) {
  51281. return (
  51282. !inVPre &&
  51283. !vnode.ns &&
  51284. !(
  51285. config.ignoredElements.length &&
  51286. config.ignoredElements.some(function (ignore) {
  51287. return isRegExp(ignore)
  51288. ? ignore.test(vnode.tag)
  51289. : ignore === vnode.tag
  51290. })
  51291. ) &&
  51292. config.isUnknownElement(vnode.tag)
  51293. )
  51294. }
  51295. var creatingElmInVPre = 0;
  51296. function createElm (
  51297. vnode,
  51298. insertedVnodeQueue,
  51299. parentElm,
  51300. refElm,
  51301. nested,
  51302. ownerArray,
  51303. index
  51304. ) {
  51305. if (isDef(vnode.elm) && isDef(ownerArray)) {
  51306. // This vnode was used in a previous render!
  51307. // now it's used as a new node, overwriting its elm would cause
  51308. // potential patch errors down the road when it's used as an insertion
  51309. // reference node. Instead, we clone the node on-demand before creating
  51310. // associated DOM element for it.
  51311. vnode = ownerArray[index] = cloneVNode(vnode);
  51312. }
  51313. vnode.isRootInsert = !nested; // for transition enter check
  51314. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  51315. return
  51316. }
  51317. var data = vnode.data;
  51318. var children = vnode.children;
  51319. var tag = vnode.tag;
  51320. if (isDef(tag)) {
  51321. {
  51322. if (data && data.pre) {
  51323. creatingElmInVPre++;
  51324. }
  51325. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  51326. warn(
  51327. 'Unknown custom element: <' + tag + '> - did you ' +
  51328. 'register the component correctly? For recursive components, ' +
  51329. 'make sure to provide the "name" option.',
  51330. vnode.context
  51331. );
  51332. }
  51333. }
  51334. vnode.elm = vnode.ns
  51335. ? nodeOps.createElementNS(vnode.ns, tag)
  51336. : nodeOps.createElement(tag, vnode);
  51337. setScope(vnode);
  51338. /* istanbul ignore if */
  51339. {
  51340. createChildren(vnode, children, insertedVnodeQueue);
  51341. if (isDef(data)) {
  51342. invokeCreateHooks(vnode, insertedVnodeQueue);
  51343. }
  51344. insert(parentElm, vnode.elm, refElm);
  51345. }
  51346. if (data && data.pre) {
  51347. creatingElmInVPre--;
  51348. }
  51349. } else if (isTrue(vnode.isComment)) {
  51350. vnode.elm = nodeOps.createComment(vnode.text);
  51351. insert(parentElm, vnode.elm, refElm);
  51352. } else {
  51353. vnode.elm = nodeOps.createTextNode(vnode.text);
  51354. insert(parentElm, vnode.elm, refElm);
  51355. }
  51356. }
  51357. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  51358. var i = vnode.data;
  51359. if (isDef(i)) {
  51360. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  51361. if (isDef(i = i.hook) && isDef(i = i.init)) {
  51362. i(vnode, false /* hydrating */);
  51363. }
  51364. // after calling the init hook, if the vnode is a child component
  51365. // it should've created a child instance and mounted it. the child
  51366. // component also has set the placeholder vnode's elm.
  51367. // in that case we can just return the element and be done.
  51368. if (isDef(vnode.componentInstance)) {
  51369. initComponent(vnode, insertedVnodeQueue);
  51370. insert(parentElm, vnode.elm, refElm);
  51371. if (isTrue(isReactivated)) {
  51372. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  51373. }
  51374. return true
  51375. }
  51376. }
  51377. }
  51378. function initComponent (vnode, insertedVnodeQueue) {
  51379. if (isDef(vnode.data.pendingInsert)) {
  51380. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  51381. vnode.data.pendingInsert = null;
  51382. }
  51383. vnode.elm = vnode.componentInstance.$el;
  51384. if (isPatchable(vnode)) {
  51385. invokeCreateHooks(vnode, insertedVnodeQueue);
  51386. setScope(vnode);
  51387. } else {
  51388. // empty component root.
  51389. // skip all element-related modules except for ref (#3455)
  51390. registerRef(vnode);
  51391. // make sure to invoke the insert hook
  51392. insertedVnodeQueue.push(vnode);
  51393. }
  51394. }
  51395. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  51396. var i;
  51397. // hack for #4339: a reactivated component with inner transition
  51398. // does not trigger because the inner node's created hooks are not called
  51399. // again. It's not ideal to involve module-specific logic in here but
  51400. // there doesn't seem to be a better way to do it.
  51401. var innerNode = vnode;
  51402. while (innerNode.componentInstance) {
  51403. innerNode = innerNode.componentInstance._vnode;
  51404. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  51405. for (i = 0; i < cbs.activate.length; ++i) {
  51406. cbs.activate[i](emptyNode, innerNode);
  51407. }
  51408. insertedVnodeQueue.push(innerNode);
  51409. break
  51410. }
  51411. }
  51412. // unlike a newly created component,
  51413. // a reactivated keep-alive component doesn't insert itself
  51414. insert(parentElm, vnode.elm, refElm);
  51415. }
  51416. function insert (parent, elm, ref$$1) {
  51417. if (isDef(parent)) {
  51418. if (isDef(ref$$1)) {
  51419. if (nodeOps.parentNode(ref$$1) === parent) {
  51420. nodeOps.insertBefore(parent, elm, ref$$1);
  51421. }
  51422. } else {
  51423. nodeOps.appendChild(parent, elm);
  51424. }
  51425. }
  51426. }
  51427. function createChildren (vnode, children, insertedVnodeQueue) {
  51428. if (Array.isArray(children)) {
  51429. {
  51430. checkDuplicateKeys(children);
  51431. }
  51432. for (var i = 0; i < children.length; ++i) {
  51433. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  51434. }
  51435. } else if (isPrimitive(vnode.text)) {
  51436. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  51437. }
  51438. }
  51439. function isPatchable (vnode) {
  51440. while (vnode.componentInstance) {
  51441. vnode = vnode.componentInstance._vnode;
  51442. }
  51443. return isDef(vnode.tag)
  51444. }
  51445. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  51446. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  51447. cbs.create[i$1](emptyNode, vnode);
  51448. }
  51449. i = vnode.data.hook; // Reuse variable
  51450. if (isDef(i)) {
  51451. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  51452. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  51453. }
  51454. }
  51455. // set scope id attribute for scoped CSS.
  51456. // this is implemented as a special case to avoid the overhead
  51457. // of going through the normal attribute patching process.
  51458. function setScope (vnode) {
  51459. var i;
  51460. if (isDef(i = vnode.fnScopeId)) {
  51461. nodeOps.setStyleScope(vnode.elm, i);
  51462. } else {
  51463. var ancestor = vnode;
  51464. while (ancestor) {
  51465. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  51466. nodeOps.setStyleScope(vnode.elm, i);
  51467. }
  51468. ancestor = ancestor.parent;
  51469. }
  51470. }
  51471. // for slot content they should also get the scopeId from the host instance.
  51472. if (isDef(i = activeInstance) &&
  51473. i !== vnode.context &&
  51474. i !== vnode.fnContext &&
  51475. isDef(i = i.$options._scopeId)
  51476. ) {
  51477. nodeOps.setStyleScope(vnode.elm, i);
  51478. }
  51479. }
  51480. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  51481. for (; startIdx <= endIdx; ++startIdx) {
  51482. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  51483. }
  51484. }
  51485. function invokeDestroyHook (vnode) {
  51486. var i, j;
  51487. var data = vnode.data;
  51488. if (isDef(data)) {
  51489. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  51490. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  51491. }
  51492. if (isDef(i = vnode.children)) {
  51493. for (j = 0; j < vnode.children.length; ++j) {
  51494. invokeDestroyHook(vnode.children[j]);
  51495. }
  51496. }
  51497. }
  51498. function removeVnodes (vnodes, startIdx, endIdx) {
  51499. for (; startIdx <= endIdx; ++startIdx) {
  51500. var ch = vnodes[startIdx];
  51501. if (isDef(ch)) {
  51502. if (isDef(ch.tag)) {
  51503. removeAndInvokeRemoveHook(ch);
  51504. invokeDestroyHook(ch);
  51505. } else { // Text node
  51506. removeNode(ch.elm);
  51507. }
  51508. }
  51509. }
  51510. }
  51511. function removeAndInvokeRemoveHook (vnode, rm) {
  51512. if (isDef(rm) || isDef(vnode.data)) {
  51513. var i;
  51514. var listeners = cbs.remove.length + 1;
  51515. if (isDef(rm)) {
  51516. // we have a recursively passed down rm callback
  51517. // increase the listeners count
  51518. rm.listeners += listeners;
  51519. } else {
  51520. // directly removing
  51521. rm = createRmCb(vnode.elm, listeners);
  51522. }
  51523. // recursively invoke hooks on child component root node
  51524. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  51525. removeAndInvokeRemoveHook(i, rm);
  51526. }
  51527. for (i = 0; i < cbs.remove.length; ++i) {
  51528. cbs.remove[i](vnode, rm);
  51529. }
  51530. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  51531. i(vnode, rm);
  51532. } else {
  51533. rm();
  51534. }
  51535. } else {
  51536. removeNode(vnode.elm);
  51537. }
  51538. }
  51539. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  51540. var oldStartIdx = 0;
  51541. var newStartIdx = 0;
  51542. var oldEndIdx = oldCh.length - 1;
  51543. var oldStartVnode = oldCh[0];
  51544. var oldEndVnode = oldCh[oldEndIdx];
  51545. var newEndIdx = newCh.length - 1;
  51546. var newStartVnode = newCh[0];
  51547. var newEndVnode = newCh[newEndIdx];
  51548. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  51549. // removeOnly is a special flag used only by <transition-group>
  51550. // to ensure removed elements stay in correct relative positions
  51551. // during leaving transitions
  51552. var canMove = !removeOnly;
  51553. {
  51554. checkDuplicateKeys(newCh);
  51555. }
  51556. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  51557. if (isUndef(oldStartVnode)) {
  51558. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  51559. } else if (isUndef(oldEndVnode)) {
  51560. oldEndVnode = oldCh[--oldEndIdx];
  51561. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  51562. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51563. oldStartVnode = oldCh[++oldStartIdx];
  51564. newStartVnode = newCh[++newStartIdx];
  51565. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  51566. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  51567. oldEndVnode = oldCh[--oldEndIdx];
  51568. newEndVnode = newCh[--newEndIdx];
  51569. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  51570. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  51571. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  51572. oldStartVnode = oldCh[++oldStartIdx];
  51573. newEndVnode = newCh[--newEndIdx];
  51574. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  51575. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51576. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  51577. oldEndVnode = oldCh[--oldEndIdx];
  51578. newStartVnode = newCh[++newStartIdx];
  51579. } else {
  51580. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  51581. idxInOld = isDef(newStartVnode.key)
  51582. ? oldKeyToIdx[newStartVnode.key]
  51583. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  51584. if (isUndef(idxInOld)) { // New element
  51585. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  51586. } else {
  51587. vnodeToMove = oldCh[idxInOld];
  51588. if (sameVnode(vnodeToMove, newStartVnode)) {
  51589. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51590. oldCh[idxInOld] = undefined;
  51591. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  51592. } else {
  51593. // same key but different element. treat as new element
  51594. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  51595. }
  51596. }
  51597. newStartVnode = newCh[++newStartIdx];
  51598. }
  51599. }
  51600. if (oldStartIdx > oldEndIdx) {
  51601. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  51602. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  51603. } else if (newStartIdx > newEndIdx) {
  51604. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  51605. }
  51606. }
  51607. function checkDuplicateKeys (children) {
  51608. var seenKeys = {};
  51609. for (var i = 0; i < children.length; i++) {
  51610. var vnode = children[i];
  51611. var key = vnode.key;
  51612. if (isDef(key)) {
  51613. if (seenKeys[key]) {
  51614. warn(
  51615. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  51616. vnode.context
  51617. );
  51618. } else {
  51619. seenKeys[key] = true;
  51620. }
  51621. }
  51622. }
  51623. }
  51624. function findIdxInOld (node, oldCh, start, end) {
  51625. for (var i = start; i < end; i++) {
  51626. var c = oldCh[i];
  51627. if (isDef(c) && sameVnode(node, c)) { return i }
  51628. }
  51629. }
  51630. function patchVnode (
  51631. oldVnode,
  51632. vnode,
  51633. insertedVnodeQueue,
  51634. ownerArray,
  51635. index,
  51636. removeOnly
  51637. ) {
  51638. if (oldVnode === vnode) {
  51639. return
  51640. }
  51641. if (isDef(vnode.elm) && isDef(ownerArray)) {
  51642. // clone reused vnode
  51643. vnode = ownerArray[index] = cloneVNode(vnode);
  51644. }
  51645. var elm = vnode.elm = oldVnode.elm;
  51646. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  51647. if (isDef(vnode.asyncFactory.resolved)) {
  51648. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  51649. } else {
  51650. vnode.isAsyncPlaceholder = true;
  51651. }
  51652. return
  51653. }
  51654. // reuse element for static trees.
  51655. // note we only do this if the vnode is cloned -
  51656. // if the new node is not cloned it means the render functions have been
  51657. // reset by the hot-reload-api and we need to do a proper re-render.
  51658. if (isTrue(vnode.isStatic) &&
  51659. isTrue(oldVnode.isStatic) &&
  51660. vnode.key === oldVnode.key &&
  51661. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  51662. ) {
  51663. vnode.componentInstance = oldVnode.componentInstance;
  51664. return
  51665. }
  51666. var i;
  51667. var data = vnode.data;
  51668. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  51669. i(oldVnode, vnode);
  51670. }
  51671. var oldCh = oldVnode.children;
  51672. var ch = vnode.children;
  51673. if (isDef(data) && isPatchable(vnode)) {
  51674. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  51675. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  51676. }
  51677. if (isUndef(vnode.text)) {
  51678. if (isDef(oldCh) && isDef(ch)) {
  51679. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  51680. } else if (isDef(ch)) {
  51681. {
  51682. checkDuplicateKeys(ch);
  51683. }
  51684. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  51685. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  51686. } else if (isDef(oldCh)) {
  51687. removeVnodes(oldCh, 0, oldCh.length - 1);
  51688. } else if (isDef(oldVnode.text)) {
  51689. nodeOps.setTextContent(elm, '');
  51690. }
  51691. } else if (oldVnode.text !== vnode.text) {
  51692. nodeOps.setTextContent(elm, vnode.text);
  51693. }
  51694. if (isDef(data)) {
  51695. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  51696. }
  51697. }
  51698. function invokeInsertHook (vnode, queue, initial) {
  51699. // delay insert hooks for component root nodes, invoke them after the
  51700. // element is really inserted
  51701. if (isTrue(initial) && isDef(vnode.parent)) {
  51702. vnode.parent.data.pendingInsert = queue;
  51703. } else {
  51704. for (var i = 0; i < queue.length; ++i) {
  51705. queue[i].data.hook.insert(queue[i]);
  51706. }
  51707. }
  51708. }
  51709. var hydrationBailed = false;
  51710. // list of modules that can skip create hook during hydration because they
  51711. // are already rendered on the client or has no need for initialization
  51712. // Note: style is excluded because it relies on initial clone for future
  51713. // deep updates (#7063).
  51714. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  51715. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  51716. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  51717. var i;
  51718. var tag = vnode.tag;
  51719. var data = vnode.data;
  51720. var children = vnode.children;
  51721. inVPre = inVPre || (data && data.pre);
  51722. vnode.elm = elm;
  51723. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  51724. vnode.isAsyncPlaceholder = true;
  51725. return true
  51726. }
  51727. // assert node match
  51728. {
  51729. if (!assertNodeMatch(elm, vnode, inVPre)) {
  51730. return false
  51731. }
  51732. }
  51733. if (isDef(data)) {
  51734. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  51735. if (isDef(i = vnode.componentInstance)) {
  51736. // child component. it should have hydrated its own tree.
  51737. initComponent(vnode, insertedVnodeQueue);
  51738. return true
  51739. }
  51740. }
  51741. if (isDef(tag)) {
  51742. if (isDef(children)) {
  51743. // empty element, allow client to pick up and populate children
  51744. if (!elm.hasChildNodes()) {
  51745. createChildren(vnode, children, insertedVnodeQueue);
  51746. } else {
  51747. // v-html and domProps: innerHTML
  51748. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  51749. if (i !== elm.innerHTML) {
  51750. /* istanbul ignore if */
  51751. if (typeof console !== 'undefined' &&
  51752. !hydrationBailed
  51753. ) {
  51754. hydrationBailed = true;
  51755. console.warn('Parent: ', elm);
  51756. console.warn('server innerHTML: ', i);
  51757. console.warn('client innerHTML: ', elm.innerHTML);
  51758. }
  51759. return false
  51760. }
  51761. } else {
  51762. // iterate and compare children lists
  51763. var childrenMatch = true;
  51764. var childNode = elm.firstChild;
  51765. for (var i$1 = 0; i$1 < children.length; i$1++) {
  51766. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  51767. childrenMatch = false;
  51768. break
  51769. }
  51770. childNode = childNode.nextSibling;
  51771. }
  51772. // if childNode is not null, it means the actual childNodes list is
  51773. // longer than the virtual children list.
  51774. if (!childrenMatch || childNode) {
  51775. /* istanbul ignore if */
  51776. if (typeof console !== 'undefined' &&
  51777. !hydrationBailed
  51778. ) {
  51779. hydrationBailed = true;
  51780. console.warn('Parent: ', elm);
  51781. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  51782. }
  51783. return false
  51784. }
  51785. }
  51786. }
  51787. }
  51788. if (isDef(data)) {
  51789. var fullInvoke = false;
  51790. for (var key in data) {
  51791. if (!isRenderedModule(key)) {
  51792. fullInvoke = true;
  51793. invokeCreateHooks(vnode, insertedVnodeQueue);
  51794. break
  51795. }
  51796. }
  51797. if (!fullInvoke && data['class']) {
  51798. // ensure collecting deps for deep class bindings for future updates
  51799. traverse(data['class']);
  51800. }
  51801. }
  51802. } else if (elm.data !== vnode.text) {
  51803. elm.data = vnode.text;
  51804. }
  51805. return true
  51806. }
  51807. function assertNodeMatch (node, vnode, inVPre) {
  51808. if (isDef(vnode.tag)) {
  51809. return vnode.tag.indexOf('vue-component') === 0 || (
  51810. !isUnknownElement$$1(vnode, inVPre) &&
  51811. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  51812. )
  51813. } else {
  51814. return node.nodeType === (vnode.isComment ? 8 : 3)
  51815. }
  51816. }
  51817. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  51818. if (isUndef(vnode)) {
  51819. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  51820. return
  51821. }
  51822. var isInitialPatch = false;
  51823. var insertedVnodeQueue = [];
  51824. if (isUndef(oldVnode)) {
  51825. // empty mount (likely as component), create new root element
  51826. isInitialPatch = true;
  51827. createElm(vnode, insertedVnodeQueue);
  51828. } else {
  51829. var isRealElement = isDef(oldVnode.nodeType);
  51830. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  51831. // patch existing root node
  51832. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  51833. } else {
  51834. if (isRealElement) {
  51835. // mounting to a real element
  51836. // check if this is server-rendered content and if we can perform
  51837. // a successful hydration.
  51838. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  51839. oldVnode.removeAttribute(SSR_ATTR);
  51840. hydrating = true;
  51841. }
  51842. if (isTrue(hydrating)) {
  51843. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  51844. invokeInsertHook(vnode, insertedVnodeQueue, true);
  51845. return oldVnode
  51846. } else {
  51847. warn(
  51848. 'The client-side rendered virtual DOM tree is not matching ' +
  51849. 'server-rendered content. This is likely caused by incorrect ' +
  51850. 'HTML markup, for example nesting block-level elements inside ' +
  51851. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  51852. 'full client-side render.'
  51853. );
  51854. }
  51855. }
  51856. // either not server-rendered, or hydration failed.
  51857. // create an empty node and replace it
  51858. oldVnode = emptyNodeAt(oldVnode);
  51859. }
  51860. // replacing existing element
  51861. var oldElm = oldVnode.elm;
  51862. var parentElm = nodeOps.parentNode(oldElm);
  51863. // create new node
  51864. createElm(
  51865. vnode,
  51866. insertedVnodeQueue,
  51867. // extremely rare edge case: do not insert if old element is in a
  51868. // leaving transition. Only happens when combining transition +
  51869. // keep-alive + HOCs. (#4590)
  51870. oldElm._leaveCb ? null : parentElm,
  51871. nodeOps.nextSibling(oldElm)
  51872. );
  51873. // update parent placeholder node element, recursively
  51874. if (isDef(vnode.parent)) {
  51875. var ancestor = vnode.parent;
  51876. var patchable = isPatchable(vnode);
  51877. while (ancestor) {
  51878. for (var i = 0; i < cbs.destroy.length; ++i) {
  51879. cbs.destroy[i](ancestor);
  51880. }
  51881. ancestor.elm = vnode.elm;
  51882. if (patchable) {
  51883. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  51884. cbs.create[i$1](emptyNode, ancestor);
  51885. }
  51886. // #6513
  51887. // invoke insert hooks that may have been merged by create hooks.
  51888. // e.g. for directives that uses the "inserted" hook.
  51889. var insert = ancestor.data.hook.insert;
  51890. if (insert.merged) {
  51891. // start at index 1 to avoid re-invoking component mounted hook
  51892. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  51893. insert.fns[i$2]();
  51894. }
  51895. }
  51896. } else {
  51897. registerRef(ancestor);
  51898. }
  51899. ancestor = ancestor.parent;
  51900. }
  51901. }
  51902. // destroy old node
  51903. if (isDef(parentElm)) {
  51904. removeVnodes([oldVnode], 0, 0);
  51905. } else if (isDef(oldVnode.tag)) {
  51906. invokeDestroyHook(oldVnode);
  51907. }
  51908. }
  51909. }
  51910. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  51911. return vnode.elm
  51912. }
  51913. }
  51914. /* */
  51915. var directives = {
  51916. create: updateDirectives,
  51917. update: updateDirectives,
  51918. destroy: function unbindDirectives (vnode) {
  51919. updateDirectives(vnode, emptyNode);
  51920. }
  51921. };
  51922. function updateDirectives (oldVnode, vnode) {
  51923. if (oldVnode.data.directives || vnode.data.directives) {
  51924. _update(oldVnode, vnode);
  51925. }
  51926. }
  51927. function _update (oldVnode, vnode) {
  51928. var isCreate = oldVnode === emptyNode;
  51929. var isDestroy = vnode === emptyNode;
  51930. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  51931. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  51932. var dirsWithInsert = [];
  51933. var dirsWithPostpatch = [];
  51934. var key, oldDir, dir;
  51935. for (key in newDirs) {
  51936. oldDir = oldDirs[key];
  51937. dir = newDirs[key];
  51938. if (!oldDir) {
  51939. // new directive, bind
  51940. callHook$1(dir, 'bind', vnode, oldVnode);
  51941. if (dir.def && dir.def.inserted) {
  51942. dirsWithInsert.push(dir);
  51943. }
  51944. } else {
  51945. // existing directive, update
  51946. dir.oldValue = oldDir.value;
  51947. dir.oldArg = oldDir.arg;
  51948. callHook$1(dir, 'update', vnode, oldVnode);
  51949. if (dir.def && dir.def.componentUpdated) {
  51950. dirsWithPostpatch.push(dir);
  51951. }
  51952. }
  51953. }
  51954. if (dirsWithInsert.length) {
  51955. var callInsert = function () {
  51956. for (var i = 0; i < dirsWithInsert.length; i++) {
  51957. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  51958. }
  51959. };
  51960. if (isCreate) {
  51961. mergeVNodeHook(vnode, 'insert', callInsert);
  51962. } else {
  51963. callInsert();
  51964. }
  51965. }
  51966. if (dirsWithPostpatch.length) {
  51967. mergeVNodeHook(vnode, 'postpatch', function () {
  51968. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  51969. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  51970. }
  51971. });
  51972. }
  51973. if (!isCreate) {
  51974. for (key in oldDirs) {
  51975. if (!newDirs[key]) {
  51976. // no longer present, unbind
  51977. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  51978. }
  51979. }
  51980. }
  51981. }
  51982. var emptyModifiers = Object.create(null);
  51983. function normalizeDirectives$1 (
  51984. dirs,
  51985. vm
  51986. ) {
  51987. var res = Object.create(null);
  51988. if (!dirs) {
  51989. // $flow-disable-line
  51990. return res
  51991. }
  51992. var i, dir;
  51993. for (i = 0; i < dirs.length; i++) {
  51994. dir = dirs[i];
  51995. if (!dir.modifiers) {
  51996. // $flow-disable-line
  51997. dir.modifiers = emptyModifiers;
  51998. }
  51999. res[getRawDirName(dir)] = dir;
  52000. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  52001. }
  52002. // $flow-disable-line
  52003. return res
  52004. }
  52005. function getRawDirName (dir) {
  52006. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  52007. }
  52008. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  52009. var fn = dir.def && dir.def[hook];
  52010. if (fn) {
  52011. try {
  52012. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  52013. } catch (e) {
  52014. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  52015. }
  52016. }
  52017. }
  52018. var baseModules = [
  52019. ref,
  52020. directives
  52021. ];
  52022. /* */
  52023. function updateAttrs (oldVnode, vnode) {
  52024. var opts = vnode.componentOptions;
  52025. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  52026. return
  52027. }
  52028. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  52029. return
  52030. }
  52031. var key, cur, old;
  52032. var elm = vnode.elm;
  52033. var oldAttrs = oldVnode.data.attrs || {};
  52034. var attrs = vnode.data.attrs || {};
  52035. // clone observed objects, as the user probably wants to mutate it
  52036. if (isDef(attrs.__ob__)) {
  52037. attrs = vnode.data.attrs = extend({}, attrs);
  52038. }
  52039. for (key in attrs) {
  52040. cur = attrs[key];
  52041. old = oldAttrs[key];
  52042. if (old !== cur) {
  52043. setAttr(elm, key, cur);
  52044. }
  52045. }
  52046. // #4391: in IE9, setting type can reset value for input[type=radio]
  52047. // #6666: IE/Edge forces progress value down to 1 before setting a max
  52048. /* istanbul ignore if */
  52049. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  52050. setAttr(elm, 'value', attrs.value);
  52051. }
  52052. for (key in oldAttrs) {
  52053. if (isUndef(attrs[key])) {
  52054. if (isXlink(key)) {
  52055. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  52056. } else if (!isEnumeratedAttr(key)) {
  52057. elm.removeAttribute(key);
  52058. }
  52059. }
  52060. }
  52061. }
  52062. function setAttr (el, key, value) {
  52063. if (el.tagName.indexOf('-') > -1) {
  52064. baseSetAttr(el, key, value);
  52065. } else if (isBooleanAttr(key)) {
  52066. // set attribute for blank value
  52067. // e.g. <option disabled>Select one</option>
  52068. if (isFalsyAttrValue(value)) {
  52069. el.removeAttribute(key);
  52070. } else {
  52071. // technically allowfullscreen is a boolean attribute for <iframe>,
  52072. // but Flash expects a value of "true" when used on <embed> tag
  52073. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  52074. ? 'true'
  52075. : key;
  52076. el.setAttribute(key, value);
  52077. }
  52078. } else if (isEnumeratedAttr(key)) {
  52079. el.setAttribute(key, convertEnumeratedValue(key, value));
  52080. } else if (isXlink(key)) {
  52081. if (isFalsyAttrValue(value)) {
  52082. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  52083. } else {
  52084. el.setAttributeNS(xlinkNS, key, value);
  52085. }
  52086. } else {
  52087. baseSetAttr(el, key, value);
  52088. }
  52089. }
  52090. function baseSetAttr (el, key, value) {
  52091. if (isFalsyAttrValue(value)) {
  52092. el.removeAttribute(key);
  52093. } else {
  52094. // #7138: IE10 & 11 fires input event when setting placeholder on
  52095. // <textarea>... block the first input event and remove the blocker
  52096. // immediately.
  52097. /* istanbul ignore if */
  52098. if (
  52099. isIE && !isIE9 &&
  52100. el.tagName === 'TEXTAREA' &&
  52101. key === 'placeholder' && value !== '' && !el.__ieph
  52102. ) {
  52103. var blocker = function (e) {
  52104. e.stopImmediatePropagation();
  52105. el.removeEventListener('input', blocker);
  52106. };
  52107. el.addEventListener('input', blocker);
  52108. // $flow-disable-line
  52109. el.__ieph = true; /* IE placeholder patched */
  52110. }
  52111. el.setAttribute(key, value);
  52112. }
  52113. }
  52114. var attrs = {
  52115. create: updateAttrs,
  52116. update: updateAttrs
  52117. };
  52118. /* */
  52119. function updateClass (oldVnode, vnode) {
  52120. var el = vnode.elm;
  52121. var data = vnode.data;
  52122. var oldData = oldVnode.data;
  52123. if (
  52124. isUndef(data.staticClass) &&
  52125. isUndef(data.class) && (
  52126. isUndef(oldData) || (
  52127. isUndef(oldData.staticClass) &&
  52128. isUndef(oldData.class)
  52129. )
  52130. )
  52131. ) {
  52132. return
  52133. }
  52134. var cls = genClassForVnode(vnode);
  52135. // handle transition classes
  52136. var transitionClass = el._transitionClasses;
  52137. if (isDef(transitionClass)) {
  52138. cls = concat(cls, stringifyClass(transitionClass));
  52139. }
  52140. // set the class
  52141. if (cls !== el._prevClass) {
  52142. el.setAttribute('class', cls);
  52143. el._prevClass = cls;
  52144. }
  52145. }
  52146. var klass = {
  52147. create: updateClass,
  52148. update: updateClass
  52149. };
  52150. /* */
  52151. var validDivisionCharRE = /[\w).+\-_$\]]/;
  52152. function parseFilters (exp) {
  52153. var inSingle = false;
  52154. var inDouble = false;
  52155. var inTemplateString = false;
  52156. var inRegex = false;
  52157. var curly = 0;
  52158. var square = 0;
  52159. var paren = 0;
  52160. var lastFilterIndex = 0;
  52161. var c, prev, i, expression, filters;
  52162. for (i = 0; i < exp.length; i++) {
  52163. prev = c;
  52164. c = exp.charCodeAt(i);
  52165. if (inSingle) {
  52166. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  52167. } else if (inDouble) {
  52168. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  52169. } else if (inTemplateString) {
  52170. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  52171. } else if (inRegex) {
  52172. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  52173. } else if (
  52174. c === 0x7C && // pipe
  52175. exp.charCodeAt(i + 1) !== 0x7C &&
  52176. exp.charCodeAt(i - 1) !== 0x7C &&
  52177. !curly && !square && !paren
  52178. ) {
  52179. if (expression === undefined) {
  52180. // first filter, end of expression
  52181. lastFilterIndex = i + 1;
  52182. expression = exp.slice(0, i).trim();
  52183. } else {
  52184. pushFilter();
  52185. }
  52186. } else {
  52187. switch (c) {
  52188. case 0x22: inDouble = true; break // "
  52189. case 0x27: inSingle = true; break // '
  52190. case 0x60: inTemplateString = true; break // `
  52191. case 0x28: paren++; break // (
  52192. case 0x29: paren--; break // )
  52193. case 0x5B: square++; break // [
  52194. case 0x5D: square--; break // ]
  52195. case 0x7B: curly++; break // {
  52196. case 0x7D: curly--; break // }
  52197. }
  52198. if (c === 0x2f) { // /
  52199. var j = i - 1;
  52200. var p = (void 0);
  52201. // find first non-whitespace prev char
  52202. for (; j >= 0; j--) {
  52203. p = exp.charAt(j);
  52204. if (p !== ' ') { break }
  52205. }
  52206. if (!p || !validDivisionCharRE.test(p)) {
  52207. inRegex = true;
  52208. }
  52209. }
  52210. }
  52211. }
  52212. if (expression === undefined) {
  52213. expression = exp.slice(0, i).trim();
  52214. } else if (lastFilterIndex !== 0) {
  52215. pushFilter();
  52216. }
  52217. function pushFilter () {
  52218. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  52219. lastFilterIndex = i + 1;
  52220. }
  52221. if (filters) {
  52222. for (i = 0; i < filters.length; i++) {
  52223. expression = wrapFilter(expression, filters[i]);
  52224. }
  52225. }
  52226. return expression
  52227. }
  52228. function wrapFilter (exp, filter) {
  52229. var i = filter.indexOf('(');
  52230. if (i < 0) {
  52231. // _f: resolveFilter
  52232. return ("_f(\"" + filter + "\")(" + exp + ")")
  52233. } else {
  52234. var name = filter.slice(0, i);
  52235. var args = filter.slice(i + 1);
  52236. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  52237. }
  52238. }
  52239. /* */
  52240. /* eslint-disable no-unused-vars */
  52241. function baseWarn (msg, range) {
  52242. console.error(("[Vue compiler]: " + msg));
  52243. }
  52244. /* eslint-enable no-unused-vars */
  52245. function pluckModuleFunction (
  52246. modules,
  52247. key
  52248. ) {
  52249. return modules
  52250. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  52251. : []
  52252. }
  52253. function addProp (el, name, value, range, dynamic) {
  52254. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  52255. el.plain = false;
  52256. }
  52257. function addAttr (el, name, value, range, dynamic) {
  52258. var attrs = dynamic
  52259. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  52260. : (el.attrs || (el.attrs = []));
  52261. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  52262. el.plain = false;
  52263. }
  52264. // add a raw attr (use this in preTransforms)
  52265. function addRawAttr (el, name, value, range) {
  52266. el.attrsMap[name] = value;
  52267. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  52268. }
  52269. function addDirective (
  52270. el,
  52271. name,
  52272. rawName,
  52273. value,
  52274. arg,
  52275. isDynamicArg,
  52276. modifiers,
  52277. range
  52278. ) {
  52279. (el.directives || (el.directives = [])).push(rangeSetItem({
  52280. name: name,
  52281. rawName: rawName,
  52282. value: value,
  52283. arg: arg,
  52284. isDynamicArg: isDynamicArg,
  52285. modifiers: modifiers
  52286. }, range));
  52287. el.plain = false;
  52288. }
  52289. function prependModifierMarker (symbol, name, dynamic) {
  52290. return dynamic
  52291. ? ("_p(" + name + ",\"" + symbol + "\")")
  52292. : symbol + name // mark the event as captured
  52293. }
  52294. function addHandler (
  52295. el,
  52296. name,
  52297. value,
  52298. modifiers,
  52299. important,
  52300. warn,
  52301. range,
  52302. dynamic
  52303. ) {
  52304. modifiers = modifiers || emptyObject;
  52305. // warn prevent and passive modifier
  52306. /* istanbul ignore if */
  52307. if (
  52308. warn &&
  52309. modifiers.prevent && modifiers.passive
  52310. ) {
  52311. warn(
  52312. 'passive and prevent can\'t be used together. ' +
  52313. 'Passive handler can\'t prevent default event.',
  52314. range
  52315. );
  52316. }
  52317. // normalize click.right and click.middle since they don't actually fire
  52318. // this is technically browser-specific, but at least for now browsers are
  52319. // the only target envs that have right/middle clicks.
  52320. if (modifiers.right) {
  52321. if (dynamic) {
  52322. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  52323. } else if (name === 'click') {
  52324. name = 'contextmenu';
  52325. delete modifiers.right;
  52326. }
  52327. } else if (modifiers.middle) {
  52328. if (dynamic) {
  52329. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  52330. } else if (name === 'click') {
  52331. name = 'mouseup';
  52332. }
  52333. }
  52334. // check capture modifier
  52335. if (modifiers.capture) {
  52336. delete modifiers.capture;
  52337. name = prependModifierMarker('!', name, dynamic);
  52338. }
  52339. if (modifiers.once) {
  52340. delete modifiers.once;
  52341. name = prependModifierMarker('~', name, dynamic);
  52342. }
  52343. /* istanbul ignore if */
  52344. if (modifiers.passive) {
  52345. delete modifiers.passive;
  52346. name = prependModifierMarker('&', name, dynamic);
  52347. }
  52348. var events;
  52349. if (modifiers.native) {
  52350. delete modifiers.native;
  52351. events = el.nativeEvents || (el.nativeEvents = {});
  52352. } else {
  52353. events = el.events || (el.events = {});
  52354. }
  52355. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  52356. if (modifiers !== emptyObject) {
  52357. newHandler.modifiers = modifiers;
  52358. }
  52359. var handlers = events[name];
  52360. /* istanbul ignore if */
  52361. if (Array.isArray(handlers)) {
  52362. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  52363. } else if (handlers) {
  52364. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  52365. } else {
  52366. events[name] = newHandler;
  52367. }
  52368. el.plain = false;
  52369. }
  52370. function getRawBindingAttr (
  52371. el,
  52372. name
  52373. ) {
  52374. return el.rawAttrsMap[':' + name] ||
  52375. el.rawAttrsMap['v-bind:' + name] ||
  52376. el.rawAttrsMap[name]
  52377. }
  52378. function getBindingAttr (
  52379. el,
  52380. name,
  52381. getStatic
  52382. ) {
  52383. var dynamicValue =
  52384. getAndRemoveAttr(el, ':' + name) ||
  52385. getAndRemoveAttr(el, 'v-bind:' + name);
  52386. if (dynamicValue != null) {
  52387. return parseFilters(dynamicValue)
  52388. } else if (getStatic !== false) {
  52389. var staticValue = getAndRemoveAttr(el, name);
  52390. if (staticValue != null) {
  52391. return JSON.stringify(staticValue)
  52392. }
  52393. }
  52394. }
  52395. // note: this only removes the attr from the Array (attrsList) so that it
  52396. // doesn't get processed by processAttrs.
  52397. // By default it does NOT remove it from the map (attrsMap) because the map is
  52398. // needed during codegen.
  52399. function getAndRemoveAttr (
  52400. el,
  52401. name,
  52402. removeFromMap
  52403. ) {
  52404. var val;
  52405. if ((val = el.attrsMap[name]) != null) {
  52406. var list = el.attrsList;
  52407. for (var i = 0, l = list.length; i < l; i++) {
  52408. if (list[i].name === name) {
  52409. list.splice(i, 1);
  52410. break
  52411. }
  52412. }
  52413. }
  52414. if (removeFromMap) {
  52415. delete el.attrsMap[name];
  52416. }
  52417. return val
  52418. }
  52419. function getAndRemoveAttrByRegex (
  52420. el,
  52421. name
  52422. ) {
  52423. var list = el.attrsList;
  52424. for (var i = 0, l = list.length; i < l; i++) {
  52425. var attr = list[i];
  52426. if (name.test(attr.name)) {
  52427. list.splice(i, 1);
  52428. return attr
  52429. }
  52430. }
  52431. }
  52432. function rangeSetItem (
  52433. item,
  52434. range
  52435. ) {
  52436. if (range) {
  52437. if (range.start != null) {
  52438. item.start = range.start;
  52439. }
  52440. if (range.end != null) {
  52441. item.end = range.end;
  52442. }
  52443. }
  52444. return item
  52445. }
  52446. /* */
  52447. /**
  52448. * Cross-platform code generation for component v-model
  52449. */
  52450. function genComponentModel (
  52451. el,
  52452. value,
  52453. modifiers
  52454. ) {
  52455. var ref = modifiers || {};
  52456. var number = ref.number;
  52457. var trim = ref.trim;
  52458. var baseValueExpression = '$$v';
  52459. var valueExpression = baseValueExpression;
  52460. if (trim) {
  52461. valueExpression =
  52462. "(typeof " + baseValueExpression + " === 'string'" +
  52463. "? " + baseValueExpression + ".trim()" +
  52464. ": " + baseValueExpression + ")";
  52465. }
  52466. if (number) {
  52467. valueExpression = "_n(" + valueExpression + ")";
  52468. }
  52469. var assignment = genAssignmentCode(value, valueExpression);
  52470. el.model = {
  52471. value: ("(" + value + ")"),
  52472. expression: JSON.stringify(value),
  52473. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  52474. };
  52475. }
  52476. /**
  52477. * Cross-platform codegen helper for generating v-model value assignment code.
  52478. */
  52479. function genAssignmentCode (
  52480. value,
  52481. assignment
  52482. ) {
  52483. var res = parseModel(value);
  52484. if (res.key === null) {
  52485. return (value + "=" + assignment)
  52486. } else {
  52487. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  52488. }
  52489. }
  52490. /**
  52491. * Parse a v-model expression into a base path and a final key segment.
  52492. * Handles both dot-path and possible square brackets.
  52493. *
  52494. * Possible cases:
  52495. *
  52496. * - test
  52497. * - test[key]
  52498. * - test[test1[key]]
  52499. * - test["a"][key]
  52500. * - xxx.test[a[a].test1[key]]
  52501. * - test.xxx.a["asa"][test1[key]]
  52502. *
  52503. */
  52504. var len, str, chr, index$1, expressionPos, expressionEndPos;
  52505. function parseModel (val) {
  52506. // Fix https://github.com/vuejs/vue/pull/7730
  52507. // allow v-model="obj.val " (trailing whitespace)
  52508. val = val.trim();
  52509. len = val.length;
  52510. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  52511. index$1 = val.lastIndexOf('.');
  52512. if (index$1 > -1) {
  52513. return {
  52514. exp: val.slice(0, index$1),
  52515. key: '"' + val.slice(index$1 + 1) + '"'
  52516. }
  52517. } else {
  52518. return {
  52519. exp: val,
  52520. key: null
  52521. }
  52522. }
  52523. }
  52524. str = val;
  52525. index$1 = expressionPos = expressionEndPos = 0;
  52526. while (!eof()) {
  52527. chr = next();
  52528. /* istanbul ignore if */
  52529. if (isStringStart(chr)) {
  52530. parseString(chr);
  52531. } else if (chr === 0x5B) {
  52532. parseBracket(chr);
  52533. }
  52534. }
  52535. return {
  52536. exp: val.slice(0, expressionPos),
  52537. key: val.slice(expressionPos + 1, expressionEndPos)
  52538. }
  52539. }
  52540. function next () {
  52541. return str.charCodeAt(++index$1)
  52542. }
  52543. function eof () {
  52544. return index$1 >= len
  52545. }
  52546. function isStringStart (chr) {
  52547. return chr === 0x22 || chr === 0x27
  52548. }
  52549. function parseBracket (chr) {
  52550. var inBracket = 1;
  52551. expressionPos = index$1;
  52552. while (!eof()) {
  52553. chr = next();
  52554. if (isStringStart(chr)) {
  52555. parseString(chr);
  52556. continue
  52557. }
  52558. if (chr === 0x5B) { inBracket++; }
  52559. if (chr === 0x5D) { inBracket--; }
  52560. if (inBracket === 0) {
  52561. expressionEndPos = index$1;
  52562. break
  52563. }
  52564. }
  52565. }
  52566. function parseString (chr) {
  52567. var stringQuote = chr;
  52568. while (!eof()) {
  52569. chr = next();
  52570. if (chr === stringQuote) {
  52571. break
  52572. }
  52573. }
  52574. }
  52575. /* */
  52576. var warn$1;
  52577. // in some cases, the event used has to be determined at runtime
  52578. // so we used some reserved tokens during compile.
  52579. var RANGE_TOKEN = '__r';
  52580. var CHECKBOX_RADIO_TOKEN = '__c';
  52581. function model (
  52582. el,
  52583. dir,
  52584. _warn
  52585. ) {
  52586. warn$1 = _warn;
  52587. var value = dir.value;
  52588. var modifiers = dir.modifiers;
  52589. var tag = el.tag;
  52590. var type = el.attrsMap.type;
  52591. {
  52592. // inputs with type="file" are read only and setting the input's
  52593. // value will throw an error.
  52594. if (tag === 'input' && type === 'file') {
  52595. warn$1(
  52596. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  52597. "File inputs are read only. Use a v-on:change listener instead.",
  52598. el.rawAttrsMap['v-model']
  52599. );
  52600. }
  52601. }
  52602. if (el.component) {
  52603. genComponentModel(el, value, modifiers);
  52604. // component v-model doesn't need extra runtime
  52605. return false
  52606. } else if (tag === 'select') {
  52607. genSelect(el, value, modifiers);
  52608. } else if (tag === 'input' && type === 'checkbox') {
  52609. genCheckboxModel(el, value, modifiers);
  52610. } else if (tag === 'input' && type === 'radio') {
  52611. genRadioModel(el, value, modifiers);
  52612. } else if (tag === 'input' || tag === 'textarea') {
  52613. genDefaultModel(el, value, modifiers);
  52614. } else if (!config.isReservedTag(tag)) {
  52615. genComponentModel(el, value, modifiers);
  52616. // component v-model doesn't need extra runtime
  52617. return false
  52618. } else {
  52619. warn$1(
  52620. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52621. "v-model is not supported on this element type. " +
  52622. 'If you are working with contenteditable, it\'s recommended to ' +
  52623. 'wrap a library dedicated for that purpose inside a custom component.',
  52624. el.rawAttrsMap['v-model']
  52625. );
  52626. }
  52627. // ensure runtime directive metadata
  52628. return true
  52629. }
  52630. function genCheckboxModel (
  52631. el,
  52632. value,
  52633. modifiers
  52634. ) {
  52635. var number = modifiers && modifiers.number;
  52636. var valueBinding = getBindingAttr(el, 'value') || 'null';
  52637. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  52638. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  52639. addProp(el, 'checked',
  52640. "Array.isArray(" + value + ")" +
  52641. "?_i(" + value + "," + valueBinding + ")>-1" + (
  52642. trueValueBinding === 'true'
  52643. ? (":(" + value + ")")
  52644. : (":_q(" + value + "," + trueValueBinding + ")")
  52645. )
  52646. );
  52647. addHandler(el, 'change',
  52648. "var $$a=" + value + "," +
  52649. '$$el=$event.target,' +
  52650. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  52651. 'if(Array.isArray($$a)){' +
  52652. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  52653. '$$i=_i($$a,$$v);' +
  52654. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  52655. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  52656. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  52657. null, true
  52658. );
  52659. }
  52660. function genRadioModel (
  52661. el,
  52662. value,
  52663. modifiers
  52664. ) {
  52665. var number = modifiers && modifiers.number;
  52666. var valueBinding = getBindingAttr(el, 'value') || 'null';
  52667. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  52668. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  52669. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  52670. }
  52671. function genSelect (
  52672. el,
  52673. value,
  52674. modifiers
  52675. ) {
  52676. var number = modifiers && modifiers.number;
  52677. var selectedVal = "Array.prototype.filter" +
  52678. ".call($event.target.options,function(o){return o.selected})" +
  52679. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  52680. "return " + (number ? '_n(val)' : 'val') + "})";
  52681. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  52682. var code = "var $$selectedVal = " + selectedVal + ";";
  52683. code = code + " " + (genAssignmentCode(value, assignment));
  52684. addHandler(el, 'change', code, null, true);
  52685. }
  52686. function genDefaultModel (
  52687. el,
  52688. value,
  52689. modifiers
  52690. ) {
  52691. var type = el.attrsMap.type;
  52692. // warn if v-bind:value conflicts with v-model
  52693. // except for inputs with v-bind:type
  52694. {
  52695. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  52696. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  52697. if (value$1 && !typeBinding) {
  52698. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  52699. warn$1(
  52700. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  52701. 'because the latter already expands to a value binding internally',
  52702. el.rawAttrsMap[binding]
  52703. );
  52704. }
  52705. }
  52706. var ref = modifiers || {};
  52707. var lazy = ref.lazy;
  52708. var number = ref.number;
  52709. var trim = ref.trim;
  52710. var needCompositionGuard = !lazy && type !== 'range';
  52711. var event = lazy
  52712. ? 'change'
  52713. : type === 'range'
  52714. ? RANGE_TOKEN
  52715. : 'input';
  52716. var valueExpression = '$event.target.value';
  52717. if (trim) {
  52718. valueExpression = "$event.target.value.trim()";
  52719. }
  52720. if (number) {
  52721. valueExpression = "_n(" + valueExpression + ")";
  52722. }
  52723. var code = genAssignmentCode(value, valueExpression);
  52724. if (needCompositionGuard) {
  52725. code = "if($event.target.composing)return;" + code;
  52726. }
  52727. addProp(el, 'value', ("(" + value + ")"));
  52728. addHandler(el, event, code, null, true);
  52729. if (trim || number) {
  52730. addHandler(el, 'blur', '$forceUpdate()');
  52731. }
  52732. }
  52733. /* */
  52734. // normalize v-model event tokens that can only be determined at runtime.
  52735. // it's important to place the event as the first in the array because
  52736. // the whole point is ensuring the v-model callback gets called before
  52737. // user-attached handlers.
  52738. function normalizeEvents (on) {
  52739. /* istanbul ignore if */
  52740. if (isDef(on[RANGE_TOKEN])) {
  52741. // IE input[type=range] only supports `change` event
  52742. var event = isIE ? 'change' : 'input';
  52743. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  52744. delete on[RANGE_TOKEN];
  52745. }
  52746. // This was originally intended to fix #4521 but no longer necessary
  52747. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  52748. /* istanbul ignore if */
  52749. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  52750. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  52751. delete on[CHECKBOX_RADIO_TOKEN];
  52752. }
  52753. }
  52754. var target$1;
  52755. function createOnceHandler$1 (event, handler, capture) {
  52756. var _target = target$1; // save current target element in closure
  52757. return function onceHandler () {
  52758. var res = handler.apply(null, arguments);
  52759. if (res !== null) {
  52760. remove$2(event, onceHandler, capture, _target);
  52761. }
  52762. }
  52763. }
  52764. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  52765. // implementation and does not fire microtasks in between event propagation, so
  52766. // safe to exclude.
  52767. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  52768. function add$1 (
  52769. name,
  52770. handler,
  52771. capture,
  52772. passive
  52773. ) {
  52774. // async edge case #6566: inner click event triggers patch, event handler
  52775. // attached to outer element during patch, and triggered again. This
  52776. // happens because browsers fire microtask ticks between event propagation.
  52777. // the solution is simple: we save the timestamp when a handler is attached,
  52778. // and the handler would only fire if the event passed to it was fired
  52779. // AFTER it was attached.
  52780. if (useMicrotaskFix) {
  52781. var attachedTimestamp = currentFlushTimestamp;
  52782. var original = handler;
  52783. handler = original._wrapper = function (e) {
  52784. if (
  52785. // no bubbling, should always fire.
  52786. // this is just a safety net in case event.timeStamp is unreliable in
  52787. // certain weird environments...
  52788. e.target === e.currentTarget ||
  52789. // event is fired after handler attachment
  52790. e.timeStamp >= attachedTimestamp ||
  52791. // bail for environments that have buggy event.timeStamp implementations
  52792. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  52793. // #9681 QtWebEngine event.timeStamp is negative value
  52794. e.timeStamp <= 0 ||
  52795. // #9448 bail if event is fired in another document in a multi-page
  52796. // electron/nw.js app, since event.timeStamp will be using a different
  52797. // starting reference
  52798. e.target.ownerDocument !== document
  52799. ) {
  52800. return original.apply(this, arguments)
  52801. }
  52802. };
  52803. }
  52804. target$1.addEventListener(
  52805. name,
  52806. handler,
  52807. supportsPassive
  52808. ? { capture: capture, passive: passive }
  52809. : capture
  52810. );
  52811. }
  52812. function remove$2 (
  52813. name,
  52814. handler,
  52815. capture,
  52816. _target
  52817. ) {
  52818. (_target || target$1).removeEventListener(
  52819. name,
  52820. handler._wrapper || handler,
  52821. capture
  52822. );
  52823. }
  52824. function updateDOMListeners (oldVnode, vnode) {
  52825. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  52826. return
  52827. }
  52828. var on = vnode.data.on || {};
  52829. var oldOn = oldVnode.data.on || {};
  52830. target$1 = vnode.elm;
  52831. normalizeEvents(on);
  52832. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  52833. target$1 = undefined;
  52834. }
  52835. var events = {
  52836. create: updateDOMListeners,
  52837. update: updateDOMListeners
  52838. };
  52839. /* */
  52840. var svgContainer;
  52841. function updateDOMProps (oldVnode, vnode) {
  52842. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  52843. return
  52844. }
  52845. var key, cur;
  52846. var elm = vnode.elm;
  52847. var oldProps = oldVnode.data.domProps || {};
  52848. var props = vnode.data.domProps || {};
  52849. // clone observed objects, as the user probably wants to mutate it
  52850. if (isDef(props.__ob__)) {
  52851. props = vnode.data.domProps = extend({}, props);
  52852. }
  52853. for (key in oldProps) {
  52854. if (!(key in props)) {
  52855. elm[key] = '';
  52856. }
  52857. }
  52858. for (key in props) {
  52859. cur = props[key];
  52860. // ignore children if the node has textContent or innerHTML,
  52861. // as these will throw away existing DOM nodes and cause removal errors
  52862. // on subsequent patches (#3360)
  52863. if (key === 'textContent' || key === 'innerHTML') {
  52864. if (vnode.children) { vnode.children.length = 0; }
  52865. if (cur === oldProps[key]) { continue }
  52866. // #6601 work around Chrome version <= 55 bug where single textNode
  52867. // replaced by innerHTML/textContent retains its parentNode property
  52868. if (elm.childNodes.length === 1) {
  52869. elm.removeChild(elm.childNodes[0]);
  52870. }
  52871. }
  52872. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  52873. // store value as _value as well since
  52874. // non-string values will be stringified
  52875. elm._value = cur;
  52876. // avoid resetting cursor position when value is the same
  52877. var strCur = isUndef(cur) ? '' : String(cur);
  52878. if (shouldUpdateValue(elm, strCur)) {
  52879. elm.value = strCur;
  52880. }
  52881. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  52882. // IE doesn't support innerHTML for SVG elements
  52883. svgContainer = svgContainer || document.createElement('div');
  52884. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  52885. var svg = svgContainer.firstChild;
  52886. while (elm.firstChild) {
  52887. elm.removeChild(elm.firstChild);
  52888. }
  52889. while (svg.firstChild) {
  52890. elm.appendChild(svg.firstChild);
  52891. }
  52892. } else if (
  52893. // skip the update if old and new VDOM state is the same.
  52894. // `value` is handled separately because the DOM value may be temporarily
  52895. // out of sync with VDOM state due to focus, composition and modifiers.
  52896. // This #4521 by skipping the unnecesarry `checked` update.
  52897. cur !== oldProps[key]
  52898. ) {
  52899. // some property updates can throw
  52900. // e.g. `value` on <progress> w/ non-finite value
  52901. try {
  52902. elm[key] = cur;
  52903. } catch (e) {}
  52904. }
  52905. }
  52906. }
  52907. // check platforms/web/util/attrs.js acceptValue
  52908. function shouldUpdateValue (elm, checkVal) {
  52909. return (!elm.composing && (
  52910. elm.tagName === 'OPTION' ||
  52911. isNotInFocusAndDirty(elm, checkVal) ||
  52912. isDirtyWithModifiers(elm, checkVal)
  52913. ))
  52914. }
  52915. function isNotInFocusAndDirty (elm, checkVal) {
  52916. // return true when textbox (.number and .trim) loses focus and its value is
  52917. // not equal to the updated value
  52918. var notInFocus = true;
  52919. // #6157
  52920. // work around IE bug when accessing document.activeElement in an iframe
  52921. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  52922. return notInFocus && elm.value !== checkVal
  52923. }
  52924. function isDirtyWithModifiers (elm, newVal) {
  52925. var value = elm.value;
  52926. var modifiers = elm._vModifiers; // injected by v-model runtime
  52927. if (isDef(modifiers)) {
  52928. if (modifiers.number) {
  52929. return toNumber(value) !== toNumber(newVal)
  52930. }
  52931. if (modifiers.trim) {
  52932. return value.trim() !== newVal.trim()
  52933. }
  52934. }
  52935. return value !== newVal
  52936. }
  52937. var domProps = {
  52938. create: updateDOMProps,
  52939. update: updateDOMProps
  52940. };
  52941. /* */
  52942. var parseStyleText = cached(function (cssText) {
  52943. var res = {};
  52944. var listDelimiter = /;(?![^(]*\))/g;
  52945. var propertyDelimiter = /:(.+)/;
  52946. cssText.split(listDelimiter).forEach(function (item) {
  52947. if (item) {
  52948. var tmp = item.split(propertyDelimiter);
  52949. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  52950. }
  52951. });
  52952. return res
  52953. });
  52954. // merge static and dynamic style data on the same vnode
  52955. function normalizeStyleData (data) {
  52956. var style = normalizeStyleBinding(data.style);
  52957. // static style is pre-processed into an object during compilation
  52958. // and is always a fresh object, so it's safe to merge into it
  52959. return data.staticStyle
  52960. ? extend(data.staticStyle, style)
  52961. : style
  52962. }
  52963. // normalize possible array / string values into Object
  52964. function normalizeStyleBinding (bindingStyle) {
  52965. if (Array.isArray(bindingStyle)) {
  52966. return toObject(bindingStyle)
  52967. }
  52968. if (typeof bindingStyle === 'string') {
  52969. return parseStyleText(bindingStyle)
  52970. }
  52971. return bindingStyle
  52972. }
  52973. /**
  52974. * parent component style should be after child's
  52975. * so that parent component's style could override it
  52976. */
  52977. function getStyle (vnode, checkChild) {
  52978. var res = {};
  52979. var styleData;
  52980. if (checkChild) {
  52981. var childNode = vnode;
  52982. while (childNode.componentInstance) {
  52983. childNode = childNode.componentInstance._vnode;
  52984. if (
  52985. childNode && childNode.data &&
  52986. (styleData = normalizeStyleData(childNode.data))
  52987. ) {
  52988. extend(res, styleData);
  52989. }
  52990. }
  52991. }
  52992. if ((styleData = normalizeStyleData(vnode.data))) {
  52993. extend(res, styleData);
  52994. }
  52995. var parentNode = vnode;
  52996. while ((parentNode = parentNode.parent)) {
  52997. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  52998. extend(res, styleData);
  52999. }
  53000. }
  53001. return res
  53002. }
  53003. /* */
  53004. var cssVarRE = /^--/;
  53005. var importantRE = /\s*!important$/;
  53006. var setProp = function (el, name, val) {
  53007. /* istanbul ignore if */
  53008. if (cssVarRE.test(name)) {
  53009. el.style.setProperty(name, val);
  53010. } else if (importantRE.test(val)) {
  53011. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  53012. } else {
  53013. var normalizedName = normalize(name);
  53014. if (Array.isArray(val)) {
  53015. // Support values array created by autoprefixer, e.g.
  53016. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  53017. // Set them one by one, and the browser will only set those it can recognize
  53018. for (var i = 0, len = val.length; i < len; i++) {
  53019. el.style[normalizedName] = val[i];
  53020. }
  53021. } else {
  53022. el.style[normalizedName] = val;
  53023. }
  53024. }
  53025. };
  53026. var vendorNames = ['Webkit', 'Moz', 'ms'];
  53027. var emptyStyle;
  53028. var normalize = cached(function (prop) {
  53029. emptyStyle = emptyStyle || document.createElement('div').style;
  53030. prop = camelize(prop);
  53031. if (prop !== 'filter' && (prop in emptyStyle)) {
  53032. return prop
  53033. }
  53034. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  53035. for (var i = 0; i < vendorNames.length; i++) {
  53036. var name = vendorNames[i] + capName;
  53037. if (name in emptyStyle) {
  53038. return name
  53039. }
  53040. }
  53041. });
  53042. function updateStyle (oldVnode, vnode) {
  53043. var data = vnode.data;
  53044. var oldData = oldVnode.data;
  53045. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  53046. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  53047. ) {
  53048. return
  53049. }
  53050. var cur, name;
  53051. var el = vnode.elm;
  53052. var oldStaticStyle = oldData.staticStyle;
  53053. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  53054. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  53055. var oldStyle = oldStaticStyle || oldStyleBinding;
  53056. var style = normalizeStyleBinding(vnode.data.style) || {};
  53057. // store normalized style under a different key for next diff
  53058. // make sure to clone it if it's reactive, since the user likely wants
  53059. // to mutate it.
  53060. vnode.data.normalizedStyle = isDef(style.__ob__)
  53061. ? extend({}, style)
  53062. : style;
  53063. var newStyle = getStyle(vnode, true);
  53064. for (name in oldStyle) {
  53065. if (isUndef(newStyle[name])) {
  53066. setProp(el, name, '');
  53067. }
  53068. }
  53069. for (name in newStyle) {
  53070. cur = newStyle[name];
  53071. if (cur !== oldStyle[name]) {
  53072. // ie9 setting to null has no effect, must use empty string
  53073. setProp(el, name, cur == null ? '' : cur);
  53074. }
  53075. }
  53076. }
  53077. var style = {
  53078. create: updateStyle,
  53079. update: updateStyle
  53080. };
  53081. /* */
  53082. var whitespaceRE = /\s+/;
  53083. /**
  53084. * Add class with compatibility for SVG since classList is not supported on
  53085. * SVG elements in IE
  53086. */
  53087. function addClass (el, cls) {
  53088. /* istanbul ignore if */
  53089. if (!cls || !(cls = cls.trim())) {
  53090. return
  53091. }
  53092. /* istanbul ignore else */
  53093. if (el.classList) {
  53094. if (cls.indexOf(' ') > -1) {
  53095. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  53096. } else {
  53097. el.classList.add(cls);
  53098. }
  53099. } else {
  53100. var cur = " " + (el.getAttribute('class') || '') + " ";
  53101. if (cur.indexOf(' ' + cls + ' ') < 0) {
  53102. el.setAttribute('class', (cur + cls).trim());
  53103. }
  53104. }
  53105. }
  53106. /**
  53107. * Remove class with compatibility for SVG since classList is not supported on
  53108. * SVG elements in IE
  53109. */
  53110. function removeClass (el, cls) {
  53111. /* istanbul ignore if */
  53112. if (!cls || !(cls = cls.trim())) {
  53113. return
  53114. }
  53115. /* istanbul ignore else */
  53116. if (el.classList) {
  53117. if (cls.indexOf(' ') > -1) {
  53118. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  53119. } else {
  53120. el.classList.remove(cls);
  53121. }
  53122. if (!el.classList.length) {
  53123. el.removeAttribute('class');
  53124. }
  53125. } else {
  53126. var cur = " " + (el.getAttribute('class') || '') + " ";
  53127. var tar = ' ' + cls + ' ';
  53128. while (cur.indexOf(tar) >= 0) {
  53129. cur = cur.replace(tar, ' ');
  53130. }
  53131. cur = cur.trim();
  53132. if (cur) {
  53133. el.setAttribute('class', cur);
  53134. } else {
  53135. el.removeAttribute('class');
  53136. }
  53137. }
  53138. }
  53139. /* */
  53140. function resolveTransition (def$$1) {
  53141. if (!def$$1) {
  53142. return
  53143. }
  53144. /* istanbul ignore else */
  53145. if (typeof def$$1 === 'object') {
  53146. var res = {};
  53147. if (def$$1.css !== false) {
  53148. extend(res, autoCssTransition(def$$1.name || 'v'));
  53149. }
  53150. extend(res, def$$1);
  53151. return res
  53152. } else if (typeof def$$1 === 'string') {
  53153. return autoCssTransition(def$$1)
  53154. }
  53155. }
  53156. var autoCssTransition = cached(function (name) {
  53157. return {
  53158. enterClass: (name + "-enter"),
  53159. enterToClass: (name + "-enter-to"),
  53160. enterActiveClass: (name + "-enter-active"),
  53161. leaveClass: (name + "-leave"),
  53162. leaveToClass: (name + "-leave-to"),
  53163. leaveActiveClass: (name + "-leave-active")
  53164. }
  53165. });
  53166. var hasTransition = inBrowser && !isIE9;
  53167. var TRANSITION = 'transition';
  53168. var ANIMATION = 'animation';
  53169. // Transition property/event sniffing
  53170. var transitionProp = 'transition';
  53171. var transitionEndEvent = 'transitionend';
  53172. var animationProp = 'animation';
  53173. var animationEndEvent = 'animationend';
  53174. if (hasTransition) {
  53175. /* istanbul ignore if */
  53176. if (window.ontransitionend === undefined &&
  53177. window.onwebkittransitionend !== undefined
  53178. ) {
  53179. transitionProp = 'WebkitTransition';
  53180. transitionEndEvent = 'webkitTransitionEnd';
  53181. }
  53182. if (window.onanimationend === undefined &&
  53183. window.onwebkitanimationend !== undefined
  53184. ) {
  53185. animationProp = 'WebkitAnimation';
  53186. animationEndEvent = 'webkitAnimationEnd';
  53187. }
  53188. }
  53189. // binding to window is necessary to make hot reload work in IE in strict mode
  53190. var raf = inBrowser
  53191. ? window.requestAnimationFrame
  53192. ? window.requestAnimationFrame.bind(window)
  53193. : setTimeout
  53194. : /* istanbul ignore next */ function (fn) { return fn(); };
  53195. function nextFrame (fn) {
  53196. raf(function () {
  53197. raf(fn);
  53198. });
  53199. }
  53200. function addTransitionClass (el, cls) {
  53201. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  53202. if (transitionClasses.indexOf(cls) < 0) {
  53203. transitionClasses.push(cls);
  53204. addClass(el, cls);
  53205. }
  53206. }
  53207. function removeTransitionClass (el, cls) {
  53208. if (el._transitionClasses) {
  53209. remove(el._transitionClasses, cls);
  53210. }
  53211. removeClass(el, cls);
  53212. }
  53213. function whenTransitionEnds (
  53214. el,
  53215. expectedType,
  53216. cb
  53217. ) {
  53218. var ref = getTransitionInfo(el, expectedType);
  53219. var type = ref.type;
  53220. var timeout = ref.timeout;
  53221. var propCount = ref.propCount;
  53222. if (!type) { return cb() }
  53223. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  53224. var ended = 0;
  53225. var end = function () {
  53226. el.removeEventListener(event, onEnd);
  53227. cb();
  53228. };
  53229. var onEnd = function (e) {
  53230. if (e.target === el) {
  53231. if (++ended >= propCount) {
  53232. end();
  53233. }
  53234. }
  53235. };
  53236. setTimeout(function () {
  53237. if (ended < propCount) {
  53238. end();
  53239. }
  53240. }, timeout + 1);
  53241. el.addEventListener(event, onEnd);
  53242. }
  53243. var transformRE = /\b(transform|all)(,|$)/;
  53244. function getTransitionInfo (el, expectedType) {
  53245. var styles = window.getComputedStyle(el);
  53246. // JSDOM may return undefined for transition properties
  53247. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  53248. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  53249. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  53250. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  53251. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  53252. var animationTimeout = getTimeout(animationDelays, animationDurations);
  53253. var type;
  53254. var timeout = 0;
  53255. var propCount = 0;
  53256. /* istanbul ignore if */
  53257. if (expectedType === TRANSITION) {
  53258. if (transitionTimeout > 0) {
  53259. type = TRANSITION;
  53260. timeout = transitionTimeout;
  53261. propCount = transitionDurations.length;
  53262. }
  53263. } else if (expectedType === ANIMATION) {
  53264. if (animationTimeout > 0) {
  53265. type = ANIMATION;
  53266. timeout = animationTimeout;
  53267. propCount = animationDurations.length;
  53268. }
  53269. } else {
  53270. timeout = Math.max(transitionTimeout, animationTimeout);
  53271. type = timeout > 0
  53272. ? transitionTimeout > animationTimeout
  53273. ? TRANSITION
  53274. : ANIMATION
  53275. : null;
  53276. propCount = type
  53277. ? type === TRANSITION
  53278. ? transitionDurations.length
  53279. : animationDurations.length
  53280. : 0;
  53281. }
  53282. var hasTransform =
  53283. type === TRANSITION &&
  53284. transformRE.test(styles[transitionProp + 'Property']);
  53285. return {
  53286. type: type,
  53287. timeout: timeout,
  53288. propCount: propCount,
  53289. hasTransform: hasTransform
  53290. }
  53291. }
  53292. function getTimeout (delays, durations) {
  53293. /* istanbul ignore next */
  53294. while (delays.length < durations.length) {
  53295. delays = delays.concat(delays);
  53296. }
  53297. return Math.max.apply(null, durations.map(function (d, i) {
  53298. return toMs(d) + toMs(delays[i])
  53299. }))
  53300. }
  53301. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  53302. // in a locale-dependent way, using a comma instead of a dot.
  53303. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  53304. // as a floor function) causing unexpected behaviors
  53305. function toMs (s) {
  53306. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  53307. }
  53308. /* */
  53309. function enter (vnode, toggleDisplay) {
  53310. var el = vnode.elm;
  53311. // call leave callback now
  53312. if (isDef(el._leaveCb)) {
  53313. el._leaveCb.cancelled = true;
  53314. el._leaveCb();
  53315. }
  53316. var data = resolveTransition(vnode.data.transition);
  53317. if (isUndef(data)) {
  53318. return
  53319. }
  53320. /* istanbul ignore if */
  53321. if (isDef(el._enterCb) || el.nodeType !== 1) {
  53322. return
  53323. }
  53324. var css = data.css;
  53325. var type = data.type;
  53326. var enterClass = data.enterClass;
  53327. var enterToClass = data.enterToClass;
  53328. var enterActiveClass = data.enterActiveClass;
  53329. var appearClass = data.appearClass;
  53330. var appearToClass = data.appearToClass;
  53331. var appearActiveClass = data.appearActiveClass;
  53332. var beforeEnter = data.beforeEnter;
  53333. var enter = data.enter;
  53334. var afterEnter = data.afterEnter;
  53335. var enterCancelled = data.enterCancelled;
  53336. var beforeAppear = data.beforeAppear;
  53337. var appear = data.appear;
  53338. var afterAppear = data.afterAppear;
  53339. var appearCancelled = data.appearCancelled;
  53340. var duration = data.duration;
  53341. // activeInstance will always be the <transition> component managing this
  53342. // transition. One edge case to check is when the <transition> is placed
  53343. // as the root node of a child component. In that case we need to check
  53344. // <transition>'s parent for appear check.
  53345. var context = activeInstance;
  53346. var transitionNode = activeInstance.$vnode;
  53347. while (transitionNode && transitionNode.parent) {
  53348. context = transitionNode.context;
  53349. transitionNode = transitionNode.parent;
  53350. }
  53351. var isAppear = !context._isMounted || !vnode.isRootInsert;
  53352. if (isAppear && !appear && appear !== '') {
  53353. return
  53354. }
  53355. var startClass = isAppear && appearClass
  53356. ? appearClass
  53357. : enterClass;
  53358. var activeClass = isAppear && appearActiveClass
  53359. ? appearActiveClass
  53360. : enterActiveClass;
  53361. var toClass = isAppear && appearToClass
  53362. ? appearToClass
  53363. : enterToClass;
  53364. var beforeEnterHook = isAppear
  53365. ? (beforeAppear || beforeEnter)
  53366. : beforeEnter;
  53367. var enterHook = isAppear
  53368. ? (typeof appear === 'function' ? appear : enter)
  53369. : enter;
  53370. var afterEnterHook = isAppear
  53371. ? (afterAppear || afterEnter)
  53372. : afterEnter;
  53373. var enterCancelledHook = isAppear
  53374. ? (appearCancelled || enterCancelled)
  53375. : enterCancelled;
  53376. var explicitEnterDuration = toNumber(
  53377. isObject(duration)
  53378. ? duration.enter
  53379. : duration
  53380. );
  53381. if (explicitEnterDuration != null) {
  53382. checkDuration(explicitEnterDuration, 'enter', vnode);
  53383. }
  53384. var expectsCSS = css !== false && !isIE9;
  53385. var userWantsControl = getHookArgumentsLength(enterHook);
  53386. var cb = el._enterCb = once(function () {
  53387. if (expectsCSS) {
  53388. removeTransitionClass(el, toClass);
  53389. removeTransitionClass(el, activeClass);
  53390. }
  53391. if (cb.cancelled) {
  53392. if (expectsCSS) {
  53393. removeTransitionClass(el, startClass);
  53394. }
  53395. enterCancelledHook && enterCancelledHook(el);
  53396. } else {
  53397. afterEnterHook && afterEnterHook(el);
  53398. }
  53399. el._enterCb = null;
  53400. });
  53401. if (!vnode.data.show) {
  53402. // remove pending leave element on enter by injecting an insert hook
  53403. mergeVNodeHook(vnode, 'insert', function () {
  53404. var parent = el.parentNode;
  53405. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  53406. if (pendingNode &&
  53407. pendingNode.tag === vnode.tag &&
  53408. pendingNode.elm._leaveCb
  53409. ) {
  53410. pendingNode.elm._leaveCb();
  53411. }
  53412. enterHook && enterHook(el, cb);
  53413. });
  53414. }
  53415. // start enter transition
  53416. beforeEnterHook && beforeEnterHook(el);
  53417. if (expectsCSS) {
  53418. addTransitionClass(el, startClass);
  53419. addTransitionClass(el, activeClass);
  53420. nextFrame(function () {
  53421. removeTransitionClass(el, startClass);
  53422. if (!cb.cancelled) {
  53423. addTransitionClass(el, toClass);
  53424. if (!userWantsControl) {
  53425. if (isValidDuration(explicitEnterDuration)) {
  53426. setTimeout(cb, explicitEnterDuration);
  53427. } else {
  53428. whenTransitionEnds(el, type, cb);
  53429. }
  53430. }
  53431. }
  53432. });
  53433. }
  53434. if (vnode.data.show) {
  53435. toggleDisplay && toggleDisplay();
  53436. enterHook && enterHook(el, cb);
  53437. }
  53438. if (!expectsCSS && !userWantsControl) {
  53439. cb();
  53440. }
  53441. }
  53442. function leave (vnode, rm) {
  53443. var el = vnode.elm;
  53444. // call enter callback now
  53445. if (isDef(el._enterCb)) {
  53446. el._enterCb.cancelled = true;
  53447. el._enterCb();
  53448. }
  53449. var data = resolveTransition(vnode.data.transition);
  53450. if (isUndef(data) || el.nodeType !== 1) {
  53451. return rm()
  53452. }
  53453. /* istanbul ignore if */
  53454. if (isDef(el._leaveCb)) {
  53455. return
  53456. }
  53457. var css = data.css;
  53458. var type = data.type;
  53459. var leaveClass = data.leaveClass;
  53460. var leaveToClass = data.leaveToClass;
  53461. var leaveActiveClass = data.leaveActiveClass;
  53462. var beforeLeave = data.beforeLeave;
  53463. var leave = data.leave;
  53464. var afterLeave = data.afterLeave;
  53465. var leaveCancelled = data.leaveCancelled;
  53466. var delayLeave = data.delayLeave;
  53467. var duration = data.duration;
  53468. var expectsCSS = css !== false && !isIE9;
  53469. var userWantsControl = getHookArgumentsLength(leave);
  53470. var explicitLeaveDuration = toNumber(
  53471. isObject(duration)
  53472. ? duration.leave
  53473. : duration
  53474. );
  53475. if (isDef(explicitLeaveDuration)) {
  53476. checkDuration(explicitLeaveDuration, 'leave', vnode);
  53477. }
  53478. var cb = el._leaveCb = once(function () {
  53479. if (el.parentNode && el.parentNode._pending) {
  53480. el.parentNode._pending[vnode.key] = null;
  53481. }
  53482. if (expectsCSS) {
  53483. removeTransitionClass(el, leaveToClass);
  53484. removeTransitionClass(el, leaveActiveClass);
  53485. }
  53486. if (cb.cancelled) {
  53487. if (expectsCSS) {
  53488. removeTransitionClass(el, leaveClass);
  53489. }
  53490. leaveCancelled && leaveCancelled(el);
  53491. } else {
  53492. rm();
  53493. afterLeave && afterLeave(el);
  53494. }
  53495. el._leaveCb = null;
  53496. });
  53497. if (delayLeave) {
  53498. delayLeave(performLeave);
  53499. } else {
  53500. performLeave();
  53501. }
  53502. function performLeave () {
  53503. // the delayed leave may have already been cancelled
  53504. if (cb.cancelled) {
  53505. return
  53506. }
  53507. // record leaving element
  53508. if (!vnode.data.show && el.parentNode) {
  53509. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  53510. }
  53511. beforeLeave && beforeLeave(el);
  53512. if (expectsCSS) {
  53513. addTransitionClass(el, leaveClass);
  53514. addTransitionClass(el, leaveActiveClass);
  53515. nextFrame(function () {
  53516. removeTransitionClass(el, leaveClass);
  53517. if (!cb.cancelled) {
  53518. addTransitionClass(el, leaveToClass);
  53519. if (!userWantsControl) {
  53520. if (isValidDuration(explicitLeaveDuration)) {
  53521. setTimeout(cb, explicitLeaveDuration);
  53522. } else {
  53523. whenTransitionEnds(el, type, cb);
  53524. }
  53525. }
  53526. }
  53527. });
  53528. }
  53529. leave && leave(el, cb);
  53530. if (!expectsCSS && !userWantsControl) {
  53531. cb();
  53532. }
  53533. }
  53534. }
  53535. // only used in dev mode
  53536. function checkDuration (val, name, vnode) {
  53537. if (typeof val !== 'number') {
  53538. warn(
  53539. "<transition> explicit " + name + " duration is not a valid number - " +
  53540. "got " + (JSON.stringify(val)) + ".",
  53541. vnode.context
  53542. );
  53543. } else if (isNaN(val)) {
  53544. warn(
  53545. "<transition> explicit " + name + " duration is NaN - " +
  53546. 'the duration expression might be incorrect.',
  53547. vnode.context
  53548. );
  53549. }
  53550. }
  53551. function isValidDuration (val) {
  53552. return typeof val === 'number' && !isNaN(val)
  53553. }
  53554. /**
  53555. * Normalize a transition hook's argument length. The hook may be:
  53556. * - a merged hook (invoker) with the original in .fns
  53557. * - a wrapped component method (check ._length)
  53558. * - a plain function (.length)
  53559. */
  53560. function getHookArgumentsLength (fn) {
  53561. if (isUndef(fn)) {
  53562. return false
  53563. }
  53564. var invokerFns = fn.fns;
  53565. if (isDef(invokerFns)) {
  53566. // invoker
  53567. return getHookArgumentsLength(
  53568. Array.isArray(invokerFns)
  53569. ? invokerFns[0]
  53570. : invokerFns
  53571. )
  53572. } else {
  53573. return (fn._length || fn.length) > 1
  53574. }
  53575. }
  53576. function _enter (_, vnode) {
  53577. if (vnode.data.show !== true) {
  53578. enter(vnode);
  53579. }
  53580. }
  53581. var transition = inBrowser ? {
  53582. create: _enter,
  53583. activate: _enter,
  53584. remove: function remove$$1 (vnode, rm) {
  53585. /* istanbul ignore else */
  53586. if (vnode.data.show !== true) {
  53587. leave(vnode, rm);
  53588. } else {
  53589. rm();
  53590. }
  53591. }
  53592. } : {};
  53593. var platformModules = [
  53594. attrs,
  53595. klass,
  53596. events,
  53597. domProps,
  53598. style,
  53599. transition
  53600. ];
  53601. /* */
  53602. // the directive module should be applied last, after all
  53603. // built-in modules have been applied.
  53604. var modules = platformModules.concat(baseModules);
  53605. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  53606. /**
  53607. * Not type checking this file because flow doesn't like attaching
  53608. * properties to Elements.
  53609. */
  53610. /* istanbul ignore if */
  53611. if (isIE9) {
  53612. // http://www.matts411.com/post/internet-explorer-9-oninput/
  53613. document.addEventListener('selectionchange', function () {
  53614. var el = document.activeElement;
  53615. if (el && el.vmodel) {
  53616. trigger(el, 'input');
  53617. }
  53618. });
  53619. }
  53620. var directive = {
  53621. inserted: function inserted (el, binding, vnode, oldVnode) {
  53622. if (vnode.tag === 'select') {
  53623. // #6903
  53624. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  53625. mergeVNodeHook(vnode, 'postpatch', function () {
  53626. directive.componentUpdated(el, binding, vnode);
  53627. });
  53628. } else {
  53629. setSelected(el, binding, vnode.context);
  53630. }
  53631. el._vOptions = [].map.call(el.options, getValue);
  53632. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  53633. el._vModifiers = binding.modifiers;
  53634. if (!binding.modifiers.lazy) {
  53635. el.addEventListener('compositionstart', onCompositionStart);
  53636. el.addEventListener('compositionend', onCompositionEnd);
  53637. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  53638. // switching focus before confirming composition choice
  53639. // this also fixes the issue where some browsers e.g. iOS Chrome
  53640. // fires "change" instead of "input" on autocomplete.
  53641. el.addEventListener('change', onCompositionEnd);
  53642. /* istanbul ignore if */
  53643. if (isIE9) {
  53644. el.vmodel = true;
  53645. }
  53646. }
  53647. }
  53648. },
  53649. componentUpdated: function componentUpdated (el, binding, vnode) {
  53650. if (vnode.tag === 'select') {
  53651. setSelected(el, binding, vnode.context);
  53652. // in case the options rendered by v-for have changed,
  53653. // it's possible that the value is out-of-sync with the rendered options.
  53654. // detect such cases and filter out values that no longer has a matching
  53655. // option in the DOM.
  53656. var prevOptions = el._vOptions;
  53657. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  53658. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  53659. // trigger change event if
  53660. // no matching option found for at least one value
  53661. var needReset = el.multiple
  53662. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  53663. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  53664. if (needReset) {
  53665. trigger(el, 'change');
  53666. }
  53667. }
  53668. }
  53669. }
  53670. };
  53671. function setSelected (el, binding, vm) {
  53672. actuallySetSelected(el, binding, vm);
  53673. /* istanbul ignore if */
  53674. if (isIE || isEdge) {
  53675. setTimeout(function () {
  53676. actuallySetSelected(el, binding, vm);
  53677. }, 0);
  53678. }
  53679. }
  53680. function actuallySetSelected (el, binding, vm) {
  53681. var value = binding.value;
  53682. var isMultiple = el.multiple;
  53683. if (isMultiple && !Array.isArray(value)) {
  53684. warn(
  53685. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  53686. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  53687. vm
  53688. );
  53689. return
  53690. }
  53691. var selected, option;
  53692. for (var i = 0, l = el.options.length; i < l; i++) {
  53693. option = el.options[i];
  53694. if (isMultiple) {
  53695. selected = looseIndexOf(value, getValue(option)) > -1;
  53696. if (option.selected !== selected) {
  53697. option.selected = selected;
  53698. }
  53699. } else {
  53700. if (looseEqual(getValue(option), value)) {
  53701. if (el.selectedIndex !== i) {
  53702. el.selectedIndex = i;
  53703. }
  53704. return
  53705. }
  53706. }
  53707. }
  53708. if (!isMultiple) {
  53709. el.selectedIndex = -1;
  53710. }
  53711. }
  53712. function hasNoMatchingOption (value, options) {
  53713. return options.every(function (o) { return !looseEqual(o, value); })
  53714. }
  53715. function getValue (option) {
  53716. return '_value' in option
  53717. ? option._value
  53718. : option.value
  53719. }
  53720. function onCompositionStart (e) {
  53721. e.target.composing = true;
  53722. }
  53723. function onCompositionEnd (e) {
  53724. // prevent triggering an input event for no reason
  53725. if (!e.target.composing) { return }
  53726. e.target.composing = false;
  53727. trigger(e.target, 'input');
  53728. }
  53729. function trigger (el, type) {
  53730. var e = document.createEvent('HTMLEvents');
  53731. e.initEvent(type, true, true);
  53732. el.dispatchEvent(e);
  53733. }
  53734. /* */
  53735. // recursively search for possible transition defined inside the component root
  53736. function locateNode (vnode) {
  53737. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  53738. ? locateNode(vnode.componentInstance._vnode)
  53739. : vnode
  53740. }
  53741. var show = {
  53742. bind: function bind (el, ref, vnode) {
  53743. var value = ref.value;
  53744. vnode = locateNode(vnode);
  53745. var transition$$1 = vnode.data && vnode.data.transition;
  53746. var originalDisplay = el.__vOriginalDisplay =
  53747. el.style.display === 'none' ? '' : el.style.display;
  53748. if (value && transition$$1) {
  53749. vnode.data.show = true;
  53750. enter(vnode, function () {
  53751. el.style.display = originalDisplay;
  53752. });
  53753. } else {
  53754. el.style.display = value ? originalDisplay : 'none';
  53755. }
  53756. },
  53757. update: function update (el, ref, vnode) {
  53758. var value = ref.value;
  53759. var oldValue = ref.oldValue;
  53760. /* istanbul ignore if */
  53761. if (!value === !oldValue) { return }
  53762. vnode = locateNode(vnode);
  53763. var transition$$1 = vnode.data && vnode.data.transition;
  53764. if (transition$$1) {
  53765. vnode.data.show = true;
  53766. if (value) {
  53767. enter(vnode, function () {
  53768. el.style.display = el.__vOriginalDisplay;
  53769. });
  53770. } else {
  53771. leave(vnode, function () {
  53772. el.style.display = 'none';
  53773. });
  53774. }
  53775. } else {
  53776. el.style.display = value ? el.__vOriginalDisplay : 'none';
  53777. }
  53778. },
  53779. unbind: function unbind (
  53780. el,
  53781. binding,
  53782. vnode,
  53783. oldVnode,
  53784. isDestroy
  53785. ) {
  53786. if (!isDestroy) {
  53787. el.style.display = el.__vOriginalDisplay;
  53788. }
  53789. }
  53790. };
  53791. var platformDirectives = {
  53792. model: directive,
  53793. show: show
  53794. };
  53795. /* */
  53796. var transitionProps = {
  53797. name: String,
  53798. appear: Boolean,
  53799. css: Boolean,
  53800. mode: String,
  53801. type: String,
  53802. enterClass: String,
  53803. leaveClass: String,
  53804. enterToClass: String,
  53805. leaveToClass: String,
  53806. enterActiveClass: String,
  53807. leaveActiveClass: String,
  53808. appearClass: String,
  53809. appearActiveClass: String,
  53810. appearToClass: String,
  53811. duration: [Number, String, Object]
  53812. };
  53813. // in case the child is also an abstract component, e.g. <keep-alive>
  53814. // we want to recursively retrieve the real component to be rendered
  53815. function getRealChild (vnode) {
  53816. var compOptions = vnode && vnode.componentOptions;
  53817. if (compOptions && compOptions.Ctor.options.abstract) {
  53818. return getRealChild(getFirstComponentChild(compOptions.children))
  53819. } else {
  53820. return vnode
  53821. }
  53822. }
  53823. function extractTransitionData (comp) {
  53824. var data = {};
  53825. var options = comp.$options;
  53826. // props
  53827. for (var key in options.propsData) {
  53828. data[key] = comp[key];
  53829. }
  53830. // events.
  53831. // extract listeners and pass them directly to the transition methods
  53832. var listeners = options._parentListeners;
  53833. for (var key$1 in listeners) {
  53834. data[camelize(key$1)] = listeners[key$1];
  53835. }
  53836. return data
  53837. }
  53838. function placeholder (h, rawChild) {
  53839. if (/\d-keep-alive$/.test(rawChild.tag)) {
  53840. return h('keep-alive', {
  53841. props: rawChild.componentOptions.propsData
  53842. })
  53843. }
  53844. }
  53845. function hasParentTransition (vnode) {
  53846. while ((vnode = vnode.parent)) {
  53847. if (vnode.data.transition) {
  53848. return true
  53849. }
  53850. }
  53851. }
  53852. function isSameChild (child, oldChild) {
  53853. return oldChild.key === child.key && oldChild.tag === child.tag
  53854. }
  53855. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  53856. var isVShowDirective = function (d) { return d.name === 'show'; };
  53857. var Transition = {
  53858. name: 'transition',
  53859. props: transitionProps,
  53860. abstract: true,
  53861. render: function render (h) {
  53862. var this$1 = this;
  53863. var children = this.$slots.default;
  53864. if (!children) {
  53865. return
  53866. }
  53867. // filter out text nodes (possible whitespaces)
  53868. children = children.filter(isNotTextNode);
  53869. /* istanbul ignore if */
  53870. if (!children.length) {
  53871. return
  53872. }
  53873. // warn multiple elements
  53874. if (children.length > 1) {
  53875. warn(
  53876. '<transition> can only be used on a single element. Use ' +
  53877. '<transition-group> for lists.',
  53878. this.$parent
  53879. );
  53880. }
  53881. var mode = this.mode;
  53882. // warn invalid mode
  53883. if (mode && mode !== 'in-out' && mode !== 'out-in'
  53884. ) {
  53885. warn(
  53886. 'invalid <transition> mode: ' + mode,
  53887. this.$parent
  53888. );
  53889. }
  53890. var rawChild = children[0];
  53891. // if this is a component root node and the component's
  53892. // parent container node also has transition, skip.
  53893. if (hasParentTransition(this.$vnode)) {
  53894. return rawChild
  53895. }
  53896. // apply transition data to child
  53897. // use getRealChild() to ignore abstract components e.g. keep-alive
  53898. var child = getRealChild(rawChild);
  53899. /* istanbul ignore if */
  53900. if (!child) {
  53901. return rawChild
  53902. }
  53903. if (this._leaving) {
  53904. return placeholder(h, rawChild)
  53905. }
  53906. // ensure a key that is unique to the vnode type and to this transition
  53907. // component instance. This key will be used to remove pending leaving nodes
  53908. // during entering.
  53909. var id = "__transition-" + (this._uid) + "-";
  53910. child.key = child.key == null
  53911. ? child.isComment
  53912. ? id + 'comment'
  53913. : id + child.tag
  53914. : isPrimitive(child.key)
  53915. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  53916. : child.key;
  53917. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  53918. var oldRawChild = this._vnode;
  53919. var oldChild = getRealChild(oldRawChild);
  53920. // mark v-show
  53921. // so that the transition module can hand over the control to the directive
  53922. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  53923. child.data.show = true;
  53924. }
  53925. if (
  53926. oldChild &&
  53927. oldChild.data &&
  53928. !isSameChild(child, oldChild) &&
  53929. !isAsyncPlaceholder(oldChild) &&
  53930. // #6687 component root is a comment node
  53931. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  53932. ) {
  53933. // replace old child transition data with fresh one
  53934. // important for dynamic transitions!
  53935. var oldData = oldChild.data.transition = extend({}, data);
  53936. // handle transition mode
  53937. if (mode === 'out-in') {
  53938. // return placeholder node and queue update when leave finishes
  53939. this._leaving = true;
  53940. mergeVNodeHook(oldData, 'afterLeave', function () {
  53941. this$1._leaving = false;
  53942. this$1.$forceUpdate();
  53943. });
  53944. return placeholder(h, rawChild)
  53945. } else if (mode === 'in-out') {
  53946. if (isAsyncPlaceholder(child)) {
  53947. return oldRawChild
  53948. }
  53949. var delayedLeave;
  53950. var performLeave = function () { delayedLeave(); };
  53951. mergeVNodeHook(data, 'afterEnter', performLeave);
  53952. mergeVNodeHook(data, 'enterCancelled', performLeave);
  53953. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  53954. }
  53955. }
  53956. return rawChild
  53957. }
  53958. };
  53959. /* */
  53960. var props = extend({
  53961. tag: String,
  53962. moveClass: String
  53963. }, transitionProps);
  53964. delete props.mode;
  53965. var TransitionGroup = {
  53966. props: props,
  53967. beforeMount: function beforeMount () {
  53968. var this$1 = this;
  53969. var update = this._update;
  53970. this._update = function (vnode, hydrating) {
  53971. var restoreActiveInstance = setActiveInstance(this$1);
  53972. // force removing pass
  53973. this$1.__patch__(
  53974. this$1._vnode,
  53975. this$1.kept,
  53976. false, // hydrating
  53977. true // removeOnly (!important, avoids unnecessary moves)
  53978. );
  53979. this$1._vnode = this$1.kept;
  53980. restoreActiveInstance();
  53981. update.call(this$1, vnode, hydrating);
  53982. };
  53983. },
  53984. render: function render (h) {
  53985. var tag = this.tag || this.$vnode.data.tag || 'span';
  53986. var map = Object.create(null);
  53987. var prevChildren = this.prevChildren = this.children;
  53988. var rawChildren = this.$slots.default || [];
  53989. var children = this.children = [];
  53990. var transitionData = extractTransitionData(this);
  53991. for (var i = 0; i < rawChildren.length; i++) {
  53992. var c = rawChildren[i];
  53993. if (c.tag) {
  53994. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  53995. children.push(c);
  53996. map[c.key] = c
  53997. ;(c.data || (c.data = {})).transition = transitionData;
  53998. } else {
  53999. var opts = c.componentOptions;
  54000. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  54001. warn(("<transition-group> children must be keyed: <" + name + ">"));
  54002. }
  54003. }
  54004. }
  54005. if (prevChildren) {
  54006. var kept = [];
  54007. var removed = [];
  54008. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  54009. var c$1 = prevChildren[i$1];
  54010. c$1.data.transition = transitionData;
  54011. c$1.data.pos = c$1.elm.getBoundingClientRect();
  54012. if (map[c$1.key]) {
  54013. kept.push(c$1);
  54014. } else {
  54015. removed.push(c$1);
  54016. }
  54017. }
  54018. this.kept = h(tag, null, kept);
  54019. this.removed = removed;
  54020. }
  54021. return h(tag, null, children)
  54022. },
  54023. updated: function updated () {
  54024. var children = this.prevChildren;
  54025. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  54026. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  54027. return
  54028. }
  54029. // we divide the work into three loops to avoid mixing DOM reads and writes
  54030. // in each iteration - which helps prevent layout thrashing.
  54031. children.forEach(callPendingCbs);
  54032. children.forEach(recordPosition);
  54033. children.forEach(applyTranslation);
  54034. // force reflow to put everything in position
  54035. // assign to this to avoid being removed in tree-shaking
  54036. // $flow-disable-line
  54037. this._reflow = document.body.offsetHeight;
  54038. children.forEach(function (c) {
  54039. if (c.data.moved) {
  54040. var el = c.elm;
  54041. var s = el.style;
  54042. addTransitionClass(el, moveClass);
  54043. s.transform = s.WebkitTransform = s.transitionDuration = '';
  54044. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  54045. if (e && e.target !== el) {
  54046. return
  54047. }
  54048. if (!e || /transform$/.test(e.propertyName)) {
  54049. el.removeEventListener(transitionEndEvent, cb);
  54050. el._moveCb = null;
  54051. removeTransitionClass(el, moveClass);
  54052. }
  54053. });
  54054. }
  54055. });
  54056. },
  54057. methods: {
  54058. hasMove: function hasMove (el, moveClass) {
  54059. /* istanbul ignore if */
  54060. if (!hasTransition) {
  54061. return false
  54062. }
  54063. /* istanbul ignore if */
  54064. if (this._hasMove) {
  54065. return this._hasMove
  54066. }
  54067. // Detect whether an element with the move class applied has
  54068. // CSS transitions. Since the element may be inside an entering
  54069. // transition at this very moment, we make a clone of it and remove
  54070. // all other transition classes applied to ensure only the move class
  54071. // is applied.
  54072. var clone = el.cloneNode();
  54073. if (el._transitionClasses) {
  54074. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  54075. }
  54076. addClass(clone, moveClass);
  54077. clone.style.display = 'none';
  54078. this.$el.appendChild(clone);
  54079. var info = getTransitionInfo(clone);
  54080. this.$el.removeChild(clone);
  54081. return (this._hasMove = info.hasTransform)
  54082. }
  54083. }
  54084. };
  54085. function callPendingCbs (c) {
  54086. /* istanbul ignore if */
  54087. if (c.elm._moveCb) {
  54088. c.elm._moveCb();
  54089. }
  54090. /* istanbul ignore if */
  54091. if (c.elm._enterCb) {
  54092. c.elm._enterCb();
  54093. }
  54094. }
  54095. function recordPosition (c) {
  54096. c.data.newPos = c.elm.getBoundingClientRect();
  54097. }
  54098. function applyTranslation (c) {
  54099. var oldPos = c.data.pos;
  54100. var newPos = c.data.newPos;
  54101. var dx = oldPos.left - newPos.left;
  54102. var dy = oldPos.top - newPos.top;
  54103. if (dx || dy) {
  54104. c.data.moved = true;
  54105. var s = c.elm.style;
  54106. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  54107. s.transitionDuration = '0s';
  54108. }
  54109. }
  54110. var platformComponents = {
  54111. Transition: Transition,
  54112. TransitionGroup: TransitionGroup
  54113. };
  54114. /* */
  54115. // install platform specific utils
  54116. Vue.config.mustUseProp = mustUseProp;
  54117. Vue.config.isReservedTag = isReservedTag;
  54118. Vue.config.isReservedAttr = isReservedAttr;
  54119. Vue.config.getTagNamespace = getTagNamespace;
  54120. Vue.config.isUnknownElement = isUnknownElement;
  54121. // install platform runtime directives & components
  54122. extend(Vue.options.directives, platformDirectives);
  54123. extend(Vue.options.components, platformComponents);
  54124. // install platform patch function
  54125. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  54126. // public mount method
  54127. Vue.prototype.$mount = function (
  54128. el,
  54129. hydrating
  54130. ) {
  54131. el = el && inBrowser ? query(el) : undefined;
  54132. return mountComponent(this, el, hydrating)
  54133. };
  54134. // devtools global hook
  54135. /* istanbul ignore next */
  54136. if (inBrowser) {
  54137. setTimeout(function () {
  54138. if (config.devtools) {
  54139. if (devtools) {
  54140. devtools.emit('init', Vue);
  54141. } else {
  54142. console[console.info ? 'info' : 'log'](
  54143. 'Download the Vue Devtools extension for a better development experience:\n' +
  54144. 'https://github.com/vuejs/vue-devtools'
  54145. );
  54146. }
  54147. }
  54148. if (config.productionTip !== false &&
  54149. typeof console !== 'undefined'
  54150. ) {
  54151. console[console.info ? 'info' : 'log'](
  54152. "You are running Vue in development mode.\n" +
  54153. "Make sure to turn on production mode when deploying for production.\n" +
  54154. "See more tips at https://vuejs.org/guide/deployment.html"
  54155. );
  54156. }
  54157. }, 0);
  54158. }
  54159. /* */
  54160. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  54161. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  54162. var buildRegex = cached(function (delimiters) {
  54163. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  54164. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  54165. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  54166. });
  54167. function parseText (
  54168. text,
  54169. delimiters
  54170. ) {
  54171. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  54172. if (!tagRE.test(text)) {
  54173. return
  54174. }
  54175. var tokens = [];
  54176. var rawTokens = [];
  54177. var lastIndex = tagRE.lastIndex = 0;
  54178. var match, index, tokenValue;
  54179. while ((match = tagRE.exec(text))) {
  54180. index = match.index;
  54181. // push text token
  54182. if (index > lastIndex) {
  54183. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  54184. tokens.push(JSON.stringify(tokenValue));
  54185. }
  54186. // tag token
  54187. var exp = parseFilters(match[1].trim());
  54188. tokens.push(("_s(" + exp + ")"));
  54189. rawTokens.push({ '@binding': exp });
  54190. lastIndex = index + match[0].length;
  54191. }
  54192. if (lastIndex < text.length) {
  54193. rawTokens.push(tokenValue = text.slice(lastIndex));
  54194. tokens.push(JSON.stringify(tokenValue));
  54195. }
  54196. return {
  54197. expression: tokens.join('+'),
  54198. tokens: rawTokens
  54199. }
  54200. }
  54201. /* */
  54202. function transformNode (el, options) {
  54203. var warn = options.warn || baseWarn;
  54204. var staticClass = getAndRemoveAttr(el, 'class');
  54205. if (staticClass) {
  54206. var res = parseText(staticClass, options.delimiters);
  54207. if (res) {
  54208. warn(
  54209. "class=\"" + staticClass + "\": " +
  54210. 'Interpolation inside attributes has been removed. ' +
  54211. 'Use v-bind or the colon shorthand instead. For example, ' +
  54212. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  54213. el.rawAttrsMap['class']
  54214. );
  54215. }
  54216. }
  54217. if (staticClass) {
  54218. el.staticClass = JSON.stringify(staticClass);
  54219. }
  54220. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  54221. if (classBinding) {
  54222. el.classBinding = classBinding;
  54223. }
  54224. }
  54225. function genData (el) {
  54226. var data = '';
  54227. if (el.staticClass) {
  54228. data += "staticClass:" + (el.staticClass) + ",";
  54229. }
  54230. if (el.classBinding) {
  54231. data += "class:" + (el.classBinding) + ",";
  54232. }
  54233. return data
  54234. }
  54235. var klass$1 = {
  54236. staticKeys: ['staticClass'],
  54237. transformNode: transformNode,
  54238. genData: genData
  54239. };
  54240. /* */
  54241. function transformNode$1 (el, options) {
  54242. var warn = options.warn || baseWarn;
  54243. var staticStyle = getAndRemoveAttr(el, 'style');
  54244. if (staticStyle) {
  54245. /* istanbul ignore if */
  54246. {
  54247. var res = parseText(staticStyle, options.delimiters);
  54248. if (res) {
  54249. warn(
  54250. "style=\"" + staticStyle + "\": " +
  54251. 'Interpolation inside attributes has been removed. ' +
  54252. 'Use v-bind or the colon shorthand instead. For example, ' +
  54253. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  54254. el.rawAttrsMap['style']
  54255. );
  54256. }
  54257. }
  54258. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  54259. }
  54260. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  54261. if (styleBinding) {
  54262. el.styleBinding = styleBinding;
  54263. }
  54264. }
  54265. function genData$1 (el) {
  54266. var data = '';
  54267. if (el.staticStyle) {
  54268. data += "staticStyle:" + (el.staticStyle) + ",";
  54269. }
  54270. if (el.styleBinding) {
  54271. data += "style:(" + (el.styleBinding) + "),";
  54272. }
  54273. return data
  54274. }
  54275. var style$1 = {
  54276. staticKeys: ['staticStyle'],
  54277. transformNode: transformNode$1,
  54278. genData: genData$1
  54279. };
  54280. /* */
  54281. var decoder;
  54282. var he = {
  54283. decode: function decode (html) {
  54284. decoder = decoder || document.createElement('div');
  54285. decoder.innerHTML = html;
  54286. return decoder.textContent
  54287. }
  54288. };
  54289. /* */
  54290. var isUnaryTag = makeMap(
  54291. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  54292. 'link,meta,param,source,track,wbr'
  54293. );
  54294. // Elements that you can, intentionally, leave open
  54295. // (and which close themselves)
  54296. var canBeLeftOpenTag = makeMap(
  54297. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  54298. );
  54299. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  54300. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  54301. var isNonPhrasingTag = makeMap(
  54302. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  54303. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  54304. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  54305. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  54306. 'title,tr,track'
  54307. );
  54308. /**
  54309. * Not type-checking this file because it's mostly vendor code.
  54310. */
  54311. // Regular Expressions for parsing tags and attributes
  54312. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  54313. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  54314. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  54315. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  54316. var startTagOpen = new RegExp(("^<" + qnameCapture));
  54317. var startTagClose = /^\s*(\/?)>/;
  54318. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  54319. var doctype = /^<!DOCTYPE [^>]+>/i;
  54320. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  54321. var comment = /^<!\--/;
  54322. var conditionalComment = /^<!\[/;
  54323. // Special Elements (can contain anything)
  54324. var isPlainTextElement = makeMap('script,style,textarea', true);
  54325. var reCache = {};
  54326. var decodingMap = {
  54327. '&lt;': '<',
  54328. '&gt;': '>',
  54329. '&quot;': '"',
  54330. '&amp;': '&',
  54331. '&#10;': '\n',
  54332. '&#9;': '\t',
  54333. '&#39;': "'"
  54334. };
  54335. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  54336. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  54337. // #5992
  54338. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  54339. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  54340. function decodeAttr (value, shouldDecodeNewlines) {
  54341. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  54342. return value.replace(re, function (match) { return decodingMap[match]; })
  54343. }
  54344. function parseHTML (html, options) {
  54345. var stack = [];
  54346. var expectHTML = options.expectHTML;
  54347. var isUnaryTag$$1 = options.isUnaryTag || no;
  54348. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  54349. var index = 0;
  54350. var last, lastTag;
  54351. while (html) {
  54352. last = html;
  54353. // Make sure we're not in a plaintext content element like script/style
  54354. if (!lastTag || !isPlainTextElement(lastTag)) {
  54355. var textEnd = html.indexOf('<');
  54356. if (textEnd === 0) {
  54357. // Comment:
  54358. if (comment.test(html)) {
  54359. var commentEnd = html.indexOf('-->');
  54360. if (commentEnd >= 0) {
  54361. if (options.shouldKeepComment) {
  54362. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  54363. }
  54364. advance(commentEnd + 3);
  54365. continue
  54366. }
  54367. }
  54368. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  54369. if (conditionalComment.test(html)) {
  54370. var conditionalEnd = html.indexOf(']>');
  54371. if (conditionalEnd >= 0) {
  54372. advance(conditionalEnd + 2);
  54373. continue
  54374. }
  54375. }
  54376. // Doctype:
  54377. var doctypeMatch = html.match(doctype);
  54378. if (doctypeMatch) {
  54379. advance(doctypeMatch[0].length);
  54380. continue
  54381. }
  54382. // End tag:
  54383. var endTagMatch = html.match(endTag);
  54384. if (endTagMatch) {
  54385. var curIndex = index;
  54386. advance(endTagMatch[0].length);
  54387. parseEndTag(endTagMatch[1], curIndex, index);
  54388. continue
  54389. }
  54390. // Start tag:
  54391. var startTagMatch = parseStartTag();
  54392. if (startTagMatch) {
  54393. handleStartTag(startTagMatch);
  54394. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  54395. advance(1);
  54396. }
  54397. continue
  54398. }
  54399. }
  54400. var text = (void 0), rest = (void 0), next = (void 0);
  54401. if (textEnd >= 0) {
  54402. rest = html.slice(textEnd);
  54403. while (
  54404. !endTag.test(rest) &&
  54405. !startTagOpen.test(rest) &&
  54406. !comment.test(rest) &&
  54407. !conditionalComment.test(rest)
  54408. ) {
  54409. // < in plain text, be forgiving and treat it as text
  54410. next = rest.indexOf('<', 1);
  54411. if (next < 0) { break }
  54412. textEnd += next;
  54413. rest = html.slice(textEnd);
  54414. }
  54415. text = html.substring(0, textEnd);
  54416. }
  54417. if (textEnd < 0) {
  54418. text = html;
  54419. }
  54420. if (text) {
  54421. advance(text.length);
  54422. }
  54423. if (options.chars && text) {
  54424. options.chars(text, index - text.length, index);
  54425. }
  54426. } else {
  54427. var endTagLength = 0;
  54428. var stackedTag = lastTag.toLowerCase();
  54429. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  54430. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  54431. endTagLength = endTag.length;
  54432. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  54433. text = text
  54434. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  54435. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  54436. }
  54437. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  54438. text = text.slice(1);
  54439. }
  54440. if (options.chars) {
  54441. options.chars(text);
  54442. }
  54443. return ''
  54444. });
  54445. index += html.length - rest$1.length;
  54446. html = rest$1;
  54447. parseEndTag(stackedTag, index - endTagLength, index);
  54448. }
  54449. if (html === last) {
  54450. options.chars && options.chars(html);
  54451. if (!stack.length && options.warn) {
  54452. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  54453. }
  54454. break
  54455. }
  54456. }
  54457. // Clean up any remaining tags
  54458. parseEndTag();
  54459. function advance (n) {
  54460. index += n;
  54461. html = html.substring(n);
  54462. }
  54463. function parseStartTag () {
  54464. var start = html.match(startTagOpen);
  54465. if (start) {
  54466. var match = {
  54467. tagName: start[1],
  54468. attrs: [],
  54469. start: index
  54470. };
  54471. advance(start[0].length);
  54472. var end, attr;
  54473. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  54474. attr.start = index;
  54475. advance(attr[0].length);
  54476. attr.end = index;
  54477. match.attrs.push(attr);
  54478. }
  54479. if (end) {
  54480. match.unarySlash = end[1];
  54481. advance(end[0].length);
  54482. match.end = index;
  54483. return match
  54484. }
  54485. }
  54486. }
  54487. function handleStartTag (match) {
  54488. var tagName = match.tagName;
  54489. var unarySlash = match.unarySlash;
  54490. if (expectHTML) {
  54491. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  54492. parseEndTag(lastTag);
  54493. }
  54494. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  54495. parseEndTag(tagName);
  54496. }
  54497. }
  54498. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  54499. var l = match.attrs.length;
  54500. var attrs = new Array(l);
  54501. for (var i = 0; i < l; i++) {
  54502. var args = match.attrs[i];
  54503. var value = args[3] || args[4] || args[5] || '';
  54504. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  54505. ? options.shouldDecodeNewlinesForHref
  54506. : options.shouldDecodeNewlines;
  54507. attrs[i] = {
  54508. name: args[1],
  54509. value: decodeAttr(value, shouldDecodeNewlines)
  54510. };
  54511. if (options.outputSourceRange) {
  54512. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  54513. attrs[i].end = args.end;
  54514. }
  54515. }
  54516. if (!unary) {
  54517. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  54518. lastTag = tagName;
  54519. }
  54520. if (options.start) {
  54521. options.start(tagName, attrs, unary, match.start, match.end);
  54522. }
  54523. }
  54524. function parseEndTag (tagName, start, end) {
  54525. var pos, lowerCasedTagName;
  54526. if (start == null) { start = index; }
  54527. if (end == null) { end = index; }
  54528. // Find the closest opened tag of the same type
  54529. if (tagName) {
  54530. lowerCasedTagName = tagName.toLowerCase();
  54531. for (pos = stack.length - 1; pos >= 0; pos--) {
  54532. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  54533. break
  54534. }
  54535. }
  54536. } else {
  54537. // If no tag name is provided, clean shop
  54538. pos = 0;
  54539. }
  54540. if (pos >= 0) {
  54541. // Close all the open elements, up the stack
  54542. for (var i = stack.length - 1; i >= pos; i--) {
  54543. if (i > pos || !tagName &&
  54544. options.warn
  54545. ) {
  54546. options.warn(
  54547. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  54548. { start: stack[i].start, end: stack[i].end }
  54549. );
  54550. }
  54551. if (options.end) {
  54552. options.end(stack[i].tag, start, end);
  54553. }
  54554. }
  54555. // Remove the open elements from the stack
  54556. stack.length = pos;
  54557. lastTag = pos && stack[pos - 1].tag;
  54558. } else if (lowerCasedTagName === 'br') {
  54559. if (options.start) {
  54560. options.start(tagName, [], true, start, end);
  54561. }
  54562. } else if (lowerCasedTagName === 'p') {
  54563. if (options.start) {
  54564. options.start(tagName, [], false, start, end);
  54565. }
  54566. if (options.end) {
  54567. options.end(tagName, start, end);
  54568. }
  54569. }
  54570. }
  54571. }
  54572. /* */
  54573. var onRE = /^@|^v-on:/;
  54574. var dirRE = /^v-|^@|^:|^#/;
  54575. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  54576. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  54577. var stripParensRE = /^\(|\)$/g;
  54578. var dynamicArgRE = /^\[.*\]$/;
  54579. var argRE = /:(.*)$/;
  54580. var bindRE = /^:|^\.|^v-bind:/;
  54581. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  54582. var slotRE = /^v-slot(:|$)|^#/;
  54583. var lineBreakRE = /[\r\n]/;
  54584. var whitespaceRE$1 = /\s+/g;
  54585. var invalidAttributeRE = /[\s"'<>\/=]/;
  54586. var decodeHTMLCached = cached(he.decode);
  54587. var emptySlotScopeToken = "_empty_";
  54588. // configurable state
  54589. var warn$2;
  54590. var delimiters;
  54591. var transforms;
  54592. var preTransforms;
  54593. var postTransforms;
  54594. var platformIsPreTag;
  54595. var platformMustUseProp;
  54596. var platformGetTagNamespace;
  54597. var maybeComponent;
  54598. function createASTElement (
  54599. tag,
  54600. attrs,
  54601. parent
  54602. ) {
  54603. return {
  54604. type: 1,
  54605. tag: tag,
  54606. attrsList: attrs,
  54607. attrsMap: makeAttrsMap(attrs),
  54608. rawAttrsMap: {},
  54609. parent: parent,
  54610. children: []
  54611. }
  54612. }
  54613. /**
  54614. * Convert HTML string to AST.
  54615. */
  54616. function parse (
  54617. template,
  54618. options
  54619. ) {
  54620. warn$2 = options.warn || baseWarn;
  54621. platformIsPreTag = options.isPreTag || no;
  54622. platformMustUseProp = options.mustUseProp || no;
  54623. platformGetTagNamespace = options.getTagNamespace || no;
  54624. var isReservedTag = options.isReservedTag || no;
  54625. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  54626. transforms = pluckModuleFunction(options.modules, 'transformNode');
  54627. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  54628. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  54629. delimiters = options.delimiters;
  54630. var stack = [];
  54631. var preserveWhitespace = options.preserveWhitespace !== false;
  54632. var whitespaceOption = options.whitespace;
  54633. var root;
  54634. var currentParent;
  54635. var inVPre = false;
  54636. var inPre = false;
  54637. var warned = false;
  54638. function warnOnce (msg, range) {
  54639. if (!warned) {
  54640. warned = true;
  54641. warn$2(msg, range);
  54642. }
  54643. }
  54644. function closeElement (element) {
  54645. trimEndingWhitespace(element);
  54646. if (!inVPre && !element.processed) {
  54647. element = processElement(element, options);
  54648. }
  54649. // tree management
  54650. if (!stack.length && element !== root) {
  54651. // allow root elements with v-if, v-else-if and v-else
  54652. if (root.if && (element.elseif || element.else)) {
  54653. {
  54654. checkRootConstraints(element);
  54655. }
  54656. addIfCondition(root, {
  54657. exp: element.elseif,
  54658. block: element
  54659. });
  54660. } else {
  54661. warnOnce(
  54662. "Component template should contain exactly one root element. " +
  54663. "If you are using v-if on multiple elements, " +
  54664. "use v-else-if to chain them instead.",
  54665. { start: element.start }
  54666. );
  54667. }
  54668. }
  54669. if (currentParent && !element.forbidden) {
  54670. if (element.elseif || element.else) {
  54671. processIfConditions(element, currentParent);
  54672. } else {
  54673. if (element.slotScope) {
  54674. // scoped slot
  54675. // keep it in the children list so that v-else(-if) conditions can
  54676. // find it as the prev node.
  54677. var name = element.slotTarget || '"default"'
  54678. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  54679. }
  54680. currentParent.children.push(element);
  54681. element.parent = currentParent;
  54682. }
  54683. }
  54684. // final children cleanup
  54685. // filter out scoped slots
  54686. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  54687. // remove trailing whitespace node again
  54688. trimEndingWhitespace(element);
  54689. // check pre state
  54690. if (element.pre) {
  54691. inVPre = false;
  54692. }
  54693. if (platformIsPreTag(element.tag)) {
  54694. inPre = false;
  54695. }
  54696. // apply post-transforms
  54697. for (var i = 0; i < postTransforms.length; i++) {
  54698. postTransforms[i](element, options);
  54699. }
  54700. }
  54701. function trimEndingWhitespace (el) {
  54702. // remove trailing whitespace node
  54703. if (!inPre) {
  54704. var lastNode;
  54705. while (
  54706. (lastNode = el.children[el.children.length - 1]) &&
  54707. lastNode.type === 3 &&
  54708. lastNode.text === ' '
  54709. ) {
  54710. el.children.pop();
  54711. }
  54712. }
  54713. }
  54714. function checkRootConstraints (el) {
  54715. if (el.tag === 'slot' || el.tag === 'template') {
  54716. warnOnce(
  54717. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  54718. 'contain multiple nodes.',
  54719. { start: el.start }
  54720. );
  54721. }
  54722. if (el.attrsMap.hasOwnProperty('v-for')) {
  54723. warnOnce(
  54724. 'Cannot use v-for on stateful component root element because ' +
  54725. 'it renders multiple elements.',
  54726. el.rawAttrsMap['v-for']
  54727. );
  54728. }
  54729. }
  54730. parseHTML(template, {
  54731. warn: warn$2,
  54732. expectHTML: options.expectHTML,
  54733. isUnaryTag: options.isUnaryTag,
  54734. canBeLeftOpenTag: options.canBeLeftOpenTag,
  54735. shouldDecodeNewlines: options.shouldDecodeNewlines,
  54736. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  54737. shouldKeepComment: options.comments,
  54738. outputSourceRange: options.outputSourceRange,
  54739. start: function start (tag, attrs, unary, start$1, end) {
  54740. // check namespace.
  54741. // inherit parent ns if there is one
  54742. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  54743. // handle IE svg bug
  54744. /* istanbul ignore if */
  54745. if (isIE && ns === 'svg') {
  54746. attrs = guardIESVGBug(attrs);
  54747. }
  54748. var element = createASTElement(tag, attrs, currentParent);
  54749. if (ns) {
  54750. element.ns = ns;
  54751. }
  54752. {
  54753. if (options.outputSourceRange) {
  54754. element.start = start$1;
  54755. element.end = end;
  54756. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  54757. cumulated[attr.name] = attr;
  54758. return cumulated
  54759. }, {});
  54760. }
  54761. attrs.forEach(function (attr) {
  54762. if (invalidAttributeRE.test(attr.name)) {
  54763. warn$2(
  54764. "Invalid dynamic argument expression: attribute names cannot contain " +
  54765. "spaces, quotes, <, >, / or =.",
  54766. {
  54767. start: attr.start + attr.name.indexOf("["),
  54768. end: attr.start + attr.name.length
  54769. }
  54770. );
  54771. }
  54772. });
  54773. }
  54774. if (isForbiddenTag(element) && !isServerRendering()) {
  54775. element.forbidden = true;
  54776. warn$2(
  54777. 'Templates should only be responsible for mapping the state to the ' +
  54778. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  54779. "<" + tag + ">" + ', as they will not be parsed.',
  54780. { start: element.start }
  54781. );
  54782. }
  54783. // apply pre-transforms
  54784. for (var i = 0; i < preTransforms.length; i++) {
  54785. element = preTransforms[i](element, options) || element;
  54786. }
  54787. if (!inVPre) {
  54788. processPre(element);
  54789. if (element.pre) {
  54790. inVPre = true;
  54791. }
  54792. }
  54793. if (platformIsPreTag(element.tag)) {
  54794. inPre = true;
  54795. }
  54796. if (inVPre) {
  54797. processRawAttrs(element);
  54798. } else if (!element.processed) {
  54799. // structural directives
  54800. processFor(element);
  54801. processIf(element);
  54802. processOnce(element);
  54803. }
  54804. if (!root) {
  54805. root = element;
  54806. {
  54807. checkRootConstraints(root);
  54808. }
  54809. }
  54810. if (!unary) {
  54811. currentParent = element;
  54812. stack.push(element);
  54813. } else {
  54814. closeElement(element);
  54815. }
  54816. },
  54817. end: function end (tag, start, end$1) {
  54818. var element = stack[stack.length - 1];
  54819. // pop stack
  54820. stack.length -= 1;
  54821. currentParent = stack[stack.length - 1];
  54822. if (options.outputSourceRange) {
  54823. element.end = end$1;
  54824. }
  54825. closeElement(element);
  54826. },
  54827. chars: function chars (text, start, end) {
  54828. if (!currentParent) {
  54829. {
  54830. if (text === template) {
  54831. warnOnce(
  54832. 'Component template requires a root element, rather than just text.',
  54833. { start: start }
  54834. );
  54835. } else if ((text = text.trim())) {
  54836. warnOnce(
  54837. ("text \"" + text + "\" outside root element will be ignored."),
  54838. { start: start }
  54839. );
  54840. }
  54841. }
  54842. return
  54843. }
  54844. // IE textarea placeholder bug
  54845. /* istanbul ignore if */
  54846. if (isIE &&
  54847. currentParent.tag === 'textarea' &&
  54848. currentParent.attrsMap.placeholder === text
  54849. ) {
  54850. return
  54851. }
  54852. var children = currentParent.children;
  54853. if (inPre || text.trim()) {
  54854. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  54855. } else if (!children.length) {
  54856. // remove the whitespace-only node right after an opening tag
  54857. text = '';
  54858. } else if (whitespaceOption) {
  54859. if (whitespaceOption === 'condense') {
  54860. // in condense mode, remove the whitespace node if it contains
  54861. // line break, otherwise condense to a single space
  54862. text = lineBreakRE.test(text) ? '' : ' ';
  54863. } else {
  54864. text = ' ';
  54865. }
  54866. } else {
  54867. text = preserveWhitespace ? ' ' : '';
  54868. }
  54869. if (text) {
  54870. if (!inPre && whitespaceOption === 'condense') {
  54871. // condense consecutive whitespaces into single space
  54872. text = text.replace(whitespaceRE$1, ' ');
  54873. }
  54874. var res;
  54875. var child;
  54876. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  54877. child = {
  54878. type: 2,
  54879. expression: res.expression,
  54880. tokens: res.tokens,
  54881. text: text
  54882. };
  54883. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  54884. child = {
  54885. type: 3,
  54886. text: text
  54887. };
  54888. }
  54889. if (child) {
  54890. if (options.outputSourceRange) {
  54891. child.start = start;
  54892. child.end = end;
  54893. }
  54894. children.push(child);
  54895. }
  54896. }
  54897. },
  54898. comment: function comment (text, start, end) {
  54899. // adding anyting as a sibling to the root node is forbidden
  54900. // comments should still be allowed, but ignored
  54901. if (currentParent) {
  54902. var child = {
  54903. type: 3,
  54904. text: text,
  54905. isComment: true
  54906. };
  54907. if (options.outputSourceRange) {
  54908. child.start = start;
  54909. child.end = end;
  54910. }
  54911. currentParent.children.push(child);
  54912. }
  54913. }
  54914. });
  54915. return root
  54916. }
  54917. function processPre (el) {
  54918. if (getAndRemoveAttr(el, 'v-pre') != null) {
  54919. el.pre = true;
  54920. }
  54921. }
  54922. function processRawAttrs (el) {
  54923. var list = el.attrsList;
  54924. var len = list.length;
  54925. if (len) {
  54926. var attrs = el.attrs = new Array(len);
  54927. for (var i = 0; i < len; i++) {
  54928. attrs[i] = {
  54929. name: list[i].name,
  54930. value: JSON.stringify(list[i].value)
  54931. };
  54932. if (list[i].start != null) {
  54933. attrs[i].start = list[i].start;
  54934. attrs[i].end = list[i].end;
  54935. }
  54936. }
  54937. } else if (!el.pre) {
  54938. // non root node in pre blocks with no attributes
  54939. el.plain = true;
  54940. }
  54941. }
  54942. function processElement (
  54943. element,
  54944. options
  54945. ) {
  54946. processKey(element);
  54947. // determine whether this is a plain element after
  54948. // removing structural attributes
  54949. element.plain = (
  54950. !element.key &&
  54951. !element.scopedSlots &&
  54952. !element.attrsList.length
  54953. );
  54954. processRef(element);
  54955. processSlotContent(element);
  54956. processSlotOutlet(element);
  54957. processComponent(element);
  54958. for (var i = 0; i < transforms.length; i++) {
  54959. element = transforms[i](element, options) || element;
  54960. }
  54961. processAttrs(element);
  54962. return element
  54963. }
  54964. function processKey (el) {
  54965. var exp = getBindingAttr(el, 'key');
  54966. if (exp) {
  54967. {
  54968. if (el.tag === 'template') {
  54969. warn$2(
  54970. "<template> cannot be keyed. Place the key on real elements instead.",
  54971. getRawBindingAttr(el, 'key')
  54972. );
  54973. }
  54974. if (el.for) {
  54975. var iterator = el.iterator2 || el.iterator1;
  54976. var parent = el.parent;
  54977. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  54978. warn$2(
  54979. "Do not use v-for index as key on <transition-group> children, " +
  54980. "this is the same as not using keys.",
  54981. getRawBindingAttr(el, 'key'),
  54982. true /* tip */
  54983. );
  54984. }
  54985. }
  54986. }
  54987. el.key = exp;
  54988. }
  54989. }
  54990. function processRef (el) {
  54991. var ref = getBindingAttr(el, 'ref');
  54992. if (ref) {
  54993. el.ref = ref;
  54994. el.refInFor = checkInFor(el);
  54995. }
  54996. }
  54997. function processFor (el) {
  54998. var exp;
  54999. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  55000. var res = parseFor(exp);
  55001. if (res) {
  55002. extend(el, res);
  55003. } else {
  55004. warn$2(
  55005. ("Invalid v-for expression: " + exp),
  55006. el.rawAttrsMap['v-for']
  55007. );
  55008. }
  55009. }
  55010. }
  55011. function parseFor (exp) {
  55012. var inMatch = exp.match(forAliasRE);
  55013. if (!inMatch) { return }
  55014. var res = {};
  55015. res.for = inMatch[2].trim();
  55016. var alias = inMatch[1].trim().replace(stripParensRE, '');
  55017. var iteratorMatch = alias.match(forIteratorRE);
  55018. if (iteratorMatch) {
  55019. res.alias = alias.replace(forIteratorRE, '').trim();
  55020. res.iterator1 = iteratorMatch[1].trim();
  55021. if (iteratorMatch[2]) {
  55022. res.iterator2 = iteratorMatch[2].trim();
  55023. }
  55024. } else {
  55025. res.alias = alias;
  55026. }
  55027. return res
  55028. }
  55029. function processIf (el) {
  55030. var exp = getAndRemoveAttr(el, 'v-if');
  55031. if (exp) {
  55032. el.if = exp;
  55033. addIfCondition(el, {
  55034. exp: exp,
  55035. block: el
  55036. });
  55037. } else {
  55038. if (getAndRemoveAttr(el, 'v-else') != null) {
  55039. el.else = true;
  55040. }
  55041. var elseif = getAndRemoveAttr(el, 'v-else-if');
  55042. if (elseif) {
  55043. el.elseif = elseif;
  55044. }
  55045. }
  55046. }
  55047. function processIfConditions (el, parent) {
  55048. var prev = findPrevElement(parent.children);
  55049. if (prev && prev.if) {
  55050. addIfCondition(prev, {
  55051. exp: el.elseif,
  55052. block: el
  55053. });
  55054. } else {
  55055. warn$2(
  55056. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  55057. "used on element <" + (el.tag) + "> without corresponding v-if.",
  55058. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  55059. );
  55060. }
  55061. }
  55062. function findPrevElement (children) {
  55063. var i = children.length;
  55064. while (i--) {
  55065. if (children[i].type === 1) {
  55066. return children[i]
  55067. } else {
  55068. if (children[i].text !== ' ') {
  55069. warn$2(
  55070. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  55071. "will be ignored.",
  55072. children[i]
  55073. );
  55074. }
  55075. children.pop();
  55076. }
  55077. }
  55078. }
  55079. function addIfCondition (el, condition) {
  55080. if (!el.ifConditions) {
  55081. el.ifConditions = [];
  55082. }
  55083. el.ifConditions.push(condition);
  55084. }
  55085. function processOnce (el) {
  55086. var once$$1 = getAndRemoveAttr(el, 'v-once');
  55087. if (once$$1 != null) {
  55088. el.once = true;
  55089. }
  55090. }
  55091. // handle content being passed to a component as slot,
  55092. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  55093. function processSlotContent (el) {
  55094. var slotScope;
  55095. if (el.tag === 'template') {
  55096. slotScope = getAndRemoveAttr(el, 'scope');
  55097. /* istanbul ignore if */
  55098. if (slotScope) {
  55099. warn$2(
  55100. "the \"scope\" attribute for scoped slots have been deprecated and " +
  55101. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  55102. "can also be used on plain elements in addition to <template> to " +
  55103. "denote scoped slots.",
  55104. el.rawAttrsMap['scope'],
  55105. true
  55106. );
  55107. }
  55108. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  55109. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  55110. /* istanbul ignore if */
  55111. if (el.attrsMap['v-for']) {
  55112. warn$2(
  55113. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  55114. "(v-for takes higher priority). Use a wrapper <template> for the " +
  55115. "scoped slot to make it clearer.",
  55116. el.rawAttrsMap['slot-scope'],
  55117. true
  55118. );
  55119. }
  55120. el.slotScope = slotScope;
  55121. }
  55122. // slot="xxx"
  55123. var slotTarget = getBindingAttr(el, 'slot');
  55124. if (slotTarget) {
  55125. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  55126. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  55127. // preserve slot as an attribute for native shadow DOM compat
  55128. // only for non-scoped slots.
  55129. if (el.tag !== 'template' && !el.slotScope) {
  55130. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  55131. }
  55132. }
  55133. // 2.6 v-slot syntax
  55134. {
  55135. if (el.tag === 'template') {
  55136. // v-slot on <template>
  55137. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  55138. if (slotBinding) {
  55139. {
  55140. if (el.slotTarget || el.slotScope) {
  55141. warn$2(
  55142. "Unexpected mixed usage of different slot syntaxes.",
  55143. el
  55144. );
  55145. }
  55146. if (el.parent && !maybeComponent(el.parent)) {
  55147. warn$2(
  55148. "<template v-slot> can only appear at the root level inside " +
  55149. "the receiving component",
  55150. el
  55151. );
  55152. }
  55153. }
  55154. var ref = getSlotName(slotBinding);
  55155. var name = ref.name;
  55156. var dynamic = ref.dynamic;
  55157. el.slotTarget = name;
  55158. el.slotTargetDynamic = dynamic;
  55159. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  55160. }
  55161. } else {
  55162. // v-slot on component, denotes default slot
  55163. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  55164. if (slotBinding$1) {
  55165. {
  55166. if (!maybeComponent(el)) {
  55167. warn$2(
  55168. "v-slot can only be used on components or <template>.",
  55169. slotBinding$1
  55170. );
  55171. }
  55172. if (el.slotScope || el.slotTarget) {
  55173. warn$2(
  55174. "Unexpected mixed usage of different slot syntaxes.",
  55175. el
  55176. );
  55177. }
  55178. if (el.scopedSlots) {
  55179. warn$2(
  55180. "To avoid scope ambiguity, the default slot should also use " +
  55181. "<template> syntax when there are other named slots.",
  55182. slotBinding$1
  55183. );
  55184. }
  55185. }
  55186. // add the component's children to its default slot
  55187. var slots = el.scopedSlots || (el.scopedSlots = {});
  55188. var ref$1 = getSlotName(slotBinding$1);
  55189. var name$1 = ref$1.name;
  55190. var dynamic$1 = ref$1.dynamic;
  55191. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  55192. slotContainer.slotTarget = name$1;
  55193. slotContainer.slotTargetDynamic = dynamic$1;
  55194. slotContainer.children = el.children.filter(function (c) {
  55195. if (!c.slotScope) {
  55196. c.parent = slotContainer;
  55197. return true
  55198. }
  55199. });
  55200. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  55201. // remove children as they are returned from scopedSlots now
  55202. el.children = [];
  55203. // mark el non-plain so data gets generated
  55204. el.plain = false;
  55205. }
  55206. }
  55207. }
  55208. }
  55209. function getSlotName (binding) {
  55210. var name = binding.name.replace(slotRE, '');
  55211. if (!name) {
  55212. if (binding.name[0] !== '#') {
  55213. name = 'default';
  55214. } else {
  55215. warn$2(
  55216. "v-slot shorthand syntax requires a slot name.",
  55217. binding
  55218. );
  55219. }
  55220. }
  55221. return dynamicArgRE.test(name)
  55222. // dynamic [name]
  55223. ? { name: name.slice(1, -1), dynamic: true }
  55224. // static name
  55225. : { name: ("\"" + name + "\""), dynamic: false }
  55226. }
  55227. // handle <slot/> outlets
  55228. function processSlotOutlet (el) {
  55229. if (el.tag === 'slot') {
  55230. el.slotName = getBindingAttr(el, 'name');
  55231. if (el.key) {
  55232. warn$2(
  55233. "`key` does not work on <slot> because slots are abstract outlets " +
  55234. "and can possibly expand into multiple elements. " +
  55235. "Use the key on a wrapping element instead.",
  55236. getRawBindingAttr(el, 'key')
  55237. );
  55238. }
  55239. }
  55240. }
  55241. function processComponent (el) {
  55242. var binding;
  55243. if ((binding = getBindingAttr(el, 'is'))) {
  55244. el.component = binding;
  55245. }
  55246. if (getAndRemoveAttr(el, 'inline-template') != null) {
  55247. el.inlineTemplate = true;
  55248. }
  55249. }
  55250. function processAttrs (el) {
  55251. var list = el.attrsList;
  55252. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  55253. for (i = 0, l = list.length; i < l; i++) {
  55254. name = rawName = list[i].name;
  55255. value = list[i].value;
  55256. if (dirRE.test(name)) {
  55257. // mark element as dynamic
  55258. el.hasBindings = true;
  55259. // modifiers
  55260. modifiers = parseModifiers(name.replace(dirRE, ''));
  55261. // support .foo shorthand syntax for the .prop modifier
  55262. if (modifiers) {
  55263. name = name.replace(modifierRE, '');
  55264. }
  55265. if (bindRE.test(name)) { // v-bind
  55266. name = name.replace(bindRE, '');
  55267. value = parseFilters(value);
  55268. isDynamic = dynamicArgRE.test(name);
  55269. if (isDynamic) {
  55270. name = name.slice(1, -1);
  55271. }
  55272. if (
  55273. value.trim().length === 0
  55274. ) {
  55275. warn$2(
  55276. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  55277. );
  55278. }
  55279. if (modifiers) {
  55280. if (modifiers.prop && !isDynamic) {
  55281. name = camelize(name);
  55282. if (name === 'innerHtml') { name = 'innerHTML'; }
  55283. }
  55284. if (modifiers.camel && !isDynamic) {
  55285. name = camelize(name);
  55286. }
  55287. if (modifiers.sync) {
  55288. syncGen = genAssignmentCode(value, "$event");
  55289. if (!isDynamic) {
  55290. addHandler(
  55291. el,
  55292. ("update:" + (camelize(name))),
  55293. syncGen,
  55294. null,
  55295. false,
  55296. warn$2,
  55297. list[i]
  55298. );
  55299. if (hyphenate(name) !== camelize(name)) {
  55300. addHandler(
  55301. el,
  55302. ("update:" + (hyphenate(name))),
  55303. syncGen,
  55304. null,
  55305. false,
  55306. warn$2,
  55307. list[i]
  55308. );
  55309. }
  55310. } else {
  55311. // handler w/ dynamic event name
  55312. addHandler(
  55313. el,
  55314. ("\"update:\"+(" + name + ")"),
  55315. syncGen,
  55316. null,
  55317. false,
  55318. warn$2,
  55319. list[i],
  55320. true // dynamic
  55321. );
  55322. }
  55323. }
  55324. }
  55325. if ((modifiers && modifiers.prop) || (
  55326. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  55327. )) {
  55328. addProp(el, name, value, list[i], isDynamic);
  55329. } else {
  55330. addAttr(el, name, value, list[i], isDynamic);
  55331. }
  55332. } else if (onRE.test(name)) { // v-on
  55333. name = name.replace(onRE, '');
  55334. isDynamic = dynamicArgRE.test(name);
  55335. if (isDynamic) {
  55336. name = name.slice(1, -1);
  55337. }
  55338. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  55339. } else { // normal directives
  55340. name = name.replace(dirRE, '');
  55341. // parse arg
  55342. var argMatch = name.match(argRE);
  55343. var arg = argMatch && argMatch[1];
  55344. isDynamic = false;
  55345. if (arg) {
  55346. name = name.slice(0, -(arg.length + 1));
  55347. if (dynamicArgRE.test(arg)) {
  55348. arg = arg.slice(1, -1);
  55349. isDynamic = true;
  55350. }
  55351. }
  55352. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  55353. if (name === 'model') {
  55354. checkForAliasModel(el, value);
  55355. }
  55356. }
  55357. } else {
  55358. // literal attribute
  55359. {
  55360. var res = parseText(value, delimiters);
  55361. if (res) {
  55362. warn$2(
  55363. name + "=\"" + value + "\": " +
  55364. 'Interpolation inside attributes has been removed. ' +
  55365. 'Use v-bind or the colon shorthand instead. For example, ' +
  55366. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  55367. list[i]
  55368. );
  55369. }
  55370. }
  55371. addAttr(el, name, JSON.stringify(value), list[i]);
  55372. // #6887 firefox doesn't update muted state if set via attribute
  55373. // even immediately after element creation
  55374. if (!el.component &&
  55375. name === 'muted' &&
  55376. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  55377. addProp(el, name, 'true', list[i]);
  55378. }
  55379. }
  55380. }
  55381. }
  55382. function checkInFor (el) {
  55383. var parent = el;
  55384. while (parent) {
  55385. if (parent.for !== undefined) {
  55386. return true
  55387. }
  55388. parent = parent.parent;
  55389. }
  55390. return false
  55391. }
  55392. function parseModifiers (name) {
  55393. var match = name.match(modifierRE);
  55394. if (match) {
  55395. var ret = {};
  55396. match.forEach(function (m) { ret[m.slice(1)] = true; });
  55397. return ret
  55398. }
  55399. }
  55400. function makeAttrsMap (attrs) {
  55401. var map = {};
  55402. for (var i = 0, l = attrs.length; i < l; i++) {
  55403. if (
  55404. map[attrs[i].name] && !isIE && !isEdge
  55405. ) {
  55406. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  55407. }
  55408. map[attrs[i].name] = attrs[i].value;
  55409. }
  55410. return map
  55411. }
  55412. // for script (e.g. type="x/template") or style, do not decode content
  55413. function isTextTag (el) {
  55414. return el.tag === 'script' || el.tag === 'style'
  55415. }
  55416. function isForbiddenTag (el) {
  55417. return (
  55418. el.tag === 'style' ||
  55419. (el.tag === 'script' && (
  55420. !el.attrsMap.type ||
  55421. el.attrsMap.type === 'text/javascript'
  55422. ))
  55423. )
  55424. }
  55425. var ieNSBug = /^xmlns:NS\d+/;
  55426. var ieNSPrefix = /^NS\d+:/;
  55427. /* istanbul ignore next */
  55428. function guardIESVGBug (attrs) {
  55429. var res = [];
  55430. for (var i = 0; i < attrs.length; i++) {
  55431. var attr = attrs[i];
  55432. if (!ieNSBug.test(attr.name)) {
  55433. attr.name = attr.name.replace(ieNSPrefix, '');
  55434. res.push(attr);
  55435. }
  55436. }
  55437. return res
  55438. }
  55439. function checkForAliasModel (el, value) {
  55440. var _el = el;
  55441. while (_el) {
  55442. if (_el.for && _el.alias === value) {
  55443. warn$2(
  55444. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  55445. "You are binding v-model directly to a v-for iteration alias. " +
  55446. "This will not be able to modify the v-for source array because " +
  55447. "writing to the alias is like modifying a function local variable. " +
  55448. "Consider using an array of objects and use v-model on an object property instead.",
  55449. el.rawAttrsMap['v-model']
  55450. );
  55451. }
  55452. _el = _el.parent;
  55453. }
  55454. }
  55455. /* */
  55456. function preTransformNode (el, options) {
  55457. if (el.tag === 'input') {
  55458. var map = el.attrsMap;
  55459. if (!map['v-model']) {
  55460. return
  55461. }
  55462. var typeBinding;
  55463. if (map[':type'] || map['v-bind:type']) {
  55464. typeBinding = getBindingAttr(el, 'type');
  55465. }
  55466. if (!map.type && !typeBinding && map['v-bind']) {
  55467. typeBinding = "(" + (map['v-bind']) + ").type";
  55468. }
  55469. if (typeBinding) {
  55470. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  55471. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  55472. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  55473. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  55474. // 1. checkbox
  55475. var branch0 = cloneASTElement(el);
  55476. // process for on the main node
  55477. processFor(branch0);
  55478. addRawAttr(branch0, 'type', 'checkbox');
  55479. processElement(branch0, options);
  55480. branch0.processed = true; // prevent it from double-processed
  55481. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  55482. addIfCondition(branch0, {
  55483. exp: branch0.if,
  55484. block: branch0
  55485. });
  55486. // 2. add radio else-if condition
  55487. var branch1 = cloneASTElement(el);
  55488. getAndRemoveAttr(branch1, 'v-for', true);
  55489. addRawAttr(branch1, 'type', 'radio');
  55490. processElement(branch1, options);
  55491. addIfCondition(branch0, {
  55492. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  55493. block: branch1
  55494. });
  55495. // 3. other
  55496. var branch2 = cloneASTElement(el);
  55497. getAndRemoveAttr(branch2, 'v-for', true);
  55498. addRawAttr(branch2, ':type', typeBinding);
  55499. processElement(branch2, options);
  55500. addIfCondition(branch0, {
  55501. exp: ifCondition,
  55502. block: branch2
  55503. });
  55504. if (hasElse) {
  55505. branch0.else = true;
  55506. } else if (elseIfCondition) {
  55507. branch0.elseif = elseIfCondition;
  55508. }
  55509. return branch0
  55510. }
  55511. }
  55512. }
  55513. function cloneASTElement (el) {
  55514. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  55515. }
  55516. var model$1 = {
  55517. preTransformNode: preTransformNode
  55518. };
  55519. var modules$1 = [
  55520. klass$1,
  55521. style$1,
  55522. model$1
  55523. ];
  55524. /* */
  55525. function text (el, dir) {
  55526. if (dir.value) {
  55527. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  55528. }
  55529. }
  55530. /* */
  55531. function html (el, dir) {
  55532. if (dir.value) {
  55533. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  55534. }
  55535. }
  55536. var directives$1 = {
  55537. model: model,
  55538. text: text,
  55539. html: html
  55540. };
  55541. /* */
  55542. var baseOptions = {
  55543. expectHTML: true,
  55544. modules: modules$1,
  55545. directives: directives$1,
  55546. isPreTag: isPreTag,
  55547. isUnaryTag: isUnaryTag,
  55548. mustUseProp: mustUseProp,
  55549. canBeLeftOpenTag: canBeLeftOpenTag,
  55550. isReservedTag: isReservedTag,
  55551. getTagNamespace: getTagNamespace,
  55552. staticKeys: genStaticKeys(modules$1)
  55553. };
  55554. /* */
  55555. var isStaticKey;
  55556. var isPlatformReservedTag;
  55557. var genStaticKeysCached = cached(genStaticKeys$1);
  55558. /**
  55559. * Goal of the optimizer: walk the generated template AST tree
  55560. * and detect sub-trees that are purely static, i.e. parts of
  55561. * the DOM that never needs to change.
  55562. *
  55563. * Once we detect these sub-trees, we can:
  55564. *
  55565. * 1. Hoist them into constants, so that we no longer need to
  55566. * create fresh nodes for them on each re-render;
  55567. * 2. Completely skip them in the patching process.
  55568. */
  55569. function optimize (root, options) {
  55570. if (!root) { return }
  55571. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  55572. isPlatformReservedTag = options.isReservedTag || no;
  55573. // first pass: mark all non-static nodes.
  55574. markStatic$1(root);
  55575. // second pass: mark static roots.
  55576. markStaticRoots(root, false);
  55577. }
  55578. function genStaticKeys$1 (keys) {
  55579. return makeMap(
  55580. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  55581. (keys ? ',' + keys : '')
  55582. )
  55583. }
  55584. function markStatic$1 (node) {
  55585. node.static = isStatic(node);
  55586. if (node.type === 1) {
  55587. // do not make component slot content static. this avoids
  55588. // 1. components not able to mutate slot nodes
  55589. // 2. static slot content fails for hot-reloading
  55590. if (
  55591. !isPlatformReservedTag(node.tag) &&
  55592. node.tag !== 'slot' &&
  55593. node.attrsMap['inline-template'] == null
  55594. ) {
  55595. return
  55596. }
  55597. for (var i = 0, l = node.children.length; i < l; i++) {
  55598. var child = node.children[i];
  55599. markStatic$1(child);
  55600. if (!child.static) {
  55601. node.static = false;
  55602. }
  55603. }
  55604. if (node.ifConditions) {
  55605. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  55606. var block = node.ifConditions[i$1].block;
  55607. markStatic$1(block);
  55608. if (!block.static) {
  55609. node.static = false;
  55610. }
  55611. }
  55612. }
  55613. }
  55614. }
  55615. function markStaticRoots (node, isInFor) {
  55616. if (node.type === 1) {
  55617. if (node.static || node.once) {
  55618. node.staticInFor = isInFor;
  55619. }
  55620. // For a node to qualify as a static root, it should have children that
  55621. // are not just static text. Otherwise the cost of hoisting out will
  55622. // outweigh the benefits and it's better off to just always render it fresh.
  55623. if (node.static && node.children.length && !(
  55624. node.children.length === 1 &&
  55625. node.children[0].type === 3
  55626. )) {
  55627. node.staticRoot = true;
  55628. return
  55629. } else {
  55630. node.staticRoot = false;
  55631. }
  55632. if (node.children) {
  55633. for (var i = 0, l = node.children.length; i < l; i++) {
  55634. markStaticRoots(node.children[i], isInFor || !!node.for);
  55635. }
  55636. }
  55637. if (node.ifConditions) {
  55638. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  55639. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  55640. }
  55641. }
  55642. }
  55643. }
  55644. function isStatic (node) {
  55645. if (node.type === 2) { // expression
  55646. return false
  55647. }
  55648. if (node.type === 3) { // text
  55649. return true
  55650. }
  55651. return !!(node.pre || (
  55652. !node.hasBindings && // no dynamic bindings
  55653. !node.if && !node.for && // not v-if or v-for or v-else
  55654. !isBuiltInTag(node.tag) && // not a built-in
  55655. isPlatformReservedTag(node.tag) && // not a component
  55656. !isDirectChildOfTemplateFor(node) &&
  55657. Object.keys(node).every(isStaticKey)
  55658. ))
  55659. }
  55660. function isDirectChildOfTemplateFor (node) {
  55661. while (node.parent) {
  55662. node = node.parent;
  55663. if (node.tag !== 'template') {
  55664. return false
  55665. }
  55666. if (node.for) {
  55667. return true
  55668. }
  55669. }
  55670. return false
  55671. }
  55672. /* */
  55673. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  55674. var fnInvokeRE = /\([^)]*?\);*$/;
  55675. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  55676. // KeyboardEvent.keyCode aliases
  55677. var keyCodes = {
  55678. esc: 27,
  55679. tab: 9,
  55680. enter: 13,
  55681. space: 32,
  55682. up: 38,
  55683. left: 37,
  55684. right: 39,
  55685. down: 40,
  55686. 'delete': [8, 46]
  55687. };
  55688. // KeyboardEvent.key aliases
  55689. var keyNames = {
  55690. // #7880: IE11 and Edge use `Esc` for Escape key name.
  55691. esc: ['Esc', 'Escape'],
  55692. tab: 'Tab',
  55693. enter: 'Enter',
  55694. // #9112: IE11 uses `Spacebar` for Space key name.
  55695. space: [' ', 'Spacebar'],
  55696. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  55697. up: ['Up', 'ArrowUp'],
  55698. left: ['Left', 'ArrowLeft'],
  55699. right: ['Right', 'ArrowRight'],
  55700. down: ['Down', 'ArrowDown'],
  55701. // #9112: IE11 uses `Del` for Delete key name.
  55702. 'delete': ['Backspace', 'Delete', 'Del']
  55703. };
  55704. // #4868: modifiers that prevent the execution of the listener
  55705. // need to explicitly return null so that we can determine whether to remove
  55706. // the listener for .once
  55707. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  55708. var modifierCode = {
  55709. stop: '$event.stopPropagation();',
  55710. prevent: '$event.preventDefault();',
  55711. self: genGuard("$event.target !== $event.currentTarget"),
  55712. ctrl: genGuard("!$event.ctrlKey"),
  55713. shift: genGuard("!$event.shiftKey"),
  55714. alt: genGuard("!$event.altKey"),
  55715. meta: genGuard("!$event.metaKey"),
  55716. left: genGuard("'button' in $event && $event.button !== 0"),
  55717. middle: genGuard("'button' in $event && $event.button !== 1"),
  55718. right: genGuard("'button' in $event && $event.button !== 2")
  55719. };
  55720. function genHandlers (
  55721. events,
  55722. isNative
  55723. ) {
  55724. var prefix = isNative ? 'nativeOn:' : 'on:';
  55725. var staticHandlers = "";
  55726. var dynamicHandlers = "";
  55727. for (var name in events) {
  55728. var handlerCode = genHandler(events[name]);
  55729. if (events[name] && events[name].dynamic) {
  55730. dynamicHandlers += name + "," + handlerCode + ",";
  55731. } else {
  55732. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  55733. }
  55734. }
  55735. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  55736. if (dynamicHandlers) {
  55737. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  55738. } else {
  55739. return prefix + staticHandlers
  55740. }
  55741. }
  55742. function genHandler (handler) {
  55743. if (!handler) {
  55744. return 'function(){}'
  55745. }
  55746. if (Array.isArray(handler)) {
  55747. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  55748. }
  55749. var isMethodPath = simplePathRE.test(handler.value);
  55750. var isFunctionExpression = fnExpRE.test(handler.value);
  55751. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  55752. if (!handler.modifiers) {
  55753. if (isMethodPath || isFunctionExpression) {
  55754. return handler.value
  55755. }
  55756. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  55757. } else {
  55758. var code = '';
  55759. var genModifierCode = '';
  55760. var keys = [];
  55761. for (var key in handler.modifiers) {
  55762. if (modifierCode[key]) {
  55763. genModifierCode += modifierCode[key];
  55764. // left/right
  55765. if (keyCodes[key]) {
  55766. keys.push(key);
  55767. }
  55768. } else if (key === 'exact') {
  55769. var modifiers = (handler.modifiers);
  55770. genModifierCode += genGuard(
  55771. ['ctrl', 'shift', 'alt', 'meta']
  55772. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  55773. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  55774. .join('||')
  55775. );
  55776. } else {
  55777. keys.push(key);
  55778. }
  55779. }
  55780. if (keys.length) {
  55781. code += genKeyFilter(keys);
  55782. }
  55783. // Make sure modifiers like prevent and stop get executed after key filtering
  55784. if (genModifierCode) {
  55785. code += genModifierCode;
  55786. }
  55787. var handlerCode = isMethodPath
  55788. ? ("return " + (handler.value) + "($event)")
  55789. : isFunctionExpression
  55790. ? ("return (" + (handler.value) + ")($event)")
  55791. : isFunctionInvocation
  55792. ? ("return " + (handler.value))
  55793. : handler.value;
  55794. return ("function($event){" + code + handlerCode + "}")
  55795. }
  55796. }
  55797. function genKeyFilter (keys) {
  55798. return (
  55799. // make sure the key filters only apply to KeyboardEvents
  55800. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  55801. // key events that do not have keyCode property...
  55802. "if(!$event.type.indexOf('key')&&" +
  55803. (keys.map(genFilterCode).join('&&')) + ")return null;"
  55804. )
  55805. }
  55806. function genFilterCode (key) {
  55807. var keyVal = parseInt(key, 10);
  55808. if (keyVal) {
  55809. return ("$event.keyCode!==" + keyVal)
  55810. }
  55811. var keyCode = keyCodes[key];
  55812. var keyName = keyNames[key];
  55813. return (
  55814. "_k($event.keyCode," +
  55815. (JSON.stringify(key)) + "," +
  55816. (JSON.stringify(keyCode)) + "," +
  55817. "$event.key," +
  55818. "" + (JSON.stringify(keyName)) +
  55819. ")"
  55820. )
  55821. }
  55822. /* */
  55823. function on (el, dir) {
  55824. if (dir.modifiers) {
  55825. warn("v-on without argument does not support modifiers.");
  55826. }
  55827. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  55828. }
  55829. /* */
  55830. function bind$1 (el, dir) {
  55831. el.wrapData = function (code) {
  55832. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  55833. };
  55834. }
  55835. /* */
  55836. var baseDirectives = {
  55837. on: on,
  55838. bind: bind$1,
  55839. cloak: noop
  55840. };
  55841. /* */
  55842. var CodegenState = function CodegenState (options) {
  55843. this.options = options;
  55844. this.warn = options.warn || baseWarn;
  55845. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  55846. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  55847. this.directives = extend(extend({}, baseDirectives), options.directives);
  55848. var isReservedTag = options.isReservedTag || no;
  55849. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  55850. this.onceId = 0;
  55851. this.staticRenderFns = [];
  55852. this.pre = false;
  55853. };
  55854. function generate (
  55855. ast,
  55856. options
  55857. ) {
  55858. var state = new CodegenState(options);
  55859. var code = ast ? genElement(ast, state) : '_c("div")';
  55860. return {
  55861. render: ("with(this){return " + code + "}"),
  55862. staticRenderFns: state.staticRenderFns
  55863. }
  55864. }
  55865. function genElement (el, state) {
  55866. if (el.parent) {
  55867. el.pre = el.pre || el.parent.pre;
  55868. }
  55869. if (el.staticRoot && !el.staticProcessed) {
  55870. return genStatic(el, state)
  55871. } else if (el.once && !el.onceProcessed) {
  55872. return genOnce(el, state)
  55873. } else if (el.for && !el.forProcessed) {
  55874. return genFor(el, state)
  55875. } else if (el.if && !el.ifProcessed) {
  55876. return genIf(el, state)
  55877. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  55878. return genChildren(el, state) || 'void 0'
  55879. } else if (el.tag === 'slot') {
  55880. return genSlot(el, state)
  55881. } else {
  55882. // component or element
  55883. var code;
  55884. if (el.component) {
  55885. code = genComponent(el.component, el, state);
  55886. } else {
  55887. var data;
  55888. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  55889. data = genData$2(el, state);
  55890. }
  55891. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  55892. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  55893. }
  55894. // module transforms
  55895. for (var i = 0; i < state.transforms.length; i++) {
  55896. code = state.transforms[i](el, code);
  55897. }
  55898. return code
  55899. }
  55900. }
  55901. // hoist static sub-trees out
  55902. function genStatic (el, state) {
  55903. el.staticProcessed = true;
  55904. // Some elements (templates) need to behave differently inside of a v-pre
  55905. // node. All pre nodes are static roots, so we can use this as a location to
  55906. // wrap a state change and reset it upon exiting the pre node.
  55907. var originalPreState = state.pre;
  55908. if (el.pre) {
  55909. state.pre = el.pre;
  55910. }
  55911. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  55912. state.pre = originalPreState;
  55913. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  55914. }
  55915. // v-once
  55916. function genOnce (el, state) {
  55917. el.onceProcessed = true;
  55918. if (el.if && !el.ifProcessed) {
  55919. return genIf(el, state)
  55920. } else if (el.staticInFor) {
  55921. var key = '';
  55922. var parent = el.parent;
  55923. while (parent) {
  55924. if (parent.for) {
  55925. key = parent.key;
  55926. break
  55927. }
  55928. parent = parent.parent;
  55929. }
  55930. if (!key) {
  55931. state.warn(
  55932. "v-once can only be used inside v-for that is keyed. ",
  55933. el.rawAttrsMap['v-once']
  55934. );
  55935. return genElement(el, state)
  55936. }
  55937. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  55938. } else {
  55939. return genStatic(el, state)
  55940. }
  55941. }
  55942. function genIf (
  55943. el,
  55944. state,
  55945. altGen,
  55946. altEmpty
  55947. ) {
  55948. el.ifProcessed = true; // avoid recursion
  55949. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  55950. }
  55951. function genIfConditions (
  55952. conditions,
  55953. state,
  55954. altGen,
  55955. altEmpty
  55956. ) {
  55957. if (!conditions.length) {
  55958. return altEmpty || '_e()'
  55959. }
  55960. var condition = conditions.shift();
  55961. if (condition.exp) {
  55962. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  55963. } else {
  55964. return ("" + (genTernaryExp(condition.block)))
  55965. }
  55966. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  55967. function genTernaryExp (el) {
  55968. return altGen
  55969. ? altGen(el, state)
  55970. : el.once
  55971. ? genOnce(el, state)
  55972. : genElement(el, state)
  55973. }
  55974. }
  55975. function genFor (
  55976. el,
  55977. state,
  55978. altGen,
  55979. altHelper
  55980. ) {
  55981. var exp = el.for;
  55982. var alias = el.alias;
  55983. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  55984. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  55985. if (state.maybeComponent(el) &&
  55986. el.tag !== 'slot' &&
  55987. el.tag !== 'template' &&
  55988. !el.key
  55989. ) {
  55990. state.warn(
  55991. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  55992. "v-for should have explicit keys. " +
  55993. "See https://vuejs.org/guide/list.html#key for more info.",
  55994. el.rawAttrsMap['v-for'],
  55995. true /* tip */
  55996. );
  55997. }
  55998. el.forProcessed = true; // avoid recursion
  55999. return (altHelper || '_l') + "((" + exp + ")," +
  56000. "function(" + alias + iterator1 + iterator2 + "){" +
  56001. "return " + ((altGen || genElement)(el, state)) +
  56002. '})'
  56003. }
  56004. function genData$2 (el, state) {
  56005. var data = '{';
  56006. // directives first.
  56007. // directives may mutate the el's other properties before they are generated.
  56008. var dirs = genDirectives(el, state);
  56009. if (dirs) { data += dirs + ','; }
  56010. // key
  56011. if (el.key) {
  56012. data += "key:" + (el.key) + ",";
  56013. }
  56014. // ref
  56015. if (el.ref) {
  56016. data += "ref:" + (el.ref) + ",";
  56017. }
  56018. if (el.refInFor) {
  56019. data += "refInFor:true,";
  56020. }
  56021. // pre
  56022. if (el.pre) {
  56023. data += "pre:true,";
  56024. }
  56025. // record original tag name for components using "is" attribute
  56026. if (el.component) {
  56027. data += "tag:\"" + (el.tag) + "\",";
  56028. }
  56029. // module data generation functions
  56030. for (var i = 0; i < state.dataGenFns.length; i++) {
  56031. data += state.dataGenFns[i](el);
  56032. }
  56033. // attributes
  56034. if (el.attrs) {
  56035. data += "attrs:" + (genProps(el.attrs)) + ",";
  56036. }
  56037. // DOM props
  56038. if (el.props) {
  56039. data += "domProps:" + (genProps(el.props)) + ",";
  56040. }
  56041. // event handlers
  56042. if (el.events) {
  56043. data += (genHandlers(el.events, false)) + ",";
  56044. }
  56045. if (el.nativeEvents) {
  56046. data += (genHandlers(el.nativeEvents, true)) + ",";
  56047. }
  56048. // slot target
  56049. // only for non-scoped slots
  56050. if (el.slotTarget && !el.slotScope) {
  56051. data += "slot:" + (el.slotTarget) + ",";
  56052. }
  56053. // scoped slots
  56054. if (el.scopedSlots) {
  56055. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  56056. }
  56057. // component v-model
  56058. if (el.model) {
  56059. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  56060. }
  56061. // inline-template
  56062. if (el.inlineTemplate) {
  56063. var inlineTemplate = genInlineTemplate(el, state);
  56064. if (inlineTemplate) {
  56065. data += inlineTemplate + ",";
  56066. }
  56067. }
  56068. data = data.replace(/,$/, '') + '}';
  56069. // v-bind dynamic argument wrap
  56070. // v-bind with dynamic arguments must be applied using the same v-bind object
  56071. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  56072. if (el.dynamicAttrs) {
  56073. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  56074. }
  56075. // v-bind data wrap
  56076. if (el.wrapData) {
  56077. data = el.wrapData(data);
  56078. }
  56079. // v-on data wrap
  56080. if (el.wrapListeners) {
  56081. data = el.wrapListeners(data);
  56082. }
  56083. return data
  56084. }
  56085. function genDirectives (el, state) {
  56086. var dirs = el.directives;
  56087. if (!dirs) { return }
  56088. var res = 'directives:[';
  56089. var hasRuntime = false;
  56090. var i, l, dir, needRuntime;
  56091. for (i = 0, l = dirs.length; i < l; i++) {
  56092. dir = dirs[i];
  56093. needRuntime = true;
  56094. var gen = state.directives[dir.name];
  56095. if (gen) {
  56096. // compile-time directive that manipulates AST.
  56097. // returns true if it also needs a runtime counterpart.
  56098. needRuntime = !!gen(el, dir, state.warn);
  56099. }
  56100. if (needRuntime) {
  56101. hasRuntime = true;
  56102. 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))) : '') + "},";
  56103. }
  56104. }
  56105. if (hasRuntime) {
  56106. return res.slice(0, -1) + ']'
  56107. }
  56108. }
  56109. function genInlineTemplate (el, state) {
  56110. var ast = el.children[0];
  56111. if (el.children.length !== 1 || ast.type !== 1) {
  56112. state.warn(
  56113. 'Inline-template components must have exactly one child element.',
  56114. { start: el.start }
  56115. );
  56116. }
  56117. if (ast && ast.type === 1) {
  56118. var inlineRenderFns = generate(ast, state.options);
  56119. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  56120. }
  56121. }
  56122. function genScopedSlots (
  56123. el,
  56124. slots,
  56125. state
  56126. ) {
  56127. // by default scoped slots are considered "stable", this allows child
  56128. // components with only scoped slots to skip forced updates from parent.
  56129. // but in some cases we have to bail-out of this optimization
  56130. // for example if the slot contains dynamic names, has v-if or v-for on them...
  56131. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  56132. var slot = slots[key];
  56133. return (
  56134. slot.slotTargetDynamic ||
  56135. slot.if ||
  56136. slot.for ||
  56137. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  56138. )
  56139. });
  56140. // #9534: if a component with scoped slots is inside a conditional branch,
  56141. // it's possible for the same component to be reused but with different
  56142. // compiled slot content. To avoid that, we generate a unique key based on
  56143. // the generated code of all the slot contents.
  56144. var needsKey = !!el.if;
  56145. // OR when it is inside another scoped slot or v-for (the reactivity may be
  56146. // disconnected due to the intermediate scope variable)
  56147. // #9438, #9506
  56148. // TODO: this can be further optimized by properly analyzing in-scope bindings
  56149. // and skip force updating ones that do not actually use scope variables.
  56150. if (!needsForceUpdate) {
  56151. var parent = el.parent;
  56152. while (parent) {
  56153. if (
  56154. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  56155. parent.for
  56156. ) {
  56157. needsForceUpdate = true;
  56158. break
  56159. }
  56160. if (parent.if) {
  56161. needsKey = true;
  56162. }
  56163. parent = parent.parent;
  56164. }
  56165. }
  56166. var generatedSlots = Object.keys(slots)
  56167. .map(function (key) { return genScopedSlot(slots[key], state); })
  56168. .join(',');
  56169. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  56170. }
  56171. function hash(str) {
  56172. var hash = 5381;
  56173. var i = str.length;
  56174. while(i) {
  56175. hash = (hash * 33) ^ str.charCodeAt(--i);
  56176. }
  56177. return hash >>> 0
  56178. }
  56179. function containsSlotChild (el) {
  56180. if (el.type === 1) {
  56181. if (el.tag === 'slot') {
  56182. return true
  56183. }
  56184. return el.children.some(containsSlotChild)
  56185. }
  56186. return false
  56187. }
  56188. function genScopedSlot (
  56189. el,
  56190. state
  56191. ) {
  56192. var isLegacySyntax = el.attrsMap['slot-scope'];
  56193. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  56194. return genIf(el, state, genScopedSlot, "null")
  56195. }
  56196. if (el.for && !el.forProcessed) {
  56197. return genFor(el, state, genScopedSlot)
  56198. }
  56199. var slotScope = el.slotScope === emptySlotScopeToken
  56200. ? ""
  56201. : String(el.slotScope);
  56202. var fn = "function(" + slotScope + "){" +
  56203. "return " + (el.tag === 'template'
  56204. ? el.if && isLegacySyntax
  56205. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  56206. : genChildren(el, state) || 'undefined'
  56207. : genElement(el, state)) + "}";
  56208. // reverse proxy v-slot without scope on this.$slots
  56209. var reverseProxy = slotScope ? "" : ",proxy:true";
  56210. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  56211. }
  56212. function genChildren (
  56213. el,
  56214. state,
  56215. checkSkip,
  56216. altGenElement,
  56217. altGenNode
  56218. ) {
  56219. var children = el.children;
  56220. if (children.length) {
  56221. var el$1 = children[0];
  56222. // optimize single v-for
  56223. if (children.length === 1 &&
  56224. el$1.for &&
  56225. el$1.tag !== 'template' &&
  56226. el$1.tag !== 'slot'
  56227. ) {
  56228. var normalizationType = checkSkip
  56229. ? state.maybeComponent(el$1) ? ",1" : ",0"
  56230. : "";
  56231. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  56232. }
  56233. var normalizationType$1 = checkSkip
  56234. ? getNormalizationType(children, state.maybeComponent)
  56235. : 0;
  56236. var gen = altGenNode || genNode;
  56237. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  56238. }
  56239. }
  56240. // determine the normalization needed for the children array.
  56241. // 0: no normalization needed
  56242. // 1: simple normalization needed (possible 1-level deep nested array)
  56243. // 2: full normalization needed
  56244. function getNormalizationType (
  56245. children,
  56246. maybeComponent
  56247. ) {
  56248. var res = 0;
  56249. for (var i = 0; i < children.length; i++) {
  56250. var el = children[i];
  56251. if (el.type !== 1) {
  56252. continue
  56253. }
  56254. if (needsNormalization(el) ||
  56255. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  56256. res = 2;
  56257. break
  56258. }
  56259. if (maybeComponent(el) ||
  56260. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  56261. res = 1;
  56262. }
  56263. }
  56264. return res
  56265. }
  56266. function needsNormalization (el) {
  56267. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  56268. }
  56269. function genNode (node, state) {
  56270. if (node.type === 1) {
  56271. return genElement(node, state)
  56272. } else if (node.type === 3 && node.isComment) {
  56273. return genComment(node)
  56274. } else {
  56275. return genText(node)
  56276. }
  56277. }
  56278. function genText (text) {
  56279. return ("_v(" + (text.type === 2
  56280. ? text.expression // no need for () because already wrapped in _s()
  56281. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  56282. }
  56283. function genComment (comment) {
  56284. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  56285. }
  56286. function genSlot (el, state) {
  56287. var slotName = el.slotName || '"default"';
  56288. var children = genChildren(el, state);
  56289. var res = "_t(" + slotName + (children ? ("," + children) : '');
  56290. var attrs = el.attrs || el.dynamicAttrs
  56291. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  56292. // slot props are camelized
  56293. name: camelize(attr.name),
  56294. value: attr.value,
  56295. dynamic: attr.dynamic
  56296. }); }))
  56297. : null;
  56298. var bind$$1 = el.attrsMap['v-bind'];
  56299. if ((attrs || bind$$1) && !children) {
  56300. res += ",null";
  56301. }
  56302. if (attrs) {
  56303. res += "," + attrs;
  56304. }
  56305. if (bind$$1) {
  56306. res += (attrs ? '' : ',null') + "," + bind$$1;
  56307. }
  56308. return res + ')'
  56309. }
  56310. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  56311. function genComponent (
  56312. componentName,
  56313. el,
  56314. state
  56315. ) {
  56316. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  56317. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  56318. }
  56319. function genProps (props) {
  56320. var staticProps = "";
  56321. var dynamicProps = "";
  56322. for (var i = 0; i < props.length; i++) {
  56323. var prop = props[i];
  56324. var value = transformSpecialNewlines(prop.value);
  56325. if (prop.dynamic) {
  56326. dynamicProps += (prop.name) + "," + value + ",";
  56327. } else {
  56328. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  56329. }
  56330. }
  56331. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  56332. if (dynamicProps) {
  56333. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  56334. } else {
  56335. return staticProps
  56336. }
  56337. }
  56338. // #3895, #4268
  56339. function transformSpecialNewlines (text) {
  56340. return text
  56341. .replace(/\u2028/g, '\\u2028')
  56342. .replace(/\u2029/g, '\\u2029')
  56343. }
  56344. /* */
  56345. // these keywords should not appear inside expressions, but operators like
  56346. // typeof, instanceof and in are allowed
  56347. var prohibitedKeywordRE = new RegExp('\\b' + (
  56348. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  56349. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  56350. 'extends,finally,continue,debugger,function,arguments'
  56351. ).split(',').join('\\b|\\b') + '\\b');
  56352. // these unary operators should not be used as property/method names
  56353. var unaryOperatorsRE = new RegExp('\\b' + (
  56354. 'delete,typeof,void'
  56355. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  56356. // strip strings in expressions
  56357. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  56358. // detect problematic expressions in a template
  56359. function detectErrors (ast, warn) {
  56360. if (ast) {
  56361. checkNode(ast, warn);
  56362. }
  56363. }
  56364. function checkNode (node, warn) {
  56365. if (node.type === 1) {
  56366. for (var name in node.attrsMap) {
  56367. if (dirRE.test(name)) {
  56368. var value = node.attrsMap[name];
  56369. if (value) {
  56370. var range = node.rawAttrsMap[name];
  56371. if (name === 'v-for') {
  56372. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  56373. } else if (name === 'v-slot' || name[0] === '#') {
  56374. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  56375. } else if (onRE.test(name)) {
  56376. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  56377. } else {
  56378. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  56379. }
  56380. }
  56381. }
  56382. }
  56383. if (node.children) {
  56384. for (var i = 0; i < node.children.length; i++) {
  56385. checkNode(node.children[i], warn);
  56386. }
  56387. }
  56388. } else if (node.type === 2) {
  56389. checkExpression(node.expression, node.text, warn, node);
  56390. }
  56391. }
  56392. function checkEvent (exp, text, warn, range) {
  56393. var stripped = exp.replace(stripStringRE, '');
  56394. var keywordMatch = stripped.match(unaryOperatorsRE);
  56395. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  56396. warn(
  56397. "avoid using JavaScript unary operator as property name: " +
  56398. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  56399. range
  56400. );
  56401. }
  56402. checkExpression(exp, text, warn, range);
  56403. }
  56404. function checkFor (node, text, warn, range) {
  56405. checkExpression(node.for || '', text, warn, range);
  56406. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  56407. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  56408. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  56409. }
  56410. function checkIdentifier (
  56411. ident,
  56412. type,
  56413. text,
  56414. warn,
  56415. range
  56416. ) {
  56417. if (typeof ident === 'string') {
  56418. try {
  56419. new Function(("var " + ident + "=_"));
  56420. } catch (e) {
  56421. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  56422. }
  56423. }
  56424. }
  56425. function checkExpression (exp, text, warn, range) {
  56426. try {
  56427. new Function(("return " + exp));
  56428. } catch (e) {
  56429. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  56430. if (keywordMatch) {
  56431. warn(
  56432. "avoid using JavaScript keyword as property name: " +
  56433. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  56434. range
  56435. );
  56436. } else {
  56437. warn(
  56438. "invalid expression: " + (e.message) + " in\n\n" +
  56439. " " + exp + "\n\n" +
  56440. " Raw expression: " + (text.trim()) + "\n",
  56441. range
  56442. );
  56443. }
  56444. }
  56445. }
  56446. function checkFunctionParameterExpression (exp, text, warn, range) {
  56447. try {
  56448. new Function(exp, '');
  56449. } catch (e) {
  56450. warn(
  56451. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  56452. " " + exp + "\n\n" +
  56453. " Raw expression: " + (text.trim()) + "\n",
  56454. range
  56455. );
  56456. }
  56457. }
  56458. /* */
  56459. var range = 2;
  56460. function generateCodeFrame (
  56461. source,
  56462. start,
  56463. end
  56464. ) {
  56465. if ( start === void 0 ) start = 0;
  56466. if ( end === void 0 ) end = source.length;
  56467. var lines = source.split(/\r?\n/);
  56468. var count = 0;
  56469. var res = [];
  56470. for (var i = 0; i < lines.length; i++) {
  56471. count += lines[i].length + 1;
  56472. if (count >= start) {
  56473. for (var j = i - range; j <= i + range || end > count; j++) {
  56474. if (j < 0 || j >= lines.length) { continue }
  56475. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  56476. var lineLength = lines[j].length;
  56477. if (j === i) {
  56478. // push underline
  56479. var pad = start - (count - lineLength) + 1;
  56480. var length = end > count ? lineLength - pad : end - start;
  56481. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  56482. } else if (j > i) {
  56483. if (end > count) {
  56484. var length$1 = Math.min(end - count, lineLength);
  56485. res.push(" | " + repeat$1("^", length$1));
  56486. }
  56487. count += lineLength + 1;
  56488. }
  56489. }
  56490. break
  56491. }
  56492. }
  56493. return res.join('\n')
  56494. }
  56495. function repeat$1 (str, n) {
  56496. var result = '';
  56497. if (n > 0) {
  56498. while (true) { // eslint-disable-line
  56499. if (n & 1) { result += str; }
  56500. n >>>= 1;
  56501. if (n <= 0) { break }
  56502. str += str;
  56503. }
  56504. }
  56505. return result
  56506. }
  56507. /* */
  56508. function createFunction (code, errors) {
  56509. try {
  56510. return new Function(code)
  56511. } catch (err) {
  56512. errors.push({ err: err, code: code });
  56513. return noop
  56514. }
  56515. }
  56516. function createCompileToFunctionFn (compile) {
  56517. var cache = Object.create(null);
  56518. return function compileToFunctions (
  56519. template,
  56520. options,
  56521. vm
  56522. ) {
  56523. options = extend({}, options);
  56524. var warn$$1 = options.warn || warn;
  56525. delete options.warn;
  56526. /* istanbul ignore if */
  56527. {
  56528. // detect possible CSP restriction
  56529. try {
  56530. new Function('return 1');
  56531. } catch (e) {
  56532. if (e.toString().match(/unsafe-eval|CSP/)) {
  56533. warn$$1(
  56534. 'It seems you are using the standalone build of Vue.js in an ' +
  56535. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  56536. 'The template compiler cannot work in this environment. Consider ' +
  56537. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  56538. 'templates into render functions.'
  56539. );
  56540. }
  56541. }
  56542. }
  56543. // check cache
  56544. var key = options.delimiters
  56545. ? String(options.delimiters) + template
  56546. : template;
  56547. if (cache[key]) {
  56548. return cache[key]
  56549. }
  56550. // compile
  56551. var compiled = compile(template, options);
  56552. // check compilation errors/tips
  56553. {
  56554. if (compiled.errors && compiled.errors.length) {
  56555. if (options.outputSourceRange) {
  56556. compiled.errors.forEach(function (e) {
  56557. warn$$1(
  56558. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  56559. generateCodeFrame(template, e.start, e.end),
  56560. vm
  56561. );
  56562. });
  56563. } else {
  56564. warn$$1(
  56565. "Error compiling template:\n\n" + template + "\n\n" +
  56566. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  56567. vm
  56568. );
  56569. }
  56570. }
  56571. if (compiled.tips && compiled.tips.length) {
  56572. if (options.outputSourceRange) {
  56573. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  56574. } else {
  56575. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  56576. }
  56577. }
  56578. }
  56579. // turn code into functions
  56580. var res = {};
  56581. var fnGenErrors = [];
  56582. res.render = createFunction(compiled.render, fnGenErrors);
  56583. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  56584. return createFunction(code, fnGenErrors)
  56585. });
  56586. // check function generation errors.
  56587. // this should only happen if there is a bug in the compiler itself.
  56588. // mostly for codegen development use
  56589. /* istanbul ignore if */
  56590. {
  56591. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  56592. warn$$1(
  56593. "Failed to generate render function:\n\n" +
  56594. fnGenErrors.map(function (ref) {
  56595. var err = ref.err;
  56596. var code = ref.code;
  56597. return ((err.toString()) + " in\n\n" + code + "\n");
  56598. }).join('\n'),
  56599. vm
  56600. );
  56601. }
  56602. }
  56603. return (cache[key] = res)
  56604. }
  56605. }
  56606. /* */
  56607. function createCompilerCreator (baseCompile) {
  56608. return function createCompiler (baseOptions) {
  56609. function compile (
  56610. template,
  56611. options
  56612. ) {
  56613. var finalOptions = Object.create(baseOptions);
  56614. var errors = [];
  56615. var tips = [];
  56616. var warn = function (msg, range, tip) {
  56617. (tip ? tips : errors).push(msg);
  56618. };
  56619. if (options) {
  56620. if (options.outputSourceRange) {
  56621. // $flow-disable-line
  56622. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  56623. warn = function (msg, range, tip) {
  56624. var data = { msg: msg };
  56625. if (range) {
  56626. if (range.start != null) {
  56627. data.start = range.start + leadingSpaceLength;
  56628. }
  56629. if (range.end != null) {
  56630. data.end = range.end + leadingSpaceLength;
  56631. }
  56632. }
  56633. (tip ? tips : errors).push(data);
  56634. };
  56635. }
  56636. // merge custom modules
  56637. if (options.modules) {
  56638. finalOptions.modules =
  56639. (baseOptions.modules || []).concat(options.modules);
  56640. }
  56641. // merge custom directives
  56642. if (options.directives) {
  56643. finalOptions.directives = extend(
  56644. Object.create(baseOptions.directives || null),
  56645. options.directives
  56646. );
  56647. }
  56648. // copy other options
  56649. for (var key in options) {
  56650. if (key !== 'modules' && key !== 'directives') {
  56651. finalOptions[key] = options[key];
  56652. }
  56653. }
  56654. }
  56655. finalOptions.warn = warn;
  56656. var compiled = baseCompile(template.trim(), finalOptions);
  56657. {
  56658. detectErrors(compiled.ast, warn);
  56659. }
  56660. compiled.errors = errors;
  56661. compiled.tips = tips;
  56662. return compiled
  56663. }
  56664. return {
  56665. compile: compile,
  56666. compileToFunctions: createCompileToFunctionFn(compile)
  56667. }
  56668. }
  56669. }
  56670. /* */
  56671. // `createCompilerCreator` allows creating compilers that use alternative
  56672. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  56673. // Here we just export a default compiler using the default parts.
  56674. var createCompiler = createCompilerCreator(function baseCompile (
  56675. template,
  56676. options
  56677. ) {
  56678. var ast = parse(template.trim(), options);
  56679. if (options.optimize !== false) {
  56680. optimize(ast, options);
  56681. }
  56682. var code = generate(ast, options);
  56683. return {
  56684. ast: ast,
  56685. render: code.render,
  56686. staticRenderFns: code.staticRenderFns
  56687. }
  56688. });
  56689. /* */
  56690. var ref$1 = createCompiler(baseOptions);
  56691. var compile = ref$1.compile;
  56692. var compileToFunctions = ref$1.compileToFunctions;
  56693. /* */
  56694. // check whether current browser encodes a char inside attribute values
  56695. var div;
  56696. function getShouldDecode (href) {
  56697. div = div || document.createElement('div');
  56698. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  56699. return div.innerHTML.indexOf('&#10;') > 0
  56700. }
  56701. // #3663: IE encodes newlines inside attribute values while other browsers don't
  56702. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  56703. // #6828: chrome encodes content in a[href]
  56704. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  56705. /* */
  56706. var idToTemplate = cached(function (id) {
  56707. var el = query(id);
  56708. return el && el.innerHTML
  56709. });
  56710. var mount = Vue.prototype.$mount;
  56711. Vue.prototype.$mount = function (
  56712. el,
  56713. hydrating
  56714. ) {
  56715. el = el && query(el);
  56716. /* istanbul ignore if */
  56717. if (el === document.body || el === document.documentElement) {
  56718. warn(
  56719. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  56720. );
  56721. return this
  56722. }
  56723. var options = this.$options;
  56724. // resolve template/el and convert to render function
  56725. if (!options.render) {
  56726. var template = options.template;
  56727. if (template) {
  56728. if (typeof template === 'string') {
  56729. if (template.charAt(0) === '#') {
  56730. template = idToTemplate(template);
  56731. /* istanbul ignore if */
  56732. if (!template) {
  56733. warn(
  56734. ("Template element not found or is empty: " + (options.template)),
  56735. this
  56736. );
  56737. }
  56738. }
  56739. } else if (template.nodeType) {
  56740. template = template.innerHTML;
  56741. } else {
  56742. {
  56743. warn('invalid template option:' + template, this);
  56744. }
  56745. return this
  56746. }
  56747. } else if (el) {
  56748. template = getOuterHTML(el);
  56749. }
  56750. if (template) {
  56751. /* istanbul ignore if */
  56752. if (config.performance && mark) {
  56753. mark('compile');
  56754. }
  56755. var ref = compileToFunctions(template, {
  56756. outputSourceRange: "development" !== 'production',
  56757. shouldDecodeNewlines: shouldDecodeNewlines,
  56758. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  56759. delimiters: options.delimiters,
  56760. comments: options.comments
  56761. }, this);
  56762. var render = ref.render;
  56763. var staticRenderFns = ref.staticRenderFns;
  56764. options.render = render;
  56765. options.staticRenderFns = staticRenderFns;
  56766. /* istanbul ignore if */
  56767. if (config.performance && mark) {
  56768. mark('compile end');
  56769. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  56770. }
  56771. }
  56772. }
  56773. return mount.call(this, el, hydrating)
  56774. };
  56775. /**
  56776. * Get outerHTML of elements, taking care
  56777. * of SVG elements in IE as well.
  56778. */
  56779. function getOuterHTML (el) {
  56780. if (el.outerHTML) {
  56781. return el.outerHTML
  56782. } else {
  56783. var container = document.createElement('div');
  56784. container.appendChild(el.cloneNode(true));
  56785. return container.innerHTML
  56786. }
  56787. }
  56788. Vue.compile = compileToFunctions;
  56789. module.exports = Vue;
  56790. /* 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))
  56791. /***/ }),
  56792. /***/ "./node_modules/vue/dist/vue.common.js":
  56793. /*!*********************************************!*\
  56794. !*** ./node_modules/vue/dist/vue.common.js ***!
  56795. \*********************************************/
  56796. /*! no static exports found */
  56797. /***/ (function(module, exports, __webpack_require__) {
  56798. if (false) {} else {
  56799. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  56800. }
  56801. /***/ }),
  56802. /***/ "./node_modules/webpack/buildin/global.js":
  56803. /*!***********************************!*\
  56804. !*** (webpack)/buildin/global.js ***!
  56805. \***********************************/
  56806. /*! no static exports found */
  56807. /***/ (function(module, exports) {
  56808. var g;
  56809. // This works in non-strict mode
  56810. g = (function() {
  56811. return this;
  56812. })();
  56813. try {
  56814. // This works if eval is allowed (see CSP)
  56815. g = g || new Function("return this")();
  56816. } catch (e) {
  56817. // This works if the window reference is available
  56818. if (typeof window === "object") g = window;
  56819. }
  56820. // g can still be undefined, but nothing to do about it...
  56821. // We return undefined, instead of nothing here, so it's
  56822. // easier to handle this case. if(!global) { ...}
  56823. module.exports = g;
  56824. /***/ }),
  56825. /***/ "./node_modules/webpack/buildin/module.js":
  56826. /*!***********************************!*\
  56827. !*** (webpack)/buildin/module.js ***!
  56828. \***********************************/
  56829. /*! no static exports found */
  56830. /***/ (function(module, exports) {
  56831. module.exports = function(module) {
  56832. if (!module.webpackPolyfill) {
  56833. module.deprecate = function() {};
  56834. module.paths = [];
  56835. // module.parent = undefined by default
  56836. if (!module.children) module.children = [];
  56837. Object.defineProperty(module, "loaded", {
  56838. enumerable: true,
  56839. get: function() {
  56840. return module.l;
  56841. }
  56842. });
  56843. Object.defineProperty(module, "id", {
  56844. enumerable: true,
  56845. get: function() {
  56846. return module.i;
  56847. }
  56848. });
  56849. module.webpackPolyfill = 1;
  56850. }
  56851. return module;
  56852. };
  56853. /***/ }),
  56854. /***/ "./resources/js/app.js":
  56855. /*!*****************************!*\
  56856. !*** ./resources/js/app.js ***!
  56857. \*****************************/
  56858. /*! no exports provided */
  56859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56860. "use strict";
  56861. __webpack_require__.r(__webpack_exports__);
  56862. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  56863. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
  56864. /* harmony import */ var vue_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-router */ "./node_modules/vue-router/dist/vue-router.esm.js");
  56865. /* harmony import */ var _views_App__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./views/App */ "./resources/js/views/App.vue");
  56866. /* harmony import */ var _views_Login__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./views/Login */ "./resources/js/views/Login.vue");
  56867. /* harmony import */ var _views_Welcome__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./views/Welcome */ "./resources/js/views/Welcome.vue");
  56868. /**
  56869. * First we will load all of this project's JavaScript dependencies which
  56870. * includes Vue and other libraries. It is a great starting point when
  56871. * building robust, powerful web applications using Vue and Laravel.
  56872. */
  56873. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  56874. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  56875. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  56876. vue__WEBPACK_IMPORTED_MODULE_0___default.a.use(vue_router__WEBPACK_IMPORTED_MODULE_1__["default"]);
  56877. // import WorkOrder from './views/WorkOrder'
  56878. var router = new vue_router__WEBPACK_IMPORTED_MODULE_1__["default"]({
  56879. mode: 'history',
  56880. routes: [{
  56881. path: '/',
  56882. name: 'home',
  56883. component: _views_Welcome__WEBPACK_IMPORTED_MODULE_4__["default"]
  56884. }, {
  56885. path: '/login',
  56886. name: 'login',
  56887. component: _views_Login__WEBPACK_IMPORTED_MODULE_3__["default"]
  56888. }
  56889. /* {
  56890. path: '/workorders',
  56891. name: 'workorders',
  56892. component: WorkOrder,
  56893. } */
  56894. ]
  56895. });
  56896. var app = new vue__WEBPACK_IMPORTED_MODULE_0___default.a({
  56897. el: '#app',
  56898. components: {
  56899. App: _views_App__WEBPACK_IMPORTED_MODULE_2__["default"]
  56900. },
  56901. router: router
  56902. });
  56903. $(function () {
  56904. $('[data-toggle="tooltip"]').tooltip();
  56905. });
  56906. var clipboard = new Clipboard('.btn-clip');
  56907. clipboard.on('success', function (e) {
  56908. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  56909. position: "right",
  56910. className: 'success'
  56911. });
  56912. e.clearSelection();
  56913. });
  56914. /***/ }),
  56915. /***/ "./resources/js/bootstrap.js":
  56916. /*!***********************************!*\
  56917. !*** ./resources/js/bootstrap.js ***!
  56918. \***********************************/
  56919. /*! no exports provided */
  56920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56921. "use strict";
  56922. __webpack_require__.r(__webpack_exports__);
  56923. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  56924. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  56925. /**
  56926. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  56927. * for JavaScript based Bootstrap features such as modals and tabs. This
  56928. * code may be modified to fit the specific needs of your application.
  56929. */
  56930. try {
  56931. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  56932. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  56933. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  56934. } catch (e) {}
  56935. /**
  56936. * We'll load the axios HTTP library which allows us to easily issue requests
  56937. * to our Laravel back-end. This library automatically handles sending the
  56938. * CSRF token as a header based on the value of the "XSRF" token cookie.
  56939. */
  56940. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  56941. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  56942. /**
  56943. * Echo exposes an expressive API for subscribing to channels and listening
  56944. * for events that are broadcast by Laravel. Echo and event broadcasting
  56945. * allows your team to easily build robust real-time web applications.
  56946. */
  56947. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  56948. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  56949. broadcaster: 'pusher',
  56950. key: "upccrt",
  56951. authEndpoint: '/broadcasting/auth',
  56952. wsHost: window.location.hostname,
  56953. wsPort: 6001,
  56954. disableStats: true
  56955. });
  56956. /***/ }),
  56957. /***/ "./resources/js/notify.min.js":
  56958. /*!************************************!*\
  56959. !*** ./resources/js/notify.min.js ***!
  56960. \************************************/
  56961. /*! no static exports found */
  56962. /***/ (function(module, exports, __webpack_require__) {
  56963. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  56964. (function (e) {
  56965. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  56966. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  56967. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  56968. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  56969. })(function (e) {
  56970. function A(t, n, i) {
  56971. typeof i == "string" && (i = {
  56972. className: i
  56973. }), this.options = E(w, e.isPlainObject(i) ? i : {}), this.loadHTML(), this.wrapper = e(h.html), this.options.clickToHide && this.wrapper.addClass(r + "-hidable"), this.wrapper.data(r, this), this.arrow = this.wrapper.find("." + r + "-arrow"), this.container = this.wrapper.find("." + r + "-container"), this.container.append(this.userContainer), t && t.length && (this.elementType = t.attr("type"), this.originalElement = t, this.elem = N(t), this.elem.data(r, this), this.elem.before(this.wrapper)), this.container.hide(), this.run(n);
  56974. }
  56975. var t = [].indexOf || function (e) {
  56976. for (var t = 0, n = this.length; t < n; t++) {
  56977. if (t in this && this[t] === e) return t;
  56978. }
  56979. return -1;
  56980. },
  56981. n = "notify",
  56982. r = n + "js",
  56983. i = n + "!blank",
  56984. s = {
  56985. t: "top",
  56986. m: "middle",
  56987. b: "bottom",
  56988. l: "left",
  56989. c: "center",
  56990. r: "right"
  56991. },
  56992. o = ["l", "c", "r"],
  56993. u = ["t", "m", "b"],
  56994. a = ["t", "b", "l", "r"],
  56995. f = {
  56996. t: "b",
  56997. m: null,
  56998. b: "t",
  56999. l: "r",
  57000. c: null,
  57001. r: "l"
  57002. },
  57003. l = function l(t) {
  57004. var n;
  57005. return n = [], e.each(t.split(/\W+/), function (e, t) {
  57006. var r;
  57007. r = t.toLowerCase().charAt(0);
  57008. if (s[r]) return n.push(r);
  57009. }), n;
  57010. },
  57011. c = {},
  57012. h = {
  57013. name: "core",
  57014. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  57015. css: "." + r + "-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n." + r + "-corner ." + r + "-wrapper,\n." + r + "-corner ." + r + "-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n." + r + "-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n." + r + "-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n." + r + "-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n." + r + "-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"
  57016. },
  57017. p = {
  57018. "border-radius": ["-webkit-", "-moz-"]
  57019. },
  57020. d = function d(e) {
  57021. return c[e];
  57022. },
  57023. v = function v(e) {
  57024. if (!e) throw "Missing Style name";
  57025. c[e] && delete c[e];
  57026. },
  57027. m = function m(t, i) {
  57028. if (!t) throw "Missing Style name";
  57029. if (!i) throw "Missing Style definition";
  57030. if (!i.html) throw "Missing Style HTML";
  57031. var s = c[t];
  57032. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  57033. var o = "";
  57034. i.classes && e.each(i.classes, function (t, n) {
  57035. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  57036. return p[t] && e.each(p[t], function (e, r) {
  57037. return o += " " + r + t + ": " + n + ";\n";
  57038. }), o += " " + t + ": " + n + ";\n";
  57039. }), o += "}\n";
  57040. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  57041. var u = {},
  57042. a = e(i.html);
  57043. y("html", a, u), y("text", a, u), i.fields = u;
  57044. },
  57045. g = function g(t) {
  57046. var n, r, i;
  57047. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  57048. try {
  57049. r.html(t);
  57050. } catch (s) {
  57051. r[0].styleSheet.cssText = t;
  57052. }
  57053. return r;
  57054. },
  57055. y = function y(t, n, r) {
  57056. var s;
  57057. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  57058. var n;
  57059. n = e(this).attr(s), n || (n = i), r[n] = t;
  57060. });
  57061. },
  57062. b = function b(e, t) {
  57063. return e.is(t) ? e : e.find(t);
  57064. },
  57065. w = {
  57066. clickToHide: !0,
  57067. autoHide: !0,
  57068. autoHideDelay: 5e3,
  57069. arrowShow: !0,
  57070. arrowSize: 5,
  57071. breakNewLines: !0,
  57072. elementPosition: "bottom",
  57073. globalPosition: "top right",
  57074. style: "bootstrap",
  57075. className: "error",
  57076. showAnimation: "slideDown",
  57077. showDuration: 400,
  57078. hideAnimation: "slideUp",
  57079. hideDuration: 200,
  57080. gap: 5
  57081. },
  57082. E = function E(t, n) {
  57083. var r;
  57084. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  57085. },
  57086. S = function S(t) {
  57087. return e.extend(w, t);
  57088. },
  57089. x = function x(t) {
  57090. return e("<" + t + "></" + t + ">");
  57091. },
  57092. T = {},
  57093. N = function N(t) {
  57094. var n;
  57095. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  57096. return e(r).attr("name") === t.attr("name");
  57097. }), t = n.first()), t;
  57098. },
  57099. C = function C(e, t, n) {
  57100. var r, i;
  57101. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  57102. if (isNaN(n)) return;
  57103. return r = s[f[t.charAt(0)]], i = t, e[r] !== undefined && (t = s[r.charAt(0)], n = -n), e[t] === undefined ? e[t] = n : e[t] += n, null;
  57104. },
  57105. k = function k(e, t, n) {
  57106. if (e === "l" || e === "t") return 0;
  57107. if (e === "c" || e === "m") return n / 2 - t / 2;
  57108. if (e === "r" || e === "b") return n - t;
  57109. throw "Invalid alignment";
  57110. },
  57111. L = function L(e) {
  57112. return L.e = L.e || x("div"), L.e.text(e).html();
  57113. };
  57114. A.prototype.loadHTML = function () {
  57115. var t;
  57116. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  57117. }, A.prototype.show = function (e, t) {
  57118. var n, r, i, s, o;
  57119. r = function (n) {
  57120. return function () {
  57121. !e && !n.elem && n.destroy();
  57122. if (t) return t();
  57123. };
  57124. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  57125. if (o && e) s = "show";else if (o && !e) s = "hide";else if (!o && e) s = this.options.showAnimation, n.push(this.options.showDuration);else {
  57126. if (!!o || !!e) return r();
  57127. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  57128. }
  57129. return n.push(r), i[s].apply(i, n);
  57130. }, A.prototype.setGlobalPosition = function () {
  57131. var t = this.getPosition(),
  57132. n = t[0],
  57133. i = t[1],
  57134. o = s[n],
  57135. u = s[i],
  57136. a = n + "|" + i,
  57137. f = T[a];
  57138. if (!f || !document.body.contains(f[0])) {
  57139. f = T[a] = x("div");
  57140. var l = {};
  57141. l[o] = 0, u === "middle" ? l.top = "45%" : u === "center" ? l.left = "45%" : l[u] = 0, f.css(l).addClass(r + "-corner"), e("body").append(f);
  57142. }
  57143. return f.prepend(this.wrapper);
  57144. }, A.prototype.setElementPosition = function () {
  57145. var n, r, i, l, c, h, p, d, v, m, g, y, b, w, E, S, x, T, N, L, A, O, M, _, D, P, H, B, j;
  57146. H = this.getPosition(), _ = H[0], O = H[1], M = H[2], g = this.elem.position(), d = this.elem.outerHeight(), y = this.elem.outerWidth(), v = this.elem.innerHeight(), m = this.elem.innerWidth(), j = this.wrapper.position(), c = this.container.height(), h = this.container.width(), T = s[_], L = f[_], A = s[L], p = {}, p[A] = _ === "b" ? d : _ === "r" ? y : 0, C(p, "top", g.top - j.top), C(p, "left", g.left - j.left), B = ["top", "left"];
  57147. for (w = 0, S = B.length; w < S; w++) {
  57148. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  57149. }
  57150. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  57151. if (!this.options.arrowShow) this.arrow.hide();else {
  57152. i = this.options.arrowSize, r = e.extend({}, p), n = this.userContainer.css("border-color") || this.userContainer.css("border-top-color") || this.userContainer.css("background-color") || "white";
  57153. for (E = 0, x = a.length; E < x; E++) {
  57154. D = a[E], P = s[D];
  57155. if (D === L) continue;
  57156. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  57157. }
  57158. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  57159. }
  57160. t.call(u, _) >= 0 ? (C(p, "left", k(O, h, y)), r && C(r, "left", k(O, i, m))) : t.call(o, _) >= 0 && (C(p, "top", k(O, c, d)), r && C(r, "top", k(O, i, v))), this.container.is(":visible") && (p.display = "block"), this.container.removeAttr("style").css(p);
  57161. if (r) return this.arrow.removeAttr("style").css(r);
  57162. }, A.prototype.getPosition = function () {
  57163. var e, n, r, i, s, f, c, h;
  57164. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  57165. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  57166. if (e.length === 1 || (r = e[0], t.call(u, r) >= 0) && (i = e[1], t.call(o, i) < 0) || (s = e[0], t.call(o, s) >= 0) && (f = e[1], t.call(u, f) < 0)) e[1] = (c = e[0], t.call(o, c) >= 0) ? "m" : "l";
  57167. return e.length === 2 && (e[2] = e[1]), e;
  57168. }, A.prototype.getStyle = function (e) {
  57169. var t;
  57170. e || (e = this.options.style), e || (e = "default"), t = c[e];
  57171. if (!t) throw "Missing style: " + e;
  57172. return t;
  57173. }, A.prototype.updateClasses = function () {
  57174. var t, n;
  57175. return t = ["base"], e.isArray(this.options.className) ? t = t.concat(this.options.className) : this.options.className && t.push(this.options.className), n = this.getStyle(), t = e.map(t, function (e) {
  57176. return r + "-" + n.name + "-" + e;
  57177. }).join(" "), this.userContainer.attr("class", t);
  57178. }, A.prototype.run = function (t, n) {
  57179. var r, s, o, u, a;
  57180. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  57181. if (this.container && !t) {
  57182. this.show(!1);
  57183. return;
  57184. }
  57185. if (!this.container && !t) return;
  57186. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  57187. for (o in s) {
  57188. r = s[o], u = this.userFields[o];
  57189. if (!u) continue;
  57190. u === "text" && (r = L(r), this.options.breakNewLines && (r = r.replace(/\n/g, "<br/>"))), a = o === i ? "" : "=" + o, b(this.userContainer, "[data-notify-" + u + a + "]").html(r);
  57191. }
  57192. this.updateClasses(), this.elem ? this.setElementPosition() : this.setGlobalPosition(), this.show(!0), this.options.autoHide && (clearTimeout(this.autohideTimer), this.autohideTimer = setTimeout(this.show.bind(this, !1), this.options.autoHideDelay));
  57193. }, A.prototype.destroy = function () {
  57194. this.wrapper.data(r, null), this.wrapper.remove();
  57195. }, e[n] = function (t, r, i) {
  57196. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  57197. }, e.fn[n] = function (t, n) {
  57198. return e(this).each(function () {
  57199. var i = N(e(this)).data(r);
  57200. i && i.destroy();
  57201. var s = new A(e(this), t, n);
  57202. }), this;
  57203. }, e.extend(e[n], {
  57204. defaults: S,
  57205. addStyle: m,
  57206. removeStyle: v,
  57207. pluginOptions: w,
  57208. getStyle: d,
  57209. insertCSS: g
  57210. }), m("bootstrap", {
  57211. html: "<div>\n<span data-notify-text></span>\n</div>",
  57212. classes: {
  57213. base: {
  57214. "font-weight": "bold",
  57215. padding: "8px 15px 8px 14px",
  57216. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  57217. "background-color": "#fcf8e3",
  57218. border: "1px solid #fbeed5",
  57219. "border-radius": "4px",
  57220. "white-space": "nowrap",
  57221. "padding-left": "25px",
  57222. "background-repeat": "no-repeat",
  57223. "background-position": "3px 7px"
  57224. },
  57225. error: {
  57226. color: "#B94A48",
  57227. "background-color": "#F2DEDE",
  57228. "border-color": "#EED3D7",
  57229. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"
  57230. },
  57231. success: {
  57232. color: "#468847",
  57233. "background-color": "#DFF0D8",
  57234. "border-color": "#D6E9C6",
  57235. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"
  57236. },
  57237. info: {
  57238. color: "#3A87AD",
  57239. "background-color": "#D9EDF7",
  57240. "border-color": "#BCE8F1",
  57241. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"
  57242. },
  57243. warn: {
  57244. color: "#C09853",
  57245. "background-color": "#FCF8E3",
  57246. "border-color": "#FBEED5",
  57247. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"
  57248. }
  57249. }
  57250. }), e(function () {
  57251. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  57252. e(this).trigger("notify-hide");
  57253. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  57254. var n = e(this).data(r);
  57255. n && n.show(!1);
  57256. });
  57257. });
  57258. });
  57259. /***/ }),
  57260. /***/ "./resources/js/views/App.vue":
  57261. /*!************************************!*\
  57262. !*** ./resources/js/views/App.vue ***!
  57263. \************************************/
  57264. /*! exports provided: default */
  57265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57266. "use strict";
  57267. __webpack_require__.r(__webpack_exports__);
  57268. /* harmony import */ var _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./App.vue?vue&type=template&id=91ac6b5c& */ "./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&");
  57269. /* harmony import */ var _App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./App.vue?vue&type=script&lang=js& */ "./resources/js/views/App.vue?vue&type=script&lang=js&");
  57270. /* 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");
  57271. /* normalize component */
  57272. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  57273. _App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  57274. _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["render"],
  57275. _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  57276. false,
  57277. null,
  57278. null,
  57279. null
  57280. )
  57281. /* hot reload */
  57282. if (false) { var api; }
  57283. component.options.__file = "resources/js/views/App.vue"
  57284. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  57285. /***/ }),
  57286. /***/ "./resources/js/views/App.vue?vue&type=script&lang=js&":
  57287. /*!*************************************************************!*\
  57288. !*** ./resources/js/views/App.vue?vue&type=script&lang=js& ***!
  57289. \*************************************************************/
  57290. /*! exports provided: default */
  57291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57292. "use strict";
  57293. __webpack_require__.r(__webpack_exports__);
  57294. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_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!./App.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=script&lang=js&");
  57295. /* 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_App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  57296. /***/ }),
  57297. /***/ "./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&":
  57298. /*!*******************************************************************!*\
  57299. !*** ./resources/js/views/App.vue?vue&type=template&id=91ac6b5c& ***!
  57300. \*******************************************************************/
  57301. /*! exports provided: render, staticRenderFns */
  57302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57303. "use strict";
  57304. __webpack_require__.r(__webpack_exports__);
  57305. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_template_id_91ac6b5c___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!./App.vue?vue&type=template&id=91ac6b5c& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&");
  57306. /* 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_App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  57307. /* 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_App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  57308. /***/ }),
  57309. /***/ "./resources/js/views/Login.vue":
  57310. /*!**************************************!*\
  57311. !*** ./resources/js/views/Login.vue ***!
  57312. \**************************************/
  57313. /*! exports provided: default */
  57314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57315. "use strict";
  57316. __webpack_require__.r(__webpack_exports__);
  57317. /* harmony import */ var _Login_vue_vue_type_template_id_12f5395a___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Login.vue?vue&type=template&id=12f5395a& */ "./resources/js/views/Login.vue?vue&type=template&id=12f5395a&");
  57318. /* harmony import */ var _Login_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Login.vue?vue&type=script&lang=js& */ "./resources/js/views/Login.vue?vue&type=script&lang=js&");
  57319. /* 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");
  57320. /* normalize component */
  57321. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  57322. _Login_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  57323. _Login_vue_vue_type_template_id_12f5395a___WEBPACK_IMPORTED_MODULE_0__["render"],
  57324. _Login_vue_vue_type_template_id_12f5395a___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  57325. false,
  57326. null,
  57327. null,
  57328. null
  57329. )
  57330. /* hot reload */
  57331. if (false) { var api; }
  57332. component.options.__file = "resources/js/views/Login.vue"
  57333. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  57334. /***/ }),
  57335. /***/ "./resources/js/views/Login.vue?vue&type=script&lang=js&":
  57336. /*!***************************************************************!*\
  57337. !*** ./resources/js/views/Login.vue?vue&type=script&lang=js& ***!
  57338. \***************************************************************/
  57339. /*! exports provided: default */
  57340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57341. "use strict";
  57342. __webpack_require__.r(__webpack_exports__);
  57343. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Login_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!./Login.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Login.vue?vue&type=script&lang=js&");
  57344. /* 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_Login_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  57345. /***/ }),
  57346. /***/ "./resources/js/views/Login.vue?vue&type=template&id=12f5395a&":
  57347. /*!*********************************************************************!*\
  57348. !*** ./resources/js/views/Login.vue?vue&type=template&id=12f5395a& ***!
  57349. \*********************************************************************/
  57350. /*! exports provided: render, staticRenderFns */
  57351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57352. "use strict";
  57353. __webpack_require__.r(__webpack_exports__);
  57354. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Login_vue_vue_type_template_id_12f5395a___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!./Login.vue?vue&type=template&id=12f5395a& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Login.vue?vue&type=template&id=12f5395a&");
  57355. /* 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_Login_vue_vue_type_template_id_12f5395a___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  57356. /* 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_Login_vue_vue_type_template_id_12f5395a___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  57357. /***/ }),
  57358. /***/ "./resources/js/views/Welcome.vue":
  57359. /*!****************************************!*\
  57360. !*** ./resources/js/views/Welcome.vue ***!
  57361. \****************************************/
  57362. /*! exports provided: default */
  57363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57364. "use strict";
  57365. __webpack_require__.r(__webpack_exports__);
  57366. /* harmony import */ var _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& */ "./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&");
  57367. /* harmony import */ var _Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Welcome.vue?vue&type=script&lang=js& */ "./resources/js/views/Welcome.vue?vue&type=script&lang=js&");
  57368. /* empty/unused harmony star reexport *//* harmony import */ var _Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  57369. /* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  57370. /* normalize component */
  57371. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__["default"])(
  57372. _Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  57373. _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"],
  57374. _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  57375. false,
  57376. null,
  57377. "1ae8ae93",
  57378. null
  57379. )
  57380. /* hot reload */
  57381. if (false) { var api; }
  57382. component.options.__file = "resources/js/views/Welcome.vue"
  57383. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  57384. /***/ }),
  57385. /***/ "./resources/js/views/Welcome.vue?vue&type=script&lang=js&":
  57386. /*!*****************************************************************!*\
  57387. !*** ./resources/js/views/Welcome.vue?vue&type=script&lang=js& ***!
  57388. \*****************************************************************/
  57389. /*! exports provided: default */
  57390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57391. "use strict";
  57392. __webpack_require__.r(__webpack_exports__);
  57393. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_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!./Welcome.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=script&lang=js&");
  57394. /* 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_Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  57395. /***/ }),
  57396. /***/ "./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  57397. /*!*************************************************************************************************!*\
  57398. !*** ./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  57399. \*************************************************************************************************/
  57400. /*! no static exports found */
  57401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57402. "use strict";
  57403. __webpack_require__.r(__webpack_exports__);
  57404. /* harmony import */ var _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/style-loader!../../../node_modules/css-loader??ref--6-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src??ref--6-2!../../../node_modules/vue-loader/lib??vue-loader-options!./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./node_modules/style-loader/index.js!./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  57405. /* harmony import */ var _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__);
  57406. /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
  57407. /* harmony default export */ __webpack_exports__["default"] = (_node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);
  57408. /***/ }),
  57409. /***/ "./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&":
  57410. /*!***********************************************************************************!*\
  57411. !*** ./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& ***!
  57412. \***********************************************************************************/
  57413. /*! exports provided: render, staticRenderFns */
  57414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57415. "use strict";
  57416. __webpack_require__.r(__webpack_exports__);
  57417. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___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!./Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&");
  57418. /* 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_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  57419. /* 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_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  57420. /***/ }),
  57421. /***/ "./resources/sass/app.scss":
  57422. /*!*********************************!*\
  57423. !*** ./resources/sass/app.scss ***!
  57424. \*********************************/
  57425. /*! no static exports found */
  57426. /***/ (function(module, exports) {
  57427. // removed by extract-text-webpack-plugin
  57428. /***/ }),
  57429. /***/ 0:
  57430. /*!*************************************************************!*\
  57431. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  57432. \*************************************************************/
  57433. /*! no static exports found */
  57434. /***/ (function(module, exports, __webpack_require__) {
  57435. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  57436. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  57437. /***/ })
  57438. /******/ });