app.js 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  1574. /*!***************************************************************************************************************************************************************************!*\
  1575. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  1576. \***************************************************************************************************************************************************************************/
  1577. /*! exports provided: default */
  1578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1579. "use strict";
  1580. __webpack_require__.r(__webpack_exports__);
  1581. //
  1582. //
  1583. //
  1584. //
  1585. //
  1586. //
  1587. //
  1588. //
  1589. //
  1590. //
  1591. //
  1592. //
  1593. //
  1594. //
  1595. //
  1596. //
  1597. /* harmony default export */ __webpack_exports__["default"] = ({
  1598. mounted: function mounted() {
  1599. console.log('Component mounted.');
  1600. }
  1601. });
  1602. /***/ }),
  1603. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  1604. /*!********************************************************************************************************************************************************************!*\
  1605. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  1606. \********************************************************************************************************************************************************************/
  1607. /*! exports provided: default */
  1608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1609. "use strict";
  1610. __webpack_require__.r(__webpack_exports__);
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. //
  1618. //
  1619. //
  1620. /* harmony default export */ __webpack_exports__["default"] = ({
  1621. props: ['asset'],
  1622. data: function data() {
  1623. return {
  1624. data: JSON.parse(this.asset)
  1625. };
  1626. },
  1627. mounted: function mounted() {
  1628. var _this = this;
  1629. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1630. _this.data = JSON.parse(e.data);
  1631. });
  1632. }
  1633. });
  1634. /***/ }),
  1635. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&":
  1636. /*!*********************************************************************************************************************************************************************!*\
  1637. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  1638. \*********************************************************************************************************************************************************************/
  1639. /*! exports provided: default */
  1640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1641. "use strict";
  1642. __webpack_require__.r(__webpack_exports__);
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. /* harmony default export */ __webpack_exports__["default"] = ({
  1653. props: ['credential'],
  1654. data: function data() {
  1655. return {
  1656. data: JSON.parse(this.credential)
  1657. };
  1658. },
  1659. mounted: function mounted() {
  1660. var _this = this;
  1661. Echo.channel('credentials').listen('CredentialUpdated', function (e) {
  1662. _this.data = JSON.parse(e.data);
  1663. });
  1664. }
  1665. });
  1666. /***/ }),
  1667. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1668. /*!*****************************************************************************************************************************************************************!*\
  1669. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  1670. \*****************************************************************************************************************************************************************/
  1671. /*! exports provided: default */
  1672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1673. "use strict";
  1674. __webpack_require__.r(__webpack_exports__);
  1675. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1676. //
  1677. //
  1678. //
  1679. //
  1680. //
  1681. //
  1682. //
  1683. //
  1684. //
  1685. //
  1686. //
  1687. //
  1688. //
  1689. //
  1690. //
  1691. //
  1692. //
  1693. //
  1694. /* harmony default export */ __webpack_exports__["default"] = ({
  1695. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1696. props: ['workOrder'],
  1697. data: function data() {
  1698. return {
  1699. data: JSON.parse(this.workOrder)
  1700. };
  1701. },
  1702. mounted: function mounted() {
  1703. var _this = this;
  1704. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1705. _this.data = JSON.parse(e.data);
  1706. });
  1707. }
  1708. });
  1709. /***/ }),
  1710. /***/ "./node_modules/base64-js/index.js":
  1711. /*!*****************************************!*\
  1712. !*** ./node_modules/base64-js/index.js ***!
  1713. \*****************************************/
  1714. /*! no static exports found */
  1715. /***/ (function(module, exports, __webpack_require__) {
  1716. "use strict";
  1717. exports.byteLength = byteLength
  1718. exports.toByteArray = toByteArray
  1719. exports.fromByteArray = fromByteArray
  1720. var lookup = []
  1721. var revLookup = []
  1722. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1723. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1724. for (var i = 0, len = code.length; i < len; ++i) {
  1725. lookup[i] = code[i]
  1726. revLookup[code.charCodeAt(i)] = i
  1727. }
  1728. // Support decoding URL-safe base64 strings, as Node.js does.
  1729. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1730. revLookup['-'.charCodeAt(0)] = 62
  1731. revLookup['_'.charCodeAt(0)] = 63
  1732. function getLens (b64) {
  1733. var len = b64.length
  1734. if (len % 4 > 0) {
  1735. throw new Error('Invalid string. Length must be a multiple of 4')
  1736. }
  1737. // Trim off extra bytes after placeholder bytes are found
  1738. // See: https://github.com/beatgammit/base64-js/issues/42
  1739. var validLen = b64.indexOf('=')
  1740. if (validLen === -1) validLen = len
  1741. var placeHoldersLen = validLen === len
  1742. ? 0
  1743. : 4 - (validLen % 4)
  1744. return [validLen, placeHoldersLen]
  1745. }
  1746. // base64 is 4/3 + up to two characters of the original data
  1747. function byteLength (b64) {
  1748. var lens = getLens(b64)
  1749. var validLen = lens[0]
  1750. var placeHoldersLen = lens[1]
  1751. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1752. }
  1753. function _byteLength (b64, validLen, placeHoldersLen) {
  1754. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1755. }
  1756. function toByteArray (b64) {
  1757. var tmp
  1758. var lens = getLens(b64)
  1759. var validLen = lens[0]
  1760. var placeHoldersLen = lens[1]
  1761. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1762. var curByte = 0
  1763. // if there are placeholders, only get up to the last complete 4 chars
  1764. var len = placeHoldersLen > 0
  1765. ? validLen - 4
  1766. : validLen
  1767. var i
  1768. for (i = 0; i < len; i += 4) {
  1769. tmp =
  1770. (revLookup[b64.charCodeAt(i)] << 18) |
  1771. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1772. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1773. revLookup[b64.charCodeAt(i + 3)]
  1774. arr[curByte++] = (tmp >> 16) & 0xFF
  1775. arr[curByte++] = (tmp >> 8) & 0xFF
  1776. arr[curByte++] = tmp & 0xFF
  1777. }
  1778. if (placeHoldersLen === 2) {
  1779. tmp =
  1780. (revLookup[b64.charCodeAt(i)] << 2) |
  1781. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1782. arr[curByte++] = tmp & 0xFF
  1783. }
  1784. if (placeHoldersLen === 1) {
  1785. tmp =
  1786. (revLookup[b64.charCodeAt(i)] << 10) |
  1787. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1788. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1789. arr[curByte++] = (tmp >> 8) & 0xFF
  1790. arr[curByte++] = tmp & 0xFF
  1791. }
  1792. return arr
  1793. }
  1794. function tripletToBase64 (num) {
  1795. return lookup[num >> 18 & 0x3F] +
  1796. lookup[num >> 12 & 0x3F] +
  1797. lookup[num >> 6 & 0x3F] +
  1798. lookup[num & 0x3F]
  1799. }
  1800. function encodeChunk (uint8, start, end) {
  1801. var tmp
  1802. var output = []
  1803. for (var i = start; i < end; i += 3) {
  1804. tmp =
  1805. ((uint8[i] << 16) & 0xFF0000) +
  1806. ((uint8[i + 1] << 8) & 0xFF00) +
  1807. (uint8[i + 2] & 0xFF)
  1808. output.push(tripletToBase64(tmp))
  1809. }
  1810. return output.join('')
  1811. }
  1812. function fromByteArray (uint8) {
  1813. var tmp
  1814. var len = uint8.length
  1815. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1816. var parts = []
  1817. var maxChunkLength = 16383 // must be multiple of 3
  1818. // go through the array every three bytes, we'll deal with trailing stuff later
  1819. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1820. parts.push(encodeChunk(
  1821. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1822. ))
  1823. }
  1824. // pad the end with zeros, but make sure to not forget the extra bytes
  1825. if (extraBytes === 1) {
  1826. tmp = uint8[len - 1]
  1827. parts.push(
  1828. lookup[tmp >> 2] +
  1829. lookup[(tmp << 4) & 0x3F] +
  1830. '=='
  1831. )
  1832. } else if (extraBytes === 2) {
  1833. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1834. parts.push(
  1835. lookup[tmp >> 10] +
  1836. lookup[(tmp >> 4) & 0x3F] +
  1837. lookup[(tmp << 2) & 0x3F] +
  1838. '='
  1839. )
  1840. }
  1841. return parts.join('')
  1842. }
  1843. /***/ }),
  1844. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1845. /*!*****************************************************!*\
  1846. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1847. \*****************************************************/
  1848. /*! no static exports found */
  1849. /***/ (function(module, exports, __webpack_require__) {
  1850. /*!
  1851. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1852. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1853. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1854. */
  1855. (function (global, factory) {
  1856. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1857. undefined;
  1858. }(this, (function (exports, $, Popper) { 'use strict';
  1859. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1860. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1861. function _defineProperties(target, props) {
  1862. for (var i = 0; i < props.length; i++) {
  1863. var descriptor = props[i];
  1864. descriptor.enumerable = descriptor.enumerable || false;
  1865. descriptor.configurable = true;
  1866. if ("value" in descriptor) descriptor.writable = true;
  1867. Object.defineProperty(target, descriptor.key, descriptor);
  1868. }
  1869. }
  1870. function _createClass(Constructor, protoProps, staticProps) {
  1871. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1872. if (staticProps) _defineProperties(Constructor, staticProps);
  1873. return Constructor;
  1874. }
  1875. function _defineProperty(obj, key, value) {
  1876. if (key in obj) {
  1877. Object.defineProperty(obj, key, {
  1878. value: value,
  1879. enumerable: true,
  1880. configurable: true,
  1881. writable: true
  1882. });
  1883. } else {
  1884. obj[key] = value;
  1885. }
  1886. return obj;
  1887. }
  1888. function ownKeys(object, enumerableOnly) {
  1889. var keys = Object.keys(object);
  1890. if (Object.getOwnPropertySymbols) {
  1891. var symbols = Object.getOwnPropertySymbols(object);
  1892. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1893. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1894. });
  1895. keys.push.apply(keys, symbols);
  1896. }
  1897. return keys;
  1898. }
  1899. function _objectSpread2(target) {
  1900. for (var i = 1; i < arguments.length; i++) {
  1901. var source = arguments[i] != null ? arguments[i] : {};
  1902. if (i % 2) {
  1903. ownKeys(Object(source), true).forEach(function (key) {
  1904. _defineProperty(target, key, source[key]);
  1905. });
  1906. } else if (Object.getOwnPropertyDescriptors) {
  1907. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1908. } else {
  1909. ownKeys(Object(source)).forEach(function (key) {
  1910. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1911. });
  1912. }
  1913. }
  1914. return target;
  1915. }
  1916. function _inheritsLoose(subClass, superClass) {
  1917. subClass.prototype = Object.create(superClass.prototype);
  1918. subClass.prototype.constructor = subClass;
  1919. subClass.__proto__ = superClass;
  1920. }
  1921. /**
  1922. * --------------------------------------------------------------------------
  1923. * Bootstrap (v4.4.1): util.js
  1924. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1925. * --------------------------------------------------------------------------
  1926. */
  1927. /**
  1928. * ------------------------------------------------------------------------
  1929. * Private TransitionEnd Helpers
  1930. * ------------------------------------------------------------------------
  1931. */
  1932. var TRANSITION_END = 'transitionend';
  1933. var MAX_UID = 1000000;
  1934. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1935. function toType(obj) {
  1936. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1937. }
  1938. function getSpecialTransitionEndEvent() {
  1939. return {
  1940. bindType: TRANSITION_END,
  1941. delegateType: TRANSITION_END,
  1942. handle: function handle(event) {
  1943. if ($(event.target).is(this)) {
  1944. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1945. }
  1946. return undefined; // eslint-disable-line no-undefined
  1947. }
  1948. };
  1949. }
  1950. function transitionEndEmulator(duration) {
  1951. var _this = this;
  1952. var called = false;
  1953. $(this).one(Util.TRANSITION_END, function () {
  1954. called = true;
  1955. });
  1956. setTimeout(function () {
  1957. if (!called) {
  1958. Util.triggerTransitionEnd(_this);
  1959. }
  1960. }, duration);
  1961. return this;
  1962. }
  1963. function setTransitionEndSupport() {
  1964. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1965. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1966. }
  1967. /**
  1968. * --------------------------------------------------------------------------
  1969. * Public Util Api
  1970. * --------------------------------------------------------------------------
  1971. */
  1972. var Util = {
  1973. TRANSITION_END: 'bsTransitionEnd',
  1974. getUID: function getUID(prefix) {
  1975. do {
  1976. // eslint-disable-next-line no-bitwise
  1977. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1978. } while (document.getElementById(prefix));
  1979. return prefix;
  1980. },
  1981. getSelectorFromElement: function getSelectorFromElement(element) {
  1982. var selector = element.getAttribute('data-target');
  1983. if (!selector || selector === '#') {
  1984. var hrefAttr = element.getAttribute('href');
  1985. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1986. }
  1987. try {
  1988. return document.querySelector(selector) ? selector : null;
  1989. } catch (err) {
  1990. return null;
  1991. }
  1992. },
  1993. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1994. if (!element) {
  1995. return 0;
  1996. } // Get transition-duration of the element
  1997. var transitionDuration = $(element).css('transition-duration');
  1998. var transitionDelay = $(element).css('transition-delay');
  1999. var floatTransitionDuration = parseFloat(transitionDuration);
  2000. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2001. if (!floatTransitionDuration && !floatTransitionDelay) {
  2002. return 0;
  2003. } // If multiple durations are defined, take the first
  2004. transitionDuration = transitionDuration.split(',')[0];
  2005. transitionDelay = transitionDelay.split(',')[0];
  2006. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2007. },
  2008. reflow: function reflow(element) {
  2009. return element.offsetHeight;
  2010. },
  2011. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2012. $(element).trigger(TRANSITION_END);
  2013. },
  2014. // TODO: Remove in v5
  2015. supportsTransitionEnd: function supportsTransitionEnd() {
  2016. return Boolean(TRANSITION_END);
  2017. },
  2018. isElement: function isElement(obj) {
  2019. return (obj[0] || obj).nodeType;
  2020. },
  2021. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2022. for (var property in configTypes) {
  2023. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2024. var expectedTypes = configTypes[property];
  2025. var value = config[property];
  2026. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2027. if (!new RegExp(expectedTypes).test(valueType)) {
  2028. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2029. }
  2030. }
  2031. }
  2032. },
  2033. findShadowRoot: function findShadowRoot(element) {
  2034. if (!document.documentElement.attachShadow) {
  2035. return null;
  2036. } // Can find the shadow root otherwise it'll return the document
  2037. if (typeof element.getRootNode === 'function') {
  2038. var root = element.getRootNode();
  2039. return root instanceof ShadowRoot ? root : null;
  2040. }
  2041. if (element instanceof ShadowRoot) {
  2042. return element;
  2043. } // when we don't find a shadow root
  2044. if (!element.parentNode) {
  2045. return null;
  2046. }
  2047. return Util.findShadowRoot(element.parentNode);
  2048. },
  2049. jQueryDetection: function jQueryDetection() {
  2050. if (typeof $ === 'undefined') {
  2051. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2052. }
  2053. var version = $.fn.jquery.split(' ')[0].split('.');
  2054. var minMajor = 1;
  2055. var ltMajor = 2;
  2056. var minMinor = 9;
  2057. var minPatch = 1;
  2058. var maxMajor = 4;
  2059. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2060. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2061. }
  2062. }
  2063. };
  2064. Util.jQueryDetection();
  2065. setTransitionEndSupport();
  2066. /**
  2067. * ------------------------------------------------------------------------
  2068. * Constants
  2069. * ------------------------------------------------------------------------
  2070. */
  2071. var NAME = 'alert';
  2072. var VERSION = '4.4.1';
  2073. var DATA_KEY = 'bs.alert';
  2074. var EVENT_KEY = "." + DATA_KEY;
  2075. var DATA_API_KEY = '.data-api';
  2076. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2077. var Selector = {
  2078. DISMISS: '[data-dismiss="alert"]'
  2079. };
  2080. var Event = {
  2081. CLOSE: "close" + EVENT_KEY,
  2082. CLOSED: "closed" + EVENT_KEY,
  2083. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2084. };
  2085. var ClassName = {
  2086. ALERT: 'alert',
  2087. FADE: 'fade',
  2088. SHOW: 'show'
  2089. };
  2090. /**
  2091. * ------------------------------------------------------------------------
  2092. * Class Definition
  2093. * ------------------------------------------------------------------------
  2094. */
  2095. var Alert =
  2096. /*#__PURE__*/
  2097. function () {
  2098. function Alert(element) {
  2099. this._element = element;
  2100. } // Getters
  2101. var _proto = Alert.prototype;
  2102. // Public
  2103. _proto.close = function close(element) {
  2104. var rootElement = this._element;
  2105. if (element) {
  2106. rootElement = this._getRootElement(element);
  2107. }
  2108. var customEvent = this._triggerCloseEvent(rootElement);
  2109. if (customEvent.isDefaultPrevented()) {
  2110. return;
  2111. }
  2112. this._removeElement(rootElement);
  2113. };
  2114. _proto.dispose = function dispose() {
  2115. $.removeData(this._element, DATA_KEY);
  2116. this._element = null;
  2117. } // Private
  2118. ;
  2119. _proto._getRootElement = function _getRootElement(element) {
  2120. var selector = Util.getSelectorFromElement(element);
  2121. var parent = false;
  2122. if (selector) {
  2123. parent = document.querySelector(selector);
  2124. }
  2125. if (!parent) {
  2126. parent = $(element).closest("." + ClassName.ALERT)[0];
  2127. }
  2128. return parent;
  2129. };
  2130. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2131. var closeEvent = $.Event(Event.CLOSE);
  2132. $(element).trigger(closeEvent);
  2133. return closeEvent;
  2134. };
  2135. _proto._removeElement = function _removeElement(element) {
  2136. var _this = this;
  2137. $(element).removeClass(ClassName.SHOW);
  2138. if (!$(element).hasClass(ClassName.FADE)) {
  2139. this._destroyElement(element);
  2140. return;
  2141. }
  2142. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2143. $(element).one(Util.TRANSITION_END, function (event) {
  2144. return _this._destroyElement(element, event);
  2145. }).emulateTransitionEnd(transitionDuration);
  2146. };
  2147. _proto._destroyElement = function _destroyElement(element) {
  2148. $(element).detach().trigger(Event.CLOSED).remove();
  2149. } // Static
  2150. ;
  2151. Alert._jQueryInterface = function _jQueryInterface(config) {
  2152. return this.each(function () {
  2153. var $element = $(this);
  2154. var data = $element.data(DATA_KEY);
  2155. if (!data) {
  2156. data = new Alert(this);
  2157. $element.data(DATA_KEY, data);
  2158. }
  2159. if (config === 'close') {
  2160. data[config](this);
  2161. }
  2162. });
  2163. };
  2164. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2165. return function (event) {
  2166. if (event) {
  2167. event.preventDefault();
  2168. }
  2169. alertInstance.close(this);
  2170. };
  2171. };
  2172. _createClass(Alert, null, [{
  2173. key: "VERSION",
  2174. get: function get() {
  2175. return VERSION;
  2176. }
  2177. }]);
  2178. return Alert;
  2179. }();
  2180. /**
  2181. * ------------------------------------------------------------------------
  2182. * Data Api implementation
  2183. * ------------------------------------------------------------------------
  2184. */
  2185. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2186. /**
  2187. * ------------------------------------------------------------------------
  2188. * jQuery
  2189. * ------------------------------------------------------------------------
  2190. */
  2191. $.fn[NAME] = Alert._jQueryInterface;
  2192. $.fn[NAME].Constructor = Alert;
  2193. $.fn[NAME].noConflict = function () {
  2194. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2195. return Alert._jQueryInterface;
  2196. };
  2197. /**
  2198. * ------------------------------------------------------------------------
  2199. * Constants
  2200. * ------------------------------------------------------------------------
  2201. */
  2202. var NAME$1 = 'button';
  2203. var VERSION$1 = '4.4.1';
  2204. var DATA_KEY$1 = 'bs.button';
  2205. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2206. var DATA_API_KEY$1 = '.data-api';
  2207. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2208. var ClassName$1 = {
  2209. ACTIVE: 'active',
  2210. BUTTON: 'btn',
  2211. FOCUS: 'focus'
  2212. };
  2213. var Selector$1 = {
  2214. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2215. DATA_TOGGLES: '[data-toggle="buttons"]',
  2216. DATA_TOGGLE: '[data-toggle="button"]',
  2217. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2218. INPUT: 'input:not([type="hidden"])',
  2219. ACTIVE: '.active',
  2220. BUTTON: '.btn'
  2221. };
  2222. var Event$1 = {
  2223. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2224. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2225. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2226. };
  2227. /**
  2228. * ------------------------------------------------------------------------
  2229. * Class Definition
  2230. * ------------------------------------------------------------------------
  2231. */
  2232. var Button =
  2233. /*#__PURE__*/
  2234. function () {
  2235. function Button(element) {
  2236. this._element = element;
  2237. } // Getters
  2238. var _proto = Button.prototype;
  2239. // Public
  2240. _proto.toggle = function toggle() {
  2241. var triggerChangeEvent = true;
  2242. var addAriaPressed = true;
  2243. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2244. if (rootElement) {
  2245. var input = this._element.querySelector(Selector$1.INPUT);
  2246. if (input) {
  2247. if (input.type === 'radio') {
  2248. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2249. triggerChangeEvent = false;
  2250. } else {
  2251. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2252. if (activeElement) {
  2253. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2254. }
  2255. }
  2256. } else if (input.type === 'checkbox') {
  2257. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2258. triggerChangeEvent = false;
  2259. }
  2260. } else {
  2261. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2262. triggerChangeEvent = false;
  2263. }
  2264. if (triggerChangeEvent) {
  2265. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2266. $(input).trigger('change');
  2267. }
  2268. input.focus();
  2269. addAriaPressed = false;
  2270. }
  2271. }
  2272. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2273. if (addAriaPressed) {
  2274. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2275. }
  2276. if (triggerChangeEvent) {
  2277. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2278. }
  2279. }
  2280. };
  2281. _proto.dispose = function dispose() {
  2282. $.removeData(this._element, DATA_KEY$1);
  2283. this._element = null;
  2284. } // Static
  2285. ;
  2286. Button._jQueryInterface = function _jQueryInterface(config) {
  2287. return this.each(function () {
  2288. var data = $(this).data(DATA_KEY$1);
  2289. if (!data) {
  2290. data = new Button(this);
  2291. $(this).data(DATA_KEY$1, data);
  2292. }
  2293. if (config === 'toggle') {
  2294. data[config]();
  2295. }
  2296. });
  2297. };
  2298. _createClass(Button, null, [{
  2299. key: "VERSION",
  2300. get: function get() {
  2301. return VERSION$1;
  2302. }
  2303. }]);
  2304. return Button;
  2305. }();
  2306. /**
  2307. * ------------------------------------------------------------------------
  2308. * Data Api implementation
  2309. * ------------------------------------------------------------------------
  2310. */
  2311. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2312. var button = event.target;
  2313. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2314. button = $(button).closest(Selector$1.BUTTON)[0];
  2315. }
  2316. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2317. event.preventDefault(); // work around Firefox bug #1540995
  2318. } else {
  2319. var inputBtn = button.querySelector(Selector$1.INPUT);
  2320. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2321. event.preventDefault(); // work around Firefox bug #1540995
  2322. return;
  2323. }
  2324. Button._jQueryInterface.call($(button), 'toggle');
  2325. }
  2326. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2327. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2328. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2329. });
  2330. $(window).on(Event$1.LOAD_DATA_API, function () {
  2331. // ensure correct active class is set to match the controls' actual values/states
  2332. // find all checkboxes/readio buttons inside data-toggle groups
  2333. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2334. for (var i = 0, len = buttons.length; i < len; i++) {
  2335. var button = buttons[i];
  2336. var input = button.querySelector(Selector$1.INPUT);
  2337. if (input.checked || input.hasAttribute('checked')) {
  2338. button.classList.add(ClassName$1.ACTIVE);
  2339. } else {
  2340. button.classList.remove(ClassName$1.ACTIVE);
  2341. }
  2342. } // find all button toggles
  2343. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2344. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2345. var _button = buttons[_i];
  2346. if (_button.getAttribute('aria-pressed') === 'true') {
  2347. _button.classList.add(ClassName$1.ACTIVE);
  2348. } else {
  2349. _button.classList.remove(ClassName$1.ACTIVE);
  2350. }
  2351. }
  2352. });
  2353. /**
  2354. * ------------------------------------------------------------------------
  2355. * jQuery
  2356. * ------------------------------------------------------------------------
  2357. */
  2358. $.fn[NAME$1] = Button._jQueryInterface;
  2359. $.fn[NAME$1].Constructor = Button;
  2360. $.fn[NAME$1].noConflict = function () {
  2361. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2362. return Button._jQueryInterface;
  2363. };
  2364. /**
  2365. * ------------------------------------------------------------------------
  2366. * Constants
  2367. * ------------------------------------------------------------------------
  2368. */
  2369. var NAME$2 = 'carousel';
  2370. var VERSION$2 = '4.4.1';
  2371. var DATA_KEY$2 = 'bs.carousel';
  2372. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2373. var DATA_API_KEY$2 = '.data-api';
  2374. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2375. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2376. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2377. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2378. var SWIPE_THRESHOLD = 40;
  2379. var Default = {
  2380. interval: 5000,
  2381. keyboard: true,
  2382. slide: false,
  2383. pause: 'hover',
  2384. wrap: true,
  2385. touch: true
  2386. };
  2387. var DefaultType = {
  2388. interval: '(number|boolean)',
  2389. keyboard: 'boolean',
  2390. slide: '(boolean|string)',
  2391. pause: '(string|boolean)',
  2392. wrap: 'boolean',
  2393. touch: 'boolean'
  2394. };
  2395. var Direction = {
  2396. NEXT: 'next',
  2397. PREV: 'prev',
  2398. LEFT: 'left',
  2399. RIGHT: 'right'
  2400. };
  2401. var Event$2 = {
  2402. SLIDE: "slide" + EVENT_KEY$2,
  2403. SLID: "slid" + EVENT_KEY$2,
  2404. KEYDOWN: "keydown" + EVENT_KEY$2,
  2405. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2406. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2407. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2408. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2409. TOUCHEND: "touchend" + EVENT_KEY$2,
  2410. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2411. POINTERUP: "pointerup" + EVENT_KEY$2,
  2412. DRAG_START: "dragstart" + EVENT_KEY$2,
  2413. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2414. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2415. };
  2416. var ClassName$2 = {
  2417. CAROUSEL: 'carousel',
  2418. ACTIVE: 'active',
  2419. SLIDE: 'slide',
  2420. RIGHT: 'carousel-item-right',
  2421. LEFT: 'carousel-item-left',
  2422. NEXT: 'carousel-item-next',
  2423. PREV: 'carousel-item-prev',
  2424. ITEM: 'carousel-item',
  2425. POINTER_EVENT: 'pointer-event'
  2426. };
  2427. var Selector$2 = {
  2428. ACTIVE: '.active',
  2429. ACTIVE_ITEM: '.active.carousel-item',
  2430. ITEM: '.carousel-item',
  2431. ITEM_IMG: '.carousel-item img',
  2432. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2433. INDICATORS: '.carousel-indicators',
  2434. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2435. DATA_RIDE: '[data-ride="carousel"]'
  2436. };
  2437. var PointerType = {
  2438. TOUCH: 'touch',
  2439. PEN: 'pen'
  2440. };
  2441. /**
  2442. * ------------------------------------------------------------------------
  2443. * Class Definition
  2444. * ------------------------------------------------------------------------
  2445. */
  2446. var Carousel =
  2447. /*#__PURE__*/
  2448. function () {
  2449. function Carousel(element, config) {
  2450. this._items = null;
  2451. this._interval = null;
  2452. this._activeElement = null;
  2453. this._isPaused = false;
  2454. this._isSliding = false;
  2455. this.touchTimeout = null;
  2456. this.touchStartX = 0;
  2457. this.touchDeltaX = 0;
  2458. this._config = this._getConfig(config);
  2459. this._element = element;
  2460. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2461. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2462. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2463. this._addEventListeners();
  2464. } // Getters
  2465. var _proto = Carousel.prototype;
  2466. // Public
  2467. _proto.next = function next() {
  2468. if (!this._isSliding) {
  2469. this._slide(Direction.NEXT);
  2470. }
  2471. };
  2472. _proto.nextWhenVisible = function nextWhenVisible() {
  2473. // Don't call next when the page isn't visible
  2474. // or the carousel or its parent isn't visible
  2475. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2476. this.next();
  2477. }
  2478. };
  2479. _proto.prev = function prev() {
  2480. if (!this._isSliding) {
  2481. this._slide(Direction.PREV);
  2482. }
  2483. };
  2484. _proto.pause = function pause(event) {
  2485. if (!event) {
  2486. this._isPaused = true;
  2487. }
  2488. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2489. Util.triggerTransitionEnd(this._element);
  2490. this.cycle(true);
  2491. }
  2492. clearInterval(this._interval);
  2493. this._interval = null;
  2494. };
  2495. _proto.cycle = function cycle(event) {
  2496. if (!event) {
  2497. this._isPaused = false;
  2498. }
  2499. if (this._interval) {
  2500. clearInterval(this._interval);
  2501. this._interval = null;
  2502. }
  2503. if (this._config.interval && !this._isPaused) {
  2504. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2505. }
  2506. };
  2507. _proto.to = function to(index) {
  2508. var _this = this;
  2509. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2510. var activeIndex = this._getItemIndex(this._activeElement);
  2511. if (index > this._items.length - 1 || index < 0) {
  2512. return;
  2513. }
  2514. if (this._isSliding) {
  2515. $(this._element).one(Event$2.SLID, function () {
  2516. return _this.to(index);
  2517. });
  2518. return;
  2519. }
  2520. if (activeIndex === index) {
  2521. this.pause();
  2522. this.cycle();
  2523. return;
  2524. }
  2525. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2526. this._slide(direction, this._items[index]);
  2527. };
  2528. _proto.dispose = function dispose() {
  2529. $(this._element).off(EVENT_KEY$2);
  2530. $.removeData(this._element, DATA_KEY$2);
  2531. this._items = null;
  2532. this._config = null;
  2533. this._element = null;
  2534. this._interval = null;
  2535. this._isPaused = null;
  2536. this._isSliding = null;
  2537. this._activeElement = null;
  2538. this._indicatorsElement = null;
  2539. } // Private
  2540. ;
  2541. _proto._getConfig = function _getConfig(config) {
  2542. config = _objectSpread2({}, Default, {}, config);
  2543. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2544. return config;
  2545. };
  2546. _proto._handleSwipe = function _handleSwipe() {
  2547. var absDeltax = Math.abs(this.touchDeltaX);
  2548. if (absDeltax <= SWIPE_THRESHOLD) {
  2549. return;
  2550. }
  2551. var direction = absDeltax / this.touchDeltaX;
  2552. this.touchDeltaX = 0; // swipe left
  2553. if (direction > 0) {
  2554. this.prev();
  2555. } // swipe right
  2556. if (direction < 0) {
  2557. this.next();
  2558. }
  2559. };
  2560. _proto._addEventListeners = function _addEventListeners() {
  2561. var _this2 = this;
  2562. if (this._config.keyboard) {
  2563. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2564. return _this2._keydown(event);
  2565. });
  2566. }
  2567. if (this._config.pause === 'hover') {
  2568. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2569. return _this2.pause(event);
  2570. }).on(Event$2.MOUSELEAVE, function (event) {
  2571. return _this2.cycle(event);
  2572. });
  2573. }
  2574. if (this._config.touch) {
  2575. this._addTouchEventListeners();
  2576. }
  2577. };
  2578. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2579. var _this3 = this;
  2580. if (!this._touchSupported) {
  2581. return;
  2582. }
  2583. var start = function start(event) {
  2584. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2585. _this3.touchStartX = event.originalEvent.clientX;
  2586. } else if (!_this3._pointerEvent) {
  2587. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2588. }
  2589. };
  2590. var move = function move(event) {
  2591. // ensure swiping with one touch and not pinching
  2592. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2593. _this3.touchDeltaX = 0;
  2594. } else {
  2595. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2596. }
  2597. };
  2598. var end = function end(event) {
  2599. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2600. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2601. }
  2602. _this3._handleSwipe();
  2603. if (_this3._config.pause === 'hover') {
  2604. // If it's a touch-enabled device, mouseenter/leave are fired as
  2605. // part of the mouse compatibility events on first tap - the carousel
  2606. // would stop cycling until user tapped out of it;
  2607. // here, we listen for touchend, explicitly pause the carousel
  2608. // (as if it's the second time we tap on it, mouseenter compat event
  2609. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2610. // events to fire) we explicitly restart cycling
  2611. _this3.pause();
  2612. if (_this3.touchTimeout) {
  2613. clearTimeout(_this3.touchTimeout);
  2614. }
  2615. _this3.touchTimeout = setTimeout(function (event) {
  2616. return _this3.cycle(event);
  2617. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2618. }
  2619. };
  2620. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2621. return e.preventDefault();
  2622. });
  2623. if (this._pointerEvent) {
  2624. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2625. return start(event);
  2626. });
  2627. $(this._element).on(Event$2.POINTERUP, function (event) {
  2628. return end(event);
  2629. });
  2630. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2631. } else {
  2632. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2633. return start(event);
  2634. });
  2635. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2636. return move(event);
  2637. });
  2638. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2639. return end(event);
  2640. });
  2641. }
  2642. };
  2643. _proto._keydown = function _keydown(event) {
  2644. if (/input|textarea/i.test(event.target.tagName)) {
  2645. return;
  2646. }
  2647. switch (event.which) {
  2648. case ARROW_LEFT_KEYCODE:
  2649. event.preventDefault();
  2650. this.prev();
  2651. break;
  2652. case ARROW_RIGHT_KEYCODE:
  2653. event.preventDefault();
  2654. this.next();
  2655. break;
  2656. }
  2657. };
  2658. _proto._getItemIndex = function _getItemIndex(element) {
  2659. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2660. return this._items.indexOf(element);
  2661. };
  2662. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2663. var isNextDirection = direction === Direction.NEXT;
  2664. var isPrevDirection = direction === Direction.PREV;
  2665. var activeIndex = this._getItemIndex(activeElement);
  2666. var lastItemIndex = this._items.length - 1;
  2667. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2668. if (isGoingToWrap && !this._config.wrap) {
  2669. return activeElement;
  2670. }
  2671. var delta = direction === Direction.PREV ? -1 : 1;
  2672. var itemIndex = (activeIndex + delta) % this._items.length;
  2673. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2674. };
  2675. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2676. var targetIndex = this._getItemIndex(relatedTarget);
  2677. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2678. var slideEvent = $.Event(Event$2.SLIDE, {
  2679. relatedTarget: relatedTarget,
  2680. direction: eventDirectionName,
  2681. from: fromIndex,
  2682. to: targetIndex
  2683. });
  2684. $(this._element).trigger(slideEvent);
  2685. return slideEvent;
  2686. };
  2687. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2688. if (this._indicatorsElement) {
  2689. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2690. $(indicators).removeClass(ClassName$2.ACTIVE);
  2691. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2692. if (nextIndicator) {
  2693. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2694. }
  2695. }
  2696. };
  2697. _proto._slide = function _slide(direction, element) {
  2698. var _this4 = this;
  2699. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2700. var activeElementIndex = this._getItemIndex(activeElement);
  2701. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2702. var nextElementIndex = this._getItemIndex(nextElement);
  2703. var isCycling = Boolean(this._interval);
  2704. var directionalClassName;
  2705. var orderClassName;
  2706. var eventDirectionName;
  2707. if (direction === Direction.NEXT) {
  2708. directionalClassName = ClassName$2.LEFT;
  2709. orderClassName = ClassName$2.NEXT;
  2710. eventDirectionName = Direction.LEFT;
  2711. } else {
  2712. directionalClassName = ClassName$2.RIGHT;
  2713. orderClassName = ClassName$2.PREV;
  2714. eventDirectionName = Direction.RIGHT;
  2715. }
  2716. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2717. this._isSliding = false;
  2718. return;
  2719. }
  2720. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2721. if (slideEvent.isDefaultPrevented()) {
  2722. return;
  2723. }
  2724. if (!activeElement || !nextElement) {
  2725. // Some weirdness is happening, so we bail
  2726. return;
  2727. }
  2728. this._isSliding = true;
  2729. if (isCycling) {
  2730. this.pause();
  2731. }
  2732. this._setActiveIndicatorElement(nextElement);
  2733. var slidEvent = $.Event(Event$2.SLID, {
  2734. relatedTarget: nextElement,
  2735. direction: eventDirectionName,
  2736. from: activeElementIndex,
  2737. to: nextElementIndex
  2738. });
  2739. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2740. $(nextElement).addClass(orderClassName);
  2741. Util.reflow(nextElement);
  2742. $(activeElement).addClass(directionalClassName);
  2743. $(nextElement).addClass(directionalClassName);
  2744. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2745. if (nextElementInterval) {
  2746. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2747. this._config.interval = nextElementInterval;
  2748. } else {
  2749. this._config.interval = this._config.defaultInterval || this._config.interval;
  2750. }
  2751. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2752. $(activeElement).one(Util.TRANSITION_END, function () {
  2753. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2754. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2755. _this4._isSliding = false;
  2756. setTimeout(function () {
  2757. return $(_this4._element).trigger(slidEvent);
  2758. }, 0);
  2759. }).emulateTransitionEnd(transitionDuration);
  2760. } else {
  2761. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2762. $(nextElement).addClass(ClassName$2.ACTIVE);
  2763. this._isSliding = false;
  2764. $(this._element).trigger(slidEvent);
  2765. }
  2766. if (isCycling) {
  2767. this.cycle();
  2768. }
  2769. } // Static
  2770. ;
  2771. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2772. return this.each(function () {
  2773. var data = $(this).data(DATA_KEY$2);
  2774. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2775. if (typeof config === 'object') {
  2776. _config = _objectSpread2({}, _config, {}, config);
  2777. }
  2778. var action = typeof config === 'string' ? config : _config.slide;
  2779. if (!data) {
  2780. data = new Carousel(this, _config);
  2781. $(this).data(DATA_KEY$2, data);
  2782. }
  2783. if (typeof config === 'number') {
  2784. data.to(config);
  2785. } else if (typeof action === 'string') {
  2786. if (typeof data[action] === 'undefined') {
  2787. throw new TypeError("No method named \"" + action + "\"");
  2788. }
  2789. data[action]();
  2790. } else if (_config.interval && _config.ride) {
  2791. data.pause();
  2792. data.cycle();
  2793. }
  2794. });
  2795. };
  2796. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2797. var selector = Util.getSelectorFromElement(this);
  2798. if (!selector) {
  2799. return;
  2800. }
  2801. var target = $(selector)[0];
  2802. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2803. return;
  2804. }
  2805. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2806. var slideIndex = this.getAttribute('data-slide-to');
  2807. if (slideIndex) {
  2808. config.interval = false;
  2809. }
  2810. Carousel._jQueryInterface.call($(target), config);
  2811. if (slideIndex) {
  2812. $(target).data(DATA_KEY$2).to(slideIndex);
  2813. }
  2814. event.preventDefault();
  2815. };
  2816. _createClass(Carousel, null, [{
  2817. key: "VERSION",
  2818. get: function get() {
  2819. return VERSION$2;
  2820. }
  2821. }, {
  2822. key: "Default",
  2823. get: function get() {
  2824. return Default;
  2825. }
  2826. }]);
  2827. return Carousel;
  2828. }();
  2829. /**
  2830. * ------------------------------------------------------------------------
  2831. * Data Api implementation
  2832. * ------------------------------------------------------------------------
  2833. */
  2834. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2835. $(window).on(Event$2.LOAD_DATA_API, function () {
  2836. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2837. for (var i = 0, len = carousels.length; i < len; i++) {
  2838. var $carousel = $(carousels[i]);
  2839. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2840. }
  2841. });
  2842. /**
  2843. * ------------------------------------------------------------------------
  2844. * jQuery
  2845. * ------------------------------------------------------------------------
  2846. */
  2847. $.fn[NAME$2] = Carousel._jQueryInterface;
  2848. $.fn[NAME$2].Constructor = Carousel;
  2849. $.fn[NAME$2].noConflict = function () {
  2850. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2851. return Carousel._jQueryInterface;
  2852. };
  2853. /**
  2854. * ------------------------------------------------------------------------
  2855. * Constants
  2856. * ------------------------------------------------------------------------
  2857. */
  2858. var NAME$3 = 'collapse';
  2859. var VERSION$3 = '4.4.1';
  2860. var DATA_KEY$3 = 'bs.collapse';
  2861. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2862. var DATA_API_KEY$3 = '.data-api';
  2863. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2864. var Default$1 = {
  2865. toggle: true,
  2866. parent: ''
  2867. };
  2868. var DefaultType$1 = {
  2869. toggle: 'boolean',
  2870. parent: '(string|element)'
  2871. };
  2872. var Event$3 = {
  2873. SHOW: "show" + EVENT_KEY$3,
  2874. SHOWN: "shown" + EVENT_KEY$3,
  2875. HIDE: "hide" + EVENT_KEY$3,
  2876. HIDDEN: "hidden" + EVENT_KEY$3,
  2877. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2878. };
  2879. var ClassName$3 = {
  2880. SHOW: 'show',
  2881. COLLAPSE: 'collapse',
  2882. COLLAPSING: 'collapsing',
  2883. COLLAPSED: 'collapsed'
  2884. };
  2885. var Dimension = {
  2886. WIDTH: 'width',
  2887. HEIGHT: 'height'
  2888. };
  2889. var Selector$3 = {
  2890. ACTIVES: '.show, .collapsing',
  2891. DATA_TOGGLE: '[data-toggle="collapse"]'
  2892. };
  2893. /**
  2894. * ------------------------------------------------------------------------
  2895. * Class Definition
  2896. * ------------------------------------------------------------------------
  2897. */
  2898. var Collapse =
  2899. /*#__PURE__*/
  2900. function () {
  2901. function Collapse(element, config) {
  2902. this._isTransitioning = false;
  2903. this._element = element;
  2904. this._config = this._getConfig(config);
  2905. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2906. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2907. for (var i = 0, len = toggleList.length; i < len; i++) {
  2908. var elem = toggleList[i];
  2909. var selector = Util.getSelectorFromElement(elem);
  2910. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2911. return foundElem === element;
  2912. });
  2913. if (selector !== null && filterElement.length > 0) {
  2914. this._selector = selector;
  2915. this._triggerArray.push(elem);
  2916. }
  2917. }
  2918. this._parent = this._config.parent ? this._getParent() : null;
  2919. if (!this._config.parent) {
  2920. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2921. }
  2922. if (this._config.toggle) {
  2923. this.toggle();
  2924. }
  2925. } // Getters
  2926. var _proto = Collapse.prototype;
  2927. // Public
  2928. _proto.toggle = function toggle() {
  2929. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2930. this.hide();
  2931. } else {
  2932. this.show();
  2933. }
  2934. };
  2935. _proto.show = function show() {
  2936. var _this = this;
  2937. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2938. return;
  2939. }
  2940. var actives;
  2941. var activesData;
  2942. if (this._parent) {
  2943. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2944. if (typeof _this._config.parent === 'string') {
  2945. return elem.getAttribute('data-parent') === _this._config.parent;
  2946. }
  2947. return elem.classList.contains(ClassName$3.COLLAPSE);
  2948. });
  2949. if (actives.length === 0) {
  2950. actives = null;
  2951. }
  2952. }
  2953. if (actives) {
  2954. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2955. if (activesData && activesData._isTransitioning) {
  2956. return;
  2957. }
  2958. }
  2959. var startEvent = $.Event(Event$3.SHOW);
  2960. $(this._element).trigger(startEvent);
  2961. if (startEvent.isDefaultPrevented()) {
  2962. return;
  2963. }
  2964. if (actives) {
  2965. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2966. if (!activesData) {
  2967. $(actives).data(DATA_KEY$3, null);
  2968. }
  2969. }
  2970. var dimension = this._getDimension();
  2971. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2972. this._element.style[dimension] = 0;
  2973. if (this._triggerArray.length) {
  2974. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2975. }
  2976. this.setTransitioning(true);
  2977. var complete = function complete() {
  2978. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2979. _this._element.style[dimension] = '';
  2980. _this.setTransitioning(false);
  2981. $(_this._element).trigger(Event$3.SHOWN);
  2982. };
  2983. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2984. var scrollSize = "scroll" + capitalizedDimension;
  2985. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2986. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2987. this._element.style[dimension] = this._element[scrollSize] + "px";
  2988. };
  2989. _proto.hide = function hide() {
  2990. var _this2 = this;
  2991. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2992. return;
  2993. }
  2994. var startEvent = $.Event(Event$3.HIDE);
  2995. $(this._element).trigger(startEvent);
  2996. if (startEvent.isDefaultPrevented()) {
  2997. return;
  2998. }
  2999. var dimension = this._getDimension();
  3000. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3001. Util.reflow(this._element);
  3002. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3003. var triggerArrayLength = this._triggerArray.length;
  3004. if (triggerArrayLength > 0) {
  3005. for (var i = 0; i < triggerArrayLength; i++) {
  3006. var trigger = this._triggerArray[i];
  3007. var selector = Util.getSelectorFromElement(trigger);
  3008. if (selector !== null) {
  3009. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3010. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3011. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3012. }
  3013. }
  3014. }
  3015. }
  3016. this.setTransitioning(true);
  3017. var complete = function complete() {
  3018. _this2.setTransitioning(false);
  3019. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3020. };
  3021. this._element.style[dimension] = '';
  3022. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3023. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3024. };
  3025. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3026. this._isTransitioning = isTransitioning;
  3027. };
  3028. _proto.dispose = function dispose() {
  3029. $.removeData(this._element, DATA_KEY$3);
  3030. this._config = null;
  3031. this._parent = null;
  3032. this._element = null;
  3033. this._triggerArray = null;
  3034. this._isTransitioning = null;
  3035. } // Private
  3036. ;
  3037. _proto._getConfig = function _getConfig(config) {
  3038. config = _objectSpread2({}, Default$1, {}, config);
  3039. config.toggle = Boolean(config.toggle); // Coerce string values
  3040. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3041. return config;
  3042. };
  3043. _proto._getDimension = function _getDimension() {
  3044. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3045. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3046. };
  3047. _proto._getParent = function _getParent() {
  3048. var _this3 = this;
  3049. var parent;
  3050. if (Util.isElement(this._config.parent)) {
  3051. parent = this._config.parent; // It's a jQuery object
  3052. if (typeof this._config.parent.jquery !== 'undefined') {
  3053. parent = this._config.parent[0];
  3054. }
  3055. } else {
  3056. parent = document.querySelector(this._config.parent);
  3057. }
  3058. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3059. var children = [].slice.call(parent.querySelectorAll(selector));
  3060. $(children).each(function (i, element) {
  3061. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3062. });
  3063. return parent;
  3064. };
  3065. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3066. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3067. if (triggerArray.length) {
  3068. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3069. }
  3070. } // Static
  3071. ;
  3072. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3073. var selector = Util.getSelectorFromElement(element);
  3074. return selector ? document.querySelector(selector) : null;
  3075. };
  3076. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3077. return this.each(function () {
  3078. var $this = $(this);
  3079. var data = $this.data(DATA_KEY$3);
  3080. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3081. if (!data && _config.toggle && /show|hide/.test(config)) {
  3082. _config.toggle = false;
  3083. }
  3084. if (!data) {
  3085. data = new Collapse(this, _config);
  3086. $this.data(DATA_KEY$3, data);
  3087. }
  3088. if (typeof config === 'string') {
  3089. if (typeof data[config] === 'undefined') {
  3090. throw new TypeError("No method named \"" + config + "\"");
  3091. }
  3092. data[config]();
  3093. }
  3094. });
  3095. };
  3096. _createClass(Collapse, null, [{
  3097. key: "VERSION",
  3098. get: function get() {
  3099. return VERSION$3;
  3100. }
  3101. }, {
  3102. key: "Default",
  3103. get: function get() {
  3104. return Default$1;
  3105. }
  3106. }]);
  3107. return Collapse;
  3108. }();
  3109. /**
  3110. * ------------------------------------------------------------------------
  3111. * Data Api implementation
  3112. * ------------------------------------------------------------------------
  3113. */
  3114. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3115. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3116. if (event.currentTarget.tagName === 'A') {
  3117. event.preventDefault();
  3118. }
  3119. var $trigger = $(this);
  3120. var selector = Util.getSelectorFromElement(this);
  3121. var selectors = [].slice.call(document.querySelectorAll(selector));
  3122. $(selectors).each(function () {
  3123. var $target = $(this);
  3124. var data = $target.data(DATA_KEY$3);
  3125. var config = data ? 'toggle' : $trigger.data();
  3126. Collapse._jQueryInterface.call($target, config);
  3127. });
  3128. });
  3129. /**
  3130. * ------------------------------------------------------------------------
  3131. * jQuery
  3132. * ------------------------------------------------------------------------
  3133. */
  3134. $.fn[NAME$3] = Collapse._jQueryInterface;
  3135. $.fn[NAME$3].Constructor = Collapse;
  3136. $.fn[NAME$3].noConflict = function () {
  3137. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3138. return Collapse._jQueryInterface;
  3139. };
  3140. /**
  3141. * ------------------------------------------------------------------------
  3142. * Constants
  3143. * ------------------------------------------------------------------------
  3144. */
  3145. var NAME$4 = 'dropdown';
  3146. var VERSION$4 = '4.4.1';
  3147. var DATA_KEY$4 = 'bs.dropdown';
  3148. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3149. var DATA_API_KEY$4 = '.data-api';
  3150. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3151. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3152. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3153. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3154. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3155. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3156. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3157. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3158. var Event$4 = {
  3159. HIDE: "hide" + EVENT_KEY$4,
  3160. HIDDEN: "hidden" + EVENT_KEY$4,
  3161. SHOW: "show" + EVENT_KEY$4,
  3162. SHOWN: "shown" + EVENT_KEY$4,
  3163. CLICK: "click" + EVENT_KEY$4,
  3164. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3165. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3166. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3167. };
  3168. var ClassName$4 = {
  3169. DISABLED: 'disabled',
  3170. SHOW: 'show',
  3171. DROPUP: 'dropup',
  3172. DROPRIGHT: 'dropright',
  3173. DROPLEFT: 'dropleft',
  3174. MENURIGHT: 'dropdown-menu-right',
  3175. MENULEFT: 'dropdown-menu-left',
  3176. POSITION_STATIC: 'position-static'
  3177. };
  3178. var Selector$4 = {
  3179. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3180. FORM_CHILD: '.dropdown form',
  3181. MENU: '.dropdown-menu',
  3182. NAVBAR_NAV: '.navbar-nav',
  3183. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3184. };
  3185. var AttachmentMap = {
  3186. TOP: 'top-start',
  3187. TOPEND: 'top-end',
  3188. BOTTOM: 'bottom-start',
  3189. BOTTOMEND: 'bottom-end',
  3190. RIGHT: 'right-start',
  3191. RIGHTEND: 'right-end',
  3192. LEFT: 'left-start',
  3193. LEFTEND: 'left-end'
  3194. };
  3195. var Default$2 = {
  3196. offset: 0,
  3197. flip: true,
  3198. boundary: 'scrollParent',
  3199. reference: 'toggle',
  3200. display: 'dynamic',
  3201. popperConfig: null
  3202. };
  3203. var DefaultType$2 = {
  3204. offset: '(number|string|function)',
  3205. flip: 'boolean',
  3206. boundary: '(string|element)',
  3207. reference: '(string|element)',
  3208. display: 'string',
  3209. popperConfig: '(null|object)'
  3210. };
  3211. /**
  3212. * ------------------------------------------------------------------------
  3213. * Class Definition
  3214. * ------------------------------------------------------------------------
  3215. */
  3216. var Dropdown =
  3217. /*#__PURE__*/
  3218. function () {
  3219. function Dropdown(element, config) {
  3220. this._element = element;
  3221. this._popper = null;
  3222. this._config = this._getConfig(config);
  3223. this._menu = this._getMenuElement();
  3224. this._inNavbar = this._detectNavbar();
  3225. this._addEventListeners();
  3226. } // Getters
  3227. var _proto = Dropdown.prototype;
  3228. // Public
  3229. _proto.toggle = function toggle() {
  3230. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3231. return;
  3232. }
  3233. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3234. Dropdown._clearMenus();
  3235. if (isActive) {
  3236. return;
  3237. }
  3238. this.show(true);
  3239. };
  3240. _proto.show = function show(usePopper) {
  3241. if (usePopper === void 0) {
  3242. usePopper = false;
  3243. }
  3244. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3245. return;
  3246. }
  3247. var relatedTarget = {
  3248. relatedTarget: this._element
  3249. };
  3250. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3251. var parent = Dropdown._getParentFromElement(this._element);
  3252. $(parent).trigger(showEvent);
  3253. if (showEvent.isDefaultPrevented()) {
  3254. return;
  3255. } // Disable totally Popper.js for Dropdown in Navbar
  3256. if (!this._inNavbar && usePopper) {
  3257. /**
  3258. * Check for Popper dependency
  3259. * Popper - https://popper.js.org
  3260. */
  3261. if (typeof Popper === 'undefined') {
  3262. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3263. }
  3264. var referenceElement = this._element;
  3265. if (this._config.reference === 'parent') {
  3266. referenceElement = parent;
  3267. } else if (Util.isElement(this._config.reference)) {
  3268. referenceElement = this._config.reference; // Check if it's jQuery element
  3269. if (typeof this._config.reference.jquery !== 'undefined') {
  3270. referenceElement = this._config.reference[0];
  3271. }
  3272. } // If boundary is not `scrollParent`, then set position to `static`
  3273. // to allow the menu to "escape" the scroll parent's boundaries
  3274. // https://github.com/twbs/bootstrap/issues/24251
  3275. if (this._config.boundary !== 'scrollParent') {
  3276. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3277. }
  3278. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3279. } // If this is a touch-enabled device we add extra
  3280. // empty mouseover listeners to the body's immediate children;
  3281. // only needed because of broken event delegation on iOS
  3282. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3283. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3284. $(document.body).children().on('mouseover', null, $.noop);
  3285. }
  3286. this._element.focus();
  3287. this._element.setAttribute('aria-expanded', true);
  3288. $(this._menu).toggleClass(ClassName$4.SHOW);
  3289. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3290. };
  3291. _proto.hide = function hide() {
  3292. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3293. return;
  3294. }
  3295. var relatedTarget = {
  3296. relatedTarget: this._element
  3297. };
  3298. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3299. var parent = Dropdown._getParentFromElement(this._element);
  3300. $(parent).trigger(hideEvent);
  3301. if (hideEvent.isDefaultPrevented()) {
  3302. return;
  3303. }
  3304. if (this._popper) {
  3305. this._popper.destroy();
  3306. }
  3307. $(this._menu).toggleClass(ClassName$4.SHOW);
  3308. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3309. };
  3310. _proto.dispose = function dispose() {
  3311. $.removeData(this._element, DATA_KEY$4);
  3312. $(this._element).off(EVENT_KEY$4);
  3313. this._element = null;
  3314. this._menu = null;
  3315. if (this._popper !== null) {
  3316. this._popper.destroy();
  3317. this._popper = null;
  3318. }
  3319. };
  3320. _proto.update = function update() {
  3321. this._inNavbar = this._detectNavbar();
  3322. if (this._popper !== null) {
  3323. this._popper.scheduleUpdate();
  3324. }
  3325. } // Private
  3326. ;
  3327. _proto._addEventListeners = function _addEventListeners() {
  3328. var _this = this;
  3329. $(this._element).on(Event$4.CLICK, function (event) {
  3330. event.preventDefault();
  3331. event.stopPropagation();
  3332. _this.toggle();
  3333. });
  3334. };
  3335. _proto._getConfig = function _getConfig(config) {
  3336. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3337. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3338. return config;
  3339. };
  3340. _proto._getMenuElement = function _getMenuElement() {
  3341. if (!this._menu) {
  3342. var parent = Dropdown._getParentFromElement(this._element);
  3343. if (parent) {
  3344. this._menu = parent.querySelector(Selector$4.MENU);
  3345. }
  3346. }
  3347. return this._menu;
  3348. };
  3349. _proto._getPlacement = function _getPlacement() {
  3350. var $parentDropdown = $(this._element.parentNode);
  3351. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3352. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3353. placement = AttachmentMap.TOP;
  3354. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3355. placement = AttachmentMap.TOPEND;
  3356. }
  3357. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3358. placement = AttachmentMap.RIGHT;
  3359. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3360. placement = AttachmentMap.LEFT;
  3361. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3362. placement = AttachmentMap.BOTTOMEND;
  3363. }
  3364. return placement;
  3365. };
  3366. _proto._detectNavbar = function _detectNavbar() {
  3367. return $(this._element).closest('.navbar').length > 0;
  3368. };
  3369. _proto._getOffset = function _getOffset() {
  3370. var _this2 = this;
  3371. var offset = {};
  3372. if (typeof this._config.offset === 'function') {
  3373. offset.fn = function (data) {
  3374. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3375. return data;
  3376. };
  3377. } else {
  3378. offset.offset = this._config.offset;
  3379. }
  3380. return offset;
  3381. };
  3382. _proto._getPopperConfig = function _getPopperConfig() {
  3383. var popperConfig = {
  3384. placement: this._getPlacement(),
  3385. modifiers: {
  3386. offset: this._getOffset(),
  3387. flip: {
  3388. enabled: this._config.flip
  3389. },
  3390. preventOverflow: {
  3391. boundariesElement: this._config.boundary
  3392. }
  3393. }
  3394. }; // Disable Popper.js if we have a static display
  3395. if (this._config.display === 'static') {
  3396. popperConfig.modifiers.applyStyle = {
  3397. enabled: false
  3398. };
  3399. }
  3400. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3401. } // Static
  3402. ;
  3403. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3404. return this.each(function () {
  3405. var data = $(this).data(DATA_KEY$4);
  3406. var _config = typeof config === 'object' ? config : null;
  3407. if (!data) {
  3408. data = new Dropdown(this, _config);
  3409. $(this).data(DATA_KEY$4, data);
  3410. }
  3411. if (typeof config === 'string') {
  3412. if (typeof data[config] === 'undefined') {
  3413. throw new TypeError("No method named \"" + config + "\"");
  3414. }
  3415. data[config]();
  3416. }
  3417. });
  3418. };
  3419. Dropdown._clearMenus = function _clearMenus(event) {
  3420. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3421. return;
  3422. }
  3423. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3424. for (var i = 0, len = toggles.length; i < len; i++) {
  3425. var parent = Dropdown._getParentFromElement(toggles[i]);
  3426. var context = $(toggles[i]).data(DATA_KEY$4);
  3427. var relatedTarget = {
  3428. relatedTarget: toggles[i]
  3429. };
  3430. if (event && event.type === 'click') {
  3431. relatedTarget.clickEvent = event;
  3432. }
  3433. if (!context) {
  3434. continue;
  3435. }
  3436. var dropdownMenu = context._menu;
  3437. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3438. continue;
  3439. }
  3440. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3441. continue;
  3442. }
  3443. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3444. $(parent).trigger(hideEvent);
  3445. if (hideEvent.isDefaultPrevented()) {
  3446. continue;
  3447. } // If this is a touch-enabled device we remove the extra
  3448. // empty mouseover listeners we added for iOS support
  3449. if ('ontouchstart' in document.documentElement) {
  3450. $(document.body).children().off('mouseover', null, $.noop);
  3451. }
  3452. toggles[i].setAttribute('aria-expanded', 'false');
  3453. if (context._popper) {
  3454. context._popper.destroy();
  3455. }
  3456. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3457. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3458. }
  3459. };
  3460. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3461. var parent;
  3462. var selector = Util.getSelectorFromElement(element);
  3463. if (selector) {
  3464. parent = document.querySelector(selector);
  3465. }
  3466. return parent || element.parentNode;
  3467. } // eslint-disable-next-line complexity
  3468. ;
  3469. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3470. // If not input/textarea:
  3471. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3472. // If input/textarea:
  3473. // - If space key => not a dropdown command
  3474. // - If key is other than escape
  3475. // - If key is not up or down => not a dropdown command
  3476. // - If trigger inside the menu => not a dropdown command
  3477. 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)) {
  3478. return;
  3479. }
  3480. event.preventDefault();
  3481. event.stopPropagation();
  3482. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3483. return;
  3484. }
  3485. var parent = Dropdown._getParentFromElement(this);
  3486. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3487. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3488. return;
  3489. }
  3490. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3491. if (event.which === ESCAPE_KEYCODE) {
  3492. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3493. $(toggle).trigger('focus');
  3494. }
  3495. $(this).trigger('click');
  3496. return;
  3497. }
  3498. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3499. return $(item).is(':visible');
  3500. });
  3501. if (items.length === 0) {
  3502. return;
  3503. }
  3504. var index = items.indexOf(event.target);
  3505. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3506. // Up
  3507. index--;
  3508. }
  3509. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3510. // Down
  3511. index++;
  3512. }
  3513. if (index < 0) {
  3514. index = 0;
  3515. }
  3516. items[index].focus();
  3517. };
  3518. _createClass(Dropdown, null, [{
  3519. key: "VERSION",
  3520. get: function get() {
  3521. return VERSION$4;
  3522. }
  3523. }, {
  3524. key: "Default",
  3525. get: function get() {
  3526. return Default$2;
  3527. }
  3528. }, {
  3529. key: "DefaultType",
  3530. get: function get() {
  3531. return DefaultType$2;
  3532. }
  3533. }]);
  3534. return Dropdown;
  3535. }();
  3536. /**
  3537. * ------------------------------------------------------------------------
  3538. * Data Api implementation
  3539. * ------------------------------------------------------------------------
  3540. */
  3541. $(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) {
  3542. event.preventDefault();
  3543. event.stopPropagation();
  3544. Dropdown._jQueryInterface.call($(this), 'toggle');
  3545. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3546. e.stopPropagation();
  3547. });
  3548. /**
  3549. * ------------------------------------------------------------------------
  3550. * jQuery
  3551. * ------------------------------------------------------------------------
  3552. */
  3553. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3554. $.fn[NAME$4].Constructor = Dropdown;
  3555. $.fn[NAME$4].noConflict = function () {
  3556. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3557. return Dropdown._jQueryInterface;
  3558. };
  3559. /**
  3560. * ------------------------------------------------------------------------
  3561. * Constants
  3562. * ------------------------------------------------------------------------
  3563. */
  3564. var NAME$5 = 'modal';
  3565. var VERSION$5 = '4.4.1';
  3566. var DATA_KEY$5 = 'bs.modal';
  3567. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3568. var DATA_API_KEY$5 = '.data-api';
  3569. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3570. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3571. var Default$3 = {
  3572. backdrop: true,
  3573. keyboard: true,
  3574. focus: true,
  3575. show: true
  3576. };
  3577. var DefaultType$3 = {
  3578. backdrop: '(boolean|string)',
  3579. keyboard: 'boolean',
  3580. focus: 'boolean',
  3581. show: 'boolean'
  3582. };
  3583. var Event$5 = {
  3584. HIDE: "hide" + EVENT_KEY$5,
  3585. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3586. HIDDEN: "hidden" + EVENT_KEY$5,
  3587. SHOW: "show" + EVENT_KEY$5,
  3588. SHOWN: "shown" + EVENT_KEY$5,
  3589. FOCUSIN: "focusin" + EVENT_KEY$5,
  3590. RESIZE: "resize" + EVENT_KEY$5,
  3591. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3592. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3593. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3594. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3595. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3596. };
  3597. var ClassName$5 = {
  3598. SCROLLABLE: 'modal-dialog-scrollable',
  3599. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3600. BACKDROP: 'modal-backdrop',
  3601. OPEN: 'modal-open',
  3602. FADE: 'fade',
  3603. SHOW: 'show',
  3604. STATIC: 'modal-static'
  3605. };
  3606. var Selector$5 = {
  3607. DIALOG: '.modal-dialog',
  3608. MODAL_BODY: '.modal-body',
  3609. DATA_TOGGLE: '[data-toggle="modal"]',
  3610. DATA_DISMISS: '[data-dismiss="modal"]',
  3611. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3612. STICKY_CONTENT: '.sticky-top'
  3613. };
  3614. /**
  3615. * ------------------------------------------------------------------------
  3616. * Class Definition
  3617. * ------------------------------------------------------------------------
  3618. */
  3619. var Modal =
  3620. /*#__PURE__*/
  3621. function () {
  3622. function Modal(element, config) {
  3623. this._config = this._getConfig(config);
  3624. this._element = element;
  3625. this._dialog = element.querySelector(Selector$5.DIALOG);
  3626. this._backdrop = null;
  3627. this._isShown = false;
  3628. this._isBodyOverflowing = false;
  3629. this._ignoreBackdropClick = false;
  3630. this._isTransitioning = false;
  3631. this._scrollbarWidth = 0;
  3632. } // Getters
  3633. var _proto = Modal.prototype;
  3634. // Public
  3635. _proto.toggle = function toggle(relatedTarget) {
  3636. return this._isShown ? this.hide() : this.show(relatedTarget);
  3637. };
  3638. _proto.show = function show(relatedTarget) {
  3639. var _this = this;
  3640. if (this._isShown || this._isTransitioning) {
  3641. return;
  3642. }
  3643. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3644. this._isTransitioning = true;
  3645. }
  3646. var showEvent = $.Event(Event$5.SHOW, {
  3647. relatedTarget: relatedTarget
  3648. });
  3649. $(this._element).trigger(showEvent);
  3650. if (this._isShown || showEvent.isDefaultPrevented()) {
  3651. return;
  3652. }
  3653. this._isShown = true;
  3654. this._checkScrollbar();
  3655. this._setScrollbar();
  3656. this._adjustDialog();
  3657. this._setEscapeEvent();
  3658. this._setResizeEvent();
  3659. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3660. return _this.hide(event);
  3661. });
  3662. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3663. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3664. if ($(event.target).is(_this._element)) {
  3665. _this._ignoreBackdropClick = true;
  3666. }
  3667. });
  3668. });
  3669. this._showBackdrop(function () {
  3670. return _this._showElement(relatedTarget);
  3671. });
  3672. };
  3673. _proto.hide = function hide(event) {
  3674. var _this2 = this;
  3675. if (event) {
  3676. event.preventDefault();
  3677. }
  3678. if (!this._isShown || this._isTransitioning) {
  3679. return;
  3680. }
  3681. var hideEvent = $.Event(Event$5.HIDE);
  3682. $(this._element).trigger(hideEvent);
  3683. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3684. return;
  3685. }
  3686. this._isShown = false;
  3687. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3688. if (transition) {
  3689. this._isTransitioning = true;
  3690. }
  3691. this._setEscapeEvent();
  3692. this._setResizeEvent();
  3693. $(document).off(Event$5.FOCUSIN);
  3694. $(this._element).removeClass(ClassName$5.SHOW);
  3695. $(this._element).off(Event$5.CLICK_DISMISS);
  3696. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3697. if (transition) {
  3698. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3699. $(this._element).one(Util.TRANSITION_END, function (event) {
  3700. return _this2._hideModal(event);
  3701. }).emulateTransitionEnd(transitionDuration);
  3702. } else {
  3703. this._hideModal();
  3704. }
  3705. };
  3706. _proto.dispose = function dispose() {
  3707. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3708. return $(htmlElement).off(EVENT_KEY$5);
  3709. });
  3710. /**
  3711. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3712. * Do not move `document` in `htmlElements` array
  3713. * It will remove `Event.CLICK_DATA_API` event that should remain
  3714. */
  3715. $(document).off(Event$5.FOCUSIN);
  3716. $.removeData(this._element, DATA_KEY$5);
  3717. this._config = null;
  3718. this._element = null;
  3719. this._dialog = null;
  3720. this._backdrop = null;
  3721. this._isShown = null;
  3722. this._isBodyOverflowing = null;
  3723. this._ignoreBackdropClick = null;
  3724. this._isTransitioning = null;
  3725. this._scrollbarWidth = null;
  3726. };
  3727. _proto.handleUpdate = function handleUpdate() {
  3728. this._adjustDialog();
  3729. } // Private
  3730. ;
  3731. _proto._getConfig = function _getConfig(config) {
  3732. config = _objectSpread2({}, Default$3, {}, config);
  3733. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3734. return config;
  3735. };
  3736. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3737. var _this3 = this;
  3738. if (this._config.backdrop === 'static') {
  3739. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3740. $(this._element).trigger(hideEventPrevented);
  3741. if (hideEventPrevented.defaultPrevented) {
  3742. return;
  3743. }
  3744. this._element.classList.add(ClassName$5.STATIC);
  3745. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3746. $(this._element).one(Util.TRANSITION_END, function () {
  3747. _this3._element.classList.remove(ClassName$5.STATIC);
  3748. }).emulateTransitionEnd(modalTransitionDuration);
  3749. this._element.focus();
  3750. } else {
  3751. this.hide();
  3752. }
  3753. };
  3754. _proto._showElement = function _showElement(relatedTarget) {
  3755. var _this4 = this;
  3756. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3757. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3758. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3759. // Don't move modal's DOM position
  3760. document.body.appendChild(this._element);
  3761. }
  3762. this._element.style.display = 'block';
  3763. this._element.removeAttribute('aria-hidden');
  3764. this._element.setAttribute('aria-modal', true);
  3765. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3766. modalBody.scrollTop = 0;
  3767. } else {
  3768. this._element.scrollTop = 0;
  3769. }
  3770. if (transition) {
  3771. Util.reflow(this._element);
  3772. }
  3773. $(this._element).addClass(ClassName$5.SHOW);
  3774. if (this._config.focus) {
  3775. this._enforceFocus();
  3776. }
  3777. var shownEvent = $.Event(Event$5.SHOWN, {
  3778. relatedTarget: relatedTarget
  3779. });
  3780. var transitionComplete = function transitionComplete() {
  3781. if (_this4._config.focus) {
  3782. _this4._element.focus();
  3783. }
  3784. _this4._isTransitioning = false;
  3785. $(_this4._element).trigger(shownEvent);
  3786. };
  3787. if (transition) {
  3788. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3789. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3790. } else {
  3791. transitionComplete();
  3792. }
  3793. };
  3794. _proto._enforceFocus = function _enforceFocus() {
  3795. var _this5 = this;
  3796. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3797. .on(Event$5.FOCUSIN, function (event) {
  3798. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3799. _this5._element.focus();
  3800. }
  3801. });
  3802. };
  3803. _proto._setEscapeEvent = function _setEscapeEvent() {
  3804. var _this6 = this;
  3805. if (this._isShown && this._config.keyboard) {
  3806. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3807. if (event.which === ESCAPE_KEYCODE$1) {
  3808. _this6._triggerBackdropTransition();
  3809. }
  3810. });
  3811. } else if (!this._isShown) {
  3812. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3813. }
  3814. };
  3815. _proto._setResizeEvent = function _setResizeEvent() {
  3816. var _this7 = this;
  3817. if (this._isShown) {
  3818. $(window).on(Event$5.RESIZE, function (event) {
  3819. return _this7.handleUpdate(event);
  3820. });
  3821. } else {
  3822. $(window).off(Event$5.RESIZE);
  3823. }
  3824. };
  3825. _proto._hideModal = function _hideModal() {
  3826. var _this8 = this;
  3827. this._element.style.display = 'none';
  3828. this._element.setAttribute('aria-hidden', true);
  3829. this._element.removeAttribute('aria-modal');
  3830. this._isTransitioning = false;
  3831. this._showBackdrop(function () {
  3832. $(document.body).removeClass(ClassName$5.OPEN);
  3833. _this8._resetAdjustments();
  3834. _this8._resetScrollbar();
  3835. $(_this8._element).trigger(Event$5.HIDDEN);
  3836. });
  3837. };
  3838. _proto._removeBackdrop = function _removeBackdrop() {
  3839. if (this._backdrop) {
  3840. $(this._backdrop).remove();
  3841. this._backdrop = null;
  3842. }
  3843. };
  3844. _proto._showBackdrop = function _showBackdrop(callback) {
  3845. var _this9 = this;
  3846. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3847. if (this._isShown && this._config.backdrop) {
  3848. this._backdrop = document.createElement('div');
  3849. this._backdrop.className = ClassName$5.BACKDROP;
  3850. if (animate) {
  3851. this._backdrop.classList.add(animate);
  3852. }
  3853. $(this._backdrop).appendTo(document.body);
  3854. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3855. if (_this9._ignoreBackdropClick) {
  3856. _this9._ignoreBackdropClick = false;
  3857. return;
  3858. }
  3859. if (event.target !== event.currentTarget) {
  3860. return;
  3861. }
  3862. _this9._triggerBackdropTransition();
  3863. });
  3864. if (animate) {
  3865. Util.reflow(this._backdrop);
  3866. }
  3867. $(this._backdrop).addClass(ClassName$5.SHOW);
  3868. if (!callback) {
  3869. return;
  3870. }
  3871. if (!animate) {
  3872. callback();
  3873. return;
  3874. }
  3875. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3876. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3877. } else if (!this._isShown && this._backdrop) {
  3878. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3879. var callbackRemove = function callbackRemove() {
  3880. _this9._removeBackdrop();
  3881. if (callback) {
  3882. callback();
  3883. }
  3884. };
  3885. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3886. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3887. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3888. } else {
  3889. callbackRemove();
  3890. }
  3891. } else if (callback) {
  3892. callback();
  3893. }
  3894. } // ----------------------------------------------------------------------
  3895. // the following methods are used to handle overflowing modals
  3896. // todo (fat): these should probably be refactored out of modal.js
  3897. // ----------------------------------------------------------------------
  3898. ;
  3899. _proto._adjustDialog = function _adjustDialog() {
  3900. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3901. if (!this._isBodyOverflowing && isModalOverflowing) {
  3902. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3903. }
  3904. if (this._isBodyOverflowing && !isModalOverflowing) {
  3905. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3906. }
  3907. };
  3908. _proto._resetAdjustments = function _resetAdjustments() {
  3909. this._element.style.paddingLeft = '';
  3910. this._element.style.paddingRight = '';
  3911. };
  3912. _proto._checkScrollbar = function _checkScrollbar() {
  3913. var rect = document.body.getBoundingClientRect();
  3914. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3915. this._scrollbarWidth = this._getScrollbarWidth();
  3916. };
  3917. _proto._setScrollbar = function _setScrollbar() {
  3918. var _this10 = this;
  3919. if (this._isBodyOverflowing) {
  3920. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3921. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3922. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3923. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3924. $(fixedContent).each(function (index, element) {
  3925. var actualPadding = element.style.paddingRight;
  3926. var calculatedPadding = $(element).css('padding-right');
  3927. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3928. }); // Adjust sticky content margin
  3929. $(stickyContent).each(function (index, element) {
  3930. var actualMargin = element.style.marginRight;
  3931. var calculatedMargin = $(element).css('margin-right');
  3932. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3933. }); // Adjust body padding
  3934. var actualPadding = document.body.style.paddingRight;
  3935. var calculatedPadding = $(document.body).css('padding-right');
  3936. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3937. }
  3938. $(document.body).addClass(ClassName$5.OPEN);
  3939. };
  3940. _proto._resetScrollbar = function _resetScrollbar() {
  3941. // Restore fixed content padding
  3942. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3943. $(fixedContent).each(function (index, element) {
  3944. var padding = $(element).data('padding-right');
  3945. $(element).removeData('padding-right');
  3946. element.style.paddingRight = padding ? padding : '';
  3947. }); // Restore sticky content
  3948. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3949. $(elements).each(function (index, element) {
  3950. var margin = $(element).data('margin-right');
  3951. if (typeof margin !== 'undefined') {
  3952. $(element).css('margin-right', margin).removeData('margin-right');
  3953. }
  3954. }); // Restore body padding
  3955. var padding = $(document.body).data('padding-right');
  3956. $(document.body).removeData('padding-right');
  3957. document.body.style.paddingRight = padding ? padding : '';
  3958. };
  3959. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3960. // thx d.walsh
  3961. var scrollDiv = document.createElement('div');
  3962. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3963. document.body.appendChild(scrollDiv);
  3964. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3965. document.body.removeChild(scrollDiv);
  3966. return scrollbarWidth;
  3967. } // Static
  3968. ;
  3969. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3970. return this.each(function () {
  3971. var data = $(this).data(DATA_KEY$5);
  3972. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3973. if (!data) {
  3974. data = new Modal(this, _config);
  3975. $(this).data(DATA_KEY$5, data);
  3976. }
  3977. if (typeof config === 'string') {
  3978. if (typeof data[config] === 'undefined') {
  3979. throw new TypeError("No method named \"" + config + "\"");
  3980. }
  3981. data[config](relatedTarget);
  3982. } else if (_config.show) {
  3983. data.show(relatedTarget);
  3984. }
  3985. });
  3986. };
  3987. _createClass(Modal, null, [{
  3988. key: "VERSION",
  3989. get: function get() {
  3990. return VERSION$5;
  3991. }
  3992. }, {
  3993. key: "Default",
  3994. get: function get() {
  3995. return Default$3;
  3996. }
  3997. }]);
  3998. return Modal;
  3999. }();
  4000. /**
  4001. * ------------------------------------------------------------------------
  4002. * Data Api implementation
  4003. * ------------------------------------------------------------------------
  4004. */
  4005. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4006. var _this11 = this;
  4007. var target;
  4008. var selector = Util.getSelectorFromElement(this);
  4009. if (selector) {
  4010. target = document.querySelector(selector);
  4011. }
  4012. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4013. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4014. event.preventDefault();
  4015. }
  4016. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4017. if (showEvent.isDefaultPrevented()) {
  4018. // Only register focus restorer if modal will actually get shown
  4019. return;
  4020. }
  4021. $target.one(Event$5.HIDDEN, function () {
  4022. if ($(_this11).is(':visible')) {
  4023. _this11.focus();
  4024. }
  4025. });
  4026. });
  4027. Modal._jQueryInterface.call($(target), config, this);
  4028. });
  4029. /**
  4030. * ------------------------------------------------------------------------
  4031. * jQuery
  4032. * ------------------------------------------------------------------------
  4033. */
  4034. $.fn[NAME$5] = Modal._jQueryInterface;
  4035. $.fn[NAME$5].Constructor = Modal;
  4036. $.fn[NAME$5].noConflict = function () {
  4037. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4038. return Modal._jQueryInterface;
  4039. };
  4040. /**
  4041. * --------------------------------------------------------------------------
  4042. * Bootstrap (v4.4.1): tools/sanitizer.js
  4043. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4044. * --------------------------------------------------------------------------
  4045. */
  4046. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4047. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4048. var DefaultWhitelist = {
  4049. // Global attributes allowed on any supplied element below.
  4050. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4051. a: ['target', 'href', 'title', 'rel'],
  4052. area: [],
  4053. b: [],
  4054. br: [],
  4055. col: [],
  4056. code: [],
  4057. div: [],
  4058. em: [],
  4059. hr: [],
  4060. h1: [],
  4061. h2: [],
  4062. h3: [],
  4063. h4: [],
  4064. h5: [],
  4065. h6: [],
  4066. i: [],
  4067. img: ['src', 'alt', 'title', 'width', 'height'],
  4068. li: [],
  4069. ol: [],
  4070. p: [],
  4071. pre: [],
  4072. s: [],
  4073. small: [],
  4074. span: [],
  4075. sub: [],
  4076. sup: [],
  4077. strong: [],
  4078. u: [],
  4079. ul: []
  4080. };
  4081. /**
  4082. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4083. *
  4084. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4085. */
  4086. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4087. /**
  4088. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4089. *
  4090. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4091. */
  4092. 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;
  4093. function allowedAttribute(attr, allowedAttributeList) {
  4094. var attrName = attr.nodeName.toLowerCase();
  4095. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4096. if (uriAttrs.indexOf(attrName) !== -1) {
  4097. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4098. }
  4099. return true;
  4100. }
  4101. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4102. return attrRegex instanceof RegExp;
  4103. }); // Check if a regular expression validates the attribute.
  4104. for (var i = 0, l = regExp.length; i < l; i++) {
  4105. if (attrName.match(regExp[i])) {
  4106. return true;
  4107. }
  4108. }
  4109. return false;
  4110. }
  4111. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4112. if (unsafeHtml.length === 0) {
  4113. return unsafeHtml;
  4114. }
  4115. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4116. return sanitizeFn(unsafeHtml);
  4117. }
  4118. var domParser = new window.DOMParser();
  4119. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4120. var whitelistKeys = Object.keys(whiteList);
  4121. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4122. var _loop = function _loop(i, len) {
  4123. var el = elements[i];
  4124. var elName = el.nodeName.toLowerCase();
  4125. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4126. el.parentNode.removeChild(el);
  4127. return "continue";
  4128. }
  4129. var attributeList = [].slice.call(el.attributes);
  4130. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4131. attributeList.forEach(function (attr) {
  4132. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4133. el.removeAttribute(attr.nodeName);
  4134. }
  4135. });
  4136. };
  4137. for (var i = 0, len = elements.length; i < len; i++) {
  4138. var _ret = _loop(i);
  4139. if (_ret === "continue") continue;
  4140. }
  4141. return createdDocument.body.innerHTML;
  4142. }
  4143. /**
  4144. * ------------------------------------------------------------------------
  4145. * Constants
  4146. * ------------------------------------------------------------------------
  4147. */
  4148. var NAME$6 = 'tooltip';
  4149. var VERSION$6 = '4.4.1';
  4150. var DATA_KEY$6 = 'bs.tooltip';
  4151. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4152. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4153. var CLASS_PREFIX = 'bs-tooltip';
  4154. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4155. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4156. var DefaultType$4 = {
  4157. animation: 'boolean',
  4158. template: 'string',
  4159. title: '(string|element|function)',
  4160. trigger: 'string',
  4161. delay: '(number|object)',
  4162. html: 'boolean',
  4163. selector: '(string|boolean)',
  4164. placement: '(string|function)',
  4165. offset: '(number|string|function)',
  4166. container: '(string|element|boolean)',
  4167. fallbackPlacement: '(string|array)',
  4168. boundary: '(string|element)',
  4169. sanitize: 'boolean',
  4170. sanitizeFn: '(null|function)',
  4171. whiteList: 'object',
  4172. popperConfig: '(null|object)'
  4173. };
  4174. var AttachmentMap$1 = {
  4175. AUTO: 'auto',
  4176. TOP: 'top',
  4177. RIGHT: 'right',
  4178. BOTTOM: 'bottom',
  4179. LEFT: 'left'
  4180. };
  4181. var Default$4 = {
  4182. animation: true,
  4183. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4184. trigger: 'hover focus',
  4185. title: '',
  4186. delay: 0,
  4187. html: false,
  4188. selector: false,
  4189. placement: 'top',
  4190. offset: 0,
  4191. container: false,
  4192. fallbackPlacement: 'flip',
  4193. boundary: 'scrollParent',
  4194. sanitize: true,
  4195. sanitizeFn: null,
  4196. whiteList: DefaultWhitelist,
  4197. popperConfig: null
  4198. };
  4199. var HoverState = {
  4200. SHOW: 'show',
  4201. OUT: 'out'
  4202. };
  4203. var Event$6 = {
  4204. HIDE: "hide" + EVENT_KEY$6,
  4205. HIDDEN: "hidden" + EVENT_KEY$6,
  4206. SHOW: "show" + EVENT_KEY$6,
  4207. SHOWN: "shown" + EVENT_KEY$6,
  4208. INSERTED: "inserted" + EVENT_KEY$6,
  4209. CLICK: "click" + EVENT_KEY$6,
  4210. FOCUSIN: "focusin" + EVENT_KEY$6,
  4211. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4212. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4213. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4214. };
  4215. var ClassName$6 = {
  4216. FADE: 'fade',
  4217. SHOW: 'show'
  4218. };
  4219. var Selector$6 = {
  4220. TOOLTIP: '.tooltip',
  4221. TOOLTIP_INNER: '.tooltip-inner',
  4222. ARROW: '.arrow'
  4223. };
  4224. var Trigger = {
  4225. HOVER: 'hover',
  4226. FOCUS: 'focus',
  4227. CLICK: 'click',
  4228. MANUAL: 'manual'
  4229. };
  4230. /**
  4231. * ------------------------------------------------------------------------
  4232. * Class Definition
  4233. * ------------------------------------------------------------------------
  4234. */
  4235. var Tooltip =
  4236. /*#__PURE__*/
  4237. function () {
  4238. function Tooltip(element, config) {
  4239. if (typeof Popper === 'undefined') {
  4240. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4241. } // private
  4242. this._isEnabled = true;
  4243. this._timeout = 0;
  4244. this._hoverState = '';
  4245. this._activeTrigger = {};
  4246. this._popper = null; // Protected
  4247. this.element = element;
  4248. this.config = this._getConfig(config);
  4249. this.tip = null;
  4250. this._setListeners();
  4251. } // Getters
  4252. var _proto = Tooltip.prototype;
  4253. // Public
  4254. _proto.enable = function enable() {
  4255. this._isEnabled = true;
  4256. };
  4257. _proto.disable = function disable() {
  4258. this._isEnabled = false;
  4259. };
  4260. _proto.toggleEnabled = function toggleEnabled() {
  4261. this._isEnabled = !this._isEnabled;
  4262. };
  4263. _proto.toggle = function toggle(event) {
  4264. if (!this._isEnabled) {
  4265. return;
  4266. }
  4267. if (event) {
  4268. var dataKey = this.constructor.DATA_KEY;
  4269. var context = $(event.currentTarget).data(dataKey);
  4270. if (!context) {
  4271. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4272. $(event.currentTarget).data(dataKey, context);
  4273. }
  4274. context._activeTrigger.click = !context._activeTrigger.click;
  4275. if (context._isWithActiveTrigger()) {
  4276. context._enter(null, context);
  4277. } else {
  4278. context._leave(null, context);
  4279. }
  4280. } else {
  4281. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4282. this._leave(null, this);
  4283. return;
  4284. }
  4285. this._enter(null, this);
  4286. }
  4287. };
  4288. _proto.dispose = function dispose() {
  4289. clearTimeout(this._timeout);
  4290. $.removeData(this.element, this.constructor.DATA_KEY);
  4291. $(this.element).off(this.constructor.EVENT_KEY);
  4292. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4293. if (this.tip) {
  4294. $(this.tip).remove();
  4295. }
  4296. this._isEnabled = null;
  4297. this._timeout = null;
  4298. this._hoverState = null;
  4299. this._activeTrigger = null;
  4300. if (this._popper) {
  4301. this._popper.destroy();
  4302. }
  4303. this._popper = null;
  4304. this.element = null;
  4305. this.config = null;
  4306. this.tip = null;
  4307. };
  4308. _proto.show = function show() {
  4309. var _this = this;
  4310. if ($(this.element).css('display') === 'none') {
  4311. throw new Error('Please use show on visible elements');
  4312. }
  4313. var showEvent = $.Event(this.constructor.Event.SHOW);
  4314. if (this.isWithContent() && this._isEnabled) {
  4315. $(this.element).trigger(showEvent);
  4316. var shadowRoot = Util.findShadowRoot(this.element);
  4317. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4318. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4319. return;
  4320. }
  4321. var tip = this.getTipElement();
  4322. var tipId = Util.getUID(this.constructor.NAME);
  4323. tip.setAttribute('id', tipId);
  4324. this.element.setAttribute('aria-describedby', tipId);
  4325. this.setContent();
  4326. if (this.config.animation) {
  4327. $(tip).addClass(ClassName$6.FADE);
  4328. }
  4329. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4330. var attachment = this._getAttachment(placement);
  4331. this.addAttachmentClass(attachment);
  4332. var container = this._getContainer();
  4333. $(tip).data(this.constructor.DATA_KEY, this);
  4334. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4335. $(tip).appendTo(container);
  4336. }
  4337. $(this.element).trigger(this.constructor.Event.INSERTED);
  4338. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4339. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4340. // empty mouseover listeners to the body's immediate children;
  4341. // only needed because of broken event delegation on iOS
  4342. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4343. if ('ontouchstart' in document.documentElement) {
  4344. $(document.body).children().on('mouseover', null, $.noop);
  4345. }
  4346. var complete = function complete() {
  4347. if (_this.config.animation) {
  4348. _this._fixTransition();
  4349. }
  4350. var prevHoverState = _this._hoverState;
  4351. _this._hoverState = null;
  4352. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4353. if (prevHoverState === HoverState.OUT) {
  4354. _this._leave(null, _this);
  4355. }
  4356. };
  4357. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4358. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4359. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4360. } else {
  4361. complete();
  4362. }
  4363. }
  4364. };
  4365. _proto.hide = function hide(callback) {
  4366. var _this2 = this;
  4367. var tip = this.getTipElement();
  4368. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4369. var complete = function complete() {
  4370. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4371. tip.parentNode.removeChild(tip);
  4372. }
  4373. _this2._cleanTipClass();
  4374. _this2.element.removeAttribute('aria-describedby');
  4375. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4376. if (_this2._popper !== null) {
  4377. _this2._popper.destroy();
  4378. }
  4379. if (callback) {
  4380. callback();
  4381. }
  4382. };
  4383. $(this.element).trigger(hideEvent);
  4384. if (hideEvent.isDefaultPrevented()) {
  4385. return;
  4386. }
  4387. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4388. // empty mouseover listeners we added for iOS support
  4389. if ('ontouchstart' in document.documentElement) {
  4390. $(document.body).children().off('mouseover', null, $.noop);
  4391. }
  4392. this._activeTrigger[Trigger.CLICK] = false;
  4393. this._activeTrigger[Trigger.FOCUS] = false;
  4394. this._activeTrigger[Trigger.HOVER] = false;
  4395. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4396. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4397. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4398. } else {
  4399. complete();
  4400. }
  4401. this._hoverState = '';
  4402. };
  4403. _proto.update = function update() {
  4404. if (this._popper !== null) {
  4405. this._popper.scheduleUpdate();
  4406. }
  4407. } // Protected
  4408. ;
  4409. _proto.isWithContent = function isWithContent() {
  4410. return Boolean(this.getTitle());
  4411. };
  4412. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4413. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4414. };
  4415. _proto.getTipElement = function getTipElement() {
  4416. this.tip = this.tip || $(this.config.template)[0];
  4417. return this.tip;
  4418. };
  4419. _proto.setContent = function setContent() {
  4420. var tip = this.getTipElement();
  4421. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4422. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4423. };
  4424. _proto.setElementContent = function setElementContent($element, content) {
  4425. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4426. // Content is a DOM node or a jQuery
  4427. if (this.config.html) {
  4428. if (!$(content).parent().is($element)) {
  4429. $element.empty().append(content);
  4430. }
  4431. } else {
  4432. $element.text($(content).text());
  4433. }
  4434. return;
  4435. }
  4436. if (this.config.html) {
  4437. if (this.config.sanitize) {
  4438. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4439. }
  4440. $element.html(content);
  4441. } else {
  4442. $element.text(content);
  4443. }
  4444. };
  4445. _proto.getTitle = function getTitle() {
  4446. var title = this.element.getAttribute('data-original-title');
  4447. if (!title) {
  4448. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4449. }
  4450. return title;
  4451. } // Private
  4452. ;
  4453. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4454. var _this3 = this;
  4455. var defaultBsConfig = {
  4456. placement: attachment,
  4457. modifiers: {
  4458. offset: this._getOffset(),
  4459. flip: {
  4460. behavior: this.config.fallbackPlacement
  4461. },
  4462. arrow: {
  4463. element: Selector$6.ARROW
  4464. },
  4465. preventOverflow: {
  4466. boundariesElement: this.config.boundary
  4467. }
  4468. },
  4469. onCreate: function onCreate(data) {
  4470. if (data.originalPlacement !== data.placement) {
  4471. _this3._handlePopperPlacementChange(data);
  4472. }
  4473. },
  4474. onUpdate: function onUpdate(data) {
  4475. return _this3._handlePopperPlacementChange(data);
  4476. }
  4477. };
  4478. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4479. };
  4480. _proto._getOffset = function _getOffset() {
  4481. var _this4 = this;
  4482. var offset = {};
  4483. if (typeof this.config.offset === 'function') {
  4484. offset.fn = function (data) {
  4485. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4486. return data;
  4487. };
  4488. } else {
  4489. offset.offset = this.config.offset;
  4490. }
  4491. return offset;
  4492. };
  4493. _proto._getContainer = function _getContainer() {
  4494. if (this.config.container === false) {
  4495. return document.body;
  4496. }
  4497. if (Util.isElement(this.config.container)) {
  4498. return $(this.config.container);
  4499. }
  4500. return $(document).find(this.config.container);
  4501. };
  4502. _proto._getAttachment = function _getAttachment(placement) {
  4503. return AttachmentMap$1[placement.toUpperCase()];
  4504. };
  4505. _proto._setListeners = function _setListeners() {
  4506. var _this5 = this;
  4507. var triggers = this.config.trigger.split(' ');
  4508. triggers.forEach(function (trigger) {
  4509. if (trigger === 'click') {
  4510. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4511. return _this5.toggle(event);
  4512. });
  4513. } else if (trigger !== Trigger.MANUAL) {
  4514. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4515. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4516. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4517. return _this5._enter(event);
  4518. }).on(eventOut, _this5.config.selector, function (event) {
  4519. return _this5._leave(event);
  4520. });
  4521. }
  4522. });
  4523. this._hideModalHandler = function () {
  4524. if (_this5.element) {
  4525. _this5.hide();
  4526. }
  4527. };
  4528. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4529. if (this.config.selector) {
  4530. this.config = _objectSpread2({}, this.config, {
  4531. trigger: 'manual',
  4532. selector: ''
  4533. });
  4534. } else {
  4535. this._fixTitle();
  4536. }
  4537. };
  4538. _proto._fixTitle = function _fixTitle() {
  4539. var titleType = typeof this.element.getAttribute('data-original-title');
  4540. if (this.element.getAttribute('title') || titleType !== 'string') {
  4541. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4542. this.element.setAttribute('title', '');
  4543. }
  4544. };
  4545. _proto._enter = function _enter(event, context) {
  4546. var dataKey = this.constructor.DATA_KEY;
  4547. context = context || $(event.currentTarget).data(dataKey);
  4548. if (!context) {
  4549. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4550. $(event.currentTarget).data(dataKey, context);
  4551. }
  4552. if (event) {
  4553. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4554. }
  4555. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4556. context._hoverState = HoverState.SHOW;
  4557. return;
  4558. }
  4559. clearTimeout(context._timeout);
  4560. context._hoverState = HoverState.SHOW;
  4561. if (!context.config.delay || !context.config.delay.show) {
  4562. context.show();
  4563. return;
  4564. }
  4565. context._timeout = setTimeout(function () {
  4566. if (context._hoverState === HoverState.SHOW) {
  4567. context.show();
  4568. }
  4569. }, context.config.delay.show);
  4570. };
  4571. _proto._leave = function _leave(event, context) {
  4572. var dataKey = this.constructor.DATA_KEY;
  4573. context = context || $(event.currentTarget).data(dataKey);
  4574. if (!context) {
  4575. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4576. $(event.currentTarget).data(dataKey, context);
  4577. }
  4578. if (event) {
  4579. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4580. }
  4581. if (context._isWithActiveTrigger()) {
  4582. return;
  4583. }
  4584. clearTimeout(context._timeout);
  4585. context._hoverState = HoverState.OUT;
  4586. if (!context.config.delay || !context.config.delay.hide) {
  4587. context.hide();
  4588. return;
  4589. }
  4590. context._timeout = setTimeout(function () {
  4591. if (context._hoverState === HoverState.OUT) {
  4592. context.hide();
  4593. }
  4594. }, context.config.delay.hide);
  4595. };
  4596. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4597. for (var trigger in this._activeTrigger) {
  4598. if (this._activeTrigger[trigger]) {
  4599. return true;
  4600. }
  4601. }
  4602. return false;
  4603. };
  4604. _proto._getConfig = function _getConfig(config) {
  4605. var dataAttributes = $(this.element).data();
  4606. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4607. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4608. delete dataAttributes[dataAttr];
  4609. }
  4610. });
  4611. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4612. if (typeof config.delay === 'number') {
  4613. config.delay = {
  4614. show: config.delay,
  4615. hide: config.delay
  4616. };
  4617. }
  4618. if (typeof config.title === 'number') {
  4619. config.title = config.title.toString();
  4620. }
  4621. if (typeof config.content === 'number') {
  4622. config.content = config.content.toString();
  4623. }
  4624. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4625. if (config.sanitize) {
  4626. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4627. }
  4628. return config;
  4629. };
  4630. _proto._getDelegateConfig = function _getDelegateConfig() {
  4631. var config = {};
  4632. if (this.config) {
  4633. for (var key in this.config) {
  4634. if (this.constructor.Default[key] !== this.config[key]) {
  4635. config[key] = this.config[key];
  4636. }
  4637. }
  4638. }
  4639. return config;
  4640. };
  4641. _proto._cleanTipClass = function _cleanTipClass() {
  4642. var $tip = $(this.getTipElement());
  4643. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4644. if (tabClass !== null && tabClass.length) {
  4645. $tip.removeClass(tabClass.join(''));
  4646. }
  4647. };
  4648. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4649. var popperInstance = popperData.instance;
  4650. this.tip = popperInstance.popper;
  4651. this._cleanTipClass();
  4652. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4653. };
  4654. _proto._fixTransition = function _fixTransition() {
  4655. var tip = this.getTipElement();
  4656. var initConfigAnimation = this.config.animation;
  4657. if (tip.getAttribute('x-placement') !== null) {
  4658. return;
  4659. }
  4660. $(tip).removeClass(ClassName$6.FADE);
  4661. this.config.animation = false;
  4662. this.hide();
  4663. this.show();
  4664. this.config.animation = initConfigAnimation;
  4665. } // Static
  4666. ;
  4667. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4668. return this.each(function () {
  4669. var data = $(this).data(DATA_KEY$6);
  4670. var _config = typeof config === 'object' && config;
  4671. if (!data && /dispose|hide/.test(config)) {
  4672. return;
  4673. }
  4674. if (!data) {
  4675. data = new Tooltip(this, _config);
  4676. $(this).data(DATA_KEY$6, data);
  4677. }
  4678. if (typeof config === 'string') {
  4679. if (typeof data[config] === 'undefined') {
  4680. throw new TypeError("No method named \"" + config + "\"");
  4681. }
  4682. data[config]();
  4683. }
  4684. });
  4685. };
  4686. _createClass(Tooltip, null, [{
  4687. key: "VERSION",
  4688. get: function get() {
  4689. return VERSION$6;
  4690. }
  4691. }, {
  4692. key: "Default",
  4693. get: function get() {
  4694. return Default$4;
  4695. }
  4696. }, {
  4697. key: "NAME",
  4698. get: function get() {
  4699. return NAME$6;
  4700. }
  4701. }, {
  4702. key: "DATA_KEY",
  4703. get: function get() {
  4704. return DATA_KEY$6;
  4705. }
  4706. }, {
  4707. key: "Event",
  4708. get: function get() {
  4709. return Event$6;
  4710. }
  4711. }, {
  4712. key: "EVENT_KEY",
  4713. get: function get() {
  4714. return EVENT_KEY$6;
  4715. }
  4716. }, {
  4717. key: "DefaultType",
  4718. get: function get() {
  4719. return DefaultType$4;
  4720. }
  4721. }]);
  4722. return Tooltip;
  4723. }();
  4724. /**
  4725. * ------------------------------------------------------------------------
  4726. * jQuery
  4727. * ------------------------------------------------------------------------
  4728. */
  4729. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4730. $.fn[NAME$6].Constructor = Tooltip;
  4731. $.fn[NAME$6].noConflict = function () {
  4732. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4733. return Tooltip._jQueryInterface;
  4734. };
  4735. /**
  4736. * ------------------------------------------------------------------------
  4737. * Constants
  4738. * ------------------------------------------------------------------------
  4739. */
  4740. var NAME$7 = 'popover';
  4741. var VERSION$7 = '4.4.1';
  4742. var DATA_KEY$7 = 'bs.popover';
  4743. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4744. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4745. var CLASS_PREFIX$1 = 'bs-popover';
  4746. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4747. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4748. placement: 'right',
  4749. trigger: 'click',
  4750. content: '',
  4751. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4752. });
  4753. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4754. content: '(string|element|function)'
  4755. });
  4756. var ClassName$7 = {
  4757. FADE: 'fade',
  4758. SHOW: 'show'
  4759. };
  4760. var Selector$7 = {
  4761. TITLE: '.popover-header',
  4762. CONTENT: '.popover-body'
  4763. };
  4764. var Event$7 = {
  4765. HIDE: "hide" + EVENT_KEY$7,
  4766. HIDDEN: "hidden" + EVENT_KEY$7,
  4767. SHOW: "show" + EVENT_KEY$7,
  4768. SHOWN: "shown" + EVENT_KEY$7,
  4769. INSERTED: "inserted" + EVENT_KEY$7,
  4770. CLICK: "click" + EVENT_KEY$7,
  4771. FOCUSIN: "focusin" + EVENT_KEY$7,
  4772. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4773. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4774. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4775. };
  4776. /**
  4777. * ------------------------------------------------------------------------
  4778. * Class Definition
  4779. * ------------------------------------------------------------------------
  4780. */
  4781. var Popover =
  4782. /*#__PURE__*/
  4783. function (_Tooltip) {
  4784. _inheritsLoose(Popover, _Tooltip);
  4785. function Popover() {
  4786. return _Tooltip.apply(this, arguments) || this;
  4787. }
  4788. var _proto = Popover.prototype;
  4789. // Overrides
  4790. _proto.isWithContent = function isWithContent() {
  4791. return this.getTitle() || this._getContent();
  4792. };
  4793. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4794. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4795. };
  4796. _proto.getTipElement = function getTipElement() {
  4797. this.tip = this.tip || $(this.config.template)[0];
  4798. return this.tip;
  4799. };
  4800. _proto.setContent = function setContent() {
  4801. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4802. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4803. var content = this._getContent();
  4804. if (typeof content === 'function') {
  4805. content = content.call(this.element);
  4806. }
  4807. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4808. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4809. } // Private
  4810. ;
  4811. _proto._getContent = function _getContent() {
  4812. return this.element.getAttribute('data-content') || this.config.content;
  4813. };
  4814. _proto._cleanTipClass = function _cleanTipClass() {
  4815. var $tip = $(this.getTipElement());
  4816. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4817. if (tabClass !== null && tabClass.length > 0) {
  4818. $tip.removeClass(tabClass.join(''));
  4819. }
  4820. } // Static
  4821. ;
  4822. Popover._jQueryInterface = function _jQueryInterface(config) {
  4823. return this.each(function () {
  4824. var data = $(this).data(DATA_KEY$7);
  4825. var _config = typeof config === 'object' ? config : null;
  4826. if (!data && /dispose|hide/.test(config)) {
  4827. return;
  4828. }
  4829. if (!data) {
  4830. data = new Popover(this, _config);
  4831. $(this).data(DATA_KEY$7, data);
  4832. }
  4833. if (typeof config === 'string') {
  4834. if (typeof data[config] === 'undefined') {
  4835. throw new TypeError("No method named \"" + config + "\"");
  4836. }
  4837. data[config]();
  4838. }
  4839. });
  4840. };
  4841. _createClass(Popover, null, [{
  4842. key: "VERSION",
  4843. // Getters
  4844. get: function get() {
  4845. return VERSION$7;
  4846. }
  4847. }, {
  4848. key: "Default",
  4849. get: function get() {
  4850. return Default$5;
  4851. }
  4852. }, {
  4853. key: "NAME",
  4854. get: function get() {
  4855. return NAME$7;
  4856. }
  4857. }, {
  4858. key: "DATA_KEY",
  4859. get: function get() {
  4860. return DATA_KEY$7;
  4861. }
  4862. }, {
  4863. key: "Event",
  4864. get: function get() {
  4865. return Event$7;
  4866. }
  4867. }, {
  4868. key: "EVENT_KEY",
  4869. get: function get() {
  4870. return EVENT_KEY$7;
  4871. }
  4872. }, {
  4873. key: "DefaultType",
  4874. get: function get() {
  4875. return DefaultType$5;
  4876. }
  4877. }]);
  4878. return Popover;
  4879. }(Tooltip);
  4880. /**
  4881. * ------------------------------------------------------------------------
  4882. * jQuery
  4883. * ------------------------------------------------------------------------
  4884. */
  4885. $.fn[NAME$7] = Popover._jQueryInterface;
  4886. $.fn[NAME$7].Constructor = Popover;
  4887. $.fn[NAME$7].noConflict = function () {
  4888. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4889. return Popover._jQueryInterface;
  4890. };
  4891. /**
  4892. * ------------------------------------------------------------------------
  4893. * Constants
  4894. * ------------------------------------------------------------------------
  4895. */
  4896. var NAME$8 = 'scrollspy';
  4897. var VERSION$8 = '4.4.1';
  4898. var DATA_KEY$8 = 'bs.scrollspy';
  4899. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4900. var DATA_API_KEY$6 = '.data-api';
  4901. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4902. var Default$6 = {
  4903. offset: 10,
  4904. method: 'auto',
  4905. target: ''
  4906. };
  4907. var DefaultType$6 = {
  4908. offset: 'number',
  4909. method: 'string',
  4910. target: '(string|element)'
  4911. };
  4912. var Event$8 = {
  4913. ACTIVATE: "activate" + EVENT_KEY$8,
  4914. SCROLL: "scroll" + EVENT_KEY$8,
  4915. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4916. };
  4917. var ClassName$8 = {
  4918. DROPDOWN_ITEM: 'dropdown-item',
  4919. DROPDOWN_MENU: 'dropdown-menu',
  4920. ACTIVE: 'active'
  4921. };
  4922. var Selector$8 = {
  4923. DATA_SPY: '[data-spy="scroll"]',
  4924. ACTIVE: '.active',
  4925. NAV_LIST_GROUP: '.nav, .list-group',
  4926. NAV_LINKS: '.nav-link',
  4927. NAV_ITEMS: '.nav-item',
  4928. LIST_ITEMS: '.list-group-item',
  4929. DROPDOWN: '.dropdown',
  4930. DROPDOWN_ITEMS: '.dropdown-item',
  4931. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4932. };
  4933. var OffsetMethod = {
  4934. OFFSET: 'offset',
  4935. POSITION: 'position'
  4936. };
  4937. /**
  4938. * ------------------------------------------------------------------------
  4939. * Class Definition
  4940. * ------------------------------------------------------------------------
  4941. */
  4942. var ScrollSpy =
  4943. /*#__PURE__*/
  4944. function () {
  4945. function ScrollSpy(element, config) {
  4946. var _this = this;
  4947. this._element = element;
  4948. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4949. this._config = this._getConfig(config);
  4950. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4951. this._offsets = [];
  4952. this._targets = [];
  4953. this._activeTarget = null;
  4954. this._scrollHeight = 0;
  4955. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4956. return _this._process(event);
  4957. });
  4958. this.refresh();
  4959. this._process();
  4960. } // Getters
  4961. var _proto = ScrollSpy.prototype;
  4962. // Public
  4963. _proto.refresh = function refresh() {
  4964. var _this2 = this;
  4965. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4966. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4967. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4968. this._offsets = [];
  4969. this._targets = [];
  4970. this._scrollHeight = this._getScrollHeight();
  4971. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4972. targets.map(function (element) {
  4973. var target;
  4974. var targetSelector = Util.getSelectorFromElement(element);
  4975. if (targetSelector) {
  4976. target = document.querySelector(targetSelector);
  4977. }
  4978. if (target) {
  4979. var targetBCR = target.getBoundingClientRect();
  4980. if (targetBCR.width || targetBCR.height) {
  4981. // TODO (fat): remove sketch reliance on jQuery position/offset
  4982. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4983. }
  4984. }
  4985. return null;
  4986. }).filter(function (item) {
  4987. return item;
  4988. }).sort(function (a, b) {
  4989. return a[0] - b[0];
  4990. }).forEach(function (item) {
  4991. _this2._offsets.push(item[0]);
  4992. _this2._targets.push(item[1]);
  4993. });
  4994. };
  4995. _proto.dispose = function dispose() {
  4996. $.removeData(this._element, DATA_KEY$8);
  4997. $(this._scrollElement).off(EVENT_KEY$8);
  4998. this._element = null;
  4999. this._scrollElement = null;
  5000. this._config = null;
  5001. this._selector = null;
  5002. this._offsets = null;
  5003. this._targets = null;
  5004. this._activeTarget = null;
  5005. this._scrollHeight = null;
  5006. } // Private
  5007. ;
  5008. _proto._getConfig = function _getConfig(config) {
  5009. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5010. if (typeof config.target !== 'string') {
  5011. var id = $(config.target).attr('id');
  5012. if (!id) {
  5013. id = Util.getUID(NAME$8);
  5014. $(config.target).attr('id', id);
  5015. }
  5016. config.target = "#" + id;
  5017. }
  5018. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5019. return config;
  5020. };
  5021. _proto._getScrollTop = function _getScrollTop() {
  5022. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5023. };
  5024. _proto._getScrollHeight = function _getScrollHeight() {
  5025. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5026. };
  5027. _proto._getOffsetHeight = function _getOffsetHeight() {
  5028. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5029. };
  5030. _proto._process = function _process() {
  5031. var scrollTop = this._getScrollTop() + this._config.offset;
  5032. var scrollHeight = this._getScrollHeight();
  5033. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5034. if (this._scrollHeight !== scrollHeight) {
  5035. this.refresh();
  5036. }
  5037. if (scrollTop >= maxScroll) {
  5038. var target = this._targets[this._targets.length - 1];
  5039. if (this._activeTarget !== target) {
  5040. this._activate(target);
  5041. }
  5042. return;
  5043. }
  5044. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5045. this._activeTarget = null;
  5046. this._clear();
  5047. return;
  5048. }
  5049. var offsetLength = this._offsets.length;
  5050. for (var i = offsetLength; i--;) {
  5051. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5052. if (isActiveTarget) {
  5053. this._activate(this._targets[i]);
  5054. }
  5055. }
  5056. };
  5057. _proto._activate = function _activate(target) {
  5058. this._activeTarget = target;
  5059. this._clear();
  5060. var queries = this._selector.split(',').map(function (selector) {
  5061. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5062. });
  5063. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5064. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5065. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5066. $link.addClass(ClassName$8.ACTIVE);
  5067. } else {
  5068. // Set triggered link as active
  5069. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5070. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5071. $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
  5072. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5073. }
  5074. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5075. relatedTarget: target
  5076. });
  5077. };
  5078. _proto._clear = function _clear() {
  5079. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5080. return node.classList.contains(ClassName$8.ACTIVE);
  5081. }).forEach(function (node) {
  5082. return node.classList.remove(ClassName$8.ACTIVE);
  5083. });
  5084. } // Static
  5085. ;
  5086. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5087. return this.each(function () {
  5088. var data = $(this).data(DATA_KEY$8);
  5089. var _config = typeof config === 'object' && config;
  5090. if (!data) {
  5091. data = new ScrollSpy(this, _config);
  5092. $(this).data(DATA_KEY$8, data);
  5093. }
  5094. if (typeof config === 'string') {
  5095. if (typeof data[config] === 'undefined') {
  5096. throw new TypeError("No method named \"" + config + "\"");
  5097. }
  5098. data[config]();
  5099. }
  5100. });
  5101. };
  5102. _createClass(ScrollSpy, null, [{
  5103. key: "VERSION",
  5104. get: function get() {
  5105. return VERSION$8;
  5106. }
  5107. }, {
  5108. key: "Default",
  5109. get: function get() {
  5110. return Default$6;
  5111. }
  5112. }]);
  5113. return ScrollSpy;
  5114. }();
  5115. /**
  5116. * ------------------------------------------------------------------------
  5117. * Data Api implementation
  5118. * ------------------------------------------------------------------------
  5119. */
  5120. $(window).on(Event$8.LOAD_DATA_API, function () {
  5121. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5122. var scrollSpysLength = scrollSpys.length;
  5123. for (var i = scrollSpysLength; i--;) {
  5124. var $spy = $(scrollSpys[i]);
  5125. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5126. }
  5127. });
  5128. /**
  5129. * ------------------------------------------------------------------------
  5130. * jQuery
  5131. * ------------------------------------------------------------------------
  5132. */
  5133. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5134. $.fn[NAME$8].Constructor = ScrollSpy;
  5135. $.fn[NAME$8].noConflict = function () {
  5136. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5137. return ScrollSpy._jQueryInterface;
  5138. };
  5139. /**
  5140. * ------------------------------------------------------------------------
  5141. * Constants
  5142. * ------------------------------------------------------------------------
  5143. */
  5144. var NAME$9 = 'tab';
  5145. var VERSION$9 = '4.4.1';
  5146. var DATA_KEY$9 = 'bs.tab';
  5147. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5148. var DATA_API_KEY$7 = '.data-api';
  5149. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5150. var Event$9 = {
  5151. HIDE: "hide" + EVENT_KEY$9,
  5152. HIDDEN: "hidden" + EVENT_KEY$9,
  5153. SHOW: "show" + EVENT_KEY$9,
  5154. SHOWN: "shown" + EVENT_KEY$9,
  5155. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5156. };
  5157. var ClassName$9 = {
  5158. DROPDOWN_MENU: 'dropdown-menu',
  5159. ACTIVE: 'active',
  5160. DISABLED: 'disabled',
  5161. FADE: 'fade',
  5162. SHOW: 'show'
  5163. };
  5164. var Selector$9 = {
  5165. DROPDOWN: '.dropdown',
  5166. NAV_LIST_GROUP: '.nav, .list-group',
  5167. ACTIVE: '.active',
  5168. ACTIVE_UL: '> li > .active',
  5169. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5170. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5171. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5172. };
  5173. /**
  5174. * ------------------------------------------------------------------------
  5175. * Class Definition
  5176. * ------------------------------------------------------------------------
  5177. */
  5178. var Tab =
  5179. /*#__PURE__*/
  5180. function () {
  5181. function Tab(element) {
  5182. this._element = element;
  5183. } // Getters
  5184. var _proto = Tab.prototype;
  5185. // Public
  5186. _proto.show = function show() {
  5187. var _this = this;
  5188. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5189. return;
  5190. }
  5191. var target;
  5192. var previous;
  5193. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5194. var selector = Util.getSelectorFromElement(this._element);
  5195. if (listElement) {
  5196. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5197. previous = $.makeArray($(listElement).find(itemSelector));
  5198. previous = previous[previous.length - 1];
  5199. }
  5200. var hideEvent = $.Event(Event$9.HIDE, {
  5201. relatedTarget: this._element
  5202. });
  5203. var showEvent = $.Event(Event$9.SHOW, {
  5204. relatedTarget: previous
  5205. });
  5206. if (previous) {
  5207. $(previous).trigger(hideEvent);
  5208. }
  5209. $(this._element).trigger(showEvent);
  5210. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5211. return;
  5212. }
  5213. if (selector) {
  5214. target = document.querySelector(selector);
  5215. }
  5216. this._activate(this._element, listElement);
  5217. var complete = function complete() {
  5218. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5219. relatedTarget: _this._element
  5220. });
  5221. var shownEvent = $.Event(Event$9.SHOWN, {
  5222. relatedTarget: previous
  5223. });
  5224. $(previous).trigger(hiddenEvent);
  5225. $(_this._element).trigger(shownEvent);
  5226. };
  5227. if (target) {
  5228. this._activate(target, target.parentNode, complete);
  5229. } else {
  5230. complete();
  5231. }
  5232. };
  5233. _proto.dispose = function dispose() {
  5234. $.removeData(this._element, DATA_KEY$9);
  5235. this._element = null;
  5236. } // Private
  5237. ;
  5238. _proto._activate = function _activate(element, container, callback) {
  5239. var _this2 = this;
  5240. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5241. var active = activeElements[0];
  5242. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5243. var complete = function complete() {
  5244. return _this2._transitionComplete(element, active, callback);
  5245. };
  5246. if (active && isTransitioning) {
  5247. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5248. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5249. } else {
  5250. complete();
  5251. }
  5252. };
  5253. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5254. if (active) {
  5255. $(active).removeClass(ClassName$9.ACTIVE);
  5256. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5257. if (dropdownChild) {
  5258. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5259. }
  5260. if (active.getAttribute('role') === 'tab') {
  5261. active.setAttribute('aria-selected', false);
  5262. }
  5263. }
  5264. $(element).addClass(ClassName$9.ACTIVE);
  5265. if (element.getAttribute('role') === 'tab') {
  5266. element.setAttribute('aria-selected', true);
  5267. }
  5268. Util.reflow(element);
  5269. if (element.classList.contains(ClassName$9.FADE)) {
  5270. element.classList.add(ClassName$9.SHOW);
  5271. }
  5272. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5273. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5274. if (dropdownElement) {
  5275. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5276. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5277. }
  5278. element.setAttribute('aria-expanded', true);
  5279. }
  5280. if (callback) {
  5281. callback();
  5282. }
  5283. } // Static
  5284. ;
  5285. Tab._jQueryInterface = function _jQueryInterface(config) {
  5286. return this.each(function () {
  5287. var $this = $(this);
  5288. var data = $this.data(DATA_KEY$9);
  5289. if (!data) {
  5290. data = new Tab(this);
  5291. $this.data(DATA_KEY$9, data);
  5292. }
  5293. if (typeof config === 'string') {
  5294. if (typeof data[config] === 'undefined') {
  5295. throw new TypeError("No method named \"" + config + "\"");
  5296. }
  5297. data[config]();
  5298. }
  5299. });
  5300. };
  5301. _createClass(Tab, null, [{
  5302. key: "VERSION",
  5303. get: function get() {
  5304. return VERSION$9;
  5305. }
  5306. }]);
  5307. return Tab;
  5308. }();
  5309. /**
  5310. * ------------------------------------------------------------------------
  5311. * Data Api implementation
  5312. * ------------------------------------------------------------------------
  5313. */
  5314. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5315. event.preventDefault();
  5316. Tab._jQueryInterface.call($(this), 'show');
  5317. });
  5318. /**
  5319. * ------------------------------------------------------------------------
  5320. * jQuery
  5321. * ------------------------------------------------------------------------
  5322. */
  5323. $.fn[NAME$9] = Tab._jQueryInterface;
  5324. $.fn[NAME$9].Constructor = Tab;
  5325. $.fn[NAME$9].noConflict = function () {
  5326. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5327. return Tab._jQueryInterface;
  5328. };
  5329. /**
  5330. * ------------------------------------------------------------------------
  5331. * Constants
  5332. * ------------------------------------------------------------------------
  5333. */
  5334. var NAME$a = 'toast';
  5335. var VERSION$a = '4.4.1';
  5336. var DATA_KEY$a = 'bs.toast';
  5337. var EVENT_KEY$a = "." + DATA_KEY$a;
  5338. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5339. var Event$a = {
  5340. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5341. HIDE: "hide" + EVENT_KEY$a,
  5342. HIDDEN: "hidden" + EVENT_KEY$a,
  5343. SHOW: "show" + EVENT_KEY$a,
  5344. SHOWN: "shown" + EVENT_KEY$a
  5345. };
  5346. var ClassName$a = {
  5347. FADE: 'fade',
  5348. HIDE: 'hide',
  5349. SHOW: 'show',
  5350. SHOWING: 'showing'
  5351. };
  5352. var DefaultType$7 = {
  5353. animation: 'boolean',
  5354. autohide: 'boolean',
  5355. delay: 'number'
  5356. };
  5357. var Default$7 = {
  5358. animation: true,
  5359. autohide: true,
  5360. delay: 500
  5361. };
  5362. var Selector$a = {
  5363. DATA_DISMISS: '[data-dismiss="toast"]'
  5364. };
  5365. /**
  5366. * ------------------------------------------------------------------------
  5367. * Class Definition
  5368. * ------------------------------------------------------------------------
  5369. */
  5370. var Toast =
  5371. /*#__PURE__*/
  5372. function () {
  5373. function Toast(element, config) {
  5374. this._element = element;
  5375. this._config = this._getConfig(config);
  5376. this._timeout = null;
  5377. this._setListeners();
  5378. } // Getters
  5379. var _proto = Toast.prototype;
  5380. // Public
  5381. _proto.show = function show() {
  5382. var _this = this;
  5383. var showEvent = $.Event(Event$a.SHOW);
  5384. $(this._element).trigger(showEvent);
  5385. if (showEvent.isDefaultPrevented()) {
  5386. return;
  5387. }
  5388. if (this._config.animation) {
  5389. this._element.classList.add(ClassName$a.FADE);
  5390. }
  5391. var complete = function complete() {
  5392. _this._element.classList.remove(ClassName$a.SHOWING);
  5393. _this._element.classList.add(ClassName$a.SHOW);
  5394. $(_this._element).trigger(Event$a.SHOWN);
  5395. if (_this._config.autohide) {
  5396. _this._timeout = setTimeout(function () {
  5397. _this.hide();
  5398. }, _this._config.delay);
  5399. }
  5400. };
  5401. this._element.classList.remove(ClassName$a.HIDE);
  5402. Util.reflow(this._element);
  5403. this._element.classList.add(ClassName$a.SHOWING);
  5404. if (this._config.animation) {
  5405. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5406. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5407. } else {
  5408. complete();
  5409. }
  5410. };
  5411. _proto.hide = function hide() {
  5412. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5413. return;
  5414. }
  5415. var hideEvent = $.Event(Event$a.HIDE);
  5416. $(this._element).trigger(hideEvent);
  5417. if (hideEvent.isDefaultPrevented()) {
  5418. return;
  5419. }
  5420. this._close();
  5421. };
  5422. _proto.dispose = function dispose() {
  5423. clearTimeout(this._timeout);
  5424. this._timeout = null;
  5425. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5426. this._element.classList.remove(ClassName$a.SHOW);
  5427. }
  5428. $(this._element).off(Event$a.CLICK_DISMISS);
  5429. $.removeData(this._element, DATA_KEY$a);
  5430. this._element = null;
  5431. this._config = null;
  5432. } // Private
  5433. ;
  5434. _proto._getConfig = function _getConfig(config) {
  5435. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5436. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5437. return config;
  5438. };
  5439. _proto._setListeners = function _setListeners() {
  5440. var _this2 = this;
  5441. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5442. return _this2.hide();
  5443. });
  5444. };
  5445. _proto._close = function _close() {
  5446. var _this3 = this;
  5447. var complete = function complete() {
  5448. _this3._element.classList.add(ClassName$a.HIDE);
  5449. $(_this3._element).trigger(Event$a.HIDDEN);
  5450. };
  5451. this._element.classList.remove(ClassName$a.SHOW);
  5452. if (this._config.animation) {
  5453. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5454. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5455. } else {
  5456. complete();
  5457. }
  5458. } // Static
  5459. ;
  5460. Toast._jQueryInterface = function _jQueryInterface(config) {
  5461. return this.each(function () {
  5462. var $element = $(this);
  5463. var data = $element.data(DATA_KEY$a);
  5464. var _config = typeof config === 'object' && config;
  5465. if (!data) {
  5466. data = new Toast(this, _config);
  5467. $element.data(DATA_KEY$a, data);
  5468. }
  5469. if (typeof config === 'string') {
  5470. if (typeof data[config] === 'undefined') {
  5471. throw new TypeError("No method named \"" + config + "\"");
  5472. }
  5473. data[config](this);
  5474. }
  5475. });
  5476. };
  5477. _createClass(Toast, null, [{
  5478. key: "VERSION",
  5479. get: function get() {
  5480. return VERSION$a;
  5481. }
  5482. }, {
  5483. key: "DefaultType",
  5484. get: function get() {
  5485. return DefaultType$7;
  5486. }
  5487. }, {
  5488. key: "Default",
  5489. get: function get() {
  5490. return Default$7;
  5491. }
  5492. }]);
  5493. return Toast;
  5494. }();
  5495. /**
  5496. * ------------------------------------------------------------------------
  5497. * jQuery
  5498. * ------------------------------------------------------------------------
  5499. */
  5500. $.fn[NAME$a] = Toast._jQueryInterface;
  5501. $.fn[NAME$a].Constructor = Toast;
  5502. $.fn[NAME$a].noConflict = function () {
  5503. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5504. return Toast._jQueryInterface;
  5505. };
  5506. exports.Alert = Alert;
  5507. exports.Button = Button;
  5508. exports.Carousel = Carousel;
  5509. exports.Collapse = Collapse;
  5510. exports.Dropdown = Dropdown;
  5511. exports.Modal = Modal;
  5512. exports.Popover = Popover;
  5513. exports.Scrollspy = ScrollSpy;
  5514. exports.Tab = Tab;
  5515. exports.Toast = Toast;
  5516. exports.Tooltip = Tooltip;
  5517. exports.Util = Util;
  5518. Object.defineProperty(exports, '__esModule', { value: true });
  5519. })));
  5520. //# sourceMappingURL=bootstrap.js.map
  5521. /***/ }),
  5522. /***/ "./node_modules/buffer/index.js":
  5523. /*!**************************************!*\
  5524. !*** ./node_modules/buffer/index.js ***!
  5525. \**************************************/
  5526. /*! no static exports found */
  5527. /***/ (function(module, exports, __webpack_require__) {
  5528. "use strict";
  5529. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5530. * The buffer module from node.js, for the browser.
  5531. *
  5532. * @author Feross Aboukhadijeh <http://feross.org>
  5533. * @license MIT
  5534. */
  5535. /* eslint-disable no-proto */
  5536. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5537. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5538. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5539. exports.Buffer = Buffer
  5540. exports.SlowBuffer = SlowBuffer
  5541. exports.INSPECT_MAX_BYTES = 50
  5542. /**
  5543. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5544. * === true Use Uint8Array implementation (fastest)
  5545. * === false Use Object implementation (most compatible, even IE6)
  5546. *
  5547. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5548. * Opera 11.6+, iOS 4.2+.
  5549. *
  5550. * Due to various browser bugs, sometimes the Object implementation will be used even
  5551. * when the browser supports typed arrays.
  5552. *
  5553. * Note:
  5554. *
  5555. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5556. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5557. *
  5558. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5559. *
  5560. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5561. * incorrect length in some situations.
  5562. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5563. * get the Object implementation, which is slower but behaves correctly.
  5564. */
  5565. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5566. ? global.TYPED_ARRAY_SUPPORT
  5567. : typedArraySupport()
  5568. /*
  5569. * Export kMaxLength after typed array support is determined.
  5570. */
  5571. exports.kMaxLength = kMaxLength()
  5572. function typedArraySupport () {
  5573. try {
  5574. var arr = new Uint8Array(1)
  5575. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5576. return arr.foo() === 42 && // typed array instances can be augmented
  5577. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5578. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5579. } catch (e) {
  5580. return false
  5581. }
  5582. }
  5583. function kMaxLength () {
  5584. return Buffer.TYPED_ARRAY_SUPPORT
  5585. ? 0x7fffffff
  5586. : 0x3fffffff
  5587. }
  5588. function createBuffer (that, length) {
  5589. if (kMaxLength() < length) {
  5590. throw new RangeError('Invalid typed array length')
  5591. }
  5592. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5593. // Return an augmented `Uint8Array` instance, for best performance
  5594. that = new Uint8Array(length)
  5595. that.__proto__ = Buffer.prototype
  5596. } else {
  5597. // Fallback: Return an object instance of the Buffer class
  5598. if (that === null) {
  5599. that = new Buffer(length)
  5600. }
  5601. that.length = length
  5602. }
  5603. return that
  5604. }
  5605. /**
  5606. * The Buffer constructor returns instances of `Uint8Array` that have their
  5607. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5608. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5609. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5610. * returns a single octet.
  5611. *
  5612. * The `Uint8Array` prototype remains unmodified.
  5613. */
  5614. function Buffer (arg, encodingOrOffset, length) {
  5615. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5616. return new Buffer(arg, encodingOrOffset, length)
  5617. }
  5618. // Common case.
  5619. if (typeof arg === 'number') {
  5620. if (typeof encodingOrOffset === 'string') {
  5621. throw new Error(
  5622. 'If encoding is specified then the first argument must be a string'
  5623. )
  5624. }
  5625. return allocUnsafe(this, arg)
  5626. }
  5627. return from(this, arg, encodingOrOffset, length)
  5628. }
  5629. Buffer.poolSize = 8192 // not used by this implementation
  5630. // TODO: Legacy, not needed anymore. Remove in next major version.
  5631. Buffer._augment = function (arr) {
  5632. arr.__proto__ = Buffer.prototype
  5633. return arr
  5634. }
  5635. function from (that, value, encodingOrOffset, length) {
  5636. if (typeof value === 'number') {
  5637. throw new TypeError('"value" argument must not be a number')
  5638. }
  5639. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5640. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5641. }
  5642. if (typeof value === 'string') {
  5643. return fromString(that, value, encodingOrOffset)
  5644. }
  5645. return fromObject(that, value)
  5646. }
  5647. /**
  5648. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5649. * if value is a number.
  5650. * Buffer.from(str[, encoding])
  5651. * Buffer.from(array)
  5652. * Buffer.from(buffer)
  5653. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5654. **/
  5655. Buffer.from = function (value, encodingOrOffset, length) {
  5656. return from(null, value, encodingOrOffset, length)
  5657. }
  5658. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5659. Buffer.prototype.__proto__ = Uint8Array.prototype
  5660. Buffer.__proto__ = Uint8Array
  5661. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5662. Buffer[Symbol.species] === Buffer) {
  5663. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5664. Object.defineProperty(Buffer, Symbol.species, {
  5665. value: null,
  5666. configurable: true
  5667. })
  5668. }
  5669. }
  5670. function assertSize (size) {
  5671. if (typeof size !== 'number') {
  5672. throw new TypeError('"size" argument must be a number')
  5673. } else if (size < 0) {
  5674. throw new RangeError('"size" argument must not be negative')
  5675. }
  5676. }
  5677. function alloc (that, size, fill, encoding) {
  5678. assertSize(size)
  5679. if (size <= 0) {
  5680. return createBuffer(that, size)
  5681. }
  5682. if (fill !== undefined) {
  5683. // Only pay attention to encoding if it's a string. This
  5684. // prevents accidentally sending in a number that would
  5685. // be interpretted as a start offset.
  5686. return typeof encoding === 'string'
  5687. ? createBuffer(that, size).fill(fill, encoding)
  5688. : createBuffer(that, size).fill(fill)
  5689. }
  5690. return createBuffer(that, size)
  5691. }
  5692. /**
  5693. * Creates a new filled Buffer instance.
  5694. * alloc(size[, fill[, encoding]])
  5695. **/
  5696. Buffer.alloc = function (size, fill, encoding) {
  5697. return alloc(null, size, fill, encoding)
  5698. }
  5699. function allocUnsafe (that, size) {
  5700. assertSize(size)
  5701. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5702. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5703. for (var i = 0; i < size; ++i) {
  5704. that[i] = 0
  5705. }
  5706. }
  5707. return that
  5708. }
  5709. /**
  5710. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5711. * */
  5712. Buffer.allocUnsafe = function (size) {
  5713. return allocUnsafe(null, size)
  5714. }
  5715. /**
  5716. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5717. */
  5718. Buffer.allocUnsafeSlow = function (size) {
  5719. return allocUnsafe(null, size)
  5720. }
  5721. function fromString (that, string, encoding) {
  5722. if (typeof encoding !== 'string' || encoding === '') {
  5723. encoding = 'utf8'
  5724. }
  5725. if (!Buffer.isEncoding(encoding)) {
  5726. throw new TypeError('"encoding" must be a valid string encoding')
  5727. }
  5728. var length = byteLength(string, encoding) | 0
  5729. that = createBuffer(that, length)
  5730. var actual = that.write(string, encoding)
  5731. if (actual !== length) {
  5732. // Writing a hex string, for example, that contains invalid characters will
  5733. // cause everything after the first invalid character to be ignored. (e.g.
  5734. // 'abxxcd' will be treated as 'ab')
  5735. that = that.slice(0, actual)
  5736. }
  5737. return that
  5738. }
  5739. function fromArrayLike (that, array) {
  5740. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5741. that = createBuffer(that, length)
  5742. for (var i = 0; i < length; i += 1) {
  5743. that[i] = array[i] & 255
  5744. }
  5745. return that
  5746. }
  5747. function fromArrayBuffer (that, array, byteOffset, length) {
  5748. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5749. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5750. throw new RangeError('\'offset\' is out of bounds')
  5751. }
  5752. if (array.byteLength < byteOffset + (length || 0)) {
  5753. throw new RangeError('\'length\' is out of bounds')
  5754. }
  5755. if (byteOffset === undefined && length === undefined) {
  5756. array = new Uint8Array(array)
  5757. } else if (length === undefined) {
  5758. array = new Uint8Array(array, byteOffset)
  5759. } else {
  5760. array = new Uint8Array(array, byteOffset, length)
  5761. }
  5762. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5763. // Return an augmented `Uint8Array` instance, for best performance
  5764. that = array
  5765. that.__proto__ = Buffer.prototype
  5766. } else {
  5767. // Fallback: Return an object instance of the Buffer class
  5768. that = fromArrayLike(that, array)
  5769. }
  5770. return that
  5771. }
  5772. function fromObject (that, obj) {
  5773. if (Buffer.isBuffer(obj)) {
  5774. var len = checked(obj.length) | 0
  5775. that = createBuffer(that, len)
  5776. if (that.length === 0) {
  5777. return that
  5778. }
  5779. obj.copy(that, 0, 0, len)
  5780. return that
  5781. }
  5782. if (obj) {
  5783. if ((typeof ArrayBuffer !== 'undefined' &&
  5784. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5785. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5786. return createBuffer(that, 0)
  5787. }
  5788. return fromArrayLike(that, obj)
  5789. }
  5790. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5791. return fromArrayLike(that, obj.data)
  5792. }
  5793. }
  5794. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5795. }
  5796. function checked (length) {
  5797. // Note: cannot use `length < kMaxLength()` here because that fails when
  5798. // length is NaN (which is otherwise coerced to zero.)
  5799. if (length >= kMaxLength()) {
  5800. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5801. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5802. }
  5803. return length | 0
  5804. }
  5805. function SlowBuffer (length) {
  5806. if (+length != length) { // eslint-disable-line eqeqeq
  5807. length = 0
  5808. }
  5809. return Buffer.alloc(+length)
  5810. }
  5811. Buffer.isBuffer = function isBuffer (b) {
  5812. return !!(b != null && b._isBuffer)
  5813. }
  5814. Buffer.compare = function compare (a, b) {
  5815. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5816. throw new TypeError('Arguments must be Buffers')
  5817. }
  5818. if (a === b) return 0
  5819. var x = a.length
  5820. var y = b.length
  5821. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5822. if (a[i] !== b[i]) {
  5823. x = a[i]
  5824. y = b[i]
  5825. break
  5826. }
  5827. }
  5828. if (x < y) return -1
  5829. if (y < x) return 1
  5830. return 0
  5831. }
  5832. Buffer.isEncoding = function isEncoding (encoding) {
  5833. switch (String(encoding).toLowerCase()) {
  5834. case 'hex':
  5835. case 'utf8':
  5836. case 'utf-8':
  5837. case 'ascii':
  5838. case 'latin1':
  5839. case 'binary':
  5840. case 'base64':
  5841. case 'ucs2':
  5842. case 'ucs-2':
  5843. case 'utf16le':
  5844. case 'utf-16le':
  5845. return true
  5846. default:
  5847. return false
  5848. }
  5849. }
  5850. Buffer.concat = function concat (list, length) {
  5851. if (!isArray(list)) {
  5852. throw new TypeError('"list" argument must be an Array of Buffers')
  5853. }
  5854. if (list.length === 0) {
  5855. return Buffer.alloc(0)
  5856. }
  5857. var i
  5858. if (length === undefined) {
  5859. length = 0
  5860. for (i = 0; i < list.length; ++i) {
  5861. length += list[i].length
  5862. }
  5863. }
  5864. var buffer = Buffer.allocUnsafe(length)
  5865. var pos = 0
  5866. for (i = 0; i < list.length; ++i) {
  5867. var buf = list[i]
  5868. if (!Buffer.isBuffer(buf)) {
  5869. throw new TypeError('"list" argument must be an Array of Buffers')
  5870. }
  5871. buf.copy(buffer, pos)
  5872. pos += buf.length
  5873. }
  5874. return buffer
  5875. }
  5876. function byteLength (string, encoding) {
  5877. if (Buffer.isBuffer(string)) {
  5878. return string.length
  5879. }
  5880. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5881. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5882. return string.byteLength
  5883. }
  5884. if (typeof string !== 'string') {
  5885. string = '' + string
  5886. }
  5887. var len = string.length
  5888. if (len === 0) return 0
  5889. // Use a for loop to avoid recursion
  5890. var loweredCase = false
  5891. for (;;) {
  5892. switch (encoding) {
  5893. case 'ascii':
  5894. case 'latin1':
  5895. case 'binary':
  5896. return len
  5897. case 'utf8':
  5898. case 'utf-8':
  5899. case undefined:
  5900. return utf8ToBytes(string).length
  5901. case 'ucs2':
  5902. case 'ucs-2':
  5903. case 'utf16le':
  5904. case 'utf-16le':
  5905. return len * 2
  5906. case 'hex':
  5907. return len >>> 1
  5908. case 'base64':
  5909. return base64ToBytes(string).length
  5910. default:
  5911. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5912. encoding = ('' + encoding).toLowerCase()
  5913. loweredCase = true
  5914. }
  5915. }
  5916. }
  5917. Buffer.byteLength = byteLength
  5918. function slowToString (encoding, start, end) {
  5919. var loweredCase = false
  5920. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5921. // property of a typed array.
  5922. // This behaves neither like String nor Uint8Array in that we set start/end
  5923. // to their upper/lower bounds if the value passed is out of range.
  5924. // undefined is handled specially as per ECMA-262 6th Edition,
  5925. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5926. if (start === undefined || start < 0) {
  5927. start = 0
  5928. }
  5929. // Return early if start > this.length. Done here to prevent potential uint32
  5930. // coercion fail below.
  5931. if (start > this.length) {
  5932. return ''
  5933. }
  5934. if (end === undefined || end > this.length) {
  5935. end = this.length
  5936. }
  5937. if (end <= 0) {
  5938. return ''
  5939. }
  5940. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5941. end >>>= 0
  5942. start >>>= 0
  5943. if (end <= start) {
  5944. return ''
  5945. }
  5946. if (!encoding) encoding = 'utf8'
  5947. while (true) {
  5948. switch (encoding) {
  5949. case 'hex':
  5950. return hexSlice(this, start, end)
  5951. case 'utf8':
  5952. case 'utf-8':
  5953. return utf8Slice(this, start, end)
  5954. case 'ascii':
  5955. return asciiSlice(this, start, end)
  5956. case 'latin1':
  5957. case 'binary':
  5958. return latin1Slice(this, start, end)
  5959. case 'base64':
  5960. return base64Slice(this, start, end)
  5961. case 'ucs2':
  5962. case 'ucs-2':
  5963. case 'utf16le':
  5964. case 'utf-16le':
  5965. return utf16leSlice(this, start, end)
  5966. default:
  5967. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5968. encoding = (encoding + '').toLowerCase()
  5969. loweredCase = true
  5970. }
  5971. }
  5972. }
  5973. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5974. // Buffer instances.
  5975. Buffer.prototype._isBuffer = true
  5976. function swap (b, n, m) {
  5977. var i = b[n]
  5978. b[n] = b[m]
  5979. b[m] = i
  5980. }
  5981. Buffer.prototype.swap16 = function swap16 () {
  5982. var len = this.length
  5983. if (len % 2 !== 0) {
  5984. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5985. }
  5986. for (var i = 0; i < len; i += 2) {
  5987. swap(this, i, i + 1)
  5988. }
  5989. return this
  5990. }
  5991. Buffer.prototype.swap32 = function swap32 () {
  5992. var len = this.length
  5993. if (len % 4 !== 0) {
  5994. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5995. }
  5996. for (var i = 0; i < len; i += 4) {
  5997. swap(this, i, i + 3)
  5998. swap(this, i + 1, i + 2)
  5999. }
  6000. return this
  6001. }
  6002. Buffer.prototype.swap64 = function swap64 () {
  6003. var len = this.length
  6004. if (len % 8 !== 0) {
  6005. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6006. }
  6007. for (var i = 0; i < len; i += 8) {
  6008. swap(this, i, i + 7)
  6009. swap(this, i + 1, i + 6)
  6010. swap(this, i + 2, i + 5)
  6011. swap(this, i + 3, i + 4)
  6012. }
  6013. return this
  6014. }
  6015. Buffer.prototype.toString = function toString () {
  6016. var length = this.length | 0
  6017. if (length === 0) return ''
  6018. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6019. return slowToString.apply(this, arguments)
  6020. }
  6021. Buffer.prototype.equals = function equals (b) {
  6022. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6023. if (this === b) return true
  6024. return Buffer.compare(this, b) === 0
  6025. }
  6026. Buffer.prototype.inspect = function inspect () {
  6027. var str = ''
  6028. var max = exports.INSPECT_MAX_BYTES
  6029. if (this.length > 0) {
  6030. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6031. if (this.length > max) str += ' ... '
  6032. }
  6033. return '<Buffer ' + str + '>'
  6034. }
  6035. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6036. if (!Buffer.isBuffer(target)) {
  6037. throw new TypeError('Argument must be a Buffer')
  6038. }
  6039. if (start === undefined) {
  6040. start = 0
  6041. }
  6042. if (end === undefined) {
  6043. end = target ? target.length : 0
  6044. }
  6045. if (thisStart === undefined) {
  6046. thisStart = 0
  6047. }
  6048. if (thisEnd === undefined) {
  6049. thisEnd = this.length
  6050. }
  6051. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6052. throw new RangeError('out of range index')
  6053. }
  6054. if (thisStart >= thisEnd && start >= end) {
  6055. return 0
  6056. }
  6057. if (thisStart >= thisEnd) {
  6058. return -1
  6059. }
  6060. if (start >= end) {
  6061. return 1
  6062. }
  6063. start >>>= 0
  6064. end >>>= 0
  6065. thisStart >>>= 0
  6066. thisEnd >>>= 0
  6067. if (this === target) return 0
  6068. var x = thisEnd - thisStart
  6069. var y = end - start
  6070. var len = Math.min(x, y)
  6071. var thisCopy = this.slice(thisStart, thisEnd)
  6072. var targetCopy = target.slice(start, end)
  6073. for (var i = 0; i < len; ++i) {
  6074. if (thisCopy[i] !== targetCopy[i]) {
  6075. x = thisCopy[i]
  6076. y = targetCopy[i]
  6077. break
  6078. }
  6079. }
  6080. if (x < y) return -1
  6081. if (y < x) return 1
  6082. return 0
  6083. }
  6084. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6085. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6086. //
  6087. // Arguments:
  6088. // - buffer - a Buffer to search
  6089. // - val - a string, Buffer, or number
  6090. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6091. // - encoding - an optional encoding, relevant is val is a string
  6092. // - dir - true for indexOf, false for lastIndexOf
  6093. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6094. // Empty buffer means no match
  6095. if (buffer.length === 0) return -1
  6096. // Normalize byteOffset
  6097. if (typeof byteOffset === 'string') {
  6098. encoding = byteOffset
  6099. byteOffset = 0
  6100. } else if (byteOffset > 0x7fffffff) {
  6101. byteOffset = 0x7fffffff
  6102. } else if (byteOffset < -0x80000000) {
  6103. byteOffset = -0x80000000
  6104. }
  6105. byteOffset = +byteOffset // Coerce to Number.
  6106. if (isNaN(byteOffset)) {
  6107. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6108. byteOffset = dir ? 0 : (buffer.length - 1)
  6109. }
  6110. // Normalize byteOffset: negative offsets start from the end of the buffer
  6111. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6112. if (byteOffset >= buffer.length) {
  6113. if (dir) return -1
  6114. else byteOffset = buffer.length - 1
  6115. } else if (byteOffset < 0) {
  6116. if (dir) byteOffset = 0
  6117. else return -1
  6118. }
  6119. // Normalize val
  6120. if (typeof val === 'string') {
  6121. val = Buffer.from(val, encoding)
  6122. }
  6123. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6124. if (Buffer.isBuffer(val)) {
  6125. // Special case: looking for empty string/buffer always fails
  6126. if (val.length === 0) {
  6127. return -1
  6128. }
  6129. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6130. } else if (typeof val === 'number') {
  6131. val = val & 0xFF // Search for a byte value [0-255]
  6132. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6133. typeof Uint8Array.prototype.indexOf === 'function') {
  6134. if (dir) {
  6135. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6136. } else {
  6137. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6138. }
  6139. }
  6140. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6141. }
  6142. throw new TypeError('val must be string, number or Buffer')
  6143. }
  6144. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6145. var indexSize = 1
  6146. var arrLength = arr.length
  6147. var valLength = val.length
  6148. if (encoding !== undefined) {
  6149. encoding = String(encoding).toLowerCase()
  6150. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6151. encoding === 'utf16le' || encoding === 'utf-16le') {
  6152. if (arr.length < 2 || val.length < 2) {
  6153. return -1
  6154. }
  6155. indexSize = 2
  6156. arrLength /= 2
  6157. valLength /= 2
  6158. byteOffset /= 2
  6159. }
  6160. }
  6161. function read (buf, i) {
  6162. if (indexSize === 1) {
  6163. return buf[i]
  6164. } else {
  6165. return buf.readUInt16BE(i * indexSize)
  6166. }
  6167. }
  6168. var i
  6169. if (dir) {
  6170. var foundIndex = -1
  6171. for (i = byteOffset; i < arrLength; i++) {
  6172. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6173. if (foundIndex === -1) foundIndex = i
  6174. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6175. } else {
  6176. if (foundIndex !== -1) i -= i - foundIndex
  6177. foundIndex = -1
  6178. }
  6179. }
  6180. } else {
  6181. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6182. for (i = byteOffset; i >= 0; i--) {
  6183. var found = true
  6184. for (var j = 0; j < valLength; j++) {
  6185. if (read(arr, i + j) !== read(val, j)) {
  6186. found = false
  6187. break
  6188. }
  6189. }
  6190. if (found) return i
  6191. }
  6192. }
  6193. return -1
  6194. }
  6195. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6196. return this.indexOf(val, byteOffset, encoding) !== -1
  6197. }
  6198. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6199. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6200. }
  6201. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6202. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6203. }
  6204. function hexWrite (buf, string, offset, length) {
  6205. offset = Number(offset) || 0
  6206. var remaining = buf.length - offset
  6207. if (!length) {
  6208. length = remaining
  6209. } else {
  6210. length = Number(length)
  6211. if (length > remaining) {
  6212. length = remaining
  6213. }
  6214. }
  6215. // must be an even number of digits
  6216. var strLen = string.length
  6217. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6218. if (length > strLen / 2) {
  6219. length = strLen / 2
  6220. }
  6221. for (var i = 0; i < length; ++i) {
  6222. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6223. if (isNaN(parsed)) return i
  6224. buf[offset + i] = parsed
  6225. }
  6226. return i
  6227. }
  6228. function utf8Write (buf, string, offset, length) {
  6229. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6230. }
  6231. function asciiWrite (buf, string, offset, length) {
  6232. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6233. }
  6234. function latin1Write (buf, string, offset, length) {
  6235. return asciiWrite(buf, string, offset, length)
  6236. }
  6237. function base64Write (buf, string, offset, length) {
  6238. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6239. }
  6240. function ucs2Write (buf, string, offset, length) {
  6241. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6242. }
  6243. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6244. // Buffer#write(string)
  6245. if (offset === undefined) {
  6246. encoding = 'utf8'
  6247. length = this.length
  6248. offset = 0
  6249. // Buffer#write(string, encoding)
  6250. } else if (length === undefined && typeof offset === 'string') {
  6251. encoding = offset
  6252. length = this.length
  6253. offset = 0
  6254. // Buffer#write(string, offset[, length][, encoding])
  6255. } else if (isFinite(offset)) {
  6256. offset = offset | 0
  6257. if (isFinite(length)) {
  6258. length = length | 0
  6259. if (encoding === undefined) encoding = 'utf8'
  6260. } else {
  6261. encoding = length
  6262. length = undefined
  6263. }
  6264. // legacy write(string, encoding, offset, length) - remove in v0.13
  6265. } else {
  6266. throw new Error(
  6267. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6268. )
  6269. }
  6270. var remaining = this.length - offset
  6271. if (length === undefined || length > remaining) length = remaining
  6272. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6273. throw new RangeError('Attempt to write outside buffer bounds')
  6274. }
  6275. if (!encoding) encoding = 'utf8'
  6276. var loweredCase = false
  6277. for (;;) {
  6278. switch (encoding) {
  6279. case 'hex':
  6280. return hexWrite(this, string, offset, length)
  6281. case 'utf8':
  6282. case 'utf-8':
  6283. return utf8Write(this, string, offset, length)
  6284. case 'ascii':
  6285. return asciiWrite(this, string, offset, length)
  6286. case 'latin1':
  6287. case 'binary':
  6288. return latin1Write(this, string, offset, length)
  6289. case 'base64':
  6290. // Warning: maxLength not taken into account in base64Write
  6291. return base64Write(this, string, offset, length)
  6292. case 'ucs2':
  6293. case 'ucs-2':
  6294. case 'utf16le':
  6295. case 'utf-16le':
  6296. return ucs2Write(this, string, offset, length)
  6297. default:
  6298. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6299. encoding = ('' + encoding).toLowerCase()
  6300. loweredCase = true
  6301. }
  6302. }
  6303. }
  6304. Buffer.prototype.toJSON = function toJSON () {
  6305. return {
  6306. type: 'Buffer',
  6307. data: Array.prototype.slice.call(this._arr || this, 0)
  6308. }
  6309. }
  6310. function base64Slice (buf, start, end) {
  6311. if (start === 0 && end === buf.length) {
  6312. return base64.fromByteArray(buf)
  6313. } else {
  6314. return base64.fromByteArray(buf.slice(start, end))
  6315. }
  6316. }
  6317. function utf8Slice (buf, start, end) {
  6318. end = Math.min(buf.length, end)
  6319. var res = []
  6320. var i = start
  6321. while (i < end) {
  6322. var firstByte = buf[i]
  6323. var codePoint = null
  6324. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6325. : (firstByte > 0xDF) ? 3
  6326. : (firstByte > 0xBF) ? 2
  6327. : 1
  6328. if (i + bytesPerSequence <= end) {
  6329. var secondByte, thirdByte, fourthByte, tempCodePoint
  6330. switch (bytesPerSequence) {
  6331. case 1:
  6332. if (firstByte < 0x80) {
  6333. codePoint = firstByte
  6334. }
  6335. break
  6336. case 2:
  6337. secondByte = buf[i + 1]
  6338. if ((secondByte & 0xC0) === 0x80) {
  6339. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6340. if (tempCodePoint > 0x7F) {
  6341. codePoint = tempCodePoint
  6342. }
  6343. }
  6344. break
  6345. case 3:
  6346. secondByte = buf[i + 1]
  6347. thirdByte = buf[i + 2]
  6348. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6349. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6350. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6351. codePoint = tempCodePoint
  6352. }
  6353. }
  6354. break
  6355. case 4:
  6356. secondByte = buf[i + 1]
  6357. thirdByte = buf[i + 2]
  6358. fourthByte = buf[i + 3]
  6359. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6360. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6361. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6362. codePoint = tempCodePoint
  6363. }
  6364. }
  6365. }
  6366. }
  6367. if (codePoint === null) {
  6368. // we did not generate a valid codePoint so insert a
  6369. // replacement char (U+FFFD) and advance only 1 byte
  6370. codePoint = 0xFFFD
  6371. bytesPerSequence = 1
  6372. } else if (codePoint > 0xFFFF) {
  6373. // encode to utf16 (surrogate pair dance)
  6374. codePoint -= 0x10000
  6375. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6376. codePoint = 0xDC00 | codePoint & 0x3FF
  6377. }
  6378. res.push(codePoint)
  6379. i += bytesPerSequence
  6380. }
  6381. return decodeCodePointsArray(res)
  6382. }
  6383. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6384. // the lowest limit is Chrome, with 0x10000 args.
  6385. // We go 1 magnitude less, for safety
  6386. var MAX_ARGUMENTS_LENGTH = 0x1000
  6387. function decodeCodePointsArray (codePoints) {
  6388. var len = codePoints.length
  6389. if (len <= MAX_ARGUMENTS_LENGTH) {
  6390. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6391. }
  6392. // Decode in chunks to avoid "call stack size exceeded".
  6393. var res = ''
  6394. var i = 0
  6395. while (i < len) {
  6396. res += String.fromCharCode.apply(
  6397. String,
  6398. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6399. )
  6400. }
  6401. return res
  6402. }
  6403. function asciiSlice (buf, start, end) {
  6404. var ret = ''
  6405. end = Math.min(buf.length, end)
  6406. for (var i = start; i < end; ++i) {
  6407. ret += String.fromCharCode(buf[i] & 0x7F)
  6408. }
  6409. return ret
  6410. }
  6411. function latin1Slice (buf, start, end) {
  6412. var ret = ''
  6413. end = Math.min(buf.length, end)
  6414. for (var i = start; i < end; ++i) {
  6415. ret += String.fromCharCode(buf[i])
  6416. }
  6417. return ret
  6418. }
  6419. function hexSlice (buf, start, end) {
  6420. var len = buf.length
  6421. if (!start || start < 0) start = 0
  6422. if (!end || end < 0 || end > len) end = len
  6423. var out = ''
  6424. for (var i = start; i < end; ++i) {
  6425. out += toHex(buf[i])
  6426. }
  6427. return out
  6428. }
  6429. function utf16leSlice (buf, start, end) {
  6430. var bytes = buf.slice(start, end)
  6431. var res = ''
  6432. for (var i = 0; i < bytes.length; i += 2) {
  6433. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6434. }
  6435. return res
  6436. }
  6437. Buffer.prototype.slice = function slice (start, end) {
  6438. var len = this.length
  6439. start = ~~start
  6440. end = end === undefined ? len : ~~end
  6441. if (start < 0) {
  6442. start += len
  6443. if (start < 0) start = 0
  6444. } else if (start > len) {
  6445. start = len
  6446. }
  6447. if (end < 0) {
  6448. end += len
  6449. if (end < 0) end = 0
  6450. } else if (end > len) {
  6451. end = len
  6452. }
  6453. if (end < start) end = start
  6454. var newBuf
  6455. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6456. newBuf = this.subarray(start, end)
  6457. newBuf.__proto__ = Buffer.prototype
  6458. } else {
  6459. var sliceLen = end - start
  6460. newBuf = new Buffer(sliceLen, undefined)
  6461. for (var i = 0; i < sliceLen; ++i) {
  6462. newBuf[i] = this[i + start]
  6463. }
  6464. }
  6465. return newBuf
  6466. }
  6467. /*
  6468. * Need to make sure that buffer isn't trying to write out of bounds.
  6469. */
  6470. function checkOffset (offset, ext, length) {
  6471. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6472. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6473. }
  6474. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6475. offset = offset | 0
  6476. byteLength = byteLength | 0
  6477. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6478. var val = this[offset]
  6479. var mul = 1
  6480. var i = 0
  6481. while (++i < byteLength && (mul *= 0x100)) {
  6482. val += this[offset + i] * mul
  6483. }
  6484. return val
  6485. }
  6486. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6487. offset = offset | 0
  6488. byteLength = byteLength | 0
  6489. if (!noAssert) {
  6490. checkOffset(offset, byteLength, this.length)
  6491. }
  6492. var val = this[offset + --byteLength]
  6493. var mul = 1
  6494. while (byteLength > 0 && (mul *= 0x100)) {
  6495. val += this[offset + --byteLength] * mul
  6496. }
  6497. return val
  6498. }
  6499. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6500. if (!noAssert) checkOffset(offset, 1, this.length)
  6501. return this[offset]
  6502. }
  6503. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6504. if (!noAssert) checkOffset(offset, 2, this.length)
  6505. return this[offset] | (this[offset + 1] << 8)
  6506. }
  6507. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6508. if (!noAssert) checkOffset(offset, 2, this.length)
  6509. return (this[offset] << 8) | this[offset + 1]
  6510. }
  6511. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6512. if (!noAssert) checkOffset(offset, 4, this.length)
  6513. return ((this[offset]) |
  6514. (this[offset + 1] << 8) |
  6515. (this[offset + 2] << 16)) +
  6516. (this[offset + 3] * 0x1000000)
  6517. }
  6518. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6519. if (!noAssert) checkOffset(offset, 4, this.length)
  6520. return (this[offset] * 0x1000000) +
  6521. ((this[offset + 1] << 16) |
  6522. (this[offset + 2] << 8) |
  6523. this[offset + 3])
  6524. }
  6525. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6526. offset = offset | 0
  6527. byteLength = byteLength | 0
  6528. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6529. var val = this[offset]
  6530. var mul = 1
  6531. var i = 0
  6532. while (++i < byteLength && (mul *= 0x100)) {
  6533. val += this[offset + i] * mul
  6534. }
  6535. mul *= 0x80
  6536. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6537. return val
  6538. }
  6539. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6540. offset = offset | 0
  6541. byteLength = byteLength | 0
  6542. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6543. var i = byteLength
  6544. var mul = 1
  6545. var val = this[offset + --i]
  6546. while (i > 0 && (mul *= 0x100)) {
  6547. val += this[offset + --i] * mul
  6548. }
  6549. mul *= 0x80
  6550. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6551. return val
  6552. }
  6553. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6554. if (!noAssert) checkOffset(offset, 1, this.length)
  6555. if (!(this[offset] & 0x80)) return (this[offset])
  6556. return ((0xff - this[offset] + 1) * -1)
  6557. }
  6558. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6559. if (!noAssert) checkOffset(offset, 2, this.length)
  6560. var val = this[offset] | (this[offset + 1] << 8)
  6561. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6562. }
  6563. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6564. if (!noAssert) checkOffset(offset, 2, this.length)
  6565. var val = this[offset + 1] | (this[offset] << 8)
  6566. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6567. }
  6568. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6569. if (!noAssert) checkOffset(offset, 4, this.length)
  6570. return (this[offset]) |
  6571. (this[offset + 1] << 8) |
  6572. (this[offset + 2] << 16) |
  6573. (this[offset + 3] << 24)
  6574. }
  6575. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6576. if (!noAssert) checkOffset(offset, 4, this.length)
  6577. return (this[offset] << 24) |
  6578. (this[offset + 1] << 16) |
  6579. (this[offset + 2] << 8) |
  6580. (this[offset + 3])
  6581. }
  6582. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6583. if (!noAssert) checkOffset(offset, 4, this.length)
  6584. return ieee754.read(this, offset, true, 23, 4)
  6585. }
  6586. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6587. if (!noAssert) checkOffset(offset, 4, this.length)
  6588. return ieee754.read(this, offset, false, 23, 4)
  6589. }
  6590. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6591. if (!noAssert) checkOffset(offset, 8, this.length)
  6592. return ieee754.read(this, offset, true, 52, 8)
  6593. }
  6594. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6595. if (!noAssert) checkOffset(offset, 8, this.length)
  6596. return ieee754.read(this, offset, false, 52, 8)
  6597. }
  6598. function checkInt (buf, value, offset, ext, max, min) {
  6599. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6600. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6601. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6602. }
  6603. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6604. value = +value
  6605. offset = offset | 0
  6606. byteLength = byteLength | 0
  6607. if (!noAssert) {
  6608. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6609. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6610. }
  6611. var mul = 1
  6612. var i = 0
  6613. this[offset] = value & 0xFF
  6614. while (++i < byteLength && (mul *= 0x100)) {
  6615. this[offset + i] = (value / mul) & 0xFF
  6616. }
  6617. return offset + byteLength
  6618. }
  6619. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6620. value = +value
  6621. offset = offset | 0
  6622. byteLength = byteLength | 0
  6623. if (!noAssert) {
  6624. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6625. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6626. }
  6627. var i = byteLength - 1
  6628. var mul = 1
  6629. this[offset + i] = value & 0xFF
  6630. while (--i >= 0 && (mul *= 0x100)) {
  6631. this[offset + i] = (value / mul) & 0xFF
  6632. }
  6633. return offset + byteLength
  6634. }
  6635. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6636. value = +value
  6637. offset = offset | 0
  6638. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6639. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6640. this[offset] = (value & 0xff)
  6641. return offset + 1
  6642. }
  6643. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6644. if (value < 0) value = 0xffff + value + 1
  6645. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6646. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6647. (littleEndian ? i : 1 - i) * 8
  6648. }
  6649. }
  6650. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6651. value = +value
  6652. offset = offset | 0
  6653. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6654. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6655. this[offset] = (value & 0xff)
  6656. this[offset + 1] = (value >>> 8)
  6657. } else {
  6658. objectWriteUInt16(this, value, offset, true)
  6659. }
  6660. return offset + 2
  6661. }
  6662. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6663. value = +value
  6664. offset = offset | 0
  6665. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6666. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6667. this[offset] = (value >>> 8)
  6668. this[offset + 1] = (value & 0xff)
  6669. } else {
  6670. objectWriteUInt16(this, value, offset, false)
  6671. }
  6672. return offset + 2
  6673. }
  6674. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6675. if (value < 0) value = 0xffffffff + value + 1
  6676. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6677. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6678. }
  6679. }
  6680. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6681. value = +value
  6682. offset = offset | 0
  6683. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6684. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6685. this[offset + 3] = (value >>> 24)
  6686. this[offset + 2] = (value >>> 16)
  6687. this[offset + 1] = (value >>> 8)
  6688. this[offset] = (value & 0xff)
  6689. } else {
  6690. objectWriteUInt32(this, value, offset, true)
  6691. }
  6692. return offset + 4
  6693. }
  6694. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6695. value = +value
  6696. offset = offset | 0
  6697. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6698. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6699. this[offset] = (value >>> 24)
  6700. this[offset + 1] = (value >>> 16)
  6701. this[offset + 2] = (value >>> 8)
  6702. this[offset + 3] = (value & 0xff)
  6703. } else {
  6704. objectWriteUInt32(this, value, offset, false)
  6705. }
  6706. return offset + 4
  6707. }
  6708. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6709. value = +value
  6710. offset = offset | 0
  6711. if (!noAssert) {
  6712. var limit = Math.pow(2, 8 * byteLength - 1)
  6713. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6714. }
  6715. var i = 0
  6716. var mul = 1
  6717. var sub = 0
  6718. this[offset] = value & 0xFF
  6719. while (++i < byteLength && (mul *= 0x100)) {
  6720. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6721. sub = 1
  6722. }
  6723. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6724. }
  6725. return offset + byteLength
  6726. }
  6727. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6728. value = +value
  6729. offset = offset | 0
  6730. if (!noAssert) {
  6731. var limit = Math.pow(2, 8 * byteLength - 1)
  6732. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6733. }
  6734. var i = byteLength - 1
  6735. var mul = 1
  6736. var sub = 0
  6737. this[offset + i] = value & 0xFF
  6738. while (--i >= 0 && (mul *= 0x100)) {
  6739. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6740. sub = 1
  6741. }
  6742. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6743. }
  6744. return offset + byteLength
  6745. }
  6746. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6747. value = +value
  6748. offset = offset | 0
  6749. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6750. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6751. if (value < 0) value = 0xff + value + 1
  6752. this[offset] = (value & 0xff)
  6753. return offset + 1
  6754. }
  6755. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6756. value = +value
  6757. offset = offset | 0
  6758. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6759. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6760. this[offset] = (value & 0xff)
  6761. this[offset + 1] = (value >>> 8)
  6762. } else {
  6763. objectWriteUInt16(this, value, offset, true)
  6764. }
  6765. return offset + 2
  6766. }
  6767. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6768. value = +value
  6769. offset = offset | 0
  6770. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6771. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6772. this[offset] = (value >>> 8)
  6773. this[offset + 1] = (value & 0xff)
  6774. } else {
  6775. objectWriteUInt16(this, value, offset, false)
  6776. }
  6777. return offset + 2
  6778. }
  6779. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6780. value = +value
  6781. offset = offset | 0
  6782. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6783. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6784. this[offset] = (value & 0xff)
  6785. this[offset + 1] = (value >>> 8)
  6786. this[offset + 2] = (value >>> 16)
  6787. this[offset + 3] = (value >>> 24)
  6788. } else {
  6789. objectWriteUInt32(this, value, offset, true)
  6790. }
  6791. return offset + 4
  6792. }
  6793. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6794. value = +value
  6795. offset = offset | 0
  6796. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6797. if (value < 0) value = 0xffffffff + value + 1
  6798. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6799. this[offset] = (value >>> 24)
  6800. this[offset + 1] = (value >>> 16)
  6801. this[offset + 2] = (value >>> 8)
  6802. this[offset + 3] = (value & 0xff)
  6803. } else {
  6804. objectWriteUInt32(this, value, offset, false)
  6805. }
  6806. return offset + 4
  6807. }
  6808. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6809. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6810. if (offset < 0) throw new RangeError('Index out of range')
  6811. }
  6812. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6813. if (!noAssert) {
  6814. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6815. }
  6816. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6817. return offset + 4
  6818. }
  6819. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6820. return writeFloat(this, value, offset, true, noAssert)
  6821. }
  6822. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6823. return writeFloat(this, value, offset, false, noAssert)
  6824. }
  6825. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6826. if (!noAssert) {
  6827. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6828. }
  6829. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6830. return offset + 8
  6831. }
  6832. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6833. return writeDouble(this, value, offset, true, noAssert)
  6834. }
  6835. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6836. return writeDouble(this, value, offset, false, noAssert)
  6837. }
  6838. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6839. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6840. if (!start) start = 0
  6841. if (!end && end !== 0) end = this.length
  6842. if (targetStart >= target.length) targetStart = target.length
  6843. if (!targetStart) targetStart = 0
  6844. if (end > 0 && end < start) end = start
  6845. // Copy 0 bytes; we're done
  6846. if (end === start) return 0
  6847. if (target.length === 0 || this.length === 0) return 0
  6848. // Fatal error conditions
  6849. if (targetStart < 0) {
  6850. throw new RangeError('targetStart out of bounds')
  6851. }
  6852. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6853. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6854. // Are we oob?
  6855. if (end > this.length) end = this.length
  6856. if (target.length - targetStart < end - start) {
  6857. end = target.length - targetStart + start
  6858. }
  6859. var len = end - start
  6860. var i
  6861. if (this === target && start < targetStart && targetStart < end) {
  6862. // descending copy from end
  6863. for (i = len - 1; i >= 0; --i) {
  6864. target[i + targetStart] = this[i + start]
  6865. }
  6866. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6867. // ascending copy from start
  6868. for (i = 0; i < len; ++i) {
  6869. target[i + targetStart] = this[i + start]
  6870. }
  6871. } else {
  6872. Uint8Array.prototype.set.call(
  6873. target,
  6874. this.subarray(start, start + len),
  6875. targetStart
  6876. )
  6877. }
  6878. return len
  6879. }
  6880. // Usage:
  6881. // buffer.fill(number[, offset[, end]])
  6882. // buffer.fill(buffer[, offset[, end]])
  6883. // buffer.fill(string[, offset[, end]][, encoding])
  6884. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6885. // Handle string cases:
  6886. if (typeof val === 'string') {
  6887. if (typeof start === 'string') {
  6888. encoding = start
  6889. start = 0
  6890. end = this.length
  6891. } else if (typeof end === 'string') {
  6892. encoding = end
  6893. end = this.length
  6894. }
  6895. if (val.length === 1) {
  6896. var code = val.charCodeAt(0)
  6897. if (code < 256) {
  6898. val = code
  6899. }
  6900. }
  6901. if (encoding !== undefined && typeof encoding !== 'string') {
  6902. throw new TypeError('encoding must be a string')
  6903. }
  6904. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6905. throw new TypeError('Unknown encoding: ' + encoding)
  6906. }
  6907. } else if (typeof val === 'number') {
  6908. val = val & 255
  6909. }
  6910. // Invalid ranges are not set to a default, so can range check early.
  6911. if (start < 0 || this.length < start || this.length < end) {
  6912. throw new RangeError('Out of range index')
  6913. }
  6914. if (end <= start) {
  6915. return this
  6916. }
  6917. start = start >>> 0
  6918. end = end === undefined ? this.length : end >>> 0
  6919. if (!val) val = 0
  6920. var i
  6921. if (typeof val === 'number') {
  6922. for (i = start; i < end; ++i) {
  6923. this[i] = val
  6924. }
  6925. } else {
  6926. var bytes = Buffer.isBuffer(val)
  6927. ? val
  6928. : utf8ToBytes(new Buffer(val, encoding).toString())
  6929. var len = bytes.length
  6930. for (i = 0; i < end - start; ++i) {
  6931. this[i + start] = bytes[i % len]
  6932. }
  6933. }
  6934. return this
  6935. }
  6936. // HELPER FUNCTIONS
  6937. // ================
  6938. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6939. function base64clean (str) {
  6940. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6941. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6942. // Node converts strings with length < 2 to ''
  6943. if (str.length < 2) return ''
  6944. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6945. while (str.length % 4 !== 0) {
  6946. str = str + '='
  6947. }
  6948. return str
  6949. }
  6950. function stringtrim (str) {
  6951. if (str.trim) return str.trim()
  6952. return str.replace(/^\s+|\s+$/g, '')
  6953. }
  6954. function toHex (n) {
  6955. if (n < 16) return '0' + n.toString(16)
  6956. return n.toString(16)
  6957. }
  6958. function utf8ToBytes (string, units) {
  6959. units = units || Infinity
  6960. var codePoint
  6961. var length = string.length
  6962. var leadSurrogate = null
  6963. var bytes = []
  6964. for (var i = 0; i < length; ++i) {
  6965. codePoint = string.charCodeAt(i)
  6966. // is surrogate component
  6967. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6968. // last char was a lead
  6969. if (!leadSurrogate) {
  6970. // no lead yet
  6971. if (codePoint > 0xDBFF) {
  6972. // unexpected trail
  6973. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6974. continue
  6975. } else if (i + 1 === length) {
  6976. // unpaired lead
  6977. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6978. continue
  6979. }
  6980. // valid lead
  6981. leadSurrogate = codePoint
  6982. continue
  6983. }
  6984. // 2 leads in a row
  6985. if (codePoint < 0xDC00) {
  6986. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6987. leadSurrogate = codePoint
  6988. continue
  6989. }
  6990. // valid surrogate pair
  6991. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6992. } else if (leadSurrogate) {
  6993. // valid bmp char, but last char was a lead
  6994. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6995. }
  6996. leadSurrogate = null
  6997. // encode utf8
  6998. if (codePoint < 0x80) {
  6999. if ((units -= 1) < 0) break
  7000. bytes.push(codePoint)
  7001. } else if (codePoint < 0x800) {
  7002. if ((units -= 2) < 0) break
  7003. bytes.push(
  7004. codePoint >> 0x6 | 0xC0,
  7005. codePoint & 0x3F | 0x80
  7006. )
  7007. } else if (codePoint < 0x10000) {
  7008. if ((units -= 3) < 0) break
  7009. bytes.push(
  7010. codePoint >> 0xC | 0xE0,
  7011. codePoint >> 0x6 & 0x3F | 0x80,
  7012. codePoint & 0x3F | 0x80
  7013. )
  7014. } else if (codePoint < 0x110000) {
  7015. if ((units -= 4) < 0) break
  7016. bytes.push(
  7017. codePoint >> 0x12 | 0xF0,
  7018. codePoint >> 0xC & 0x3F | 0x80,
  7019. codePoint >> 0x6 & 0x3F | 0x80,
  7020. codePoint & 0x3F | 0x80
  7021. )
  7022. } else {
  7023. throw new Error('Invalid code point')
  7024. }
  7025. }
  7026. return bytes
  7027. }
  7028. function asciiToBytes (str) {
  7029. var byteArray = []
  7030. for (var i = 0; i < str.length; ++i) {
  7031. // Node's code seems to be doing this and not & 0x7F..
  7032. byteArray.push(str.charCodeAt(i) & 0xFF)
  7033. }
  7034. return byteArray
  7035. }
  7036. function utf16leToBytes (str, units) {
  7037. var c, hi, lo
  7038. var byteArray = []
  7039. for (var i = 0; i < str.length; ++i) {
  7040. if ((units -= 2) < 0) break
  7041. c = str.charCodeAt(i)
  7042. hi = c >> 8
  7043. lo = c % 256
  7044. byteArray.push(lo)
  7045. byteArray.push(hi)
  7046. }
  7047. return byteArray
  7048. }
  7049. function base64ToBytes (str) {
  7050. return base64.toByteArray(base64clean(str))
  7051. }
  7052. function blitBuffer (src, dst, offset, length) {
  7053. for (var i = 0; i < length; ++i) {
  7054. if ((i + offset >= dst.length) || (i >= src.length)) break
  7055. dst[i + offset] = src[i]
  7056. }
  7057. return i
  7058. }
  7059. function isnan (val) {
  7060. return val !== val // eslint-disable-line no-self-compare
  7061. }
  7062. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7063. /***/ }),
  7064. /***/ "./node_modules/ieee754/index.js":
  7065. /*!***************************************!*\
  7066. !*** ./node_modules/ieee754/index.js ***!
  7067. \***************************************/
  7068. /*! no static exports found */
  7069. /***/ (function(module, exports) {
  7070. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7071. var e, m
  7072. var eLen = (nBytes * 8) - mLen - 1
  7073. var eMax = (1 << eLen) - 1
  7074. var eBias = eMax >> 1
  7075. var nBits = -7
  7076. var i = isLE ? (nBytes - 1) : 0
  7077. var d = isLE ? -1 : 1
  7078. var s = buffer[offset + i]
  7079. i += d
  7080. e = s & ((1 << (-nBits)) - 1)
  7081. s >>= (-nBits)
  7082. nBits += eLen
  7083. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7084. m = e & ((1 << (-nBits)) - 1)
  7085. e >>= (-nBits)
  7086. nBits += mLen
  7087. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7088. if (e === 0) {
  7089. e = 1 - eBias
  7090. } else if (e === eMax) {
  7091. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7092. } else {
  7093. m = m + Math.pow(2, mLen)
  7094. e = e - eBias
  7095. }
  7096. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7097. }
  7098. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7099. var e, m, c
  7100. var eLen = (nBytes * 8) - mLen - 1
  7101. var eMax = (1 << eLen) - 1
  7102. var eBias = eMax >> 1
  7103. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7104. var i = isLE ? 0 : (nBytes - 1)
  7105. var d = isLE ? 1 : -1
  7106. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7107. value = Math.abs(value)
  7108. if (isNaN(value) || value === Infinity) {
  7109. m = isNaN(value) ? 1 : 0
  7110. e = eMax
  7111. } else {
  7112. e = Math.floor(Math.log(value) / Math.LN2)
  7113. if (value * (c = Math.pow(2, -e)) < 1) {
  7114. e--
  7115. c *= 2
  7116. }
  7117. if (e + eBias >= 1) {
  7118. value += rt / c
  7119. } else {
  7120. value += rt * Math.pow(2, 1 - eBias)
  7121. }
  7122. if (value * c >= 2) {
  7123. e++
  7124. c /= 2
  7125. }
  7126. if (e + eBias >= eMax) {
  7127. m = 0
  7128. e = eMax
  7129. } else if (e + eBias >= 1) {
  7130. m = ((value * c) - 1) * Math.pow(2, mLen)
  7131. e = e + eBias
  7132. } else {
  7133. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7134. e = 0
  7135. }
  7136. }
  7137. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7138. e = (e << mLen) | m
  7139. eLen += mLen
  7140. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7141. buffer[offset + i - d] |= s * 128
  7142. }
  7143. /***/ }),
  7144. /***/ "./node_modules/isarray/index.js":
  7145. /*!***************************************!*\
  7146. !*** ./node_modules/isarray/index.js ***!
  7147. \***************************************/
  7148. /*! no static exports found */
  7149. /***/ (function(module, exports) {
  7150. var toString = {}.toString;
  7151. module.exports = Array.isArray || function (arr) {
  7152. return toString.call(arr) == '[object Array]';
  7153. };
  7154. /***/ }),
  7155. /***/ "./node_modules/jquery/dist/jquery.js":
  7156. /*!********************************************!*\
  7157. !*** ./node_modules/jquery/dist/jquery.js ***!
  7158. \********************************************/
  7159. /*! no static exports found */
  7160. /***/ (function(module, exports, __webpack_require__) {
  7161. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7162. * jQuery JavaScript Library v3.4.1
  7163. * https://jquery.com/
  7164. *
  7165. * Includes Sizzle.js
  7166. * https://sizzlejs.com/
  7167. *
  7168. * Copyright JS Foundation and other contributors
  7169. * Released under the MIT license
  7170. * https://jquery.org/license
  7171. *
  7172. * Date: 2019-05-01T21:04Z
  7173. */
  7174. ( function( global, factory ) {
  7175. "use strict";
  7176. if ( true && typeof module.exports === "object" ) {
  7177. // For CommonJS and CommonJS-like environments where a proper `window`
  7178. // is present, execute the factory and get jQuery.
  7179. // For environments that do not have a `window` with a `document`
  7180. // (such as Node.js), expose a factory as module.exports.
  7181. // This accentuates the need for the creation of a real `window`.
  7182. // e.g. var jQuery = require("jquery")(window);
  7183. // See ticket #14549 for more info.
  7184. module.exports = global.document ?
  7185. factory( global, true ) :
  7186. function( w ) {
  7187. if ( !w.document ) {
  7188. throw new Error( "jQuery requires a window with a document" );
  7189. }
  7190. return factory( w );
  7191. };
  7192. } else {
  7193. factory( global );
  7194. }
  7195. // Pass this if window is not defined yet
  7196. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7197. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7198. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7199. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7200. // enough that all such attempts are guarded in a try block.
  7201. "use strict";
  7202. var arr = [];
  7203. var document = window.document;
  7204. var getProto = Object.getPrototypeOf;
  7205. var slice = arr.slice;
  7206. var concat = arr.concat;
  7207. var push = arr.push;
  7208. var indexOf = arr.indexOf;
  7209. var class2type = {};
  7210. var toString = class2type.toString;
  7211. var hasOwn = class2type.hasOwnProperty;
  7212. var fnToString = hasOwn.toString;
  7213. var ObjectFunctionString = fnToString.call( Object );
  7214. var support = {};
  7215. var isFunction = function isFunction( obj ) {
  7216. // Support: Chrome <=57, Firefox <=52
  7217. // In some browsers, typeof returns "function" for HTML <object> elements
  7218. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7219. // We don't want to classify *any* DOM node as a function.
  7220. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7221. };
  7222. var isWindow = function isWindow( obj ) {
  7223. return obj != null && obj === obj.window;
  7224. };
  7225. var preservedScriptAttributes = {
  7226. type: true,
  7227. src: true,
  7228. nonce: true,
  7229. noModule: true
  7230. };
  7231. function DOMEval( code, node, doc ) {
  7232. doc = doc || document;
  7233. var i, val,
  7234. script = doc.createElement( "script" );
  7235. script.text = code;
  7236. if ( node ) {
  7237. for ( i in preservedScriptAttributes ) {
  7238. // Support: Firefox 64+, Edge 18+
  7239. // Some browsers don't support the "nonce" property on scripts.
  7240. // On the other hand, just using `getAttribute` is not enough as
  7241. // the `nonce` attribute is reset to an empty string whenever it
  7242. // becomes browsing-context connected.
  7243. // See https://github.com/whatwg/html/issues/2369
  7244. // See https://html.spec.whatwg.org/#nonce-attributes
  7245. // The `node.getAttribute` check was added for the sake of
  7246. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7247. // via an object.
  7248. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7249. if ( val ) {
  7250. script.setAttribute( i, val );
  7251. }
  7252. }
  7253. }
  7254. doc.head.appendChild( script ).parentNode.removeChild( script );
  7255. }
  7256. function toType( obj ) {
  7257. if ( obj == null ) {
  7258. return obj + "";
  7259. }
  7260. // Support: Android <=2.3 only (functionish RegExp)
  7261. return typeof obj === "object" || typeof obj === "function" ?
  7262. class2type[ toString.call( obj ) ] || "object" :
  7263. typeof obj;
  7264. }
  7265. /* global Symbol */
  7266. // Defining this global in .eslintrc.json would create a danger of using the global
  7267. // unguarded in another place, it seems safer to define global only for this module
  7268. var
  7269. version = "3.4.1",
  7270. // Define a local copy of jQuery
  7271. jQuery = function( selector, context ) {
  7272. // The jQuery object is actually just the init constructor 'enhanced'
  7273. // Need init if jQuery is called (just allow error to be thrown if not included)
  7274. return new jQuery.fn.init( selector, context );
  7275. },
  7276. // Support: Android <=4.0 only
  7277. // Make sure we trim BOM and NBSP
  7278. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7279. jQuery.fn = jQuery.prototype = {
  7280. // The current version of jQuery being used
  7281. jquery: version,
  7282. constructor: jQuery,
  7283. // The default length of a jQuery object is 0
  7284. length: 0,
  7285. toArray: function() {
  7286. return slice.call( this );
  7287. },
  7288. // Get the Nth element in the matched element set OR
  7289. // Get the whole matched element set as a clean array
  7290. get: function( num ) {
  7291. // Return all the elements in a clean array
  7292. if ( num == null ) {
  7293. return slice.call( this );
  7294. }
  7295. // Return just the one element from the set
  7296. return num < 0 ? this[ num + this.length ] : this[ num ];
  7297. },
  7298. // Take an array of elements and push it onto the stack
  7299. // (returning the new matched element set)
  7300. pushStack: function( elems ) {
  7301. // Build a new jQuery matched element set
  7302. var ret = jQuery.merge( this.constructor(), elems );
  7303. // Add the old object onto the stack (as a reference)
  7304. ret.prevObject = this;
  7305. // Return the newly-formed element set
  7306. return ret;
  7307. },
  7308. // Execute a callback for every element in the matched set.
  7309. each: function( callback ) {
  7310. return jQuery.each( this, callback );
  7311. },
  7312. map: function( callback ) {
  7313. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7314. return callback.call( elem, i, elem );
  7315. } ) );
  7316. },
  7317. slice: function() {
  7318. return this.pushStack( slice.apply( this, arguments ) );
  7319. },
  7320. first: function() {
  7321. return this.eq( 0 );
  7322. },
  7323. last: function() {
  7324. return this.eq( -1 );
  7325. },
  7326. eq: function( i ) {
  7327. var len = this.length,
  7328. j = +i + ( i < 0 ? len : 0 );
  7329. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7330. },
  7331. end: function() {
  7332. return this.prevObject || this.constructor();
  7333. },
  7334. // For internal use only.
  7335. // Behaves like an Array's method, not like a jQuery method.
  7336. push: push,
  7337. sort: arr.sort,
  7338. splice: arr.splice
  7339. };
  7340. jQuery.extend = jQuery.fn.extend = function() {
  7341. var options, name, src, copy, copyIsArray, clone,
  7342. target = arguments[ 0 ] || {},
  7343. i = 1,
  7344. length = arguments.length,
  7345. deep = false;
  7346. // Handle a deep copy situation
  7347. if ( typeof target === "boolean" ) {
  7348. deep = target;
  7349. // Skip the boolean and the target
  7350. target = arguments[ i ] || {};
  7351. i++;
  7352. }
  7353. // Handle case when target is a string or something (possible in deep copy)
  7354. if ( typeof target !== "object" && !isFunction( target ) ) {
  7355. target = {};
  7356. }
  7357. // Extend jQuery itself if only one argument is passed
  7358. if ( i === length ) {
  7359. target = this;
  7360. i--;
  7361. }
  7362. for ( ; i < length; i++ ) {
  7363. // Only deal with non-null/undefined values
  7364. if ( ( options = arguments[ i ] ) != null ) {
  7365. // Extend the base object
  7366. for ( name in options ) {
  7367. copy = options[ name ];
  7368. // Prevent Object.prototype pollution
  7369. // Prevent never-ending loop
  7370. if ( name === "__proto__" || target === copy ) {
  7371. continue;
  7372. }
  7373. // Recurse if we're merging plain objects or arrays
  7374. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7375. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7376. src = target[ name ];
  7377. // Ensure proper type for the source value
  7378. if ( copyIsArray && !Array.isArray( src ) ) {
  7379. clone = [];
  7380. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7381. clone = {};
  7382. } else {
  7383. clone = src;
  7384. }
  7385. copyIsArray = false;
  7386. // Never move original objects, clone them
  7387. target[ name ] = jQuery.extend( deep, clone, copy );
  7388. // Don't bring in undefined values
  7389. } else if ( copy !== undefined ) {
  7390. target[ name ] = copy;
  7391. }
  7392. }
  7393. }
  7394. }
  7395. // Return the modified object
  7396. return target;
  7397. };
  7398. jQuery.extend( {
  7399. // Unique for each copy of jQuery on the page
  7400. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7401. // Assume jQuery is ready without the ready module
  7402. isReady: true,
  7403. error: function( msg ) {
  7404. throw new Error( msg );
  7405. },
  7406. noop: function() {},
  7407. isPlainObject: function( obj ) {
  7408. var proto, Ctor;
  7409. // Detect obvious negatives
  7410. // Use toString instead of jQuery.type to catch host objects
  7411. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7412. return false;
  7413. }
  7414. proto = getProto( obj );
  7415. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7416. if ( !proto ) {
  7417. return true;
  7418. }
  7419. // Objects with prototype are plain iff they were constructed by a global Object function
  7420. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7421. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7422. },
  7423. isEmptyObject: function( obj ) {
  7424. var name;
  7425. for ( name in obj ) {
  7426. return false;
  7427. }
  7428. return true;
  7429. },
  7430. // Evaluates a script in a global context
  7431. globalEval: function( code, options ) {
  7432. DOMEval( code, { nonce: options && options.nonce } );
  7433. },
  7434. each: function( obj, callback ) {
  7435. var length, i = 0;
  7436. if ( isArrayLike( obj ) ) {
  7437. length = obj.length;
  7438. for ( ; i < length; i++ ) {
  7439. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7440. break;
  7441. }
  7442. }
  7443. } else {
  7444. for ( i in obj ) {
  7445. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7446. break;
  7447. }
  7448. }
  7449. }
  7450. return obj;
  7451. },
  7452. // Support: Android <=4.0 only
  7453. trim: function( text ) {
  7454. return text == null ?
  7455. "" :
  7456. ( text + "" ).replace( rtrim, "" );
  7457. },
  7458. // results is for internal usage only
  7459. makeArray: function( arr, results ) {
  7460. var ret = results || [];
  7461. if ( arr != null ) {
  7462. if ( isArrayLike( Object( arr ) ) ) {
  7463. jQuery.merge( ret,
  7464. typeof arr === "string" ?
  7465. [ arr ] : arr
  7466. );
  7467. } else {
  7468. push.call( ret, arr );
  7469. }
  7470. }
  7471. return ret;
  7472. },
  7473. inArray: function( elem, arr, i ) {
  7474. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7475. },
  7476. // Support: Android <=4.0 only, PhantomJS 1 only
  7477. // push.apply(_, arraylike) throws on ancient WebKit
  7478. merge: function( first, second ) {
  7479. var len = +second.length,
  7480. j = 0,
  7481. i = first.length;
  7482. for ( ; j < len; j++ ) {
  7483. first[ i++ ] = second[ j ];
  7484. }
  7485. first.length = i;
  7486. return first;
  7487. },
  7488. grep: function( elems, callback, invert ) {
  7489. var callbackInverse,
  7490. matches = [],
  7491. i = 0,
  7492. length = elems.length,
  7493. callbackExpect = !invert;
  7494. // Go through the array, only saving the items
  7495. // that pass the validator function
  7496. for ( ; i < length; i++ ) {
  7497. callbackInverse = !callback( elems[ i ], i );
  7498. if ( callbackInverse !== callbackExpect ) {
  7499. matches.push( elems[ i ] );
  7500. }
  7501. }
  7502. return matches;
  7503. },
  7504. // arg is for internal usage only
  7505. map: function( elems, callback, arg ) {
  7506. var length, value,
  7507. i = 0,
  7508. ret = [];
  7509. // Go through the array, translating each of the items to their new values
  7510. if ( isArrayLike( elems ) ) {
  7511. length = elems.length;
  7512. for ( ; i < length; i++ ) {
  7513. value = callback( elems[ i ], i, arg );
  7514. if ( value != null ) {
  7515. ret.push( value );
  7516. }
  7517. }
  7518. // Go through every key on the object,
  7519. } else {
  7520. for ( i in elems ) {
  7521. value = callback( elems[ i ], i, arg );
  7522. if ( value != null ) {
  7523. ret.push( value );
  7524. }
  7525. }
  7526. }
  7527. // Flatten any nested arrays
  7528. return concat.apply( [], ret );
  7529. },
  7530. // A global GUID counter for objects
  7531. guid: 1,
  7532. // jQuery.support is not used in Core but other projects attach their
  7533. // properties to it so it needs to exist.
  7534. support: support
  7535. } );
  7536. if ( typeof Symbol === "function" ) {
  7537. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7538. }
  7539. // Populate the class2type map
  7540. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7541. function( i, name ) {
  7542. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7543. } );
  7544. function isArrayLike( obj ) {
  7545. // Support: real iOS 8.2 only (not reproducible in simulator)
  7546. // `in` check used to prevent JIT error (gh-2145)
  7547. // hasOwn isn't used here due to false negatives
  7548. // regarding Nodelist length in IE
  7549. var length = !!obj && "length" in obj && obj.length,
  7550. type = toType( obj );
  7551. if ( isFunction( obj ) || isWindow( obj ) ) {
  7552. return false;
  7553. }
  7554. return type === "array" || length === 0 ||
  7555. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7556. }
  7557. var Sizzle =
  7558. /*!
  7559. * Sizzle CSS Selector Engine v2.3.4
  7560. * https://sizzlejs.com/
  7561. *
  7562. * Copyright JS Foundation and other contributors
  7563. * Released under the MIT license
  7564. * https://js.foundation/
  7565. *
  7566. * Date: 2019-04-08
  7567. */
  7568. (function( window ) {
  7569. var i,
  7570. support,
  7571. Expr,
  7572. getText,
  7573. isXML,
  7574. tokenize,
  7575. compile,
  7576. select,
  7577. outermostContext,
  7578. sortInput,
  7579. hasDuplicate,
  7580. // Local document vars
  7581. setDocument,
  7582. document,
  7583. docElem,
  7584. documentIsHTML,
  7585. rbuggyQSA,
  7586. rbuggyMatches,
  7587. matches,
  7588. contains,
  7589. // Instance-specific data
  7590. expando = "sizzle" + 1 * new Date(),
  7591. preferredDoc = window.document,
  7592. dirruns = 0,
  7593. done = 0,
  7594. classCache = createCache(),
  7595. tokenCache = createCache(),
  7596. compilerCache = createCache(),
  7597. nonnativeSelectorCache = createCache(),
  7598. sortOrder = function( a, b ) {
  7599. if ( a === b ) {
  7600. hasDuplicate = true;
  7601. }
  7602. return 0;
  7603. },
  7604. // Instance methods
  7605. hasOwn = ({}).hasOwnProperty,
  7606. arr = [],
  7607. pop = arr.pop,
  7608. push_native = arr.push,
  7609. push = arr.push,
  7610. slice = arr.slice,
  7611. // Use a stripped-down indexOf as it's faster than native
  7612. // https://jsperf.com/thor-indexof-vs-for/5
  7613. indexOf = function( list, elem ) {
  7614. var i = 0,
  7615. len = list.length;
  7616. for ( ; i < len; i++ ) {
  7617. if ( list[i] === elem ) {
  7618. return i;
  7619. }
  7620. }
  7621. return -1;
  7622. },
  7623. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7624. // Regular expressions
  7625. // http://www.w3.org/TR/css3-selectors/#whitespace
  7626. whitespace = "[\\x20\\t\\r\\n\\f]",
  7627. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7628. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7629. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7630. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7631. // Operator (capture 2)
  7632. "*([*^$|!~]?=)" + whitespace +
  7633. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7634. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7635. "*\\]",
  7636. pseudos = ":(" + identifier + ")(?:\\((" +
  7637. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7638. // 1. quoted (capture 3; capture 4 or capture 5)
  7639. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7640. // 2. simple (capture 6)
  7641. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7642. // 3. anything else (capture 2)
  7643. ".*" +
  7644. ")\\)|)",
  7645. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7646. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7647. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7648. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7649. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7650. rdescend = new RegExp( whitespace + "|>" ),
  7651. rpseudo = new RegExp( pseudos ),
  7652. ridentifier = new RegExp( "^" + identifier + "$" ),
  7653. matchExpr = {
  7654. "ID": new RegExp( "^#(" + identifier + ")" ),
  7655. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7656. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7657. "ATTR": new RegExp( "^" + attributes ),
  7658. "PSEUDO": new RegExp( "^" + pseudos ),
  7659. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7660. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7661. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7662. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7663. // For use in libraries implementing .is()
  7664. // We use this for POS matching in `select`
  7665. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7666. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7667. },
  7668. rhtml = /HTML$/i,
  7669. rinputs = /^(?:input|select|textarea|button)$/i,
  7670. rheader = /^h\d$/i,
  7671. rnative = /^[^{]+\{\s*\[native \w/,
  7672. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7673. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7674. rsibling = /[+~]/,
  7675. // CSS escapes
  7676. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7677. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7678. funescape = function( _, escaped, escapedWhitespace ) {
  7679. var high = "0x" + escaped - 0x10000;
  7680. // NaN means non-codepoint
  7681. // Support: Firefox<24
  7682. // Workaround erroneous numeric interpretation of +"0x"
  7683. return high !== high || escapedWhitespace ?
  7684. escaped :
  7685. high < 0 ?
  7686. // BMP codepoint
  7687. String.fromCharCode( high + 0x10000 ) :
  7688. // Supplemental Plane codepoint (surrogate pair)
  7689. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7690. },
  7691. // CSS string/identifier serialization
  7692. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7693. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7694. fcssescape = function( ch, asCodePoint ) {
  7695. if ( asCodePoint ) {
  7696. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7697. if ( ch === "\0" ) {
  7698. return "\uFFFD";
  7699. }
  7700. // Control characters and (dependent upon position) numbers get escaped as code points
  7701. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7702. }
  7703. // Other potentially-special ASCII characters get backslash-escaped
  7704. return "\\" + ch;
  7705. },
  7706. // Used for iframes
  7707. // See setDocument()
  7708. // Removing the function wrapper causes a "Permission Denied"
  7709. // error in IE
  7710. unloadHandler = function() {
  7711. setDocument();
  7712. },
  7713. inDisabledFieldset = addCombinator(
  7714. function( elem ) {
  7715. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7716. },
  7717. { dir: "parentNode", next: "legend" }
  7718. );
  7719. // Optimize for push.apply( _, NodeList )
  7720. try {
  7721. push.apply(
  7722. (arr = slice.call( preferredDoc.childNodes )),
  7723. preferredDoc.childNodes
  7724. );
  7725. // Support: Android<4.0
  7726. // Detect silently failing push.apply
  7727. arr[ preferredDoc.childNodes.length ].nodeType;
  7728. } catch ( e ) {
  7729. push = { apply: arr.length ?
  7730. // Leverage slice if possible
  7731. function( target, els ) {
  7732. push_native.apply( target, slice.call(els) );
  7733. } :
  7734. // Support: IE<9
  7735. // Otherwise append directly
  7736. function( target, els ) {
  7737. var j = target.length,
  7738. i = 0;
  7739. // Can't trust NodeList.length
  7740. while ( (target[j++] = els[i++]) ) {}
  7741. target.length = j - 1;
  7742. }
  7743. };
  7744. }
  7745. function Sizzle( selector, context, results, seed ) {
  7746. var m, i, elem, nid, match, groups, newSelector,
  7747. newContext = context && context.ownerDocument,
  7748. // nodeType defaults to 9, since context defaults to document
  7749. nodeType = context ? context.nodeType : 9;
  7750. results = results || [];
  7751. // Return early from calls with invalid selector or context
  7752. if ( typeof selector !== "string" || !selector ||
  7753. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7754. return results;
  7755. }
  7756. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7757. if ( !seed ) {
  7758. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7759. setDocument( context );
  7760. }
  7761. context = context || document;
  7762. if ( documentIsHTML ) {
  7763. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7764. // (excepting DocumentFragment context, where the methods don't exist)
  7765. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7766. // ID selector
  7767. if ( (m = match[1]) ) {
  7768. // Document context
  7769. if ( nodeType === 9 ) {
  7770. if ( (elem = context.getElementById( m )) ) {
  7771. // Support: IE, Opera, Webkit
  7772. // TODO: identify versions
  7773. // getElementById can match elements by name instead of ID
  7774. if ( elem.id === m ) {
  7775. results.push( elem );
  7776. return results;
  7777. }
  7778. } else {
  7779. return results;
  7780. }
  7781. // Element context
  7782. } else {
  7783. // Support: IE, Opera, Webkit
  7784. // TODO: identify versions
  7785. // getElementById can match elements by name instead of ID
  7786. if ( newContext && (elem = newContext.getElementById( m )) &&
  7787. contains( context, elem ) &&
  7788. elem.id === m ) {
  7789. results.push( elem );
  7790. return results;
  7791. }
  7792. }
  7793. // Type selector
  7794. } else if ( match[2] ) {
  7795. push.apply( results, context.getElementsByTagName( selector ) );
  7796. return results;
  7797. // Class selector
  7798. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7799. context.getElementsByClassName ) {
  7800. push.apply( results, context.getElementsByClassName( m ) );
  7801. return results;
  7802. }
  7803. }
  7804. // Take advantage of querySelectorAll
  7805. if ( support.qsa &&
  7806. !nonnativeSelectorCache[ selector + " " ] &&
  7807. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7808. // Support: IE 8 only
  7809. // Exclude object elements
  7810. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7811. newSelector = selector;
  7812. newContext = context;
  7813. // qSA considers elements outside a scoping root when evaluating child or
  7814. // descendant combinators, which is not what we want.
  7815. // In such cases, we work around the behavior by prefixing every selector in the
  7816. // list with an ID selector referencing the scope context.
  7817. // Thanks to Andrew Dupont for this technique.
  7818. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7819. // Capture the context ID, setting it first if necessary
  7820. if ( (nid = context.getAttribute( "id" )) ) {
  7821. nid = nid.replace( rcssescape, fcssescape );
  7822. } else {
  7823. context.setAttribute( "id", (nid = expando) );
  7824. }
  7825. // Prefix every selector in the list
  7826. groups = tokenize( selector );
  7827. i = groups.length;
  7828. while ( i-- ) {
  7829. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7830. }
  7831. newSelector = groups.join( "," );
  7832. // Expand context for sibling selectors
  7833. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7834. context;
  7835. }
  7836. try {
  7837. push.apply( results,
  7838. newContext.querySelectorAll( newSelector )
  7839. );
  7840. return results;
  7841. } catch ( qsaError ) {
  7842. nonnativeSelectorCache( selector, true );
  7843. } finally {
  7844. if ( nid === expando ) {
  7845. context.removeAttribute( "id" );
  7846. }
  7847. }
  7848. }
  7849. }
  7850. }
  7851. // All others
  7852. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7853. }
  7854. /**
  7855. * Create key-value caches of limited size
  7856. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7857. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7858. * deleting the oldest entry
  7859. */
  7860. function createCache() {
  7861. var keys = [];
  7862. function cache( key, value ) {
  7863. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7864. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7865. // Only keep the most recent entries
  7866. delete cache[ keys.shift() ];
  7867. }
  7868. return (cache[ key + " " ] = value);
  7869. }
  7870. return cache;
  7871. }
  7872. /**
  7873. * Mark a function for special use by Sizzle
  7874. * @param {Function} fn The function to mark
  7875. */
  7876. function markFunction( fn ) {
  7877. fn[ expando ] = true;
  7878. return fn;
  7879. }
  7880. /**
  7881. * Support testing using an element
  7882. * @param {Function} fn Passed the created element and returns a boolean result
  7883. */
  7884. function assert( fn ) {
  7885. var el = document.createElement("fieldset");
  7886. try {
  7887. return !!fn( el );
  7888. } catch (e) {
  7889. return false;
  7890. } finally {
  7891. // Remove from its parent by default
  7892. if ( el.parentNode ) {
  7893. el.parentNode.removeChild( el );
  7894. }
  7895. // release memory in IE
  7896. el = null;
  7897. }
  7898. }
  7899. /**
  7900. * Adds the same handler for all of the specified attrs
  7901. * @param {String} attrs Pipe-separated list of attributes
  7902. * @param {Function} handler The method that will be applied
  7903. */
  7904. function addHandle( attrs, handler ) {
  7905. var arr = attrs.split("|"),
  7906. i = arr.length;
  7907. while ( i-- ) {
  7908. Expr.attrHandle[ arr[i] ] = handler;
  7909. }
  7910. }
  7911. /**
  7912. * Checks document order of two siblings
  7913. * @param {Element} a
  7914. * @param {Element} b
  7915. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7916. */
  7917. function siblingCheck( a, b ) {
  7918. var cur = b && a,
  7919. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7920. a.sourceIndex - b.sourceIndex;
  7921. // Use IE sourceIndex if available on both nodes
  7922. if ( diff ) {
  7923. return diff;
  7924. }
  7925. // Check if b follows a
  7926. if ( cur ) {
  7927. while ( (cur = cur.nextSibling) ) {
  7928. if ( cur === b ) {
  7929. return -1;
  7930. }
  7931. }
  7932. }
  7933. return a ? 1 : -1;
  7934. }
  7935. /**
  7936. * Returns a function to use in pseudos for input types
  7937. * @param {String} type
  7938. */
  7939. function createInputPseudo( type ) {
  7940. return function( elem ) {
  7941. var name = elem.nodeName.toLowerCase();
  7942. return name === "input" && elem.type === type;
  7943. };
  7944. }
  7945. /**
  7946. * Returns a function to use in pseudos for buttons
  7947. * @param {String} type
  7948. */
  7949. function createButtonPseudo( type ) {
  7950. return function( elem ) {
  7951. var name = elem.nodeName.toLowerCase();
  7952. return (name === "input" || name === "button") && elem.type === type;
  7953. };
  7954. }
  7955. /**
  7956. * Returns a function to use in pseudos for :enabled/:disabled
  7957. * @param {Boolean} disabled true for :disabled; false for :enabled
  7958. */
  7959. function createDisabledPseudo( disabled ) {
  7960. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7961. return function( elem ) {
  7962. // Only certain elements can match :enabled or :disabled
  7963. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7964. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7965. if ( "form" in elem ) {
  7966. // Check for inherited disabledness on relevant non-disabled elements:
  7967. // * listed form-associated elements in a disabled fieldset
  7968. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7969. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7970. // * option elements in a disabled optgroup
  7971. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7972. // All such elements have a "form" property.
  7973. if ( elem.parentNode && elem.disabled === false ) {
  7974. // Option elements defer to a parent optgroup if present
  7975. if ( "label" in elem ) {
  7976. if ( "label" in elem.parentNode ) {
  7977. return elem.parentNode.disabled === disabled;
  7978. } else {
  7979. return elem.disabled === disabled;
  7980. }
  7981. }
  7982. // Support: IE 6 - 11
  7983. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7984. return elem.isDisabled === disabled ||
  7985. // Where there is no isDisabled, check manually
  7986. /* jshint -W018 */
  7987. elem.isDisabled !== !disabled &&
  7988. inDisabledFieldset( elem ) === disabled;
  7989. }
  7990. return elem.disabled === disabled;
  7991. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7992. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7993. // even exist on them, let alone have a boolean value.
  7994. } else if ( "label" in elem ) {
  7995. return elem.disabled === disabled;
  7996. }
  7997. // Remaining elements are neither :enabled nor :disabled
  7998. return false;
  7999. };
  8000. }
  8001. /**
  8002. * Returns a function to use in pseudos for positionals
  8003. * @param {Function} fn
  8004. */
  8005. function createPositionalPseudo( fn ) {
  8006. return markFunction(function( argument ) {
  8007. argument = +argument;
  8008. return markFunction(function( seed, matches ) {
  8009. var j,
  8010. matchIndexes = fn( [], seed.length, argument ),
  8011. i = matchIndexes.length;
  8012. // Match elements found at the specified indexes
  8013. while ( i-- ) {
  8014. if ( seed[ (j = matchIndexes[i]) ] ) {
  8015. seed[j] = !(matches[j] = seed[j]);
  8016. }
  8017. }
  8018. });
  8019. });
  8020. }
  8021. /**
  8022. * Checks a node for validity as a Sizzle context
  8023. * @param {Element|Object=} context
  8024. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8025. */
  8026. function testContext( context ) {
  8027. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8028. }
  8029. // Expose support vars for convenience
  8030. support = Sizzle.support = {};
  8031. /**
  8032. * Detects XML nodes
  8033. * @param {Element|Object} elem An element or a document
  8034. * @returns {Boolean} True iff elem is a non-HTML XML node
  8035. */
  8036. isXML = Sizzle.isXML = function( elem ) {
  8037. var namespace = elem.namespaceURI,
  8038. docElem = (elem.ownerDocument || elem).documentElement;
  8039. // Support: IE <=8
  8040. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8041. // https://bugs.jquery.com/ticket/4833
  8042. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8043. };
  8044. /**
  8045. * Sets document-related variables once based on the current document
  8046. * @param {Element|Object} [doc] An element or document object to use to set the document
  8047. * @returns {Object} Returns the current document
  8048. */
  8049. setDocument = Sizzle.setDocument = function( node ) {
  8050. var hasCompare, subWindow,
  8051. doc = node ? node.ownerDocument || node : preferredDoc;
  8052. // Return early if doc is invalid or already selected
  8053. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8054. return document;
  8055. }
  8056. // Update global variables
  8057. document = doc;
  8058. docElem = document.documentElement;
  8059. documentIsHTML = !isXML( document );
  8060. // Support: IE 9-11, Edge
  8061. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8062. if ( preferredDoc !== document &&
  8063. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8064. // Support: IE 11, Edge
  8065. if ( subWindow.addEventListener ) {
  8066. subWindow.addEventListener( "unload", unloadHandler, false );
  8067. // Support: IE 9 - 10 only
  8068. } else if ( subWindow.attachEvent ) {
  8069. subWindow.attachEvent( "onunload", unloadHandler );
  8070. }
  8071. }
  8072. /* Attributes
  8073. ---------------------------------------------------------------------- */
  8074. // Support: IE<8
  8075. // Verify that getAttribute really returns attributes and not properties
  8076. // (excepting IE8 booleans)
  8077. support.attributes = assert(function( el ) {
  8078. el.className = "i";
  8079. return !el.getAttribute("className");
  8080. });
  8081. /* getElement(s)By*
  8082. ---------------------------------------------------------------------- */
  8083. // Check if getElementsByTagName("*") returns only elements
  8084. support.getElementsByTagName = assert(function( el ) {
  8085. el.appendChild( document.createComment("") );
  8086. return !el.getElementsByTagName("*").length;
  8087. });
  8088. // Support: IE<9
  8089. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8090. // Support: IE<10
  8091. // Check if getElementById returns elements by name
  8092. // The broken getElementById methods don't pick up programmatically-set names,
  8093. // so use a roundabout getElementsByName test
  8094. support.getById = assert(function( el ) {
  8095. docElem.appendChild( el ).id = expando;
  8096. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8097. });
  8098. // ID filter and find
  8099. if ( support.getById ) {
  8100. Expr.filter["ID"] = function( id ) {
  8101. var attrId = id.replace( runescape, funescape );
  8102. return function( elem ) {
  8103. return elem.getAttribute("id") === attrId;
  8104. };
  8105. };
  8106. Expr.find["ID"] = function( id, context ) {
  8107. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8108. var elem = context.getElementById( id );
  8109. return elem ? [ elem ] : [];
  8110. }
  8111. };
  8112. } else {
  8113. Expr.filter["ID"] = function( id ) {
  8114. var attrId = id.replace( runescape, funescape );
  8115. return function( elem ) {
  8116. var node = typeof elem.getAttributeNode !== "undefined" &&
  8117. elem.getAttributeNode("id");
  8118. return node && node.value === attrId;
  8119. };
  8120. };
  8121. // Support: IE 6 - 7 only
  8122. // getElementById is not reliable as a find shortcut
  8123. Expr.find["ID"] = function( id, context ) {
  8124. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8125. var node, i, elems,
  8126. elem = context.getElementById( id );
  8127. if ( elem ) {
  8128. // Verify the id attribute
  8129. node = elem.getAttributeNode("id");
  8130. if ( node && node.value === id ) {
  8131. return [ elem ];
  8132. }
  8133. // Fall back on getElementsByName
  8134. elems = context.getElementsByName( id );
  8135. i = 0;
  8136. while ( (elem = elems[i++]) ) {
  8137. node = elem.getAttributeNode("id");
  8138. if ( node && node.value === id ) {
  8139. return [ elem ];
  8140. }
  8141. }
  8142. }
  8143. return [];
  8144. }
  8145. };
  8146. }
  8147. // Tag
  8148. Expr.find["TAG"] = support.getElementsByTagName ?
  8149. function( tag, context ) {
  8150. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8151. return context.getElementsByTagName( tag );
  8152. // DocumentFragment nodes don't have gEBTN
  8153. } else if ( support.qsa ) {
  8154. return context.querySelectorAll( tag );
  8155. }
  8156. } :
  8157. function( tag, context ) {
  8158. var elem,
  8159. tmp = [],
  8160. i = 0,
  8161. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8162. results = context.getElementsByTagName( tag );
  8163. // Filter out possible comments
  8164. if ( tag === "*" ) {
  8165. while ( (elem = results[i++]) ) {
  8166. if ( elem.nodeType === 1 ) {
  8167. tmp.push( elem );
  8168. }
  8169. }
  8170. return tmp;
  8171. }
  8172. return results;
  8173. };
  8174. // Class
  8175. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8176. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8177. return context.getElementsByClassName( className );
  8178. }
  8179. };
  8180. /* QSA/matchesSelector
  8181. ---------------------------------------------------------------------- */
  8182. // QSA and matchesSelector support
  8183. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8184. rbuggyMatches = [];
  8185. // qSa(:focus) reports false when true (Chrome 21)
  8186. // We allow this because of a bug in IE8/9 that throws an error
  8187. // whenever `document.activeElement` is accessed on an iframe
  8188. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8189. // See https://bugs.jquery.com/ticket/13378
  8190. rbuggyQSA = [];
  8191. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8192. // Build QSA regex
  8193. // Regex strategy adopted from Diego Perini
  8194. assert(function( el ) {
  8195. // Select is set to empty string on purpose
  8196. // This is to test IE's treatment of not explicitly
  8197. // setting a boolean content attribute,
  8198. // since its presence should be enough
  8199. // https://bugs.jquery.com/ticket/12359
  8200. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8201. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8202. "<option selected=''></option></select>";
  8203. // Support: IE8, Opera 11-12.16
  8204. // Nothing should be selected when empty strings follow ^= or $= or *=
  8205. // The test attribute must be unknown in Opera but "safe" for WinRT
  8206. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8207. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8208. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8209. }
  8210. // Support: IE8
  8211. // Boolean attributes and "value" are not treated correctly
  8212. if ( !el.querySelectorAll("[selected]").length ) {
  8213. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8214. }
  8215. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8216. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8217. rbuggyQSA.push("~=");
  8218. }
  8219. // Webkit/Opera - :checked should return selected option elements
  8220. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8221. // IE8 throws error here and will not see later tests
  8222. if ( !el.querySelectorAll(":checked").length ) {
  8223. rbuggyQSA.push(":checked");
  8224. }
  8225. // Support: Safari 8+, iOS 8+
  8226. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8227. // In-page `selector#id sibling-combinator selector` fails
  8228. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8229. rbuggyQSA.push(".#.+[+~]");
  8230. }
  8231. });
  8232. assert(function( el ) {
  8233. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8234. "<select disabled='disabled'><option/></select>";
  8235. // Support: Windows 8 Native Apps
  8236. // The type and name attributes are restricted during .innerHTML assignment
  8237. var input = document.createElement("input");
  8238. input.setAttribute( "type", "hidden" );
  8239. el.appendChild( input ).setAttribute( "name", "D" );
  8240. // Support: IE8
  8241. // Enforce case-sensitivity of name attribute
  8242. if ( el.querySelectorAll("[name=d]").length ) {
  8243. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8244. }
  8245. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8246. // IE8 throws error here and will not see later tests
  8247. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8248. rbuggyQSA.push( ":enabled", ":disabled" );
  8249. }
  8250. // Support: IE9-11+
  8251. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8252. docElem.appendChild( el ).disabled = true;
  8253. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8254. rbuggyQSA.push( ":enabled", ":disabled" );
  8255. }
  8256. // Opera 10-11 does not throw on post-comma invalid pseudos
  8257. el.querySelectorAll("*,:x");
  8258. rbuggyQSA.push(",.*:");
  8259. });
  8260. }
  8261. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8262. docElem.webkitMatchesSelector ||
  8263. docElem.mozMatchesSelector ||
  8264. docElem.oMatchesSelector ||
  8265. docElem.msMatchesSelector) )) ) {
  8266. assert(function( el ) {
  8267. // Check to see if it's possible to do matchesSelector
  8268. // on a disconnected node (IE 9)
  8269. support.disconnectedMatch = matches.call( el, "*" );
  8270. // This should fail with an exception
  8271. // Gecko does not error, returns false instead
  8272. matches.call( el, "[s!='']:x" );
  8273. rbuggyMatches.push( "!=", pseudos );
  8274. });
  8275. }
  8276. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8277. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8278. /* Contains
  8279. ---------------------------------------------------------------------- */
  8280. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8281. // Element contains another
  8282. // Purposefully self-exclusive
  8283. // As in, an element does not contain itself
  8284. contains = hasCompare || rnative.test( docElem.contains ) ?
  8285. function( a, b ) {
  8286. var adown = a.nodeType === 9 ? a.documentElement : a,
  8287. bup = b && b.parentNode;
  8288. return a === bup || !!( bup && bup.nodeType === 1 && (
  8289. adown.contains ?
  8290. adown.contains( bup ) :
  8291. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8292. ));
  8293. } :
  8294. function( a, b ) {
  8295. if ( b ) {
  8296. while ( (b = b.parentNode) ) {
  8297. if ( b === a ) {
  8298. return true;
  8299. }
  8300. }
  8301. }
  8302. return false;
  8303. };
  8304. /* Sorting
  8305. ---------------------------------------------------------------------- */
  8306. // Document order sorting
  8307. sortOrder = hasCompare ?
  8308. function( a, b ) {
  8309. // Flag for duplicate removal
  8310. if ( a === b ) {
  8311. hasDuplicate = true;
  8312. return 0;
  8313. }
  8314. // Sort on method existence if only one input has compareDocumentPosition
  8315. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8316. if ( compare ) {
  8317. return compare;
  8318. }
  8319. // Calculate position if both inputs belong to the same document
  8320. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8321. a.compareDocumentPosition( b ) :
  8322. // Otherwise we know they are disconnected
  8323. 1;
  8324. // Disconnected nodes
  8325. if ( compare & 1 ||
  8326. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8327. // Choose the first element that is related to our preferred document
  8328. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8329. return -1;
  8330. }
  8331. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8332. return 1;
  8333. }
  8334. // Maintain original order
  8335. return sortInput ?
  8336. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8337. 0;
  8338. }
  8339. return compare & 4 ? -1 : 1;
  8340. } :
  8341. function( a, b ) {
  8342. // Exit early if the nodes are identical
  8343. if ( a === b ) {
  8344. hasDuplicate = true;
  8345. return 0;
  8346. }
  8347. var cur,
  8348. i = 0,
  8349. aup = a.parentNode,
  8350. bup = b.parentNode,
  8351. ap = [ a ],
  8352. bp = [ b ];
  8353. // Parentless nodes are either documents or disconnected
  8354. if ( !aup || !bup ) {
  8355. return a === document ? -1 :
  8356. b === document ? 1 :
  8357. aup ? -1 :
  8358. bup ? 1 :
  8359. sortInput ?
  8360. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8361. 0;
  8362. // If the nodes are siblings, we can do a quick check
  8363. } else if ( aup === bup ) {
  8364. return siblingCheck( a, b );
  8365. }
  8366. // Otherwise we need full lists of their ancestors for comparison
  8367. cur = a;
  8368. while ( (cur = cur.parentNode) ) {
  8369. ap.unshift( cur );
  8370. }
  8371. cur = b;
  8372. while ( (cur = cur.parentNode) ) {
  8373. bp.unshift( cur );
  8374. }
  8375. // Walk down the tree looking for a discrepancy
  8376. while ( ap[i] === bp[i] ) {
  8377. i++;
  8378. }
  8379. return i ?
  8380. // Do a sibling check if the nodes have a common ancestor
  8381. siblingCheck( ap[i], bp[i] ) :
  8382. // Otherwise nodes in our document sort first
  8383. ap[i] === preferredDoc ? -1 :
  8384. bp[i] === preferredDoc ? 1 :
  8385. 0;
  8386. };
  8387. return document;
  8388. };
  8389. Sizzle.matches = function( expr, elements ) {
  8390. return Sizzle( expr, null, null, elements );
  8391. };
  8392. Sizzle.matchesSelector = function( elem, expr ) {
  8393. // Set document vars if needed
  8394. if ( ( elem.ownerDocument || elem ) !== document ) {
  8395. setDocument( elem );
  8396. }
  8397. if ( support.matchesSelector && documentIsHTML &&
  8398. !nonnativeSelectorCache[ expr + " " ] &&
  8399. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8400. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8401. try {
  8402. var ret = matches.call( elem, expr );
  8403. // IE 9's matchesSelector returns false on disconnected nodes
  8404. if ( ret || support.disconnectedMatch ||
  8405. // As well, disconnected nodes are said to be in a document
  8406. // fragment in IE 9
  8407. elem.document && elem.document.nodeType !== 11 ) {
  8408. return ret;
  8409. }
  8410. } catch (e) {
  8411. nonnativeSelectorCache( expr, true );
  8412. }
  8413. }
  8414. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8415. };
  8416. Sizzle.contains = function( context, elem ) {
  8417. // Set document vars if needed
  8418. if ( ( context.ownerDocument || context ) !== document ) {
  8419. setDocument( context );
  8420. }
  8421. return contains( context, elem );
  8422. };
  8423. Sizzle.attr = function( elem, name ) {
  8424. // Set document vars if needed
  8425. if ( ( elem.ownerDocument || elem ) !== document ) {
  8426. setDocument( elem );
  8427. }
  8428. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8429. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8430. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8431. fn( elem, name, !documentIsHTML ) :
  8432. undefined;
  8433. return val !== undefined ?
  8434. val :
  8435. support.attributes || !documentIsHTML ?
  8436. elem.getAttribute( name ) :
  8437. (val = elem.getAttributeNode(name)) && val.specified ?
  8438. val.value :
  8439. null;
  8440. };
  8441. Sizzle.escape = function( sel ) {
  8442. return (sel + "").replace( rcssescape, fcssescape );
  8443. };
  8444. Sizzle.error = function( msg ) {
  8445. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8446. };
  8447. /**
  8448. * Document sorting and removing duplicates
  8449. * @param {ArrayLike} results
  8450. */
  8451. Sizzle.uniqueSort = function( results ) {
  8452. var elem,
  8453. duplicates = [],
  8454. j = 0,
  8455. i = 0;
  8456. // Unless we *know* we can detect duplicates, assume their presence
  8457. hasDuplicate = !support.detectDuplicates;
  8458. sortInput = !support.sortStable && results.slice( 0 );
  8459. results.sort( sortOrder );
  8460. if ( hasDuplicate ) {
  8461. while ( (elem = results[i++]) ) {
  8462. if ( elem === results[ i ] ) {
  8463. j = duplicates.push( i );
  8464. }
  8465. }
  8466. while ( j-- ) {
  8467. results.splice( duplicates[ j ], 1 );
  8468. }
  8469. }
  8470. // Clear input after sorting to release objects
  8471. // See https://github.com/jquery/sizzle/pull/225
  8472. sortInput = null;
  8473. return results;
  8474. };
  8475. /**
  8476. * Utility function for retrieving the text value of an array of DOM nodes
  8477. * @param {Array|Element} elem
  8478. */
  8479. getText = Sizzle.getText = function( elem ) {
  8480. var node,
  8481. ret = "",
  8482. i = 0,
  8483. nodeType = elem.nodeType;
  8484. if ( !nodeType ) {
  8485. // If no nodeType, this is expected to be an array
  8486. while ( (node = elem[i++]) ) {
  8487. // Do not traverse comment nodes
  8488. ret += getText( node );
  8489. }
  8490. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8491. // Use textContent for elements
  8492. // innerText usage removed for consistency of new lines (jQuery #11153)
  8493. if ( typeof elem.textContent === "string" ) {
  8494. return elem.textContent;
  8495. } else {
  8496. // Traverse its children
  8497. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8498. ret += getText( elem );
  8499. }
  8500. }
  8501. } else if ( nodeType === 3 || nodeType === 4 ) {
  8502. return elem.nodeValue;
  8503. }
  8504. // Do not include comment or processing instruction nodes
  8505. return ret;
  8506. };
  8507. Expr = Sizzle.selectors = {
  8508. // Can be adjusted by the user
  8509. cacheLength: 50,
  8510. createPseudo: markFunction,
  8511. match: matchExpr,
  8512. attrHandle: {},
  8513. find: {},
  8514. relative: {
  8515. ">": { dir: "parentNode", first: true },
  8516. " ": { dir: "parentNode" },
  8517. "+": { dir: "previousSibling", first: true },
  8518. "~": { dir: "previousSibling" }
  8519. },
  8520. preFilter: {
  8521. "ATTR": function( match ) {
  8522. match[1] = match[1].replace( runescape, funescape );
  8523. // Move the given value to match[3] whether quoted or unquoted
  8524. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8525. if ( match[2] === "~=" ) {
  8526. match[3] = " " + match[3] + " ";
  8527. }
  8528. return match.slice( 0, 4 );
  8529. },
  8530. "CHILD": function( match ) {
  8531. /* matches from matchExpr["CHILD"]
  8532. 1 type (only|nth|...)
  8533. 2 what (child|of-type)
  8534. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8535. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8536. 5 sign of xn-component
  8537. 6 x of xn-component
  8538. 7 sign of y-component
  8539. 8 y of y-component
  8540. */
  8541. match[1] = match[1].toLowerCase();
  8542. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8543. // nth-* requires argument
  8544. if ( !match[3] ) {
  8545. Sizzle.error( match[0] );
  8546. }
  8547. // numeric x and y parameters for Expr.filter.CHILD
  8548. // remember that false/true cast respectively to 0/1
  8549. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8550. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8551. // other types prohibit arguments
  8552. } else if ( match[3] ) {
  8553. Sizzle.error( match[0] );
  8554. }
  8555. return match;
  8556. },
  8557. "PSEUDO": function( match ) {
  8558. var excess,
  8559. unquoted = !match[6] && match[2];
  8560. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8561. return null;
  8562. }
  8563. // Accept quoted arguments as-is
  8564. if ( match[3] ) {
  8565. match[2] = match[4] || match[5] || "";
  8566. // Strip excess characters from unquoted arguments
  8567. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8568. // Get excess from tokenize (recursively)
  8569. (excess = tokenize( unquoted, true )) &&
  8570. // advance to the next closing parenthesis
  8571. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8572. // excess is a negative index
  8573. match[0] = match[0].slice( 0, excess );
  8574. match[2] = unquoted.slice( 0, excess );
  8575. }
  8576. // Return only captures needed by the pseudo filter method (type and argument)
  8577. return match.slice( 0, 3 );
  8578. }
  8579. },
  8580. filter: {
  8581. "TAG": function( nodeNameSelector ) {
  8582. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8583. return nodeNameSelector === "*" ?
  8584. function() { return true; } :
  8585. function( elem ) {
  8586. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8587. };
  8588. },
  8589. "CLASS": function( className ) {
  8590. var pattern = classCache[ className + " " ];
  8591. return pattern ||
  8592. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8593. classCache( className, function( elem ) {
  8594. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8595. });
  8596. },
  8597. "ATTR": function( name, operator, check ) {
  8598. return function( elem ) {
  8599. var result = Sizzle.attr( elem, name );
  8600. if ( result == null ) {
  8601. return operator === "!=";
  8602. }
  8603. if ( !operator ) {
  8604. return true;
  8605. }
  8606. result += "";
  8607. return operator === "=" ? result === check :
  8608. operator === "!=" ? result !== check :
  8609. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8610. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8611. operator === "$=" ? check && result.slice( -check.length ) === check :
  8612. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8613. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8614. false;
  8615. };
  8616. },
  8617. "CHILD": function( type, what, argument, first, last ) {
  8618. var simple = type.slice( 0, 3 ) !== "nth",
  8619. forward = type.slice( -4 ) !== "last",
  8620. ofType = what === "of-type";
  8621. return first === 1 && last === 0 ?
  8622. // Shortcut for :nth-*(n)
  8623. function( elem ) {
  8624. return !!elem.parentNode;
  8625. } :
  8626. function( elem, context, xml ) {
  8627. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8628. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8629. parent = elem.parentNode,
  8630. name = ofType && elem.nodeName.toLowerCase(),
  8631. useCache = !xml && !ofType,
  8632. diff = false;
  8633. if ( parent ) {
  8634. // :(first|last|only)-(child|of-type)
  8635. if ( simple ) {
  8636. while ( dir ) {
  8637. node = elem;
  8638. while ( (node = node[ dir ]) ) {
  8639. if ( ofType ?
  8640. node.nodeName.toLowerCase() === name :
  8641. node.nodeType === 1 ) {
  8642. return false;
  8643. }
  8644. }
  8645. // Reverse direction for :only-* (if we haven't yet done so)
  8646. start = dir = type === "only" && !start && "nextSibling";
  8647. }
  8648. return true;
  8649. }
  8650. start = [ forward ? parent.firstChild : parent.lastChild ];
  8651. // non-xml :nth-child(...) stores cache data on `parent`
  8652. if ( forward && useCache ) {
  8653. // Seek `elem` from a previously-cached index
  8654. // ...in a gzip-friendly way
  8655. node = parent;
  8656. outerCache = node[ expando ] || (node[ expando ] = {});
  8657. // Support: IE <9 only
  8658. // Defend against cloned attroperties (jQuery gh-1709)
  8659. uniqueCache = outerCache[ node.uniqueID ] ||
  8660. (outerCache[ node.uniqueID ] = {});
  8661. cache = uniqueCache[ type ] || [];
  8662. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8663. diff = nodeIndex && cache[ 2 ];
  8664. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8665. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8666. // Fallback to seeking `elem` from the start
  8667. (diff = nodeIndex = 0) || start.pop()) ) {
  8668. // When found, cache indexes on `parent` and break
  8669. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8670. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8671. break;
  8672. }
  8673. }
  8674. } else {
  8675. // Use previously-cached element index if available
  8676. if ( useCache ) {
  8677. // ...in a gzip-friendly way
  8678. node = elem;
  8679. outerCache = node[ expando ] || (node[ expando ] = {});
  8680. // Support: IE <9 only
  8681. // Defend against cloned attroperties (jQuery gh-1709)
  8682. uniqueCache = outerCache[ node.uniqueID ] ||
  8683. (outerCache[ node.uniqueID ] = {});
  8684. cache = uniqueCache[ type ] || [];
  8685. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8686. diff = nodeIndex;
  8687. }
  8688. // xml :nth-child(...)
  8689. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8690. if ( diff === false ) {
  8691. // Use the same loop as above to seek `elem` from the start
  8692. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8693. (diff = nodeIndex = 0) || start.pop()) ) {
  8694. if ( ( ofType ?
  8695. node.nodeName.toLowerCase() === name :
  8696. node.nodeType === 1 ) &&
  8697. ++diff ) {
  8698. // Cache the index of each encountered element
  8699. if ( useCache ) {
  8700. outerCache = node[ expando ] || (node[ expando ] = {});
  8701. // Support: IE <9 only
  8702. // Defend against cloned attroperties (jQuery gh-1709)
  8703. uniqueCache = outerCache[ node.uniqueID ] ||
  8704. (outerCache[ node.uniqueID ] = {});
  8705. uniqueCache[ type ] = [ dirruns, diff ];
  8706. }
  8707. if ( node === elem ) {
  8708. break;
  8709. }
  8710. }
  8711. }
  8712. }
  8713. }
  8714. // Incorporate the offset, then check against cycle size
  8715. diff -= last;
  8716. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8717. }
  8718. };
  8719. },
  8720. "PSEUDO": function( pseudo, argument ) {
  8721. // pseudo-class names are case-insensitive
  8722. // http://www.w3.org/TR/selectors/#pseudo-classes
  8723. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8724. // Remember that setFilters inherits from pseudos
  8725. var args,
  8726. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8727. Sizzle.error( "unsupported pseudo: " + pseudo );
  8728. // The user may use createPseudo to indicate that
  8729. // arguments are needed to create the filter function
  8730. // just as Sizzle does
  8731. if ( fn[ expando ] ) {
  8732. return fn( argument );
  8733. }
  8734. // But maintain support for old signatures
  8735. if ( fn.length > 1 ) {
  8736. args = [ pseudo, pseudo, "", argument ];
  8737. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8738. markFunction(function( seed, matches ) {
  8739. var idx,
  8740. matched = fn( seed, argument ),
  8741. i = matched.length;
  8742. while ( i-- ) {
  8743. idx = indexOf( seed, matched[i] );
  8744. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8745. }
  8746. }) :
  8747. function( elem ) {
  8748. return fn( elem, 0, args );
  8749. };
  8750. }
  8751. return fn;
  8752. }
  8753. },
  8754. pseudos: {
  8755. // Potentially complex pseudos
  8756. "not": markFunction(function( selector ) {
  8757. // Trim the selector passed to compile
  8758. // to avoid treating leading and trailing
  8759. // spaces as combinators
  8760. var input = [],
  8761. results = [],
  8762. matcher = compile( selector.replace( rtrim, "$1" ) );
  8763. return matcher[ expando ] ?
  8764. markFunction(function( seed, matches, context, xml ) {
  8765. var elem,
  8766. unmatched = matcher( seed, null, xml, [] ),
  8767. i = seed.length;
  8768. // Match elements unmatched by `matcher`
  8769. while ( i-- ) {
  8770. if ( (elem = unmatched[i]) ) {
  8771. seed[i] = !(matches[i] = elem);
  8772. }
  8773. }
  8774. }) :
  8775. function( elem, context, xml ) {
  8776. input[0] = elem;
  8777. matcher( input, null, xml, results );
  8778. // Don't keep the element (issue #299)
  8779. input[0] = null;
  8780. return !results.pop();
  8781. };
  8782. }),
  8783. "has": markFunction(function( selector ) {
  8784. return function( elem ) {
  8785. return Sizzle( selector, elem ).length > 0;
  8786. };
  8787. }),
  8788. "contains": markFunction(function( text ) {
  8789. text = text.replace( runescape, funescape );
  8790. return function( elem ) {
  8791. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8792. };
  8793. }),
  8794. // "Whether an element is represented by a :lang() selector
  8795. // is based solely on the element's language value
  8796. // being equal to the identifier C,
  8797. // or beginning with the identifier C immediately followed by "-".
  8798. // The matching of C against the element's language value is performed case-insensitively.
  8799. // The identifier C does not have to be a valid language name."
  8800. // http://www.w3.org/TR/selectors/#lang-pseudo
  8801. "lang": markFunction( function( lang ) {
  8802. // lang value must be a valid identifier
  8803. if ( !ridentifier.test(lang || "") ) {
  8804. Sizzle.error( "unsupported lang: " + lang );
  8805. }
  8806. lang = lang.replace( runescape, funescape ).toLowerCase();
  8807. return function( elem ) {
  8808. var elemLang;
  8809. do {
  8810. if ( (elemLang = documentIsHTML ?
  8811. elem.lang :
  8812. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8813. elemLang = elemLang.toLowerCase();
  8814. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8815. }
  8816. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8817. return false;
  8818. };
  8819. }),
  8820. // Miscellaneous
  8821. "target": function( elem ) {
  8822. var hash = window.location && window.location.hash;
  8823. return hash && hash.slice( 1 ) === elem.id;
  8824. },
  8825. "root": function( elem ) {
  8826. return elem === docElem;
  8827. },
  8828. "focus": function( elem ) {
  8829. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8830. },
  8831. // Boolean properties
  8832. "enabled": createDisabledPseudo( false ),
  8833. "disabled": createDisabledPseudo( true ),
  8834. "checked": function( elem ) {
  8835. // In CSS3, :checked should return both checked and selected elements
  8836. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8837. var nodeName = elem.nodeName.toLowerCase();
  8838. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8839. },
  8840. "selected": function( elem ) {
  8841. // Accessing this property makes selected-by-default
  8842. // options in Safari work properly
  8843. if ( elem.parentNode ) {
  8844. elem.parentNode.selectedIndex;
  8845. }
  8846. return elem.selected === true;
  8847. },
  8848. // Contents
  8849. "empty": function( elem ) {
  8850. // http://www.w3.org/TR/selectors/#empty-pseudo
  8851. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8852. // but not by others (comment: 8; processing instruction: 7; etc.)
  8853. // nodeType < 6 works because attributes (2) do not appear as children
  8854. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8855. if ( elem.nodeType < 6 ) {
  8856. return false;
  8857. }
  8858. }
  8859. return true;
  8860. },
  8861. "parent": function( elem ) {
  8862. return !Expr.pseudos["empty"]( elem );
  8863. },
  8864. // Element/input types
  8865. "header": function( elem ) {
  8866. return rheader.test( elem.nodeName );
  8867. },
  8868. "input": function( elem ) {
  8869. return rinputs.test( elem.nodeName );
  8870. },
  8871. "button": function( elem ) {
  8872. var name = elem.nodeName.toLowerCase();
  8873. return name === "input" && elem.type === "button" || name === "button";
  8874. },
  8875. "text": function( elem ) {
  8876. var attr;
  8877. return elem.nodeName.toLowerCase() === "input" &&
  8878. elem.type === "text" &&
  8879. // Support: IE<8
  8880. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8881. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8882. },
  8883. // Position-in-collection
  8884. "first": createPositionalPseudo(function() {
  8885. return [ 0 ];
  8886. }),
  8887. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8888. return [ length - 1 ];
  8889. }),
  8890. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8891. return [ argument < 0 ? argument + length : argument ];
  8892. }),
  8893. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8894. var i = 0;
  8895. for ( ; i < length; i += 2 ) {
  8896. matchIndexes.push( i );
  8897. }
  8898. return matchIndexes;
  8899. }),
  8900. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8901. var i = 1;
  8902. for ( ; i < length; i += 2 ) {
  8903. matchIndexes.push( i );
  8904. }
  8905. return matchIndexes;
  8906. }),
  8907. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8908. var i = argument < 0 ?
  8909. argument + length :
  8910. argument > length ?
  8911. length :
  8912. argument;
  8913. for ( ; --i >= 0; ) {
  8914. matchIndexes.push( i );
  8915. }
  8916. return matchIndexes;
  8917. }),
  8918. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8919. var i = argument < 0 ? argument + length : argument;
  8920. for ( ; ++i < length; ) {
  8921. matchIndexes.push( i );
  8922. }
  8923. return matchIndexes;
  8924. })
  8925. }
  8926. };
  8927. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8928. // Add button/input type pseudos
  8929. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8930. Expr.pseudos[ i ] = createInputPseudo( i );
  8931. }
  8932. for ( i in { submit: true, reset: true } ) {
  8933. Expr.pseudos[ i ] = createButtonPseudo( i );
  8934. }
  8935. // Easy API for creating new setFilters
  8936. function setFilters() {}
  8937. setFilters.prototype = Expr.filters = Expr.pseudos;
  8938. Expr.setFilters = new setFilters();
  8939. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8940. var matched, match, tokens, type,
  8941. soFar, groups, preFilters,
  8942. cached = tokenCache[ selector + " " ];
  8943. if ( cached ) {
  8944. return parseOnly ? 0 : cached.slice( 0 );
  8945. }
  8946. soFar = selector;
  8947. groups = [];
  8948. preFilters = Expr.preFilter;
  8949. while ( soFar ) {
  8950. // Comma and first run
  8951. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8952. if ( match ) {
  8953. // Don't consume trailing commas as valid
  8954. soFar = soFar.slice( match[0].length ) || soFar;
  8955. }
  8956. groups.push( (tokens = []) );
  8957. }
  8958. matched = false;
  8959. // Combinators
  8960. if ( (match = rcombinators.exec( soFar )) ) {
  8961. matched = match.shift();
  8962. tokens.push({
  8963. value: matched,
  8964. // Cast descendant combinators to space
  8965. type: match[0].replace( rtrim, " " )
  8966. });
  8967. soFar = soFar.slice( matched.length );
  8968. }
  8969. // Filters
  8970. for ( type in Expr.filter ) {
  8971. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8972. (match = preFilters[ type ]( match ))) ) {
  8973. matched = match.shift();
  8974. tokens.push({
  8975. value: matched,
  8976. type: type,
  8977. matches: match
  8978. });
  8979. soFar = soFar.slice( matched.length );
  8980. }
  8981. }
  8982. if ( !matched ) {
  8983. break;
  8984. }
  8985. }
  8986. // Return the length of the invalid excess
  8987. // if we're just parsing
  8988. // Otherwise, throw an error or return tokens
  8989. return parseOnly ?
  8990. soFar.length :
  8991. soFar ?
  8992. Sizzle.error( selector ) :
  8993. // Cache the tokens
  8994. tokenCache( selector, groups ).slice( 0 );
  8995. };
  8996. function toSelector( tokens ) {
  8997. var i = 0,
  8998. len = tokens.length,
  8999. selector = "";
  9000. for ( ; i < len; i++ ) {
  9001. selector += tokens[i].value;
  9002. }
  9003. return selector;
  9004. }
  9005. function addCombinator( matcher, combinator, base ) {
  9006. var dir = combinator.dir,
  9007. skip = combinator.next,
  9008. key = skip || dir,
  9009. checkNonElements = base && key === "parentNode",
  9010. doneName = done++;
  9011. return combinator.first ?
  9012. // Check against closest ancestor/preceding element
  9013. function( elem, context, xml ) {
  9014. while ( (elem = elem[ dir ]) ) {
  9015. if ( elem.nodeType === 1 || checkNonElements ) {
  9016. return matcher( elem, context, xml );
  9017. }
  9018. }
  9019. return false;
  9020. } :
  9021. // Check against all ancestor/preceding elements
  9022. function( elem, context, xml ) {
  9023. var oldCache, uniqueCache, outerCache,
  9024. newCache = [ dirruns, doneName ];
  9025. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9026. if ( xml ) {
  9027. while ( (elem = elem[ dir ]) ) {
  9028. if ( elem.nodeType === 1 || checkNonElements ) {
  9029. if ( matcher( elem, context, xml ) ) {
  9030. return true;
  9031. }
  9032. }
  9033. }
  9034. } else {
  9035. while ( (elem = elem[ dir ]) ) {
  9036. if ( elem.nodeType === 1 || checkNonElements ) {
  9037. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9038. // Support: IE <9 only
  9039. // Defend against cloned attroperties (jQuery gh-1709)
  9040. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9041. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9042. elem = elem[ dir ] || elem;
  9043. } else if ( (oldCache = uniqueCache[ key ]) &&
  9044. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9045. // Assign to newCache so results back-propagate to previous elements
  9046. return (newCache[ 2 ] = oldCache[ 2 ]);
  9047. } else {
  9048. // Reuse newcache so results back-propagate to previous elements
  9049. uniqueCache[ key ] = newCache;
  9050. // A match means we're done; a fail means we have to keep checking
  9051. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9052. return true;
  9053. }
  9054. }
  9055. }
  9056. }
  9057. }
  9058. return false;
  9059. };
  9060. }
  9061. function elementMatcher( matchers ) {
  9062. return matchers.length > 1 ?
  9063. function( elem, context, xml ) {
  9064. var i = matchers.length;
  9065. while ( i-- ) {
  9066. if ( !matchers[i]( elem, context, xml ) ) {
  9067. return false;
  9068. }
  9069. }
  9070. return true;
  9071. } :
  9072. matchers[0];
  9073. }
  9074. function multipleContexts( selector, contexts, results ) {
  9075. var i = 0,
  9076. len = contexts.length;
  9077. for ( ; i < len; i++ ) {
  9078. Sizzle( selector, contexts[i], results );
  9079. }
  9080. return results;
  9081. }
  9082. function condense( unmatched, map, filter, context, xml ) {
  9083. var elem,
  9084. newUnmatched = [],
  9085. i = 0,
  9086. len = unmatched.length,
  9087. mapped = map != null;
  9088. for ( ; i < len; i++ ) {
  9089. if ( (elem = unmatched[i]) ) {
  9090. if ( !filter || filter( elem, context, xml ) ) {
  9091. newUnmatched.push( elem );
  9092. if ( mapped ) {
  9093. map.push( i );
  9094. }
  9095. }
  9096. }
  9097. }
  9098. return newUnmatched;
  9099. }
  9100. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9101. if ( postFilter && !postFilter[ expando ] ) {
  9102. postFilter = setMatcher( postFilter );
  9103. }
  9104. if ( postFinder && !postFinder[ expando ] ) {
  9105. postFinder = setMatcher( postFinder, postSelector );
  9106. }
  9107. return markFunction(function( seed, results, context, xml ) {
  9108. var temp, i, elem,
  9109. preMap = [],
  9110. postMap = [],
  9111. preexisting = results.length,
  9112. // Get initial elements from seed or context
  9113. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9114. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9115. matcherIn = preFilter && ( seed || !selector ) ?
  9116. condense( elems, preMap, preFilter, context, xml ) :
  9117. elems,
  9118. matcherOut = matcher ?
  9119. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9120. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9121. // ...intermediate processing is necessary
  9122. [] :
  9123. // ...otherwise use results directly
  9124. results :
  9125. matcherIn;
  9126. // Find primary matches
  9127. if ( matcher ) {
  9128. matcher( matcherIn, matcherOut, context, xml );
  9129. }
  9130. // Apply postFilter
  9131. if ( postFilter ) {
  9132. temp = condense( matcherOut, postMap );
  9133. postFilter( temp, [], context, xml );
  9134. // Un-match failing elements by moving them back to matcherIn
  9135. i = temp.length;
  9136. while ( i-- ) {
  9137. if ( (elem = temp[i]) ) {
  9138. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9139. }
  9140. }
  9141. }
  9142. if ( seed ) {
  9143. if ( postFinder || preFilter ) {
  9144. if ( postFinder ) {
  9145. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9146. temp = [];
  9147. i = matcherOut.length;
  9148. while ( i-- ) {
  9149. if ( (elem = matcherOut[i]) ) {
  9150. // Restore matcherIn since elem is not yet a final match
  9151. temp.push( (matcherIn[i] = elem) );
  9152. }
  9153. }
  9154. postFinder( null, (matcherOut = []), temp, xml );
  9155. }
  9156. // Move matched elements from seed to results to keep them synchronized
  9157. i = matcherOut.length;
  9158. while ( i-- ) {
  9159. if ( (elem = matcherOut[i]) &&
  9160. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9161. seed[temp] = !(results[temp] = elem);
  9162. }
  9163. }
  9164. }
  9165. // Add elements to results, through postFinder if defined
  9166. } else {
  9167. matcherOut = condense(
  9168. matcherOut === results ?
  9169. matcherOut.splice( preexisting, matcherOut.length ) :
  9170. matcherOut
  9171. );
  9172. if ( postFinder ) {
  9173. postFinder( null, results, matcherOut, xml );
  9174. } else {
  9175. push.apply( results, matcherOut );
  9176. }
  9177. }
  9178. });
  9179. }
  9180. function matcherFromTokens( tokens ) {
  9181. var checkContext, matcher, j,
  9182. len = tokens.length,
  9183. leadingRelative = Expr.relative[ tokens[0].type ],
  9184. implicitRelative = leadingRelative || Expr.relative[" "],
  9185. i = leadingRelative ? 1 : 0,
  9186. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9187. matchContext = addCombinator( function( elem ) {
  9188. return elem === checkContext;
  9189. }, implicitRelative, true ),
  9190. matchAnyContext = addCombinator( function( elem ) {
  9191. return indexOf( checkContext, elem ) > -1;
  9192. }, implicitRelative, true ),
  9193. matchers = [ function( elem, context, xml ) {
  9194. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9195. (checkContext = context).nodeType ?
  9196. matchContext( elem, context, xml ) :
  9197. matchAnyContext( elem, context, xml ) );
  9198. // Avoid hanging onto element (issue #299)
  9199. checkContext = null;
  9200. return ret;
  9201. } ];
  9202. for ( ; i < len; i++ ) {
  9203. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9204. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9205. } else {
  9206. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9207. // Return special upon seeing a positional matcher
  9208. if ( matcher[ expando ] ) {
  9209. // Find the next relative operator (if any) for proper handling
  9210. j = ++i;
  9211. for ( ; j < len; j++ ) {
  9212. if ( Expr.relative[ tokens[j].type ] ) {
  9213. break;
  9214. }
  9215. }
  9216. return setMatcher(
  9217. i > 1 && elementMatcher( matchers ),
  9218. i > 1 && toSelector(
  9219. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9220. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9221. ).replace( rtrim, "$1" ),
  9222. matcher,
  9223. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9224. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9225. j < len && toSelector( tokens )
  9226. );
  9227. }
  9228. matchers.push( matcher );
  9229. }
  9230. }
  9231. return elementMatcher( matchers );
  9232. }
  9233. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9234. var bySet = setMatchers.length > 0,
  9235. byElement = elementMatchers.length > 0,
  9236. superMatcher = function( seed, context, xml, results, outermost ) {
  9237. var elem, j, matcher,
  9238. matchedCount = 0,
  9239. i = "0",
  9240. unmatched = seed && [],
  9241. setMatched = [],
  9242. contextBackup = outermostContext,
  9243. // We must always have either seed elements or outermost context
  9244. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9245. // Use integer dirruns iff this is the outermost matcher
  9246. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9247. len = elems.length;
  9248. if ( outermost ) {
  9249. outermostContext = context === document || context || outermost;
  9250. }
  9251. // Add elements passing elementMatchers directly to results
  9252. // Support: IE<9, Safari
  9253. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9254. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9255. if ( byElement && elem ) {
  9256. j = 0;
  9257. if ( !context && elem.ownerDocument !== document ) {
  9258. setDocument( elem );
  9259. xml = !documentIsHTML;
  9260. }
  9261. while ( (matcher = elementMatchers[j++]) ) {
  9262. if ( matcher( elem, context || document, xml) ) {
  9263. results.push( elem );
  9264. break;
  9265. }
  9266. }
  9267. if ( outermost ) {
  9268. dirruns = dirrunsUnique;
  9269. }
  9270. }
  9271. // Track unmatched elements for set filters
  9272. if ( bySet ) {
  9273. // They will have gone through all possible matchers
  9274. if ( (elem = !matcher && elem) ) {
  9275. matchedCount--;
  9276. }
  9277. // Lengthen the array for every element, matched or not
  9278. if ( seed ) {
  9279. unmatched.push( elem );
  9280. }
  9281. }
  9282. }
  9283. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9284. // makes the latter nonnegative.
  9285. matchedCount += i;
  9286. // Apply set filters to unmatched elements
  9287. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9288. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9289. // no element matchers and no seed.
  9290. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9291. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9292. // numerically zero.
  9293. if ( bySet && i !== matchedCount ) {
  9294. j = 0;
  9295. while ( (matcher = setMatchers[j++]) ) {
  9296. matcher( unmatched, setMatched, context, xml );
  9297. }
  9298. if ( seed ) {
  9299. // Reintegrate element matches to eliminate the need for sorting
  9300. if ( matchedCount > 0 ) {
  9301. while ( i-- ) {
  9302. if ( !(unmatched[i] || setMatched[i]) ) {
  9303. setMatched[i] = pop.call( results );
  9304. }
  9305. }
  9306. }
  9307. // Discard index placeholder values to get only actual matches
  9308. setMatched = condense( setMatched );
  9309. }
  9310. // Add matches to results
  9311. push.apply( results, setMatched );
  9312. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9313. if ( outermost && !seed && setMatched.length > 0 &&
  9314. ( matchedCount + setMatchers.length ) > 1 ) {
  9315. Sizzle.uniqueSort( results );
  9316. }
  9317. }
  9318. // Override manipulation of globals by nested matchers
  9319. if ( outermost ) {
  9320. dirruns = dirrunsUnique;
  9321. outermostContext = contextBackup;
  9322. }
  9323. return unmatched;
  9324. };
  9325. return bySet ?
  9326. markFunction( superMatcher ) :
  9327. superMatcher;
  9328. }
  9329. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9330. var i,
  9331. setMatchers = [],
  9332. elementMatchers = [],
  9333. cached = compilerCache[ selector + " " ];
  9334. if ( !cached ) {
  9335. // Generate a function of recursive functions that can be used to check each element
  9336. if ( !match ) {
  9337. match = tokenize( selector );
  9338. }
  9339. i = match.length;
  9340. while ( i-- ) {
  9341. cached = matcherFromTokens( match[i] );
  9342. if ( cached[ expando ] ) {
  9343. setMatchers.push( cached );
  9344. } else {
  9345. elementMatchers.push( cached );
  9346. }
  9347. }
  9348. // Cache the compiled function
  9349. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9350. // Save selector and tokenization
  9351. cached.selector = selector;
  9352. }
  9353. return cached;
  9354. };
  9355. /**
  9356. * A low-level selection function that works with Sizzle's compiled
  9357. * selector functions
  9358. * @param {String|Function} selector A selector or a pre-compiled
  9359. * selector function built with Sizzle.compile
  9360. * @param {Element} context
  9361. * @param {Array} [results]
  9362. * @param {Array} [seed] A set of elements to match against
  9363. */
  9364. select = Sizzle.select = function( selector, context, results, seed ) {
  9365. var i, tokens, token, type, find,
  9366. compiled = typeof selector === "function" && selector,
  9367. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9368. results = results || [];
  9369. // Try to minimize operations if there is only one selector in the list and no seed
  9370. // (the latter of which guarantees us context)
  9371. if ( match.length === 1 ) {
  9372. // Reduce context if the leading compound selector is an ID
  9373. tokens = match[0] = match[0].slice( 0 );
  9374. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9375. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9376. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9377. if ( !context ) {
  9378. return results;
  9379. // Precompiled matchers will still verify ancestry, so step up a level
  9380. } else if ( compiled ) {
  9381. context = context.parentNode;
  9382. }
  9383. selector = selector.slice( tokens.shift().value.length );
  9384. }
  9385. // Fetch a seed set for right-to-left matching
  9386. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9387. while ( i-- ) {
  9388. token = tokens[i];
  9389. // Abort if we hit a combinator
  9390. if ( Expr.relative[ (type = token.type) ] ) {
  9391. break;
  9392. }
  9393. if ( (find = Expr.find[ type ]) ) {
  9394. // Search, expanding context for leading sibling combinators
  9395. if ( (seed = find(
  9396. token.matches[0].replace( runescape, funescape ),
  9397. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9398. )) ) {
  9399. // If seed is empty or no tokens remain, we can return early
  9400. tokens.splice( i, 1 );
  9401. selector = seed.length && toSelector( tokens );
  9402. if ( !selector ) {
  9403. push.apply( results, seed );
  9404. return results;
  9405. }
  9406. break;
  9407. }
  9408. }
  9409. }
  9410. }
  9411. // Compile and execute a filtering function if one is not provided
  9412. // Provide `match` to avoid retokenization if we modified the selector above
  9413. ( compiled || compile( selector, match ) )(
  9414. seed,
  9415. context,
  9416. !documentIsHTML,
  9417. results,
  9418. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9419. );
  9420. return results;
  9421. };
  9422. // One-time assignments
  9423. // Sort stability
  9424. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9425. // Support: Chrome 14-35+
  9426. // Always assume duplicates if they aren't passed to the comparison function
  9427. support.detectDuplicates = !!hasDuplicate;
  9428. // Initialize against the default document
  9429. setDocument();
  9430. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9431. // Detached nodes confoundingly follow *each other*
  9432. support.sortDetached = assert(function( el ) {
  9433. // Should return 1, but returns 4 (following)
  9434. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9435. });
  9436. // Support: IE<8
  9437. // Prevent attribute/property "interpolation"
  9438. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9439. if ( !assert(function( el ) {
  9440. el.innerHTML = "<a href='#'></a>";
  9441. return el.firstChild.getAttribute("href") === "#" ;
  9442. }) ) {
  9443. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9444. if ( !isXML ) {
  9445. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9446. }
  9447. });
  9448. }
  9449. // Support: IE<9
  9450. // Use defaultValue in place of getAttribute("value")
  9451. if ( !support.attributes || !assert(function( el ) {
  9452. el.innerHTML = "<input/>";
  9453. el.firstChild.setAttribute( "value", "" );
  9454. return el.firstChild.getAttribute( "value" ) === "";
  9455. }) ) {
  9456. addHandle( "value", function( elem, name, isXML ) {
  9457. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9458. return elem.defaultValue;
  9459. }
  9460. });
  9461. }
  9462. // Support: IE<9
  9463. // Use getAttributeNode to fetch booleans when getAttribute lies
  9464. if ( !assert(function( el ) {
  9465. return el.getAttribute("disabled") == null;
  9466. }) ) {
  9467. addHandle( booleans, function( elem, name, isXML ) {
  9468. var val;
  9469. if ( !isXML ) {
  9470. return elem[ name ] === true ? name.toLowerCase() :
  9471. (val = elem.getAttributeNode( name )) && val.specified ?
  9472. val.value :
  9473. null;
  9474. }
  9475. });
  9476. }
  9477. return Sizzle;
  9478. })( window );
  9479. jQuery.find = Sizzle;
  9480. jQuery.expr = Sizzle.selectors;
  9481. // Deprecated
  9482. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9483. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9484. jQuery.text = Sizzle.getText;
  9485. jQuery.isXMLDoc = Sizzle.isXML;
  9486. jQuery.contains = Sizzle.contains;
  9487. jQuery.escapeSelector = Sizzle.escape;
  9488. var dir = function( elem, dir, until ) {
  9489. var matched = [],
  9490. truncate = until !== undefined;
  9491. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9492. if ( elem.nodeType === 1 ) {
  9493. if ( truncate && jQuery( elem ).is( until ) ) {
  9494. break;
  9495. }
  9496. matched.push( elem );
  9497. }
  9498. }
  9499. return matched;
  9500. };
  9501. var siblings = function( n, elem ) {
  9502. var matched = [];
  9503. for ( ; n; n = n.nextSibling ) {
  9504. if ( n.nodeType === 1 && n !== elem ) {
  9505. matched.push( n );
  9506. }
  9507. }
  9508. return matched;
  9509. };
  9510. var rneedsContext = jQuery.expr.match.needsContext;
  9511. function nodeName( elem, name ) {
  9512. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9513. };
  9514. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9515. // Implement the identical functionality for filter and not
  9516. function winnow( elements, qualifier, not ) {
  9517. if ( isFunction( qualifier ) ) {
  9518. return jQuery.grep( elements, function( elem, i ) {
  9519. return !!qualifier.call( elem, i, elem ) !== not;
  9520. } );
  9521. }
  9522. // Single element
  9523. if ( qualifier.nodeType ) {
  9524. return jQuery.grep( elements, function( elem ) {
  9525. return ( elem === qualifier ) !== not;
  9526. } );
  9527. }
  9528. // Arraylike of elements (jQuery, arguments, Array)
  9529. if ( typeof qualifier !== "string" ) {
  9530. return jQuery.grep( elements, function( elem ) {
  9531. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9532. } );
  9533. }
  9534. // Filtered directly for both simple and complex selectors
  9535. return jQuery.filter( qualifier, elements, not );
  9536. }
  9537. jQuery.filter = function( expr, elems, not ) {
  9538. var elem = elems[ 0 ];
  9539. if ( not ) {
  9540. expr = ":not(" + expr + ")";
  9541. }
  9542. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9543. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9544. }
  9545. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9546. return elem.nodeType === 1;
  9547. } ) );
  9548. };
  9549. jQuery.fn.extend( {
  9550. find: function( selector ) {
  9551. var i, ret,
  9552. len = this.length,
  9553. self = this;
  9554. if ( typeof selector !== "string" ) {
  9555. return this.pushStack( jQuery( selector ).filter( function() {
  9556. for ( i = 0; i < len; i++ ) {
  9557. if ( jQuery.contains( self[ i ], this ) ) {
  9558. return true;
  9559. }
  9560. }
  9561. } ) );
  9562. }
  9563. ret = this.pushStack( [] );
  9564. for ( i = 0; i < len; i++ ) {
  9565. jQuery.find( selector, self[ i ], ret );
  9566. }
  9567. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9568. },
  9569. filter: function( selector ) {
  9570. return this.pushStack( winnow( this, selector || [], false ) );
  9571. },
  9572. not: function( selector ) {
  9573. return this.pushStack( winnow( this, selector || [], true ) );
  9574. },
  9575. is: function( selector ) {
  9576. return !!winnow(
  9577. this,
  9578. // If this is a positional/relative selector, check membership in the returned set
  9579. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9580. typeof selector === "string" && rneedsContext.test( selector ) ?
  9581. jQuery( selector ) :
  9582. selector || [],
  9583. false
  9584. ).length;
  9585. }
  9586. } );
  9587. // Initialize a jQuery object
  9588. // A central reference to the root jQuery(document)
  9589. var rootjQuery,
  9590. // A simple way to check for HTML strings
  9591. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9592. // Strict HTML recognition (#11290: must start with <)
  9593. // Shortcut simple #id case for speed
  9594. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9595. init = jQuery.fn.init = function( selector, context, root ) {
  9596. var match, elem;
  9597. // HANDLE: $(""), $(null), $(undefined), $(false)
  9598. if ( !selector ) {
  9599. return this;
  9600. }
  9601. // Method init() accepts an alternate rootjQuery
  9602. // so migrate can support jQuery.sub (gh-2101)
  9603. root = root || rootjQuery;
  9604. // Handle HTML strings
  9605. if ( typeof selector === "string" ) {
  9606. if ( selector[ 0 ] === "<" &&
  9607. selector[ selector.length - 1 ] === ">" &&
  9608. selector.length >= 3 ) {
  9609. // Assume that strings that start and end with <> are HTML and skip the regex check
  9610. match = [ null, selector, null ];
  9611. } else {
  9612. match = rquickExpr.exec( selector );
  9613. }
  9614. // Match html or make sure no context is specified for #id
  9615. if ( match && ( match[ 1 ] || !context ) ) {
  9616. // HANDLE: $(html) -> $(array)
  9617. if ( match[ 1 ] ) {
  9618. context = context instanceof jQuery ? context[ 0 ] : context;
  9619. // Option to run scripts is true for back-compat
  9620. // Intentionally let the error be thrown if parseHTML is not present
  9621. jQuery.merge( this, jQuery.parseHTML(
  9622. match[ 1 ],
  9623. context && context.nodeType ? context.ownerDocument || context : document,
  9624. true
  9625. ) );
  9626. // HANDLE: $(html, props)
  9627. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9628. for ( match in context ) {
  9629. // Properties of context are called as methods if possible
  9630. if ( isFunction( this[ match ] ) ) {
  9631. this[ match ]( context[ match ] );
  9632. // ...and otherwise set as attributes
  9633. } else {
  9634. this.attr( match, context[ match ] );
  9635. }
  9636. }
  9637. }
  9638. return this;
  9639. // HANDLE: $(#id)
  9640. } else {
  9641. elem = document.getElementById( match[ 2 ] );
  9642. if ( elem ) {
  9643. // Inject the element directly into the jQuery object
  9644. this[ 0 ] = elem;
  9645. this.length = 1;
  9646. }
  9647. return this;
  9648. }
  9649. // HANDLE: $(expr, $(...))
  9650. } else if ( !context || context.jquery ) {
  9651. return ( context || root ).find( selector );
  9652. // HANDLE: $(expr, context)
  9653. // (which is just equivalent to: $(context).find(expr)
  9654. } else {
  9655. return this.constructor( context ).find( selector );
  9656. }
  9657. // HANDLE: $(DOMElement)
  9658. } else if ( selector.nodeType ) {
  9659. this[ 0 ] = selector;
  9660. this.length = 1;
  9661. return this;
  9662. // HANDLE: $(function)
  9663. // Shortcut for document ready
  9664. } else if ( isFunction( selector ) ) {
  9665. return root.ready !== undefined ?
  9666. root.ready( selector ) :
  9667. // Execute immediately if ready is not present
  9668. selector( jQuery );
  9669. }
  9670. return jQuery.makeArray( selector, this );
  9671. };
  9672. // Give the init function the jQuery prototype for later instantiation
  9673. init.prototype = jQuery.fn;
  9674. // Initialize central reference
  9675. rootjQuery = jQuery( document );
  9676. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9677. // Methods guaranteed to produce a unique set when starting from a unique set
  9678. guaranteedUnique = {
  9679. children: true,
  9680. contents: true,
  9681. next: true,
  9682. prev: true
  9683. };
  9684. jQuery.fn.extend( {
  9685. has: function( target ) {
  9686. var targets = jQuery( target, this ),
  9687. l = targets.length;
  9688. return this.filter( function() {
  9689. var i = 0;
  9690. for ( ; i < l; i++ ) {
  9691. if ( jQuery.contains( this, targets[ i ] ) ) {
  9692. return true;
  9693. }
  9694. }
  9695. } );
  9696. },
  9697. closest: function( selectors, context ) {
  9698. var cur,
  9699. i = 0,
  9700. l = this.length,
  9701. matched = [],
  9702. targets = typeof selectors !== "string" && jQuery( selectors );
  9703. // Positional selectors never match, since there's no _selection_ context
  9704. if ( !rneedsContext.test( selectors ) ) {
  9705. for ( ; i < l; i++ ) {
  9706. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9707. // Always skip document fragments
  9708. if ( cur.nodeType < 11 && ( targets ?
  9709. targets.index( cur ) > -1 :
  9710. // Don't pass non-elements to Sizzle
  9711. cur.nodeType === 1 &&
  9712. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9713. matched.push( cur );
  9714. break;
  9715. }
  9716. }
  9717. }
  9718. }
  9719. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9720. },
  9721. // Determine the position of an element within the set
  9722. index: function( elem ) {
  9723. // No argument, return index in parent
  9724. if ( !elem ) {
  9725. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9726. }
  9727. // Index in selector
  9728. if ( typeof elem === "string" ) {
  9729. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9730. }
  9731. // Locate the position of the desired element
  9732. return indexOf.call( this,
  9733. // If it receives a jQuery object, the first element is used
  9734. elem.jquery ? elem[ 0 ] : elem
  9735. );
  9736. },
  9737. add: function( selector, context ) {
  9738. return this.pushStack(
  9739. jQuery.uniqueSort(
  9740. jQuery.merge( this.get(), jQuery( selector, context ) )
  9741. )
  9742. );
  9743. },
  9744. addBack: function( selector ) {
  9745. return this.add( selector == null ?
  9746. this.prevObject : this.prevObject.filter( selector )
  9747. );
  9748. }
  9749. } );
  9750. function sibling( cur, dir ) {
  9751. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9752. return cur;
  9753. }
  9754. jQuery.each( {
  9755. parent: function( elem ) {
  9756. var parent = elem.parentNode;
  9757. return parent && parent.nodeType !== 11 ? parent : null;
  9758. },
  9759. parents: function( elem ) {
  9760. return dir( elem, "parentNode" );
  9761. },
  9762. parentsUntil: function( elem, i, until ) {
  9763. return dir( elem, "parentNode", until );
  9764. },
  9765. next: function( elem ) {
  9766. return sibling( elem, "nextSibling" );
  9767. },
  9768. prev: function( elem ) {
  9769. return sibling( elem, "previousSibling" );
  9770. },
  9771. nextAll: function( elem ) {
  9772. return dir( elem, "nextSibling" );
  9773. },
  9774. prevAll: function( elem ) {
  9775. return dir( elem, "previousSibling" );
  9776. },
  9777. nextUntil: function( elem, i, until ) {
  9778. return dir( elem, "nextSibling", until );
  9779. },
  9780. prevUntil: function( elem, i, until ) {
  9781. return dir( elem, "previousSibling", until );
  9782. },
  9783. siblings: function( elem ) {
  9784. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9785. },
  9786. children: function( elem ) {
  9787. return siblings( elem.firstChild );
  9788. },
  9789. contents: function( elem ) {
  9790. if ( typeof elem.contentDocument !== "undefined" ) {
  9791. return elem.contentDocument;
  9792. }
  9793. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9794. // Treat the template element as a regular one in browsers that
  9795. // don't support it.
  9796. if ( nodeName( elem, "template" ) ) {
  9797. elem = elem.content || elem;
  9798. }
  9799. return jQuery.merge( [], elem.childNodes );
  9800. }
  9801. }, function( name, fn ) {
  9802. jQuery.fn[ name ] = function( until, selector ) {
  9803. var matched = jQuery.map( this, fn, until );
  9804. if ( name.slice( -5 ) !== "Until" ) {
  9805. selector = until;
  9806. }
  9807. if ( selector && typeof selector === "string" ) {
  9808. matched = jQuery.filter( selector, matched );
  9809. }
  9810. if ( this.length > 1 ) {
  9811. // Remove duplicates
  9812. if ( !guaranteedUnique[ name ] ) {
  9813. jQuery.uniqueSort( matched );
  9814. }
  9815. // Reverse order for parents* and prev-derivatives
  9816. if ( rparentsprev.test( name ) ) {
  9817. matched.reverse();
  9818. }
  9819. }
  9820. return this.pushStack( matched );
  9821. };
  9822. } );
  9823. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9824. // Convert String-formatted options into Object-formatted ones
  9825. function createOptions( options ) {
  9826. var object = {};
  9827. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9828. object[ flag ] = true;
  9829. } );
  9830. return object;
  9831. }
  9832. /*
  9833. * Create a callback list using the following parameters:
  9834. *
  9835. * options: an optional list of space-separated options that will change how
  9836. * the callback list behaves or a more traditional option object
  9837. *
  9838. * By default a callback list will act like an event callback list and can be
  9839. * "fired" multiple times.
  9840. *
  9841. * Possible options:
  9842. *
  9843. * once: will ensure the callback list can only be fired once (like a Deferred)
  9844. *
  9845. * memory: will keep track of previous values and will call any callback added
  9846. * after the list has been fired right away with the latest "memorized"
  9847. * values (like a Deferred)
  9848. *
  9849. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9850. *
  9851. * stopOnFalse: interrupt callings when a callback returns false
  9852. *
  9853. */
  9854. jQuery.Callbacks = function( options ) {
  9855. // Convert options from String-formatted to Object-formatted if needed
  9856. // (we check in cache first)
  9857. options = typeof options === "string" ?
  9858. createOptions( options ) :
  9859. jQuery.extend( {}, options );
  9860. var // Flag to know if list is currently firing
  9861. firing,
  9862. // Last fire value for non-forgettable lists
  9863. memory,
  9864. // Flag to know if list was already fired
  9865. fired,
  9866. // Flag to prevent firing
  9867. locked,
  9868. // Actual callback list
  9869. list = [],
  9870. // Queue of execution data for repeatable lists
  9871. queue = [],
  9872. // Index of currently firing callback (modified by add/remove as needed)
  9873. firingIndex = -1,
  9874. // Fire callbacks
  9875. fire = function() {
  9876. // Enforce single-firing
  9877. locked = locked || options.once;
  9878. // Execute callbacks for all pending executions,
  9879. // respecting firingIndex overrides and runtime changes
  9880. fired = firing = true;
  9881. for ( ; queue.length; firingIndex = -1 ) {
  9882. memory = queue.shift();
  9883. while ( ++firingIndex < list.length ) {
  9884. // Run callback and check for early termination
  9885. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9886. options.stopOnFalse ) {
  9887. // Jump to end and forget the data so .add doesn't re-fire
  9888. firingIndex = list.length;
  9889. memory = false;
  9890. }
  9891. }
  9892. }
  9893. // Forget the data if we're done with it
  9894. if ( !options.memory ) {
  9895. memory = false;
  9896. }
  9897. firing = false;
  9898. // Clean up if we're done firing for good
  9899. if ( locked ) {
  9900. // Keep an empty list if we have data for future add calls
  9901. if ( memory ) {
  9902. list = [];
  9903. // Otherwise, this object is spent
  9904. } else {
  9905. list = "";
  9906. }
  9907. }
  9908. },
  9909. // Actual Callbacks object
  9910. self = {
  9911. // Add a callback or a collection of callbacks to the list
  9912. add: function() {
  9913. if ( list ) {
  9914. // If we have memory from a past run, we should fire after adding
  9915. if ( memory && !firing ) {
  9916. firingIndex = list.length - 1;
  9917. queue.push( memory );
  9918. }
  9919. ( function add( args ) {
  9920. jQuery.each( args, function( _, arg ) {
  9921. if ( isFunction( arg ) ) {
  9922. if ( !options.unique || !self.has( arg ) ) {
  9923. list.push( arg );
  9924. }
  9925. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9926. // Inspect recursively
  9927. add( arg );
  9928. }
  9929. } );
  9930. } )( arguments );
  9931. if ( memory && !firing ) {
  9932. fire();
  9933. }
  9934. }
  9935. return this;
  9936. },
  9937. // Remove a callback from the list
  9938. remove: function() {
  9939. jQuery.each( arguments, function( _, arg ) {
  9940. var index;
  9941. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9942. list.splice( index, 1 );
  9943. // Handle firing indexes
  9944. if ( index <= firingIndex ) {
  9945. firingIndex--;
  9946. }
  9947. }
  9948. } );
  9949. return this;
  9950. },
  9951. // Check if a given callback is in the list.
  9952. // If no argument is given, return whether or not list has callbacks attached.
  9953. has: function( fn ) {
  9954. return fn ?
  9955. jQuery.inArray( fn, list ) > -1 :
  9956. list.length > 0;
  9957. },
  9958. // Remove all callbacks from the list
  9959. empty: function() {
  9960. if ( list ) {
  9961. list = [];
  9962. }
  9963. return this;
  9964. },
  9965. // Disable .fire and .add
  9966. // Abort any current/pending executions
  9967. // Clear all callbacks and values
  9968. disable: function() {
  9969. locked = queue = [];
  9970. list = memory = "";
  9971. return this;
  9972. },
  9973. disabled: function() {
  9974. return !list;
  9975. },
  9976. // Disable .fire
  9977. // Also disable .add unless we have memory (since it would have no effect)
  9978. // Abort any pending executions
  9979. lock: function() {
  9980. locked = queue = [];
  9981. if ( !memory && !firing ) {
  9982. list = memory = "";
  9983. }
  9984. return this;
  9985. },
  9986. locked: function() {
  9987. return !!locked;
  9988. },
  9989. // Call all callbacks with the given context and arguments
  9990. fireWith: function( context, args ) {
  9991. if ( !locked ) {
  9992. args = args || [];
  9993. args = [ context, args.slice ? args.slice() : args ];
  9994. queue.push( args );
  9995. if ( !firing ) {
  9996. fire();
  9997. }
  9998. }
  9999. return this;
  10000. },
  10001. // Call all the callbacks with the given arguments
  10002. fire: function() {
  10003. self.fireWith( this, arguments );
  10004. return this;
  10005. },
  10006. // To know if the callbacks have already been called at least once
  10007. fired: function() {
  10008. return !!fired;
  10009. }
  10010. };
  10011. return self;
  10012. };
  10013. function Identity( v ) {
  10014. return v;
  10015. }
  10016. function Thrower( ex ) {
  10017. throw ex;
  10018. }
  10019. function adoptValue( value, resolve, reject, noValue ) {
  10020. var method;
  10021. try {
  10022. // Check for promise aspect first to privilege synchronous behavior
  10023. if ( value && isFunction( ( method = value.promise ) ) ) {
  10024. method.call( value ).done( resolve ).fail( reject );
  10025. // Other thenables
  10026. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10027. method.call( value, resolve, reject );
  10028. // Other non-thenables
  10029. } else {
  10030. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10031. // * false: [ value ].slice( 0 ) => resolve( value )
  10032. // * true: [ value ].slice( 1 ) => resolve()
  10033. resolve.apply( undefined, [ value ].slice( noValue ) );
  10034. }
  10035. // For Promises/A+, convert exceptions into rejections
  10036. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10037. // Deferred#then to conditionally suppress rejection.
  10038. } catch ( value ) {
  10039. // Support: Android 4.0 only
  10040. // Strict mode functions invoked without .call/.apply get global-object context
  10041. reject.apply( undefined, [ value ] );
  10042. }
  10043. }
  10044. jQuery.extend( {
  10045. Deferred: function( func ) {
  10046. var tuples = [
  10047. // action, add listener, callbacks,
  10048. // ... .then handlers, argument index, [final state]
  10049. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10050. jQuery.Callbacks( "memory" ), 2 ],
  10051. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10052. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10053. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10054. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10055. ],
  10056. state = "pending",
  10057. promise = {
  10058. state: function() {
  10059. return state;
  10060. },
  10061. always: function() {
  10062. deferred.done( arguments ).fail( arguments );
  10063. return this;
  10064. },
  10065. "catch": function( fn ) {
  10066. return promise.then( null, fn );
  10067. },
  10068. // Keep pipe for back-compat
  10069. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10070. var fns = arguments;
  10071. return jQuery.Deferred( function( newDefer ) {
  10072. jQuery.each( tuples, function( i, tuple ) {
  10073. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10074. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10075. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10076. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10077. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10078. deferred[ tuple[ 1 ] ]( function() {
  10079. var returned = fn && fn.apply( this, arguments );
  10080. if ( returned && isFunction( returned.promise ) ) {
  10081. returned.promise()
  10082. .progress( newDefer.notify )
  10083. .done( newDefer.resolve )
  10084. .fail( newDefer.reject );
  10085. } else {
  10086. newDefer[ tuple[ 0 ] + "With" ](
  10087. this,
  10088. fn ? [ returned ] : arguments
  10089. );
  10090. }
  10091. } );
  10092. } );
  10093. fns = null;
  10094. } ).promise();
  10095. },
  10096. then: function( onFulfilled, onRejected, onProgress ) {
  10097. var maxDepth = 0;
  10098. function resolve( depth, deferred, handler, special ) {
  10099. return function() {
  10100. var that = this,
  10101. args = arguments,
  10102. mightThrow = function() {
  10103. var returned, then;
  10104. // Support: Promises/A+ section 2.3.3.3.3
  10105. // https://promisesaplus.com/#point-59
  10106. // Ignore double-resolution attempts
  10107. if ( depth < maxDepth ) {
  10108. return;
  10109. }
  10110. returned = handler.apply( that, args );
  10111. // Support: Promises/A+ section 2.3.1
  10112. // https://promisesaplus.com/#point-48
  10113. if ( returned === deferred.promise() ) {
  10114. throw new TypeError( "Thenable self-resolution" );
  10115. }
  10116. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10117. // https://promisesaplus.com/#point-54
  10118. // https://promisesaplus.com/#point-75
  10119. // Retrieve `then` only once
  10120. then = returned &&
  10121. // Support: Promises/A+ section 2.3.4
  10122. // https://promisesaplus.com/#point-64
  10123. // Only check objects and functions for thenability
  10124. ( typeof returned === "object" ||
  10125. typeof returned === "function" ) &&
  10126. returned.then;
  10127. // Handle a returned thenable
  10128. if ( isFunction( then ) ) {
  10129. // Special processors (notify) just wait for resolution
  10130. if ( special ) {
  10131. then.call(
  10132. returned,
  10133. resolve( maxDepth, deferred, Identity, special ),
  10134. resolve( maxDepth, deferred, Thrower, special )
  10135. );
  10136. // Normal processors (resolve) also hook into progress
  10137. } else {
  10138. // ...and disregard older resolution values
  10139. maxDepth++;
  10140. then.call(
  10141. returned,
  10142. resolve( maxDepth, deferred, Identity, special ),
  10143. resolve( maxDepth, deferred, Thrower, special ),
  10144. resolve( maxDepth, deferred, Identity,
  10145. deferred.notifyWith )
  10146. );
  10147. }
  10148. // Handle all other returned values
  10149. } else {
  10150. // Only substitute handlers pass on context
  10151. // and multiple values (non-spec behavior)
  10152. if ( handler !== Identity ) {
  10153. that = undefined;
  10154. args = [ returned ];
  10155. }
  10156. // Process the value(s)
  10157. // Default process is resolve
  10158. ( special || deferred.resolveWith )( that, args );
  10159. }
  10160. },
  10161. // Only normal processors (resolve) catch and reject exceptions
  10162. process = special ?
  10163. mightThrow :
  10164. function() {
  10165. try {
  10166. mightThrow();
  10167. } catch ( e ) {
  10168. if ( jQuery.Deferred.exceptionHook ) {
  10169. jQuery.Deferred.exceptionHook( e,
  10170. process.stackTrace );
  10171. }
  10172. // Support: Promises/A+ section 2.3.3.3.4.1
  10173. // https://promisesaplus.com/#point-61
  10174. // Ignore post-resolution exceptions
  10175. if ( depth + 1 >= maxDepth ) {
  10176. // Only substitute handlers pass on context
  10177. // and multiple values (non-spec behavior)
  10178. if ( handler !== Thrower ) {
  10179. that = undefined;
  10180. args = [ e ];
  10181. }
  10182. deferred.rejectWith( that, args );
  10183. }
  10184. }
  10185. };
  10186. // Support: Promises/A+ section 2.3.3.3.1
  10187. // https://promisesaplus.com/#point-57
  10188. // Re-resolve promises immediately to dodge false rejection from
  10189. // subsequent errors
  10190. if ( depth ) {
  10191. process();
  10192. } else {
  10193. // Call an optional hook to record the stack, in case of exception
  10194. // since it's otherwise lost when execution goes async
  10195. if ( jQuery.Deferred.getStackHook ) {
  10196. process.stackTrace = jQuery.Deferred.getStackHook();
  10197. }
  10198. window.setTimeout( process );
  10199. }
  10200. };
  10201. }
  10202. return jQuery.Deferred( function( newDefer ) {
  10203. // progress_handlers.add( ... )
  10204. tuples[ 0 ][ 3 ].add(
  10205. resolve(
  10206. 0,
  10207. newDefer,
  10208. isFunction( onProgress ) ?
  10209. onProgress :
  10210. Identity,
  10211. newDefer.notifyWith
  10212. )
  10213. );
  10214. // fulfilled_handlers.add( ... )
  10215. tuples[ 1 ][ 3 ].add(
  10216. resolve(
  10217. 0,
  10218. newDefer,
  10219. isFunction( onFulfilled ) ?
  10220. onFulfilled :
  10221. Identity
  10222. )
  10223. );
  10224. // rejected_handlers.add( ... )
  10225. tuples[ 2 ][ 3 ].add(
  10226. resolve(
  10227. 0,
  10228. newDefer,
  10229. isFunction( onRejected ) ?
  10230. onRejected :
  10231. Thrower
  10232. )
  10233. );
  10234. } ).promise();
  10235. },
  10236. // Get a promise for this deferred
  10237. // If obj is provided, the promise aspect is added to the object
  10238. promise: function( obj ) {
  10239. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10240. }
  10241. },
  10242. deferred = {};
  10243. // Add list-specific methods
  10244. jQuery.each( tuples, function( i, tuple ) {
  10245. var list = tuple[ 2 ],
  10246. stateString = tuple[ 5 ];
  10247. // promise.progress = list.add
  10248. // promise.done = list.add
  10249. // promise.fail = list.add
  10250. promise[ tuple[ 1 ] ] = list.add;
  10251. // Handle state
  10252. if ( stateString ) {
  10253. list.add(
  10254. function() {
  10255. // state = "resolved" (i.e., fulfilled)
  10256. // state = "rejected"
  10257. state = stateString;
  10258. },
  10259. // rejected_callbacks.disable
  10260. // fulfilled_callbacks.disable
  10261. tuples[ 3 - i ][ 2 ].disable,
  10262. // rejected_handlers.disable
  10263. // fulfilled_handlers.disable
  10264. tuples[ 3 - i ][ 3 ].disable,
  10265. // progress_callbacks.lock
  10266. tuples[ 0 ][ 2 ].lock,
  10267. // progress_handlers.lock
  10268. tuples[ 0 ][ 3 ].lock
  10269. );
  10270. }
  10271. // progress_handlers.fire
  10272. // fulfilled_handlers.fire
  10273. // rejected_handlers.fire
  10274. list.add( tuple[ 3 ].fire );
  10275. // deferred.notify = function() { deferred.notifyWith(...) }
  10276. // deferred.resolve = function() { deferred.resolveWith(...) }
  10277. // deferred.reject = function() { deferred.rejectWith(...) }
  10278. deferred[ tuple[ 0 ] ] = function() {
  10279. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10280. return this;
  10281. };
  10282. // deferred.notifyWith = list.fireWith
  10283. // deferred.resolveWith = list.fireWith
  10284. // deferred.rejectWith = list.fireWith
  10285. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10286. } );
  10287. // Make the deferred a promise
  10288. promise.promise( deferred );
  10289. // Call given func if any
  10290. if ( func ) {
  10291. func.call( deferred, deferred );
  10292. }
  10293. // All done!
  10294. return deferred;
  10295. },
  10296. // Deferred helper
  10297. when: function( singleValue ) {
  10298. var
  10299. // count of uncompleted subordinates
  10300. remaining = arguments.length,
  10301. // count of unprocessed arguments
  10302. i = remaining,
  10303. // subordinate fulfillment data
  10304. resolveContexts = Array( i ),
  10305. resolveValues = slice.call( arguments ),
  10306. // the master Deferred
  10307. master = jQuery.Deferred(),
  10308. // subordinate callback factory
  10309. updateFunc = function( i ) {
  10310. return function( value ) {
  10311. resolveContexts[ i ] = this;
  10312. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10313. if ( !( --remaining ) ) {
  10314. master.resolveWith( resolveContexts, resolveValues );
  10315. }
  10316. };
  10317. };
  10318. // Single- and empty arguments are adopted like Promise.resolve
  10319. if ( remaining <= 1 ) {
  10320. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10321. !remaining );
  10322. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10323. if ( master.state() === "pending" ||
  10324. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10325. return master.then();
  10326. }
  10327. }
  10328. // Multiple arguments are aggregated like Promise.all array elements
  10329. while ( i-- ) {
  10330. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10331. }
  10332. return master.promise();
  10333. }
  10334. } );
  10335. // These usually indicate a programmer mistake during development,
  10336. // warn about them ASAP rather than swallowing them by default.
  10337. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10338. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10339. // Support: IE 8 - 9 only
  10340. // Console exists when dev tools are open, which can happen at any time
  10341. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10342. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10343. }
  10344. };
  10345. jQuery.readyException = function( error ) {
  10346. window.setTimeout( function() {
  10347. throw error;
  10348. } );
  10349. };
  10350. // The deferred used on DOM ready
  10351. var readyList = jQuery.Deferred();
  10352. jQuery.fn.ready = function( fn ) {
  10353. readyList
  10354. .then( fn )
  10355. // Wrap jQuery.readyException in a function so that the lookup
  10356. // happens at the time of error handling instead of callback
  10357. // registration.
  10358. .catch( function( error ) {
  10359. jQuery.readyException( error );
  10360. } );
  10361. return this;
  10362. };
  10363. jQuery.extend( {
  10364. // Is the DOM ready to be used? Set to true once it occurs.
  10365. isReady: false,
  10366. // A counter to track how many items to wait for before
  10367. // the ready event fires. See #6781
  10368. readyWait: 1,
  10369. // Handle when the DOM is ready
  10370. ready: function( wait ) {
  10371. // Abort if there are pending holds or we're already ready
  10372. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10373. return;
  10374. }
  10375. // Remember that the DOM is ready
  10376. jQuery.isReady = true;
  10377. // If a normal DOM Ready event fired, decrement, and wait if need be
  10378. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10379. return;
  10380. }
  10381. // If there are functions bound, to execute
  10382. readyList.resolveWith( document, [ jQuery ] );
  10383. }
  10384. } );
  10385. jQuery.ready.then = readyList.then;
  10386. // The ready event handler and self cleanup method
  10387. function completed() {
  10388. document.removeEventListener( "DOMContentLoaded", completed );
  10389. window.removeEventListener( "load", completed );
  10390. jQuery.ready();
  10391. }
  10392. // Catch cases where $(document).ready() is called
  10393. // after the browser event has already occurred.
  10394. // Support: IE <=9 - 10 only
  10395. // Older IE sometimes signals "interactive" too soon
  10396. if ( document.readyState === "complete" ||
  10397. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10398. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10399. window.setTimeout( jQuery.ready );
  10400. } else {
  10401. // Use the handy event callback
  10402. document.addEventListener( "DOMContentLoaded", completed );
  10403. // A fallback to window.onload, that will always work
  10404. window.addEventListener( "load", completed );
  10405. }
  10406. // Multifunctional method to get and set values of a collection
  10407. // The value/s can optionally be executed if it's a function
  10408. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10409. var i = 0,
  10410. len = elems.length,
  10411. bulk = key == null;
  10412. // Sets many values
  10413. if ( toType( key ) === "object" ) {
  10414. chainable = true;
  10415. for ( i in key ) {
  10416. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10417. }
  10418. // Sets one value
  10419. } else if ( value !== undefined ) {
  10420. chainable = true;
  10421. if ( !isFunction( value ) ) {
  10422. raw = true;
  10423. }
  10424. if ( bulk ) {
  10425. // Bulk operations run against the entire set
  10426. if ( raw ) {
  10427. fn.call( elems, value );
  10428. fn = null;
  10429. // ...except when executing function values
  10430. } else {
  10431. bulk = fn;
  10432. fn = function( elem, key, value ) {
  10433. return bulk.call( jQuery( elem ), value );
  10434. };
  10435. }
  10436. }
  10437. if ( fn ) {
  10438. for ( ; i < len; i++ ) {
  10439. fn(
  10440. elems[ i ], key, raw ?
  10441. value :
  10442. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10443. );
  10444. }
  10445. }
  10446. }
  10447. if ( chainable ) {
  10448. return elems;
  10449. }
  10450. // Gets
  10451. if ( bulk ) {
  10452. return fn.call( elems );
  10453. }
  10454. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10455. };
  10456. // Matches dashed string for camelizing
  10457. var rmsPrefix = /^-ms-/,
  10458. rdashAlpha = /-([a-z])/g;
  10459. // Used by camelCase as callback to replace()
  10460. function fcamelCase( all, letter ) {
  10461. return letter.toUpperCase();
  10462. }
  10463. // Convert dashed to camelCase; used by the css and data modules
  10464. // Support: IE <=9 - 11, Edge 12 - 15
  10465. // Microsoft forgot to hump their vendor prefix (#9572)
  10466. function camelCase( string ) {
  10467. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10468. }
  10469. var acceptData = function( owner ) {
  10470. // Accepts only:
  10471. // - Node
  10472. // - Node.ELEMENT_NODE
  10473. // - Node.DOCUMENT_NODE
  10474. // - Object
  10475. // - Any
  10476. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10477. };
  10478. function Data() {
  10479. this.expando = jQuery.expando + Data.uid++;
  10480. }
  10481. Data.uid = 1;
  10482. Data.prototype = {
  10483. cache: function( owner ) {
  10484. // Check if the owner object already has a cache
  10485. var value = owner[ this.expando ];
  10486. // If not, create one
  10487. if ( !value ) {
  10488. value = {};
  10489. // We can accept data for non-element nodes in modern browsers,
  10490. // but we should not, see #8335.
  10491. // Always return an empty object.
  10492. if ( acceptData( owner ) ) {
  10493. // If it is a node unlikely to be stringify-ed or looped over
  10494. // use plain assignment
  10495. if ( owner.nodeType ) {
  10496. owner[ this.expando ] = value;
  10497. // Otherwise secure it in a non-enumerable property
  10498. // configurable must be true to allow the property to be
  10499. // deleted when data is removed
  10500. } else {
  10501. Object.defineProperty( owner, this.expando, {
  10502. value: value,
  10503. configurable: true
  10504. } );
  10505. }
  10506. }
  10507. }
  10508. return value;
  10509. },
  10510. set: function( owner, data, value ) {
  10511. var prop,
  10512. cache = this.cache( owner );
  10513. // Handle: [ owner, key, value ] args
  10514. // Always use camelCase key (gh-2257)
  10515. if ( typeof data === "string" ) {
  10516. cache[ camelCase( data ) ] = value;
  10517. // Handle: [ owner, { properties } ] args
  10518. } else {
  10519. // Copy the properties one-by-one to the cache object
  10520. for ( prop in data ) {
  10521. cache[ camelCase( prop ) ] = data[ prop ];
  10522. }
  10523. }
  10524. return cache;
  10525. },
  10526. get: function( owner, key ) {
  10527. return key === undefined ?
  10528. this.cache( owner ) :
  10529. // Always use camelCase key (gh-2257)
  10530. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10531. },
  10532. access: function( owner, key, value ) {
  10533. // In cases where either:
  10534. //
  10535. // 1. No key was specified
  10536. // 2. A string key was specified, but no value provided
  10537. //
  10538. // Take the "read" path and allow the get method to determine
  10539. // which value to return, respectively either:
  10540. //
  10541. // 1. The entire cache object
  10542. // 2. The data stored at the key
  10543. //
  10544. if ( key === undefined ||
  10545. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10546. return this.get( owner, key );
  10547. }
  10548. // When the key is not a string, or both a key and value
  10549. // are specified, set or extend (existing objects) with either:
  10550. //
  10551. // 1. An object of properties
  10552. // 2. A key and value
  10553. //
  10554. this.set( owner, key, value );
  10555. // Since the "set" path can have two possible entry points
  10556. // return the expected data based on which path was taken[*]
  10557. return value !== undefined ? value : key;
  10558. },
  10559. remove: function( owner, key ) {
  10560. var i,
  10561. cache = owner[ this.expando ];
  10562. if ( cache === undefined ) {
  10563. return;
  10564. }
  10565. if ( key !== undefined ) {
  10566. // Support array or space separated string of keys
  10567. if ( Array.isArray( key ) ) {
  10568. // If key is an array of keys...
  10569. // We always set camelCase keys, so remove that.
  10570. key = key.map( camelCase );
  10571. } else {
  10572. key = camelCase( key );
  10573. // If a key with the spaces exists, use it.
  10574. // Otherwise, create an array by matching non-whitespace
  10575. key = key in cache ?
  10576. [ key ] :
  10577. ( key.match( rnothtmlwhite ) || [] );
  10578. }
  10579. i = key.length;
  10580. while ( i-- ) {
  10581. delete cache[ key[ i ] ];
  10582. }
  10583. }
  10584. // Remove the expando if there's no more data
  10585. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10586. // Support: Chrome <=35 - 45
  10587. // Webkit & Blink performance suffers when deleting properties
  10588. // from DOM nodes, so set to undefined instead
  10589. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10590. if ( owner.nodeType ) {
  10591. owner[ this.expando ] = undefined;
  10592. } else {
  10593. delete owner[ this.expando ];
  10594. }
  10595. }
  10596. },
  10597. hasData: function( owner ) {
  10598. var cache = owner[ this.expando ];
  10599. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10600. }
  10601. };
  10602. var dataPriv = new Data();
  10603. var dataUser = new Data();
  10604. // Implementation Summary
  10605. //
  10606. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10607. // 2. Improve the module's maintainability by reducing the storage
  10608. // paths to a single mechanism.
  10609. // 3. Use the same single mechanism to support "private" and "user" data.
  10610. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10611. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10612. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10613. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10614. rmultiDash = /[A-Z]/g;
  10615. function getData( data ) {
  10616. if ( data === "true" ) {
  10617. return true;
  10618. }
  10619. if ( data === "false" ) {
  10620. return false;
  10621. }
  10622. if ( data === "null" ) {
  10623. return null;
  10624. }
  10625. // Only convert to a number if it doesn't change the string
  10626. if ( data === +data + "" ) {
  10627. return +data;
  10628. }
  10629. if ( rbrace.test( data ) ) {
  10630. return JSON.parse( data );
  10631. }
  10632. return data;
  10633. }
  10634. function dataAttr( elem, key, data ) {
  10635. var name;
  10636. // If nothing was found internally, try to fetch any
  10637. // data from the HTML5 data-* attribute
  10638. if ( data === undefined && elem.nodeType === 1 ) {
  10639. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10640. data = elem.getAttribute( name );
  10641. if ( typeof data === "string" ) {
  10642. try {
  10643. data = getData( data );
  10644. } catch ( e ) {}
  10645. // Make sure we set the data so it isn't changed later
  10646. dataUser.set( elem, key, data );
  10647. } else {
  10648. data = undefined;
  10649. }
  10650. }
  10651. return data;
  10652. }
  10653. jQuery.extend( {
  10654. hasData: function( elem ) {
  10655. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10656. },
  10657. data: function( elem, name, data ) {
  10658. return dataUser.access( elem, name, data );
  10659. },
  10660. removeData: function( elem, name ) {
  10661. dataUser.remove( elem, name );
  10662. },
  10663. // TODO: Now that all calls to _data and _removeData have been replaced
  10664. // with direct calls to dataPriv methods, these can be deprecated.
  10665. _data: function( elem, name, data ) {
  10666. return dataPriv.access( elem, name, data );
  10667. },
  10668. _removeData: function( elem, name ) {
  10669. dataPriv.remove( elem, name );
  10670. }
  10671. } );
  10672. jQuery.fn.extend( {
  10673. data: function( key, value ) {
  10674. var i, name, data,
  10675. elem = this[ 0 ],
  10676. attrs = elem && elem.attributes;
  10677. // Gets all values
  10678. if ( key === undefined ) {
  10679. if ( this.length ) {
  10680. data = dataUser.get( elem );
  10681. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10682. i = attrs.length;
  10683. while ( i-- ) {
  10684. // Support: IE 11 only
  10685. // The attrs elements can be null (#14894)
  10686. if ( attrs[ i ] ) {
  10687. name = attrs[ i ].name;
  10688. if ( name.indexOf( "data-" ) === 0 ) {
  10689. name = camelCase( name.slice( 5 ) );
  10690. dataAttr( elem, name, data[ name ] );
  10691. }
  10692. }
  10693. }
  10694. dataPriv.set( elem, "hasDataAttrs", true );
  10695. }
  10696. }
  10697. return data;
  10698. }
  10699. // Sets multiple values
  10700. if ( typeof key === "object" ) {
  10701. return this.each( function() {
  10702. dataUser.set( this, key );
  10703. } );
  10704. }
  10705. return access( this, function( value ) {
  10706. var data;
  10707. // The calling jQuery object (element matches) is not empty
  10708. // (and therefore has an element appears at this[ 0 ]) and the
  10709. // `value` parameter was not undefined. An empty jQuery object
  10710. // will result in `undefined` for elem = this[ 0 ] which will
  10711. // throw an exception if an attempt to read a data cache is made.
  10712. if ( elem && value === undefined ) {
  10713. // Attempt to get data from the cache
  10714. // The key will always be camelCased in Data
  10715. data = dataUser.get( elem, key );
  10716. if ( data !== undefined ) {
  10717. return data;
  10718. }
  10719. // Attempt to "discover" the data in
  10720. // HTML5 custom data-* attrs
  10721. data = dataAttr( elem, key );
  10722. if ( data !== undefined ) {
  10723. return data;
  10724. }
  10725. // We tried really hard, but the data doesn't exist.
  10726. return;
  10727. }
  10728. // Set the data...
  10729. this.each( function() {
  10730. // We always store the camelCased key
  10731. dataUser.set( this, key, value );
  10732. } );
  10733. }, null, value, arguments.length > 1, null, true );
  10734. },
  10735. removeData: function( key ) {
  10736. return this.each( function() {
  10737. dataUser.remove( this, key );
  10738. } );
  10739. }
  10740. } );
  10741. jQuery.extend( {
  10742. queue: function( elem, type, data ) {
  10743. var queue;
  10744. if ( elem ) {
  10745. type = ( type || "fx" ) + "queue";
  10746. queue = dataPriv.get( elem, type );
  10747. // Speed up dequeue by getting out quickly if this is just a lookup
  10748. if ( data ) {
  10749. if ( !queue || Array.isArray( data ) ) {
  10750. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10751. } else {
  10752. queue.push( data );
  10753. }
  10754. }
  10755. return queue || [];
  10756. }
  10757. },
  10758. dequeue: function( elem, type ) {
  10759. type = type || "fx";
  10760. var queue = jQuery.queue( elem, type ),
  10761. startLength = queue.length,
  10762. fn = queue.shift(),
  10763. hooks = jQuery._queueHooks( elem, type ),
  10764. next = function() {
  10765. jQuery.dequeue( elem, type );
  10766. };
  10767. // If the fx queue is dequeued, always remove the progress sentinel
  10768. if ( fn === "inprogress" ) {
  10769. fn = queue.shift();
  10770. startLength--;
  10771. }
  10772. if ( fn ) {
  10773. // Add a progress sentinel to prevent the fx queue from being
  10774. // automatically dequeued
  10775. if ( type === "fx" ) {
  10776. queue.unshift( "inprogress" );
  10777. }
  10778. // Clear up the last queue stop function
  10779. delete hooks.stop;
  10780. fn.call( elem, next, hooks );
  10781. }
  10782. if ( !startLength && hooks ) {
  10783. hooks.empty.fire();
  10784. }
  10785. },
  10786. // Not public - generate a queueHooks object, or return the current one
  10787. _queueHooks: function( elem, type ) {
  10788. var key = type + "queueHooks";
  10789. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10790. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10791. dataPriv.remove( elem, [ type + "queue", key ] );
  10792. } )
  10793. } );
  10794. }
  10795. } );
  10796. jQuery.fn.extend( {
  10797. queue: function( type, data ) {
  10798. var setter = 2;
  10799. if ( typeof type !== "string" ) {
  10800. data = type;
  10801. type = "fx";
  10802. setter--;
  10803. }
  10804. if ( arguments.length < setter ) {
  10805. return jQuery.queue( this[ 0 ], type );
  10806. }
  10807. return data === undefined ?
  10808. this :
  10809. this.each( function() {
  10810. var queue = jQuery.queue( this, type, data );
  10811. // Ensure a hooks for this queue
  10812. jQuery._queueHooks( this, type );
  10813. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10814. jQuery.dequeue( this, type );
  10815. }
  10816. } );
  10817. },
  10818. dequeue: function( type ) {
  10819. return this.each( function() {
  10820. jQuery.dequeue( this, type );
  10821. } );
  10822. },
  10823. clearQueue: function( type ) {
  10824. return this.queue( type || "fx", [] );
  10825. },
  10826. // Get a promise resolved when queues of a certain type
  10827. // are emptied (fx is the type by default)
  10828. promise: function( type, obj ) {
  10829. var tmp,
  10830. count = 1,
  10831. defer = jQuery.Deferred(),
  10832. elements = this,
  10833. i = this.length,
  10834. resolve = function() {
  10835. if ( !( --count ) ) {
  10836. defer.resolveWith( elements, [ elements ] );
  10837. }
  10838. };
  10839. if ( typeof type !== "string" ) {
  10840. obj = type;
  10841. type = undefined;
  10842. }
  10843. type = type || "fx";
  10844. while ( i-- ) {
  10845. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10846. if ( tmp && tmp.empty ) {
  10847. count++;
  10848. tmp.empty.add( resolve );
  10849. }
  10850. }
  10851. resolve();
  10852. return defer.promise( obj );
  10853. }
  10854. } );
  10855. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10856. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10857. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10858. var documentElement = document.documentElement;
  10859. var isAttached = function( elem ) {
  10860. return jQuery.contains( elem.ownerDocument, elem );
  10861. },
  10862. composed = { composed: true };
  10863. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10864. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10865. // Support: iOS 10.0-10.2 only
  10866. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10867. // leading to errors. We need to check for `getRootNode`.
  10868. if ( documentElement.getRootNode ) {
  10869. isAttached = function( elem ) {
  10870. return jQuery.contains( elem.ownerDocument, elem ) ||
  10871. elem.getRootNode( composed ) === elem.ownerDocument;
  10872. };
  10873. }
  10874. var isHiddenWithinTree = function( elem, el ) {
  10875. // isHiddenWithinTree might be called from jQuery#filter function;
  10876. // in that case, element will be second argument
  10877. elem = el || elem;
  10878. // Inline style trumps all
  10879. return elem.style.display === "none" ||
  10880. elem.style.display === "" &&
  10881. // Otherwise, check computed style
  10882. // Support: Firefox <=43 - 45
  10883. // Disconnected elements can have computed display: none, so first confirm that elem is
  10884. // in the document.
  10885. isAttached( elem ) &&
  10886. jQuery.css( elem, "display" ) === "none";
  10887. };
  10888. var swap = function( elem, options, callback, args ) {
  10889. var ret, name,
  10890. old = {};
  10891. // Remember the old values, and insert the new ones
  10892. for ( name in options ) {
  10893. old[ name ] = elem.style[ name ];
  10894. elem.style[ name ] = options[ name ];
  10895. }
  10896. ret = callback.apply( elem, args || [] );
  10897. // Revert the old values
  10898. for ( name in options ) {
  10899. elem.style[ name ] = old[ name ];
  10900. }
  10901. return ret;
  10902. };
  10903. function adjustCSS( elem, prop, valueParts, tween ) {
  10904. var adjusted, scale,
  10905. maxIterations = 20,
  10906. currentValue = tween ?
  10907. function() {
  10908. return tween.cur();
  10909. } :
  10910. function() {
  10911. return jQuery.css( elem, prop, "" );
  10912. },
  10913. initial = currentValue(),
  10914. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10915. // Starting value computation is required for potential unit mismatches
  10916. initialInUnit = elem.nodeType &&
  10917. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10918. rcssNum.exec( jQuery.css( elem, prop ) );
  10919. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10920. // Support: Firefox <=54
  10921. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10922. initial = initial / 2;
  10923. // Trust units reported by jQuery.css
  10924. unit = unit || initialInUnit[ 3 ];
  10925. // Iteratively approximate from a nonzero starting point
  10926. initialInUnit = +initial || 1;
  10927. while ( maxIterations-- ) {
  10928. // Evaluate and update our best guess (doubling guesses that zero out).
  10929. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10930. jQuery.style( elem, prop, initialInUnit + unit );
  10931. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10932. maxIterations = 0;
  10933. }
  10934. initialInUnit = initialInUnit / scale;
  10935. }
  10936. initialInUnit = initialInUnit * 2;
  10937. jQuery.style( elem, prop, initialInUnit + unit );
  10938. // Make sure we update the tween properties later on
  10939. valueParts = valueParts || [];
  10940. }
  10941. if ( valueParts ) {
  10942. initialInUnit = +initialInUnit || +initial || 0;
  10943. // Apply relative offset (+=/-=) if specified
  10944. adjusted = valueParts[ 1 ] ?
  10945. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10946. +valueParts[ 2 ];
  10947. if ( tween ) {
  10948. tween.unit = unit;
  10949. tween.start = initialInUnit;
  10950. tween.end = adjusted;
  10951. }
  10952. }
  10953. return adjusted;
  10954. }
  10955. var defaultDisplayMap = {};
  10956. function getDefaultDisplay( elem ) {
  10957. var temp,
  10958. doc = elem.ownerDocument,
  10959. nodeName = elem.nodeName,
  10960. display = defaultDisplayMap[ nodeName ];
  10961. if ( display ) {
  10962. return display;
  10963. }
  10964. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10965. display = jQuery.css( temp, "display" );
  10966. temp.parentNode.removeChild( temp );
  10967. if ( display === "none" ) {
  10968. display = "block";
  10969. }
  10970. defaultDisplayMap[ nodeName ] = display;
  10971. return display;
  10972. }
  10973. function showHide( elements, show ) {
  10974. var display, elem,
  10975. values = [],
  10976. index = 0,
  10977. length = elements.length;
  10978. // Determine new display value for elements that need to change
  10979. for ( ; index < length; index++ ) {
  10980. elem = elements[ index ];
  10981. if ( !elem.style ) {
  10982. continue;
  10983. }
  10984. display = elem.style.display;
  10985. if ( show ) {
  10986. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10987. // check is required in this first loop unless we have a nonempty display value (either
  10988. // inline or about-to-be-restored)
  10989. if ( display === "none" ) {
  10990. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10991. if ( !values[ index ] ) {
  10992. elem.style.display = "";
  10993. }
  10994. }
  10995. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10996. values[ index ] = getDefaultDisplay( elem );
  10997. }
  10998. } else {
  10999. if ( display !== "none" ) {
  11000. values[ index ] = "none";
  11001. // Remember what we're overwriting
  11002. dataPriv.set( elem, "display", display );
  11003. }
  11004. }
  11005. }
  11006. // Set the display of the elements in a second loop to avoid constant reflow
  11007. for ( index = 0; index < length; index++ ) {
  11008. if ( values[ index ] != null ) {
  11009. elements[ index ].style.display = values[ index ];
  11010. }
  11011. }
  11012. return elements;
  11013. }
  11014. jQuery.fn.extend( {
  11015. show: function() {
  11016. return showHide( this, true );
  11017. },
  11018. hide: function() {
  11019. return showHide( this );
  11020. },
  11021. toggle: function( state ) {
  11022. if ( typeof state === "boolean" ) {
  11023. return state ? this.show() : this.hide();
  11024. }
  11025. return this.each( function() {
  11026. if ( isHiddenWithinTree( this ) ) {
  11027. jQuery( this ).show();
  11028. } else {
  11029. jQuery( this ).hide();
  11030. }
  11031. } );
  11032. }
  11033. } );
  11034. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11035. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11036. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11037. // We have to close these tags to support XHTML (#13200)
  11038. var wrapMap = {
  11039. // Support: IE <=9 only
  11040. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11041. // XHTML parsers do not magically insert elements in the
  11042. // same way that tag soup parsers do. So we cannot shorten
  11043. // this by omitting <tbody> or other required elements.
  11044. thead: [ 1, "<table>", "</table>" ],
  11045. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11046. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11047. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11048. _default: [ 0, "", "" ]
  11049. };
  11050. // Support: IE <=9 only
  11051. wrapMap.optgroup = wrapMap.option;
  11052. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11053. wrapMap.th = wrapMap.td;
  11054. function getAll( context, tag ) {
  11055. // Support: IE <=9 - 11 only
  11056. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11057. var ret;
  11058. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11059. ret = context.getElementsByTagName( tag || "*" );
  11060. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11061. ret = context.querySelectorAll( tag || "*" );
  11062. } else {
  11063. ret = [];
  11064. }
  11065. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11066. return jQuery.merge( [ context ], ret );
  11067. }
  11068. return ret;
  11069. }
  11070. // Mark scripts as having already been evaluated
  11071. function setGlobalEval( elems, refElements ) {
  11072. var i = 0,
  11073. l = elems.length;
  11074. for ( ; i < l; i++ ) {
  11075. dataPriv.set(
  11076. elems[ i ],
  11077. "globalEval",
  11078. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11079. );
  11080. }
  11081. }
  11082. var rhtml = /<|&#?\w+;/;
  11083. function buildFragment( elems, context, scripts, selection, ignored ) {
  11084. var elem, tmp, tag, wrap, attached, j,
  11085. fragment = context.createDocumentFragment(),
  11086. nodes = [],
  11087. i = 0,
  11088. l = elems.length;
  11089. for ( ; i < l; i++ ) {
  11090. elem = elems[ i ];
  11091. if ( elem || elem === 0 ) {
  11092. // Add nodes directly
  11093. if ( toType( elem ) === "object" ) {
  11094. // Support: Android <=4.0 only, PhantomJS 1 only
  11095. // push.apply(_, arraylike) throws on ancient WebKit
  11096. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11097. // Convert non-html into a text node
  11098. } else if ( !rhtml.test( elem ) ) {
  11099. nodes.push( context.createTextNode( elem ) );
  11100. // Convert html into DOM nodes
  11101. } else {
  11102. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11103. // Deserialize a standard representation
  11104. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11105. wrap = wrapMap[ tag ] || wrapMap._default;
  11106. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11107. // Descend through wrappers to the right content
  11108. j = wrap[ 0 ];
  11109. while ( j-- ) {
  11110. tmp = tmp.lastChild;
  11111. }
  11112. // Support: Android <=4.0 only, PhantomJS 1 only
  11113. // push.apply(_, arraylike) throws on ancient WebKit
  11114. jQuery.merge( nodes, tmp.childNodes );
  11115. // Remember the top-level container
  11116. tmp = fragment.firstChild;
  11117. // Ensure the created nodes are orphaned (#12392)
  11118. tmp.textContent = "";
  11119. }
  11120. }
  11121. }
  11122. // Remove wrapper from fragment
  11123. fragment.textContent = "";
  11124. i = 0;
  11125. while ( ( elem = nodes[ i++ ] ) ) {
  11126. // Skip elements already in the context collection (trac-4087)
  11127. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11128. if ( ignored ) {
  11129. ignored.push( elem );
  11130. }
  11131. continue;
  11132. }
  11133. attached = isAttached( elem );
  11134. // Append to fragment
  11135. tmp = getAll( fragment.appendChild( elem ), "script" );
  11136. // Preserve script evaluation history
  11137. if ( attached ) {
  11138. setGlobalEval( tmp );
  11139. }
  11140. // Capture executables
  11141. if ( scripts ) {
  11142. j = 0;
  11143. while ( ( elem = tmp[ j++ ] ) ) {
  11144. if ( rscriptType.test( elem.type || "" ) ) {
  11145. scripts.push( elem );
  11146. }
  11147. }
  11148. }
  11149. }
  11150. return fragment;
  11151. }
  11152. ( function() {
  11153. var fragment = document.createDocumentFragment(),
  11154. div = fragment.appendChild( document.createElement( "div" ) ),
  11155. input = document.createElement( "input" );
  11156. // Support: Android 4.0 - 4.3 only
  11157. // Check state lost if the name is set (#11217)
  11158. // Support: Windows Web Apps (WWA)
  11159. // `name` and `type` must use .setAttribute for WWA (#14901)
  11160. input.setAttribute( "type", "radio" );
  11161. input.setAttribute( "checked", "checked" );
  11162. input.setAttribute( "name", "t" );
  11163. div.appendChild( input );
  11164. // Support: Android <=4.1 only
  11165. // Older WebKit doesn't clone checked state correctly in fragments
  11166. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11167. // Support: IE <=11 only
  11168. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11169. div.innerHTML = "<textarea>x</textarea>";
  11170. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11171. } )();
  11172. var
  11173. rkeyEvent = /^key/,
  11174. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11175. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11176. function returnTrue() {
  11177. return true;
  11178. }
  11179. function returnFalse() {
  11180. return false;
  11181. }
  11182. // Support: IE <=9 - 11+
  11183. // focus() and blur() are asynchronous, except when they are no-op.
  11184. // So expect focus to be synchronous when the element is already active,
  11185. // and blur to be synchronous when the element is not already active.
  11186. // (focus and blur are always synchronous in other supported browsers,
  11187. // this just defines when we can count on it).
  11188. function expectSync( elem, type ) {
  11189. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11190. }
  11191. // Support: IE <=9 only
  11192. // Accessing document.activeElement can throw unexpectedly
  11193. // https://bugs.jquery.com/ticket/13393
  11194. function safeActiveElement() {
  11195. try {
  11196. return document.activeElement;
  11197. } catch ( err ) { }
  11198. }
  11199. function on( elem, types, selector, data, fn, one ) {
  11200. var origFn, type;
  11201. // Types can be a map of types/handlers
  11202. if ( typeof types === "object" ) {
  11203. // ( types-Object, selector, data )
  11204. if ( typeof selector !== "string" ) {
  11205. // ( types-Object, data )
  11206. data = data || selector;
  11207. selector = undefined;
  11208. }
  11209. for ( type in types ) {
  11210. on( elem, type, selector, data, types[ type ], one );
  11211. }
  11212. return elem;
  11213. }
  11214. if ( data == null && fn == null ) {
  11215. // ( types, fn )
  11216. fn = selector;
  11217. data = selector = undefined;
  11218. } else if ( fn == null ) {
  11219. if ( typeof selector === "string" ) {
  11220. // ( types, selector, fn )
  11221. fn = data;
  11222. data = undefined;
  11223. } else {
  11224. // ( types, data, fn )
  11225. fn = data;
  11226. data = selector;
  11227. selector = undefined;
  11228. }
  11229. }
  11230. if ( fn === false ) {
  11231. fn = returnFalse;
  11232. } else if ( !fn ) {
  11233. return elem;
  11234. }
  11235. if ( one === 1 ) {
  11236. origFn = fn;
  11237. fn = function( event ) {
  11238. // Can use an empty set, since event contains the info
  11239. jQuery().off( event );
  11240. return origFn.apply( this, arguments );
  11241. };
  11242. // Use same guid so caller can remove using origFn
  11243. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11244. }
  11245. return elem.each( function() {
  11246. jQuery.event.add( this, types, fn, data, selector );
  11247. } );
  11248. }
  11249. /*
  11250. * Helper functions for managing events -- not part of the public interface.
  11251. * Props to Dean Edwards' addEvent library for many of the ideas.
  11252. */
  11253. jQuery.event = {
  11254. global: {},
  11255. add: function( elem, types, handler, data, selector ) {
  11256. var handleObjIn, eventHandle, tmp,
  11257. events, t, handleObj,
  11258. special, handlers, type, namespaces, origType,
  11259. elemData = dataPriv.get( elem );
  11260. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11261. if ( !elemData ) {
  11262. return;
  11263. }
  11264. // Caller can pass in an object of custom data in lieu of the handler
  11265. if ( handler.handler ) {
  11266. handleObjIn = handler;
  11267. handler = handleObjIn.handler;
  11268. selector = handleObjIn.selector;
  11269. }
  11270. // Ensure that invalid selectors throw exceptions at attach time
  11271. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11272. if ( selector ) {
  11273. jQuery.find.matchesSelector( documentElement, selector );
  11274. }
  11275. // Make sure that the handler has a unique ID, used to find/remove it later
  11276. if ( !handler.guid ) {
  11277. handler.guid = jQuery.guid++;
  11278. }
  11279. // Init the element's event structure and main handler, if this is the first
  11280. if ( !( events = elemData.events ) ) {
  11281. events = elemData.events = {};
  11282. }
  11283. if ( !( eventHandle = elemData.handle ) ) {
  11284. eventHandle = elemData.handle = function( e ) {
  11285. // Discard the second event of a jQuery.event.trigger() and
  11286. // when an event is called after a page has unloaded
  11287. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11288. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11289. };
  11290. }
  11291. // Handle multiple events separated by a space
  11292. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11293. t = types.length;
  11294. while ( t-- ) {
  11295. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11296. type = origType = tmp[ 1 ];
  11297. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11298. // There *must* be a type, no attaching namespace-only handlers
  11299. if ( !type ) {
  11300. continue;
  11301. }
  11302. // If event changes its type, use the special event handlers for the changed type
  11303. special = jQuery.event.special[ type ] || {};
  11304. // If selector defined, determine special event api type, otherwise given type
  11305. type = ( selector ? special.delegateType : special.bindType ) || type;
  11306. // Update special based on newly reset type
  11307. special = jQuery.event.special[ type ] || {};
  11308. // handleObj is passed to all event handlers
  11309. handleObj = jQuery.extend( {
  11310. type: type,
  11311. origType: origType,
  11312. data: data,
  11313. handler: handler,
  11314. guid: handler.guid,
  11315. selector: selector,
  11316. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11317. namespace: namespaces.join( "." )
  11318. }, handleObjIn );
  11319. // Init the event handler queue if we're the first
  11320. if ( !( handlers = events[ type ] ) ) {
  11321. handlers = events[ type ] = [];
  11322. handlers.delegateCount = 0;
  11323. // Only use addEventListener if the special events handler returns false
  11324. if ( !special.setup ||
  11325. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11326. if ( elem.addEventListener ) {
  11327. elem.addEventListener( type, eventHandle );
  11328. }
  11329. }
  11330. }
  11331. if ( special.add ) {
  11332. special.add.call( elem, handleObj );
  11333. if ( !handleObj.handler.guid ) {
  11334. handleObj.handler.guid = handler.guid;
  11335. }
  11336. }
  11337. // Add to the element's handler list, delegates in front
  11338. if ( selector ) {
  11339. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11340. } else {
  11341. handlers.push( handleObj );
  11342. }
  11343. // Keep track of which events have ever been used, for event optimization
  11344. jQuery.event.global[ type ] = true;
  11345. }
  11346. },
  11347. // Detach an event or set of events from an element
  11348. remove: function( elem, types, handler, selector, mappedTypes ) {
  11349. var j, origCount, tmp,
  11350. events, t, handleObj,
  11351. special, handlers, type, namespaces, origType,
  11352. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11353. if ( !elemData || !( events = elemData.events ) ) {
  11354. return;
  11355. }
  11356. // Once for each type.namespace in types; type may be omitted
  11357. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11358. t = types.length;
  11359. while ( t-- ) {
  11360. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11361. type = origType = tmp[ 1 ];
  11362. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11363. // Unbind all events (on this namespace, if provided) for the element
  11364. if ( !type ) {
  11365. for ( type in events ) {
  11366. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11367. }
  11368. continue;
  11369. }
  11370. special = jQuery.event.special[ type ] || {};
  11371. type = ( selector ? special.delegateType : special.bindType ) || type;
  11372. handlers = events[ type ] || [];
  11373. tmp = tmp[ 2 ] &&
  11374. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11375. // Remove matching events
  11376. origCount = j = handlers.length;
  11377. while ( j-- ) {
  11378. handleObj = handlers[ j ];
  11379. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11380. ( !handler || handler.guid === handleObj.guid ) &&
  11381. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11382. ( !selector || selector === handleObj.selector ||
  11383. selector === "**" && handleObj.selector ) ) {
  11384. handlers.splice( j, 1 );
  11385. if ( handleObj.selector ) {
  11386. handlers.delegateCount--;
  11387. }
  11388. if ( special.remove ) {
  11389. special.remove.call( elem, handleObj );
  11390. }
  11391. }
  11392. }
  11393. // Remove generic event handler if we removed something and no more handlers exist
  11394. // (avoids potential for endless recursion during removal of special event handlers)
  11395. if ( origCount && !handlers.length ) {
  11396. if ( !special.teardown ||
  11397. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11398. jQuery.removeEvent( elem, type, elemData.handle );
  11399. }
  11400. delete events[ type ];
  11401. }
  11402. }
  11403. // Remove data and the expando if it's no longer used
  11404. if ( jQuery.isEmptyObject( events ) ) {
  11405. dataPriv.remove( elem, "handle events" );
  11406. }
  11407. },
  11408. dispatch: function( nativeEvent ) {
  11409. // Make a writable jQuery.Event from the native event object
  11410. var event = jQuery.event.fix( nativeEvent );
  11411. var i, j, ret, matched, handleObj, handlerQueue,
  11412. args = new Array( arguments.length ),
  11413. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11414. special = jQuery.event.special[ event.type ] || {};
  11415. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11416. args[ 0 ] = event;
  11417. for ( i = 1; i < arguments.length; i++ ) {
  11418. args[ i ] = arguments[ i ];
  11419. }
  11420. event.delegateTarget = this;
  11421. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11422. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11423. return;
  11424. }
  11425. // Determine handlers
  11426. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11427. // Run delegates first; they may want to stop propagation beneath us
  11428. i = 0;
  11429. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11430. event.currentTarget = matched.elem;
  11431. j = 0;
  11432. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11433. !event.isImmediatePropagationStopped() ) {
  11434. // If the event is namespaced, then each handler is only invoked if it is
  11435. // specially universal or its namespaces are a superset of the event's.
  11436. if ( !event.rnamespace || handleObj.namespace === false ||
  11437. event.rnamespace.test( handleObj.namespace ) ) {
  11438. event.handleObj = handleObj;
  11439. event.data = handleObj.data;
  11440. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11441. handleObj.handler ).apply( matched.elem, args );
  11442. if ( ret !== undefined ) {
  11443. if ( ( event.result = ret ) === false ) {
  11444. event.preventDefault();
  11445. event.stopPropagation();
  11446. }
  11447. }
  11448. }
  11449. }
  11450. }
  11451. // Call the postDispatch hook for the mapped type
  11452. if ( special.postDispatch ) {
  11453. special.postDispatch.call( this, event );
  11454. }
  11455. return event.result;
  11456. },
  11457. handlers: function( event, handlers ) {
  11458. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11459. handlerQueue = [],
  11460. delegateCount = handlers.delegateCount,
  11461. cur = event.target;
  11462. // Find delegate handlers
  11463. if ( delegateCount &&
  11464. // Support: IE <=9
  11465. // Black-hole SVG <use> instance trees (trac-13180)
  11466. cur.nodeType &&
  11467. // Support: Firefox <=42
  11468. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11469. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11470. // Support: IE 11 only
  11471. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11472. !( event.type === "click" && event.button >= 1 ) ) {
  11473. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11474. // Don't check non-elements (#13208)
  11475. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11476. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11477. matchedHandlers = [];
  11478. matchedSelectors = {};
  11479. for ( i = 0; i < delegateCount; i++ ) {
  11480. handleObj = handlers[ i ];
  11481. // Don't conflict with Object.prototype properties (#13203)
  11482. sel = handleObj.selector + " ";
  11483. if ( matchedSelectors[ sel ] === undefined ) {
  11484. matchedSelectors[ sel ] = handleObj.needsContext ?
  11485. jQuery( sel, this ).index( cur ) > -1 :
  11486. jQuery.find( sel, this, null, [ cur ] ).length;
  11487. }
  11488. if ( matchedSelectors[ sel ] ) {
  11489. matchedHandlers.push( handleObj );
  11490. }
  11491. }
  11492. if ( matchedHandlers.length ) {
  11493. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11494. }
  11495. }
  11496. }
  11497. }
  11498. // Add the remaining (directly-bound) handlers
  11499. cur = this;
  11500. if ( delegateCount < handlers.length ) {
  11501. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11502. }
  11503. return handlerQueue;
  11504. },
  11505. addProp: function( name, hook ) {
  11506. Object.defineProperty( jQuery.Event.prototype, name, {
  11507. enumerable: true,
  11508. configurable: true,
  11509. get: isFunction( hook ) ?
  11510. function() {
  11511. if ( this.originalEvent ) {
  11512. return hook( this.originalEvent );
  11513. }
  11514. } :
  11515. function() {
  11516. if ( this.originalEvent ) {
  11517. return this.originalEvent[ name ];
  11518. }
  11519. },
  11520. set: function( value ) {
  11521. Object.defineProperty( this, name, {
  11522. enumerable: true,
  11523. configurable: true,
  11524. writable: true,
  11525. value: value
  11526. } );
  11527. }
  11528. } );
  11529. },
  11530. fix: function( originalEvent ) {
  11531. return originalEvent[ jQuery.expando ] ?
  11532. originalEvent :
  11533. new jQuery.Event( originalEvent );
  11534. },
  11535. special: {
  11536. load: {
  11537. // Prevent triggered image.load events from bubbling to window.load
  11538. noBubble: true
  11539. },
  11540. click: {
  11541. // Utilize native event to ensure correct state for checkable inputs
  11542. setup: function( data ) {
  11543. // For mutual compressibility with _default, replace `this` access with a local var.
  11544. // `|| data` is dead code meant only to preserve the variable through minification.
  11545. var el = this || data;
  11546. // Claim the first handler
  11547. if ( rcheckableType.test( el.type ) &&
  11548. el.click && nodeName( el, "input" ) ) {
  11549. // dataPriv.set( el, "click", ... )
  11550. leverageNative( el, "click", returnTrue );
  11551. }
  11552. // Return false to allow normal processing in the caller
  11553. return false;
  11554. },
  11555. trigger: function( data ) {
  11556. // For mutual compressibility with _default, replace `this` access with a local var.
  11557. // `|| data` is dead code meant only to preserve the variable through minification.
  11558. var el = this || data;
  11559. // Force setup before triggering a click
  11560. if ( rcheckableType.test( el.type ) &&
  11561. el.click && nodeName( el, "input" ) ) {
  11562. leverageNative( el, "click" );
  11563. }
  11564. // Return non-false to allow normal event-path propagation
  11565. return true;
  11566. },
  11567. // For cross-browser consistency, suppress native .click() on links
  11568. // Also prevent it if we're currently inside a leveraged native-event stack
  11569. _default: function( event ) {
  11570. var target = event.target;
  11571. return rcheckableType.test( target.type ) &&
  11572. target.click && nodeName( target, "input" ) &&
  11573. dataPriv.get( target, "click" ) ||
  11574. nodeName( target, "a" );
  11575. }
  11576. },
  11577. beforeunload: {
  11578. postDispatch: function( event ) {
  11579. // Support: Firefox 20+
  11580. // Firefox doesn't alert if the returnValue field is not set.
  11581. if ( event.result !== undefined && event.originalEvent ) {
  11582. event.originalEvent.returnValue = event.result;
  11583. }
  11584. }
  11585. }
  11586. }
  11587. };
  11588. // Ensure the presence of an event listener that handles manually-triggered
  11589. // synthetic events by interrupting progress until reinvoked in response to
  11590. // *native* events that it fires directly, ensuring that state changes have
  11591. // already occurred before other listeners are invoked.
  11592. function leverageNative( el, type, expectSync ) {
  11593. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11594. if ( !expectSync ) {
  11595. if ( dataPriv.get( el, type ) === undefined ) {
  11596. jQuery.event.add( el, type, returnTrue );
  11597. }
  11598. return;
  11599. }
  11600. // Register the controller as a special universal handler for all event namespaces
  11601. dataPriv.set( el, type, false );
  11602. jQuery.event.add( el, type, {
  11603. namespace: false,
  11604. handler: function( event ) {
  11605. var notAsync, result,
  11606. saved = dataPriv.get( this, type );
  11607. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11608. // Interrupt processing of the outer synthetic .trigger()ed event
  11609. // Saved data should be false in such cases, but might be a leftover capture object
  11610. // from an async native handler (gh-4350)
  11611. if ( !saved.length ) {
  11612. // Store arguments for use when handling the inner native event
  11613. // There will always be at least one argument (an event object), so this array
  11614. // will not be confused with a leftover capture object.
  11615. saved = slice.call( arguments );
  11616. dataPriv.set( this, type, saved );
  11617. // Trigger the native event and capture its result
  11618. // Support: IE <=9 - 11+
  11619. // focus() and blur() are asynchronous
  11620. notAsync = expectSync( this, type );
  11621. this[ type ]();
  11622. result = dataPriv.get( this, type );
  11623. if ( saved !== result || notAsync ) {
  11624. dataPriv.set( this, type, false );
  11625. } else {
  11626. result = {};
  11627. }
  11628. if ( saved !== result ) {
  11629. // Cancel the outer synthetic event
  11630. event.stopImmediatePropagation();
  11631. event.preventDefault();
  11632. return result.value;
  11633. }
  11634. // If this is an inner synthetic event for an event with a bubbling surrogate
  11635. // (focus or blur), assume that the surrogate already propagated from triggering the
  11636. // native event and prevent that from happening again here.
  11637. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11638. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11639. // less bad than duplication.
  11640. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11641. event.stopPropagation();
  11642. }
  11643. // If this is a native event triggered above, everything is now in order
  11644. // Fire an inner synthetic event with the original arguments
  11645. } else if ( saved.length ) {
  11646. // ...and capture the result
  11647. dataPriv.set( this, type, {
  11648. value: jQuery.event.trigger(
  11649. // Support: IE <=9 - 11+
  11650. // Extend with the prototype to reset the above stopImmediatePropagation()
  11651. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11652. saved.slice( 1 ),
  11653. this
  11654. )
  11655. } );
  11656. // Abort handling of the native event
  11657. event.stopImmediatePropagation();
  11658. }
  11659. }
  11660. } );
  11661. }
  11662. jQuery.removeEvent = function( elem, type, handle ) {
  11663. // This "if" is needed for plain objects
  11664. if ( elem.removeEventListener ) {
  11665. elem.removeEventListener( type, handle );
  11666. }
  11667. };
  11668. jQuery.Event = function( src, props ) {
  11669. // Allow instantiation without the 'new' keyword
  11670. if ( !( this instanceof jQuery.Event ) ) {
  11671. return new jQuery.Event( src, props );
  11672. }
  11673. // Event object
  11674. if ( src && src.type ) {
  11675. this.originalEvent = src;
  11676. this.type = src.type;
  11677. // Events bubbling up the document may have been marked as prevented
  11678. // by a handler lower down the tree; reflect the correct value.
  11679. this.isDefaultPrevented = src.defaultPrevented ||
  11680. src.defaultPrevented === undefined &&
  11681. // Support: Android <=2.3 only
  11682. src.returnValue === false ?
  11683. returnTrue :
  11684. returnFalse;
  11685. // Create target properties
  11686. // Support: Safari <=6 - 7 only
  11687. // Target should not be a text node (#504, #13143)
  11688. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11689. src.target.parentNode :
  11690. src.target;
  11691. this.currentTarget = src.currentTarget;
  11692. this.relatedTarget = src.relatedTarget;
  11693. // Event type
  11694. } else {
  11695. this.type = src;
  11696. }
  11697. // Put explicitly provided properties onto the event object
  11698. if ( props ) {
  11699. jQuery.extend( this, props );
  11700. }
  11701. // Create a timestamp if incoming event doesn't have one
  11702. this.timeStamp = src && src.timeStamp || Date.now();
  11703. // Mark it as fixed
  11704. this[ jQuery.expando ] = true;
  11705. };
  11706. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11707. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11708. jQuery.Event.prototype = {
  11709. constructor: jQuery.Event,
  11710. isDefaultPrevented: returnFalse,
  11711. isPropagationStopped: returnFalse,
  11712. isImmediatePropagationStopped: returnFalse,
  11713. isSimulated: false,
  11714. preventDefault: function() {
  11715. var e = this.originalEvent;
  11716. this.isDefaultPrevented = returnTrue;
  11717. if ( e && !this.isSimulated ) {
  11718. e.preventDefault();
  11719. }
  11720. },
  11721. stopPropagation: function() {
  11722. var e = this.originalEvent;
  11723. this.isPropagationStopped = returnTrue;
  11724. if ( e && !this.isSimulated ) {
  11725. e.stopPropagation();
  11726. }
  11727. },
  11728. stopImmediatePropagation: function() {
  11729. var e = this.originalEvent;
  11730. this.isImmediatePropagationStopped = returnTrue;
  11731. if ( e && !this.isSimulated ) {
  11732. e.stopImmediatePropagation();
  11733. }
  11734. this.stopPropagation();
  11735. }
  11736. };
  11737. // Includes all common event props including KeyEvent and MouseEvent specific props
  11738. jQuery.each( {
  11739. altKey: true,
  11740. bubbles: true,
  11741. cancelable: true,
  11742. changedTouches: true,
  11743. ctrlKey: true,
  11744. detail: true,
  11745. eventPhase: true,
  11746. metaKey: true,
  11747. pageX: true,
  11748. pageY: true,
  11749. shiftKey: true,
  11750. view: true,
  11751. "char": true,
  11752. code: true,
  11753. charCode: true,
  11754. key: true,
  11755. keyCode: true,
  11756. button: true,
  11757. buttons: true,
  11758. clientX: true,
  11759. clientY: true,
  11760. offsetX: true,
  11761. offsetY: true,
  11762. pointerId: true,
  11763. pointerType: true,
  11764. screenX: true,
  11765. screenY: true,
  11766. targetTouches: true,
  11767. toElement: true,
  11768. touches: true,
  11769. which: function( event ) {
  11770. var button = event.button;
  11771. // Add which for key events
  11772. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11773. return event.charCode != null ? event.charCode : event.keyCode;
  11774. }
  11775. // Add which for click: 1 === left; 2 === middle; 3 === right
  11776. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11777. if ( button & 1 ) {
  11778. return 1;
  11779. }
  11780. if ( button & 2 ) {
  11781. return 3;
  11782. }
  11783. if ( button & 4 ) {
  11784. return 2;
  11785. }
  11786. return 0;
  11787. }
  11788. return event.which;
  11789. }
  11790. }, jQuery.event.addProp );
  11791. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11792. jQuery.event.special[ type ] = {
  11793. // Utilize native event if possible so blur/focus sequence is correct
  11794. setup: function() {
  11795. // Claim the first handler
  11796. // dataPriv.set( this, "focus", ... )
  11797. // dataPriv.set( this, "blur", ... )
  11798. leverageNative( this, type, expectSync );
  11799. // Return false to allow normal processing in the caller
  11800. return false;
  11801. },
  11802. trigger: function() {
  11803. // Force setup before trigger
  11804. leverageNative( this, type );
  11805. // Return non-false to allow normal event-path propagation
  11806. return true;
  11807. },
  11808. delegateType: delegateType
  11809. };
  11810. } );
  11811. // Create mouseenter/leave events using mouseover/out and event-time checks
  11812. // so that event delegation works in jQuery.
  11813. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11814. //
  11815. // Support: Safari 7 only
  11816. // Safari sends mouseenter too often; see:
  11817. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11818. // for the description of the bug (it existed in older Chrome versions as well).
  11819. jQuery.each( {
  11820. mouseenter: "mouseover",
  11821. mouseleave: "mouseout",
  11822. pointerenter: "pointerover",
  11823. pointerleave: "pointerout"
  11824. }, function( orig, fix ) {
  11825. jQuery.event.special[ orig ] = {
  11826. delegateType: fix,
  11827. bindType: fix,
  11828. handle: function( event ) {
  11829. var ret,
  11830. target = this,
  11831. related = event.relatedTarget,
  11832. handleObj = event.handleObj;
  11833. // For mouseenter/leave call the handler if related is outside the target.
  11834. // NB: No relatedTarget if the mouse left/entered the browser window
  11835. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11836. event.type = handleObj.origType;
  11837. ret = handleObj.handler.apply( this, arguments );
  11838. event.type = fix;
  11839. }
  11840. return ret;
  11841. }
  11842. };
  11843. } );
  11844. jQuery.fn.extend( {
  11845. on: function( types, selector, data, fn ) {
  11846. return on( this, types, selector, data, fn );
  11847. },
  11848. one: function( types, selector, data, fn ) {
  11849. return on( this, types, selector, data, fn, 1 );
  11850. },
  11851. off: function( types, selector, fn ) {
  11852. var handleObj, type;
  11853. if ( types && types.preventDefault && types.handleObj ) {
  11854. // ( event ) dispatched jQuery.Event
  11855. handleObj = types.handleObj;
  11856. jQuery( types.delegateTarget ).off(
  11857. handleObj.namespace ?
  11858. handleObj.origType + "." + handleObj.namespace :
  11859. handleObj.origType,
  11860. handleObj.selector,
  11861. handleObj.handler
  11862. );
  11863. return this;
  11864. }
  11865. if ( typeof types === "object" ) {
  11866. // ( types-object [, selector] )
  11867. for ( type in types ) {
  11868. this.off( type, selector, types[ type ] );
  11869. }
  11870. return this;
  11871. }
  11872. if ( selector === false || typeof selector === "function" ) {
  11873. // ( types [, fn] )
  11874. fn = selector;
  11875. selector = undefined;
  11876. }
  11877. if ( fn === false ) {
  11878. fn = returnFalse;
  11879. }
  11880. return this.each( function() {
  11881. jQuery.event.remove( this, types, fn, selector );
  11882. } );
  11883. }
  11884. } );
  11885. var
  11886. /* eslint-disable max-len */
  11887. // See https://github.com/eslint/eslint/issues/3229
  11888. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11889. /* eslint-enable */
  11890. // Support: IE <=10 - 11, Edge 12 - 13 only
  11891. // In IE/Edge using regex groups here causes severe slowdowns.
  11892. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11893. rnoInnerhtml = /<script|<style|<link/i,
  11894. // checked="checked" or checked
  11895. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11896. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11897. // Prefer a tbody over its parent table for containing new rows
  11898. function manipulationTarget( elem, content ) {
  11899. if ( nodeName( elem, "table" ) &&
  11900. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11901. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11902. }
  11903. return elem;
  11904. }
  11905. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11906. function disableScript( elem ) {
  11907. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11908. return elem;
  11909. }
  11910. function restoreScript( elem ) {
  11911. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11912. elem.type = elem.type.slice( 5 );
  11913. } else {
  11914. elem.removeAttribute( "type" );
  11915. }
  11916. return elem;
  11917. }
  11918. function cloneCopyEvent( src, dest ) {
  11919. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11920. if ( dest.nodeType !== 1 ) {
  11921. return;
  11922. }
  11923. // 1. Copy private data: events, handlers, etc.
  11924. if ( dataPriv.hasData( src ) ) {
  11925. pdataOld = dataPriv.access( src );
  11926. pdataCur = dataPriv.set( dest, pdataOld );
  11927. events = pdataOld.events;
  11928. if ( events ) {
  11929. delete pdataCur.handle;
  11930. pdataCur.events = {};
  11931. for ( type in events ) {
  11932. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11933. jQuery.event.add( dest, type, events[ type ][ i ] );
  11934. }
  11935. }
  11936. }
  11937. }
  11938. // 2. Copy user data
  11939. if ( dataUser.hasData( src ) ) {
  11940. udataOld = dataUser.access( src );
  11941. udataCur = jQuery.extend( {}, udataOld );
  11942. dataUser.set( dest, udataCur );
  11943. }
  11944. }
  11945. // Fix IE bugs, see support tests
  11946. function fixInput( src, dest ) {
  11947. var nodeName = dest.nodeName.toLowerCase();
  11948. // Fails to persist the checked state of a cloned checkbox or radio button.
  11949. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11950. dest.checked = src.checked;
  11951. // Fails to return the selected option to the default selected state when cloning options
  11952. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11953. dest.defaultValue = src.defaultValue;
  11954. }
  11955. }
  11956. function domManip( collection, args, callback, ignored ) {
  11957. // Flatten any nested arrays
  11958. args = concat.apply( [], args );
  11959. var fragment, first, scripts, hasScripts, node, doc,
  11960. i = 0,
  11961. l = collection.length,
  11962. iNoClone = l - 1,
  11963. value = args[ 0 ],
  11964. valueIsFunction = isFunction( value );
  11965. // We can't cloneNode fragments that contain checked, in WebKit
  11966. if ( valueIsFunction ||
  11967. ( l > 1 && typeof value === "string" &&
  11968. !support.checkClone && rchecked.test( value ) ) ) {
  11969. return collection.each( function( index ) {
  11970. var self = collection.eq( index );
  11971. if ( valueIsFunction ) {
  11972. args[ 0 ] = value.call( this, index, self.html() );
  11973. }
  11974. domManip( self, args, callback, ignored );
  11975. } );
  11976. }
  11977. if ( l ) {
  11978. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11979. first = fragment.firstChild;
  11980. if ( fragment.childNodes.length === 1 ) {
  11981. fragment = first;
  11982. }
  11983. // Require either new content or an interest in ignored elements to invoke the callback
  11984. if ( first || ignored ) {
  11985. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11986. hasScripts = scripts.length;
  11987. // Use the original fragment for the last item
  11988. // instead of the first because it can end up
  11989. // being emptied incorrectly in certain situations (#8070).
  11990. for ( ; i < l; i++ ) {
  11991. node = fragment;
  11992. if ( i !== iNoClone ) {
  11993. node = jQuery.clone( node, true, true );
  11994. // Keep references to cloned scripts for later restoration
  11995. if ( hasScripts ) {
  11996. // Support: Android <=4.0 only, PhantomJS 1 only
  11997. // push.apply(_, arraylike) throws on ancient WebKit
  11998. jQuery.merge( scripts, getAll( node, "script" ) );
  11999. }
  12000. }
  12001. callback.call( collection[ i ], node, i );
  12002. }
  12003. if ( hasScripts ) {
  12004. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12005. // Reenable scripts
  12006. jQuery.map( scripts, restoreScript );
  12007. // Evaluate executable scripts on first document insertion
  12008. for ( i = 0; i < hasScripts; i++ ) {
  12009. node = scripts[ i ];
  12010. if ( rscriptType.test( node.type || "" ) &&
  12011. !dataPriv.access( node, "globalEval" ) &&
  12012. jQuery.contains( doc, node ) ) {
  12013. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12014. // Optional AJAX dependency, but won't run scripts if not present
  12015. if ( jQuery._evalUrl && !node.noModule ) {
  12016. jQuery._evalUrl( node.src, {
  12017. nonce: node.nonce || node.getAttribute( "nonce" )
  12018. } );
  12019. }
  12020. } else {
  12021. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12022. }
  12023. }
  12024. }
  12025. }
  12026. }
  12027. }
  12028. return collection;
  12029. }
  12030. function remove( elem, selector, keepData ) {
  12031. var node,
  12032. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12033. i = 0;
  12034. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12035. if ( !keepData && node.nodeType === 1 ) {
  12036. jQuery.cleanData( getAll( node ) );
  12037. }
  12038. if ( node.parentNode ) {
  12039. if ( keepData && isAttached( node ) ) {
  12040. setGlobalEval( getAll( node, "script" ) );
  12041. }
  12042. node.parentNode.removeChild( node );
  12043. }
  12044. }
  12045. return elem;
  12046. }
  12047. jQuery.extend( {
  12048. htmlPrefilter: function( html ) {
  12049. return html.replace( rxhtmlTag, "<$1></$2>" );
  12050. },
  12051. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12052. var i, l, srcElements, destElements,
  12053. clone = elem.cloneNode( true ),
  12054. inPage = isAttached( elem );
  12055. // Fix IE cloning issues
  12056. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12057. !jQuery.isXMLDoc( elem ) ) {
  12058. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12059. destElements = getAll( clone );
  12060. srcElements = getAll( elem );
  12061. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12062. fixInput( srcElements[ i ], destElements[ i ] );
  12063. }
  12064. }
  12065. // Copy the events from the original to the clone
  12066. if ( dataAndEvents ) {
  12067. if ( deepDataAndEvents ) {
  12068. srcElements = srcElements || getAll( elem );
  12069. destElements = destElements || getAll( clone );
  12070. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12071. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12072. }
  12073. } else {
  12074. cloneCopyEvent( elem, clone );
  12075. }
  12076. }
  12077. // Preserve script evaluation history
  12078. destElements = getAll( clone, "script" );
  12079. if ( destElements.length > 0 ) {
  12080. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12081. }
  12082. // Return the cloned set
  12083. return clone;
  12084. },
  12085. cleanData: function( elems ) {
  12086. var data, elem, type,
  12087. special = jQuery.event.special,
  12088. i = 0;
  12089. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12090. if ( acceptData( elem ) ) {
  12091. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12092. if ( data.events ) {
  12093. for ( type in data.events ) {
  12094. if ( special[ type ] ) {
  12095. jQuery.event.remove( elem, type );
  12096. // This is a shortcut to avoid jQuery.event.remove's overhead
  12097. } else {
  12098. jQuery.removeEvent( elem, type, data.handle );
  12099. }
  12100. }
  12101. }
  12102. // Support: Chrome <=35 - 45+
  12103. // Assign undefined instead of using delete, see Data#remove
  12104. elem[ dataPriv.expando ] = undefined;
  12105. }
  12106. if ( elem[ dataUser.expando ] ) {
  12107. // Support: Chrome <=35 - 45+
  12108. // Assign undefined instead of using delete, see Data#remove
  12109. elem[ dataUser.expando ] = undefined;
  12110. }
  12111. }
  12112. }
  12113. }
  12114. } );
  12115. jQuery.fn.extend( {
  12116. detach: function( selector ) {
  12117. return remove( this, selector, true );
  12118. },
  12119. remove: function( selector ) {
  12120. return remove( this, selector );
  12121. },
  12122. text: function( value ) {
  12123. return access( this, function( value ) {
  12124. return value === undefined ?
  12125. jQuery.text( this ) :
  12126. this.empty().each( function() {
  12127. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12128. this.textContent = value;
  12129. }
  12130. } );
  12131. }, null, value, arguments.length );
  12132. },
  12133. append: function() {
  12134. return domManip( this, arguments, function( elem ) {
  12135. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12136. var target = manipulationTarget( this, elem );
  12137. target.appendChild( elem );
  12138. }
  12139. } );
  12140. },
  12141. prepend: function() {
  12142. return domManip( this, arguments, function( elem ) {
  12143. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12144. var target = manipulationTarget( this, elem );
  12145. target.insertBefore( elem, target.firstChild );
  12146. }
  12147. } );
  12148. },
  12149. before: function() {
  12150. return domManip( this, arguments, function( elem ) {
  12151. if ( this.parentNode ) {
  12152. this.parentNode.insertBefore( elem, this );
  12153. }
  12154. } );
  12155. },
  12156. after: function() {
  12157. return domManip( this, arguments, function( elem ) {
  12158. if ( this.parentNode ) {
  12159. this.parentNode.insertBefore( elem, this.nextSibling );
  12160. }
  12161. } );
  12162. },
  12163. empty: function() {
  12164. var elem,
  12165. i = 0;
  12166. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12167. if ( elem.nodeType === 1 ) {
  12168. // Prevent memory leaks
  12169. jQuery.cleanData( getAll( elem, false ) );
  12170. // Remove any remaining nodes
  12171. elem.textContent = "";
  12172. }
  12173. }
  12174. return this;
  12175. },
  12176. clone: function( dataAndEvents, deepDataAndEvents ) {
  12177. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12178. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12179. return this.map( function() {
  12180. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12181. } );
  12182. },
  12183. html: function( value ) {
  12184. return access( this, function( value ) {
  12185. var elem = this[ 0 ] || {},
  12186. i = 0,
  12187. l = this.length;
  12188. if ( value === undefined && elem.nodeType === 1 ) {
  12189. return elem.innerHTML;
  12190. }
  12191. // See if we can take a shortcut and just use innerHTML
  12192. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12193. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12194. value = jQuery.htmlPrefilter( value );
  12195. try {
  12196. for ( ; i < l; i++ ) {
  12197. elem = this[ i ] || {};
  12198. // Remove element nodes and prevent memory leaks
  12199. if ( elem.nodeType === 1 ) {
  12200. jQuery.cleanData( getAll( elem, false ) );
  12201. elem.innerHTML = value;
  12202. }
  12203. }
  12204. elem = 0;
  12205. // If using innerHTML throws an exception, use the fallback method
  12206. } catch ( e ) {}
  12207. }
  12208. if ( elem ) {
  12209. this.empty().append( value );
  12210. }
  12211. }, null, value, arguments.length );
  12212. },
  12213. replaceWith: function() {
  12214. var ignored = [];
  12215. // Make the changes, replacing each non-ignored context element with the new content
  12216. return domManip( this, arguments, function( elem ) {
  12217. var parent = this.parentNode;
  12218. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12219. jQuery.cleanData( getAll( this ) );
  12220. if ( parent ) {
  12221. parent.replaceChild( elem, this );
  12222. }
  12223. }
  12224. // Force callback invocation
  12225. }, ignored );
  12226. }
  12227. } );
  12228. jQuery.each( {
  12229. appendTo: "append",
  12230. prependTo: "prepend",
  12231. insertBefore: "before",
  12232. insertAfter: "after",
  12233. replaceAll: "replaceWith"
  12234. }, function( name, original ) {
  12235. jQuery.fn[ name ] = function( selector ) {
  12236. var elems,
  12237. ret = [],
  12238. insert = jQuery( selector ),
  12239. last = insert.length - 1,
  12240. i = 0;
  12241. for ( ; i <= last; i++ ) {
  12242. elems = i === last ? this : this.clone( true );
  12243. jQuery( insert[ i ] )[ original ]( elems );
  12244. // Support: Android <=4.0 only, PhantomJS 1 only
  12245. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12246. push.apply( ret, elems.get() );
  12247. }
  12248. return this.pushStack( ret );
  12249. };
  12250. } );
  12251. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12252. var getStyles = function( elem ) {
  12253. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12254. // IE throws on elements created in popups
  12255. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12256. var view = elem.ownerDocument.defaultView;
  12257. if ( !view || !view.opener ) {
  12258. view = window;
  12259. }
  12260. return view.getComputedStyle( elem );
  12261. };
  12262. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12263. ( function() {
  12264. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12265. // so they're executed at the same time to save the second computation.
  12266. function computeStyleTests() {
  12267. // This is a singleton, we need to execute it only once
  12268. if ( !div ) {
  12269. return;
  12270. }
  12271. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12272. "margin-top:1px;padding:0;border:0";
  12273. div.style.cssText =
  12274. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12275. "margin:auto;border:1px;padding:1px;" +
  12276. "width:60%;top:1%";
  12277. documentElement.appendChild( container ).appendChild( div );
  12278. var divStyle = window.getComputedStyle( div );
  12279. pixelPositionVal = divStyle.top !== "1%";
  12280. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12281. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12282. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12283. // Some styles come back with percentage values, even though they shouldn't
  12284. div.style.right = "60%";
  12285. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12286. // Support: IE 9 - 11 only
  12287. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12288. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12289. // Support: IE 9 only
  12290. // Detect overflow:scroll screwiness (gh-3699)
  12291. // Support: Chrome <=64
  12292. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12293. div.style.position = "absolute";
  12294. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12295. documentElement.removeChild( container );
  12296. // Nullify the div so it wouldn't be stored in the memory and
  12297. // it will also be a sign that checks already performed
  12298. div = null;
  12299. }
  12300. function roundPixelMeasures( measure ) {
  12301. return Math.round( parseFloat( measure ) );
  12302. }
  12303. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12304. reliableMarginLeftVal,
  12305. container = document.createElement( "div" ),
  12306. div = document.createElement( "div" );
  12307. // Finish early in limited (non-browser) environments
  12308. if ( !div.style ) {
  12309. return;
  12310. }
  12311. // Support: IE <=9 - 11 only
  12312. // Style of cloned element affects source element cloned (#8908)
  12313. div.style.backgroundClip = "content-box";
  12314. div.cloneNode( true ).style.backgroundClip = "";
  12315. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12316. jQuery.extend( support, {
  12317. boxSizingReliable: function() {
  12318. computeStyleTests();
  12319. return boxSizingReliableVal;
  12320. },
  12321. pixelBoxStyles: function() {
  12322. computeStyleTests();
  12323. return pixelBoxStylesVal;
  12324. },
  12325. pixelPosition: function() {
  12326. computeStyleTests();
  12327. return pixelPositionVal;
  12328. },
  12329. reliableMarginLeft: function() {
  12330. computeStyleTests();
  12331. return reliableMarginLeftVal;
  12332. },
  12333. scrollboxSize: function() {
  12334. computeStyleTests();
  12335. return scrollboxSizeVal;
  12336. }
  12337. } );
  12338. } )();
  12339. function curCSS( elem, name, computed ) {
  12340. var width, minWidth, maxWidth, ret,
  12341. // Support: Firefox 51+
  12342. // Retrieving style before computed somehow
  12343. // fixes an issue with getting wrong values
  12344. // on detached elements
  12345. style = elem.style;
  12346. computed = computed || getStyles( elem );
  12347. // getPropertyValue is needed for:
  12348. // .css('filter') (IE 9 only, #12537)
  12349. // .css('--customProperty) (#3144)
  12350. if ( computed ) {
  12351. ret = computed.getPropertyValue( name ) || computed[ name ];
  12352. if ( ret === "" && !isAttached( elem ) ) {
  12353. ret = jQuery.style( elem, name );
  12354. }
  12355. // A tribute to the "awesome hack by Dean Edwards"
  12356. // Android Browser returns percentage for some values,
  12357. // but width seems to be reliably pixels.
  12358. // This is against the CSSOM draft spec:
  12359. // https://drafts.csswg.org/cssom/#resolved-values
  12360. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12361. // Remember the original values
  12362. width = style.width;
  12363. minWidth = style.minWidth;
  12364. maxWidth = style.maxWidth;
  12365. // Put in the new values to get a computed value out
  12366. style.minWidth = style.maxWidth = style.width = ret;
  12367. ret = computed.width;
  12368. // Revert the changed values
  12369. style.width = width;
  12370. style.minWidth = minWidth;
  12371. style.maxWidth = maxWidth;
  12372. }
  12373. }
  12374. return ret !== undefined ?
  12375. // Support: IE <=9 - 11 only
  12376. // IE returns zIndex value as an integer.
  12377. ret + "" :
  12378. ret;
  12379. }
  12380. function addGetHookIf( conditionFn, hookFn ) {
  12381. // Define the hook, we'll check on the first run if it's really needed.
  12382. return {
  12383. get: function() {
  12384. if ( conditionFn() ) {
  12385. // Hook not needed (or it's not possible to use it due
  12386. // to missing dependency), remove it.
  12387. delete this.get;
  12388. return;
  12389. }
  12390. // Hook needed; redefine it so that the support test is not executed again.
  12391. return ( this.get = hookFn ).apply( this, arguments );
  12392. }
  12393. };
  12394. }
  12395. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12396. emptyStyle = document.createElement( "div" ).style,
  12397. vendorProps = {};
  12398. // Return a vendor-prefixed property or undefined
  12399. function vendorPropName( name ) {
  12400. // Check for vendor prefixed names
  12401. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12402. i = cssPrefixes.length;
  12403. while ( i-- ) {
  12404. name = cssPrefixes[ i ] + capName;
  12405. if ( name in emptyStyle ) {
  12406. return name;
  12407. }
  12408. }
  12409. }
  12410. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12411. function finalPropName( name ) {
  12412. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12413. if ( final ) {
  12414. return final;
  12415. }
  12416. if ( name in emptyStyle ) {
  12417. return name;
  12418. }
  12419. return vendorProps[ name ] = vendorPropName( name ) || name;
  12420. }
  12421. var
  12422. // Swappable if display is none or starts with table
  12423. // except "table", "table-cell", or "table-caption"
  12424. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12425. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12426. rcustomProp = /^--/,
  12427. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12428. cssNormalTransform = {
  12429. letterSpacing: "0",
  12430. fontWeight: "400"
  12431. };
  12432. function setPositiveNumber( elem, value, subtract ) {
  12433. // Any relative (+/-) values have already been
  12434. // normalized at this point
  12435. var matches = rcssNum.exec( value );
  12436. return matches ?
  12437. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12438. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12439. value;
  12440. }
  12441. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12442. var i = dimension === "width" ? 1 : 0,
  12443. extra = 0,
  12444. delta = 0;
  12445. // Adjustment may not be necessary
  12446. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12447. return 0;
  12448. }
  12449. for ( ; i < 4; i += 2 ) {
  12450. // Both box models exclude margin
  12451. if ( box === "margin" ) {
  12452. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12453. }
  12454. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12455. if ( !isBorderBox ) {
  12456. // Add padding
  12457. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12458. // For "border" or "margin", add border
  12459. if ( box !== "padding" ) {
  12460. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12461. // But still keep track of it otherwise
  12462. } else {
  12463. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12464. }
  12465. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12466. // "padding" or "margin"
  12467. } else {
  12468. // For "content", subtract padding
  12469. if ( box === "content" ) {
  12470. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12471. }
  12472. // For "content" or "padding", subtract border
  12473. if ( box !== "margin" ) {
  12474. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12475. }
  12476. }
  12477. }
  12478. // Account for positive content-box scroll gutter when requested by providing computedVal
  12479. if ( !isBorderBox && computedVal >= 0 ) {
  12480. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12481. // Assuming integer scroll gutter, subtract the rest and round down
  12482. delta += Math.max( 0, Math.ceil(
  12483. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12484. computedVal -
  12485. delta -
  12486. extra -
  12487. 0.5
  12488. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12489. // Use an explicit zero to avoid NaN (gh-3964)
  12490. ) ) || 0;
  12491. }
  12492. return delta;
  12493. }
  12494. function getWidthOrHeight( elem, dimension, extra ) {
  12495. // Start with computed style
  12496. var styles = getStyles( elem ),
  12497. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12498. // Fake content-box until we know it's needed to know the true value.
  12499. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12500. isBorderBox = boxSizingNeeded &&
  12501. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12502. valueIsBorderBox = isBorderBox,
  12503. val = curCSS( elem, dimension, styles ),
  12504. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12505. // Support: Firefox <=54
  12506. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12507. if ( rnumnonpx.test( val ) ) {
  12508. if ( !extra ) {
  12509. return val;
  12510. }
  12511. val = "auto";
  12512. }
  12513. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12514. // This happens for inline elements with no explicit setting (gh-3571)
  12515. // Support: Android <=4.1 - 4.3 only
  12516. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12517. // Support: IE 9-11 only
  12518. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12519. // We use getClientRects() to check for hidden/disconnected.
  12520. // In those cases, the computed value can be trusted to be border-box
  12521. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12522. val === "auto" ||
  12523. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12524. elem.getClientRects().length ) {
  12525. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12526. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12527. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12528. // retrieved value as a content box dimension.
  12529. valueIsBorderBox = offsetProp in elem;
  12530. if ( valueIsBorderBox ) {
  12531. val = elem[ offsetProp ];
  12532. }
  12533. }
  12534. // Normalize "" and auto
  12535. val = parseFloat( val ) || 0;
  12536. // Adjust for the element's box model
  12537. return ( val +
  12538. boxModelAdjustment(
  12539. elem,
  12540. dimension,
  12541. extra || ( isBorderBox ? "border" : "content" ),
  12542. valueIsBorderBox,
  12543. styles,
  12544. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12545. val
  12546. )
  12547. ) + "px";
  12548. }
  12549. jQuery.extend( {
  12550. // Add in style property hooks for overriding the default
  12551. // behavior of getting and setting a style property
  12552. cssHooks: {
  12553. opacity: {
  12554. get: function( elem, computed ) {
  12555. if ( computed ) {
  12556. // We should always get a number back from opacity
  12557. var ret = curCSS( elem, "opacity" );
  12558. return ret === "" ? "1" : ret;
  12559. }
  12560. }
  12561. }
  12562. },
  12563. // Don't automatically add "px" to these possibly-unitless properties
  12564. cssNumber: {
  12565. "animationIterationCount": true,
  12566. "columnCount": true,
  12567. "fillOpacity": true,
  12568. "flexGrow": true,
  12569. "flexShrink": true,
  12570. "fontWeight": true,
  12571. "gridArea": true,
  12572. "gridColumn": true,
  12573. "gridColumnEnd": true,
  12574. "gridColumnStart": true,
  12575. "gridRow": true,
  12576. "gridRowEnd": true,
  12577. "gridRowStart": true,
  12578. "lineHeight": true,
  12579. "opacity": true,
  12580. "order": true,
  12581. "orphans": true,
  12582. "widows": true,
  12583. "zIndex": true,
  12584. "zoom": true
  12585. },
  12586. // Add in properties whose names you wish to fix before
  12587. // setting or getting the value
  12588. cssProps: {},
  12589. // Get and set the style property on a DOM Node
  12590. style: function( elem, name, value, extra ) {
  12591. // Don't set styles on text and comment nodes
  12592. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12593. return;
  12594. }
  12595. // Make sure that we're working with the right name
  12596. var ret, type, hooks,
  12597. origName = camelCase( name ),
  12598. isCustomProp = rcustomProp.test( name ),
  12599. style = elem.style;
  12600. // Make sure that we're working with the right name. We don't
  12601. // want to query the value if it is a CSS custom property
  12602. // since they are user-defined.
  12603. if ( !isCustomProp ) {
  12604. name = finalPropName( origName );
  12605. }
  12606. // Gets hook for the prefixed version, then unprefixed version
  12607. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12608. // Check if we're setting a value
  12609. if ( value !== undefined ) {
  12610. type = typeof value;
  12611. // Convert "+=" or "-=" to relative numbers (#7345)
  12612. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12613. value = adjustCSS( elem, name, ret );
  12614. // Fixes bug #9237
  12615. type = "number";
  12616. }
  12617. // Make sure that null and NaN values aren't set (#7116)
  12618. if ( value == null || value !== value ) {
  12619. return;
  12620. }
  12621. // If a number was passed in, add the unit (except for certain CSS properties)
  12622. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12623. // "px" to a few hardcoded values.
  12624. if ( type === "number" && !isCustomProp ) {
  12625. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12626. }
  12627. // background-* props affect original clone's values
  12628. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12629. style[ name ] = "inherit";
  12630. }
  12631. // If a hook was provided, use that value, otherwise just set the specified value
  12632. if ( !hooks || !( "set" in hooks ) ||
  12633. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12634. if ( isCustomProp ) {
  12635. style.setProperty( name, value );
  12636. } else {
  12637. style[ name ] = value;
  12638. }
  12639. }
  12640. } else {
  12641. // If a hook was provided get the non-computed value from there
  12642. if ( hooks && "get" in hooks &&
  12643. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12644. return ret;
  12645. }
  12646. // Otherwise just get the value from the style object
  12647. return style[ name ];
  12648. }
  12649. },
  12650. css: function( elem, name, extra, styles ) {
  12651. var val, num, hooks,
  12652. origName = camelCase( name ),
  12653. isCustomProp = rcustomProp.test( name );
  12654. // Make sure that we're working with the right name. We don't
  12655. // want to modify the value if it is a CSS custom property
  12656. // since they are user-defined.
  12657. if ( !isCustomProp ) {
  12658. name = finalPropName( origName );
  12659. }
  12660. // Try prefixed name followed by the unprefixed name
  12661. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12662. // If a hook was provided get the computed value from there
  12663. if ( hooks && "get" in hooks ) {
  12664. val = hooks.get( elem, true, extra );
  12665. }
  12666. // Otherwise, if a way to get the computed value exists, use that
  12667. if ( val === undefined ) {
  12668. val = curCSS( elem, name, styles );
  12669. }
  12670. // Convert "normal" to computed value
  12671. if ( val === "normal" && name in cssNormalTransform ) {
  12672. val = cssNormalTransform[ name ];
  12673. }
  12674. // Make numeric if forced or a qualifier was provided and val looks numeric
  12675. if ( extra === "" || extra ) {
  12676. num = parseFloat( val );
  12677. return extra === true || isFinite( num ) ? num || 0 : val;
  12678. }
  12679. return val;
  12680. }
  12681. } );
  12682. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12683. jQuery.cssHooks[ dimension ] = {
  12684. get: function( elem, computed, extra ) {
  12685. if ( computed ) {
  12686. // Certain elements can have dimension info if we invisibly show them
  12687. // but it must have a current display style that would benefit
  12688. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12689. // Support: Safari 8+
  12690. // Table columns in Safari have non-zero offsetWidth & zero
  12691. // getBoundingClientRect().width unless display is changed.
  12692. // Support: IE <=11 only
  12693. // Running getBoundingClientRect on a disconnected node
  12694. // in IE throws an error.
  12695. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12696. swap( elem, cssShow, function() {
  12697. return getWidthOrHeight( elem, dimension, extra );
  12698. } ) :
  12699. getWidthOrHeight( elem, dimension, extra );
  12700. }
  12701. },
  12702. set: function( elem, value, extra ) {
  12703. var matches,
  12704. styles = getStyles( elem ),
  12705. // Only read styles.position if the test has a chance to fail
  12706. // to avoid forcing a reflow.
  12707. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12708. styles.position === "absolute",
  12709. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12710. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12711. isBorderBox = boxSizingNeeded &&
  12712. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12713. subtract = extra ?
  12714. boxModelAdjustment(
  12715. elem,
  12716. dimension,
  12717. extra,
  12718. isBorderBox,
  12719. styles
  12720. ) :
  12721. 0;
  12722. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12723. // faking a content-box to get border and padding (gh-3699)
  12724. if ( isBorderBox && scrollboxSizeBuggy ) {
  12725. subtract -= Math.ceil(
  12726. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12727. parseFloat( styles[ dimension ] ) -
  12728. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12729. 0.5
  12730. );
  12731. }
  12732. // Convert to pixels if value adjustment is needed
  12733. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12734. ( matches[ 3 ] || "px" ) !== "px" ) {
  12735. elem.style[ dimension ] = value;
  12736. value = jQuery.css( elem, dimension );
  12737. }
  12738. return setPositiveNumber( elem, value, subtract );
  12739. }
  12740. };
  12741. } );
  12742. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12743. function( elem, computed ) {
  12744. if ( computed ) {
  12745. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12746. elem.getBoundingClientRect().left -
  12747. swap( elem, { marginLeft: 0 }, function() {
  12748. return elem.getBoundingClientRect().left;
  12749. } )
  12750. ) + "px";
  12751. }
  12752. }
  12753. );
  12754. // These hooks are used by animate to expand properties
  12755. jQuery.each( {
  12756. margin: "",
  12757. padding: "",
  12758. border: "Width"
  12759. }, function( prefix, suffix ) {
  12760. jQuery.cssHooks[ prefix + suffix ] = {
  12761. expand: function( value ) {
  12762. var i = 0,
  12763. expanded = {},
  12764. // Assumes a single number if not a string
  12765. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12766. for ( ; i < 4; i++ ) {
  12767. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12768. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12769. }
  12770. return expanded;
  12771. }
  12772. };
  12773. if ( prefix !== "margin" ) {
  12774. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12775. }
  12776. } );
  12777. jQuery.fn.extend( {
  12778. css: function( name, value ) {
  12779. return access( this, function( elem, name, value ) {
  12780. var styles, len,
  12781. map = {},
  12782. i = 0;
  12783. if ( Array.isArray( name ) ) {
  12784. styles = getStyles( elem );
  12785. len = name.length;
  12786. for ( ; i < len; i++ ) {
  12787. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12788. }
  12789. return map;
  12790. }
  12791. return value !== undefined ?
  12792. jQuery.style( elem, name, value ) :
  12793. jQuery.css( elem, name );
  12794. }, name, value, arguments.length > 1 );
  12795. }
  12796. } );
  12797. function Tween( elem, options, prop, end, easing ) {
  12798. return new Tween.prototype.init( elem, options, prop, end, easing );
  12799. }
  12800. jQuery.Tween = Tween;
  12801. Tween.prototype = {
  12802. constructor: Tween,
  12803. init: function( elem, options, prop, end, easing, unit ) {
  12804. this.elem = elem;
  12805. this.prop = prop;
  12806. this.easing = easing || jQuery.easing._default;
  12807. this.options = options;
  12808. this.start = this.now = this.cur();
  12809. this.end = end;
  12810. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12811. },
  12812. cur: function() {
  12813. var hooks = Tween.propHooks[ this.prop ];
  12814. return hooks && hooks.get ?
  12815. hooks.get( this ) :
  12816. Tween.propHooks._default.get( this );
  12817. },
  12818. run: function( percent ) {
  12819. var eased,
  12820. hooks = Tween.propHooks[ this.prop ];
  12821. if ( this.options.duration ) {
  12822. this.pos = eased = jQuery.easing[ this.easing ](
  12823. percent, this.options.duration * percent, 0, 1, this.options.duration
  12824. );
  12825. } else {
  12826. this.pos = eased = percent;
  12827. }
  12828. this.now = ( this.end - this.start ) * eased + this.start;
  12829. if ( this.options.step ) {
  12830. this.options.step.call( this.elem, this.now, this );
  12831. }
  12832. if ( hooks && hooks.set ) {
  12833. hooks.set( this );
  12834. } else {
  12835. Tween.propHooks._default.set( this );
  12836. }
  12837. return this;
  12838. }
  12839. };
  12840. Tween.prototype.init.prototype = Tween.prototype;
  12841. Tween.propHooks = {
  12842. _default: {
  12843. get: function( tween ) {
  12844. var result;
  12845. // Use a property on the element directly when it is not a DOM element,
  12846. // or when there is no matching style property that exists.
  12847. if ( tween.elem.nodeType !== 1 ||
  12848. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12849. return tween.elem[ tween.prop ];
  12850. }
  12851. // Passing an empty string as a 3rd parameter to .css will automatically
  12852. // attempt a parseFloat and fallback to a string if the parse fails.
  12853. // Simple values such as "10px" are parsed to Float;
  12854. // complex values such as "rotate(1rad)" are returned as-is.
  12855. result = jQuery.css( tween.elem, tween.prop, "" );
  12856. // Empty strings, null, undefined and "auto" are converted to 0.
  12857. return !result || result === "auto" ? 0 : result;
  12858. },
  12859. set: function( tween ) {
  12860. // Use step hook for back compat.
  12861. // Use cssHook if its there.
  12862. // Use .style if available and use plain properties where available.
  12863. if ( jQuery.fx.step[ tween.prop ] ) {
  12864. jQuery.fx.step[ tween.prop ]( tween );
  12865. } else if ( tween.elem.nodeType === 1 && (
  12866. jQuery.cssHooks[ tween.prop ] ||
  12867. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12868. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12869. } else {
  12870. tween.elem[ tween.prop ] = tween.now;
  12871. }
  12872. }
  12873. }
  12874. };
  12875. // Support: IE <=9 only
  12876. // Panic based approach to setting things on disconnected nodes
  12877. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12878. set: function( tween ) {
  12879. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12880. tween.elem[ tween.prop ] = tween.now;
  12881. }
  12882. }
  12883. };
  12884. jQuery.easing = {
  12885. linear: function( p ) {
  12886. return p;
  12887. },
  12888. swing: function( p ) {
  12889. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12890. },
  12891. _default: "swing"
  12892. };
  12893. jQuery.fx = Tween.prototype.init;
  12894. // Back compat <1.8 extension point
  12895. jQuery.fx.step = {};
  12896. var
  12897. fxNow, inProgress,
  12898. rfxtypes = /^(?:toggle|show|hide)$/,
  12899. rrun = /queueHooks$/;
  12900. function schedule() {
  12901. if ( inProgress ) {
  12902. if ( document.hidden === false && window.requestAnimationFrame ) {
  12903. window.requestAnimationFrame( schedule );
  12904. } else {
  12905. window.setTimeout( schedule, jQuery.fx.interval );
  12906. }
  12907. jQuery.fx.tick();
  12908. }
  12909. }
  12910. // Animations created synchronously will run synchronously
  12911. function createFxNow() {
  12912. window.setTimeout( function() {
  12913. fxNow = undefined;
  12914. } );
  12915. return ( fxNow = Date.now() );
  12916. }
  12917. // Generate parameters to create a standard animation
  12918. function genFx( type, includeWidth ) {
  12919. var which,
  12920. i = 0,
  12921. attrs = { height: type };
  12922. // If we include width, step value is 1 to do all cssExpand values,
  12923. // otherwise step value is 2 to skip over Left and Right
  12924. includeWidth = includeWidth ? 1 : 0;
  12925. for ( ; i < 4; i += 2 - includeWidth ) {
  12926. which = cssExpand[ i ];
  12927. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12928. }
  12929. if ( includeWidth ) {
  12930. attrs.opacity = attrs.width = type;
  12931. }
  12932. return attrs;
  12933. }
  12934. function createTween( value, prop, animation ) {
  12935. var tween,
  12936. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12937. index = 0,
  12938. length = collection.length;
  12939. for ( ; index < length; index++ ) {
  12940. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12941. // We're done with this property
  12942. return tween;
  12943. }
  12944. }
  12945. }
  12946. function defaultPrefilter( elem, props, opts ) {
  12947. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12948. isBox = "width" in props || "height" in props,
  12949. anim = this,
  12950. orig = {},
  12951. style = elem.style,
  12952. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12953. dataShow = dataPriv.get( elem, "fxshow" );
  12954. // Queue-skipping animations hijack the fx hooks
  12955. if ( !opts.queue ) {
  12956. hooks = jQuery._queueHooks( elem, "fx" );
  12957. if ( hooks.unqueued == null ) {
  12958. hooks.unqueued = 0;
  12959. oldfire = hooks.empty.fire;
  12960. hooks.empty.fire = function() {
  12961. if ( !hooks.unqueued ) {
  12962. oldfire();
  12963. }
  12964. };
  12965. }
  12966. hooks.unqueued++;
  12967. anim.always( function() {
  12968. // Ensure the complete handler is called before this completes
  12969. anim.always( function() {
  12970. hooks.unqueued--;
  12971. if ( !jQuery.queue( elem, "fx" ).length ) {
  12972. hooks.empty.fire();
  12973. }
  12974. } );
  12975. } );
  12976. }
  12977. // Detect show/hide animations
  12978. for ( prop in props ) {
  12979. value = props[ prop ];
  12980. if ( rfxtypes.test( value ) ) {
  12981. delete props[ prop ];
  12982. toggle = toggle || value === "toggle";
  12983. if ( value === ( hidden ? "hide" : "show" ) ) {
  12984. // Pretend to be hidden if this is a "show" and
  12985. // there is still data from a stopped show/hide
  12986. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12987. hidden = true;
  12988. // Ignore all other no-op show/hide data
  12989. } else {
  12990. continue;
  12991. }
  12992. }
  12993. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12994. }
  12995. }
  12996. // Bail out if this is a no-op like .hide().hide()
  12997. propTween = !jQuery.isEmptyObject( props );
  12998. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12999. return;
  13000. }
  13001. // Restrict "overflow" and "display" styles during box animations
  13002. if ( isBox && elem.nodeType === 1 ) {
  13003. // Support: IE <=9 - 11, Edge 12 - 15
  13004. // Record all 3 overflow attributes because IE does not infer the shorthand
  13005. // from identically-valued overflowX and overflowY and Edge just mirrors
  13006. // the overflowX value there.
  13007. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13008. // Identify a display type, preferring old show/hide data over the CSS cascade
  13009. restoreDisplay = dataShow && dataShow.display;
  13010. if ( restoreDisplay == null ) {
  13011. restoreDisplay = dataPriv.get( elem, "display" );
  13012. }
  13013. display = jQuery.css( elem, "display" );
  13014. if ( display === "none" ) {
  13015. if ( restoreDisplay ) {
  13016. display = restoreDisplay;
  13017. } else {
  13018. // Get nonempty value(s) by temporarily forcing visibility
  13019. showHide( [ elem ], true );
  13020. restoreDisplay = elem.style.display || restoreDisplay;
  13021. display = jQuery.css( elem, "display" );
  13022. showHide( [ elem ] );
  13023. }
  13024. }
  13025. // Animate inline elements as inline-block
  13026. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13027. if ( jQuery.css( elem, "float" ) === "none" ) {
  13028. // Restore the original display value at the end of pure show/hide animations
  13029. if ( !propTween ) {
  13030. anim.done( function() {
  13031. style.display = restoreDisplay;
  13032. } );
  13033. if ( restoreDisplay == null ) {
  13034. display = style.display;
  13035. restoreDisplay = display === "none" ? "" : display;
  13036. }
  13037. }
  13038. style.display = "inline-block";
  13039. }
  13040. }
  13041. }
  13042. if ( opts.overflow ) {
  13043. style.overflow = "hidden";
  13044. anim.always( function() {
  13045. style.overflow = opts.overflow[ 0 ];
  13046. style.overflowX = opts.overflow[ 1 ];
  13047. style.overflowY = opts.overflow[ 2 ];
  13048. } );
  13049. }
  13050. // Implement show/hide animations
  13051. propTween = false;
  13052. for ( prop in orig ) {
  13053. // General show/hide setup for this element animation
  13054. if ( !propTween ) {
  13055. if ( dataShow ) {
  13056. if ( "hidden" in dataShow ) {
  13057. hidden = dataShow.hidden;
  13058. }
  13059. } else {
  13060. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13061. }
  13062. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13063. if ( toggle ) {
  13064. dataShow.hidden = !hidden;
  13065. }
  13066. // Show elements before animating them
  13067. if ( hidden ) {
  13068. showHide( [ elem ], true );
  13069. }
  13070. /* eslint-disable no-loop-func */
  13071. anim.done( function() {
  13072. /* eslint-enable no-loop-func */
  13073. // The final step of a "hide" animation is actually hiding the element
  13074. if ( !hidden ) {
  13075. showHide( [ elem ] );
  13076. }
  13077. dataPriv.remove( elem, "fxshow" );
  13078. for ( prop in orig ) {
  13079. jQuery.style( elem, prop, orig[ prop ] );
  13080. }
  13081. } );
  13082. }
  13083. // Per-property setup
  13084. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13085. if ( !( prop in dataShow ) ) {
  13086. dataShow[ prop ] = propTween.start;
  13087. if ( hidden ) {
  13088. propTween.end = propTween.start;
  13089. propTween.start = 0;
  13090. }
  13091. }
  13092. }
  13093. }
  13094. function propFilter( props, specialEasing ) {
  13095. var index, name, easing, value, hooks;
  13096. // camelCase, specialEasing and expand cssHook pass
  13097. for ( index in props ) {
  13098. name = camelCase( index );
  13099. easing = specialEasing[ name ];
  13100. value = props[ index ];
  13101. if ( Array.isArray( value ) ) {
  13102. easing = value[ 1 ];
  13103. value = props[ index ] = value[ 0 ];
  13104. }
  13105. if ( index !== name ) {
  13106. props[ name ] = value;
  13107. delete props[ index ];
  13108. }
  13109. hooks = jQuery.cssHooks[ name ];
  13110. if ( hooks && "expand" in hooks ) {
  13111. value = hooks.expand( value );
  13112. delete props[ name ];
  13113. // Not quite $.extend, this won't overwrite existing keys.
  13114. // Reusing 'index' because we have the correct "name"
  13115. for ( index in value ) {
  13116. if ( !( index in props ) ) {
  13117. props[ index ] = value[ index ];
  13118. specialEasing[ index ] = easing;
  13119. }
  13120. }
  13121. } else {
  13122. specialEasing[ name ] = easing;
  13123. }
  13124. }
  13125. }
  13126. function Animation( elem, properties, options ) {
  13127. var result,
  13128. stopped,
  13129. index = 0,
  13130. length = Animation.prefilters.length,
  13131. deferred = jQuery.Deferred().always( function() {
  13132. // Don't match elem in the :animated selector
  13133. delete tick.elem;
  13134. } ),
  13135. tick = function() {
  13136. if ( stopped ) {
  13137. return false;
  13138. }
  13139. var currentTime = fxNow || createFxNow(),
  13140. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13141. // Support: Android 2.3 only
  13142. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13143. temp = remaining / animation.duration || 0,
  13144. percent = 1 - temp,
  13145. index = 0,
  13146. length = animation.tweens.length;
  13147. for ( ; index < length; index++ ) {
  13148. animation.tweens[ index ].run( percent );
  13149. }
  13150. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13151. // If there's more to do, yield
  13152. if ( percent < 1 && length ) {
  13153. return remaining;
  13154. }
  13155. // If this was an empty animation, synthesize a final progress notification
  13156. if ( !length ) {
  13157. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13158. }
  13159. // Resolve the animation and report its conclusion
  13160. deferred.resolveWith( elem, [ animation ] );
  13161. return false;
  13162. },
  13163. animation = deferred.promise( {
  13164. elem: elem,
  13165. props: jQuery.extend( {}, properties ),
  13166. opts: jQuery.extend( true, {
  13167. specialEasing: {},
  13168. easing: jQuery.easing._default
  13169. }, options ),
  13170. originalProperties: properties,
  13171. originalOptions: options,
  13172. startTime: fxNow || createFxNow(),
  13173. duration: options.duration,
  13174. tweens: [],
  13175. createTween: function( prop, end ) {
  13176. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13177. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13178. animation.tweens.push( tween );
  13179. return tween;
  13180. },
  13181. stop: function( gotoEnd ) {
  13182. var index = 0,
  13183. // If we are going to the end, we want to run all the tweens
  13184. // otherwise we skip this part
  13185. length = gotoEnd ? animation.tweens.length : 0;
  13186. if ( stopped ) {
  13187. return this;
  13188. }
  13189. stopped = true;
  13190. for ( ; index < length; index++ ) {
  13191. animation.tweens[ index ].run( 1 );
  13192. }
  13193. // Resolve when we played the last frame; otherwise, reject
  13194. if ( gotoEnd ) {
  13195. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13196. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13197. } else {
  13198. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13199. }
  13200. return this;
  13201. }
  13202. } ),
  13203. props = animation.props;
  13204. propFilter( props, animation.opts.specialEasing );
  13205. for ( ; index < length; index++ ) {
  13206. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13207. if ( result ) {
  13208. if ( isFunction( result.stop ) ) {
  13209. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13210. result.stop.bind( result );
  13211. }
  13212. return result;
  13213. }
  13214. }
  13215. jQuery.map( props, createTween, animation );
  13216. if ( isFunction( animation.opts.start ) ) {
  13217. animation.opts.start.call( elem, animation );
  13218. }
  13219. // Attach callbacks from options
  13220. animation
  13221. .progress( animation.opts.progress )
  13222. .done( animation.opts.done, animation.opts.complete )
  13223. .fail( animation.opts.fail )
  13224. .always( animation.opts.always );
  13225. jQuery.fx.timer(
  13226. jQuery.extend( tick, {
  13227. elem: elem,
  13228. anim: animation,
  13229. queue: animation.opts.queue
  13230. } )
  13231. );
  13232. return animation;
  13233. }
  13234. jQuery.Animation = jQuery.extend( Animation, {
  13235. tweeners: {
  13236. "*": [ function( prop, value ) {
  13237. var tween = this.createTween( prop, value );
  13238. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13239. return tween;
  13240. } ]
  13241. },
  13242. tweener: function( props, callback ) {
  13243. if ( isFunction( props ) ) {
  13244. callback = props;
  13245. props = [ "*" ];
  13246. } else {
  13247. props = props.match( rnothtmlwhite );
  13248. }
  13249. var prop,
  13250. index = 0,
  13251. length = props.length;
  13252. for ( ; index < length; index++ ) {
  13253. prop = props[ index ];
  13254. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13255. Animation.tweeners[ prop ].unshift( callback );
  13256. }
  13257. },
  13258. prefilters: [ defaultPrefilter ],
  13259. prefilter: function( callback, prepend ) {
  13260. if ( prepend ) {
  13261. Animation.prefilters.unshift( callback );
  13262. } else {
  13263. Animation.prefilters.push( callback );
  13264. }
  13265. }
  13266. } );
  13267. jQuery.speed = function( speed, easing, fn ) {
  13268. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13269. complete: fn || !fn && easing ||
  13270. isFunction( speed ) && speed,
  13271. duration: speed,
  13272. easing: fn && easing || easing && !isFunction( easing ) && easing
  13273. };
  13274. // Go to the end state if fx are off
  13275. if ( jQuery.fx.off ) {
  13276. opt.duration = 0;
  13277. } else {
  13278. if ( typeof opt.duration !== "number" ) {
  13279. if ( opt.duration in jQuery.fx.speeds ) {
  13280. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13281. } else {
  13282. opt.duration = jQuery.fx.speeds._default;
  13283. }
  13284. }
  13285. }
  13286. // Normalize opt.queue - true/undefined/null -> "fx"
  13287. if ( opt.queue == null || opt.queue === true ) {
  13288. opt.queue = "fx";
  13289. }
  13290. // Queueing
  13291. opt.old = opt.complete;
  13292. opt.complete = function() {
  13293. if ( isFunction( opt.old ) ) {
  13294. opt.old.call( this );
  13295. }
  13296. if ( opt.queue ) {
  13297. jQuery.dequeue( this, opt.queue );
  13298. }
  13299. };
  13300. return opt;
  13301. };
  13302. jQuery.fn.extend( {
  13303. fadeTo: function( speed, to, easing, callback ) {
  13304. // Show any hidden elements after setting opacity to 0
  13305. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13306. // Animate to the value specified
  13307. .end().animate( { opacity: to }, speed, easing, callback );
  13308. },
  13309. animate: function( prop, speed, easing, callback ) {
  13310. var empty = jQuery.isEmptyObject( prop ),
  13311. optall = jQuery.speed( speed, easing, callback ),
  13312. doAnimation = function() {
  13313. // Operate on a copy of prop so per-property easing won't be lost
  13314. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13315. // Empty animations, or finishing resolves immediately
  13316. if ( empty || dataPriv.get( this, "finish" ) ) {
  13317. anim.stop( true );
  13318. }
  13319. };
  13320. doAnimation.finish = doAnimation;
  13321. return empty || optall.queue === false ?
  13322. this.each( doAnimation ) :
  13323. this.queue( optall.queue, doAnimation );
  13324. },
  13325. stop: function( type, clearQueue, gotoEnd ) {
  13326. var stopQueue = function( hooks ) {
  13327. var stop = hooks.stop;
  13328. delete hooks.stop;
  13329. stop( gotoEnd );
  13330. };
  13331. if ( typeof type !== "string" ) {
  13332. gotoEnd = clearQueue;
  13333. clearQueue = type;
  13334. type = undefined;
  13335. }
  13336. if ( clearQueue && type !== false ) {
  13337. this.queue( type || "fx", [] );
  13338. }
  13339. return this.each( function() {
  13340. var dequeue = true,
  13341. index = type != null && type + "queueHooks",
  13342. timers = jQuery.timers,
  13343. data = dataPriv.get( this );
  13344. if ( index ) {
  13345. if ( data[ index ] && data[ index ].stop ) {
  13346. stopQueue( data[ index ] );
  13347. }
  13348. } else {
  13349. for ( index in data ) {
  13350. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13351. stopQueue( data[ index ] );
  13352. }
  13353. }
  13354. }
  13355. for ( index = timers.length; index--; ) {
  13356. if ( timers[ index ].elem === this &&
  13357. ( type == null || timers[ index ].queue === type ) ) {
  13358. timers[ index ].anim.stop( gotoEnd );
  13359. dequeue = false;
  13360. timers.splice( index, 1 );
  13361. }
  13362. }
  13363. // Start the next in the queue if the last step wasn't forced.
  13364. // Timers currently will call their complete callbacks, which
  13365. // will dequeue but only if they were gotoEnd.
  13366. if ( dequeue || !gotoEnd ) {
  13367. jQuery.dequeue( this, type );
  13368. }
  13369. } );
  13370. },
  13371. finish: function( type ) {
  13372. if ( type !== false ) {
  13373. type = type || "fx";
  13374. }
  13375. return this.each( function() {
  13376. var index,
  13377. data = dataPriv.get( this ),
  13378. queue = data[ type + "queue" ],
  13379. hooks = data[ type + "queueHooks" ],
  13380. timers = jQuery.timers,
  13381. length = queue ? queue.length : 0;
  13382. // Enable finishing flag on private data
  13383. data.finish = true;
  13384. // Empty the queue first
  13385. jQuery.queue( this, type, [] );
  13386. if ( hooks && hooks.stop ) {
  13387. hooks.stop.call( this, true );
  13388. }
  13389. // Look for any active animations, and finish them
  13390. for ( index = timers.length; index--; ) {
  13391. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13392. timers[ index ].anim.stop( true );
  13393. timers.splice( index, 1 );
  13394. }
  13395. }
  13396. // Look for any animations in the old queue and finish them
  13397. for ( index = 0; index < length; index++ ) {
  13398. if ( queue[ index ] && queue[ index ].finish ) {
  13399. queue[ index ].finish.call( this );
  13400. }
  13401. }
  13402. // Turn off finishing flag
  13403. delete data.finish;
  13404. } );
  13405. }
  13406. } );
  13407. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13408. var cssFn = jQuery.fn[ name ];
  13409. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13410. return speed == null || typeof speed === "boolean" ?
  13411. cssFn.apply( this, arguments ) :
  13412. this.animate( genFx( name, true ), speed, easing, callback );
  13413. };
  13414. } );
  13415. // Generate shortcuts for custom animations
  13416. jQuery.each( {
  13417. slideDown: genFx( "show" ),
  13418. slideUp: genFx( "hide" ),
  13419. slideToggle: genFx( "toggle" ),
  13420. fadeIn: { opacity: "show" },
  13421. fadeOut: { opacity: "hide" },
  13422. fadeToggle: { opacity: "toggle" }
  13423. }, function( name, props ) {
  13424. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13425. return this.animate( props, speed, easing, callback );
  13426. };
  13427. } );
  13428. jQuery.timers = [];
  13429. jQuery.fx.tick = function() {
  13430. var timer,
  13431. i = 0,
  13432. timers = jQuery.timers;
  13433. fxNow = Date.now();
  13434. for ( ; i < timers.length; i++ ) {
  13435. timer = timers[ i ];
  13436. // Run the timer and safely remove it when done (allowing for external removal)
  13437. if ( !timer() && timers[ i ] === timer ) {
  13438. timers.splice( i--, 1 );
  13439. }
  13440. }
  13441. if ( !timers.length ) {
  13442. jQuery.fx.stop();
  13443. }
  13444. fxNow = undefined;
  13445. };
  13446. jQuery.fx.timer = function( timer ) {
  13447. jQuery.timers.push( timer );
  13448. jQuery.fx.start();
  13449. };
  13450. jQuery.fx.interval = 13;
  13451. jQuery.fx.start = function() {
  13452. if ( inProgress ) {
  13453. return;
  13454. }
  13455. inProgress = true;
  13456. schedule();
  13457. };
  13458. jQuery.fx.stop = function() {
  13459. inProgress = null;
  13460. };
  13461. jQuery.fx.speeds = {
  13462. slow: 600,
  13463. fast: 200,
  13464. // Default speed
  13465. _default: 400
  13466. };
  13467. // Based off of the plugin by Clint Helfers, with permission.
  13468. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13469. jQuery.fn.delay = function( time, type ) {
  13470. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13471. type = type || "fx";
  13472. return this.queue( type, function( next, hooks ) {
  13473. var timeout = window.setTimeout( next, time );
  13474. hooks.stop = function() {
  13475. window.clearTimeout( timeout );
  13476. };
  13477. } );
  13478. };
  13479. ( function() {
  13480. var input = document.createElement( "input" ),
  13481. select = document.createElement( "select" ),
  13482. opt = select.appendChild( document.createElement( "option" ) );
  13483. input.type = "checkbox";
  13484. // Support: Android <=4.3 only
  13485. // Default value for a checkbox should be "on"
  13486. support.checkOn = input.value !== "";
  13487. // Support: IE <=11 only
  13488. // Must access selectedIndex to make default options select
  13489. support.optSelected = opt.selected;
  13490. // Support: IE <=11 only
  13491. // An input loses its value after becoming a radio
  13492. input = document.createElement( "input" );
  13493. input.value = "t";
  13494. input.type = "radio";
  13495. support.radioValue = input.value === "t";
  13496. } )();
  13497. var boolHook,
  13498. attrHandle = jQuery.expr.attrHandle;
  13499. jQuery.fn.extend( {
  13500. attr: function( name, value ) {
  13501. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13502. },
  13503. removeAttr: function( name ) {
  13504. return this.each( function() {
  13505. jQuery.removeAttr( this, name );
  13506. } );
  13507. }
  13508. } );
  13509. jQuery.extend( {
  13510. attr: function( elem, name, value ) {
  13511. var ret, hooks,
  13512. nType = elem.nodeType;
  13513. // Don't get/set attributes on text, comment and attribute nodes
  13514. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13515. return;
  13516. }
  13517. // Fallback to prop when attributes are not supported
  13518. if ( typeof elem.getAttribute === "undefined" ) {
  13519. return jQuery.prop( elem, name, value );
  13520. }
  13521. // Attribute hooks are determined by the lowercase version
  13522. // Grab necessary hook if one is defined
  13523. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13524. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13525. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13526. }
  13527. if ( value !== undefined ) {
  13528. if ( value === null ) {
  13529. jQuery.removeAttr( elem, name );
  13530. return;
  13531. }
  13532. if ( hooks && "set" in hooks &&
  13533. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13534. return ret;
  13535. }
  13536. elem.setAttribute( name, value + "" );
  13537. return value;
  13538. }
  13539. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13540. return ret;
  13541. }
  13542. ret = jQuery.find.attr( elem, name );
  13543. // Non-existent attributes return null, we normalize to undefined
  13544. return ret == null ? undefined : ret;
  13545. },
  13546. attrHooks: {
  13547. type: {
  13548. set: function( elem, value ) {
  13549. if ( !support.radioValue && value === "radio" &&
  13550. nodeName( elem, "input" ) ) {
  13551. var val = elem.value;
  13552. elem.setAttribute( "type", value );
  13553. if ( val ) {
  13554. elem.value = val;
  13555. }
  13556. return value;
  13557. }
  13558. }
  13559. }
  13560. },
  13561. removeAttr: function( elem, value ) {
  13562. var name,
  13563. i = 0,
  13564. // Attribute names can contain non-HTML whitespace characters
  13565. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13566. attrNames = value && value.match( rnothtmlwhite );
  13567. if ( attrNames && elem.nodeType === 1 ) {
  13568. while ( ( name = attrNames[ i++ ] ) ) {
  13569. elem.removeAttribute( name );
  13570. }
  13571. }
  13572. }
  13573. } );
  13574. // Hooks for boolean attributes
  13575. boolHook = {
  13576. set: function( elem, value, name ) {
  13577. if ( value === false ) {
  13578. // Remove boolean attributes when set to false
  13579. jQuery.removeAttr( elem, name );
  13580. } else {
  13581. elem.setAttribute( name, name );
  13582. }
  13583. return name;
  13584. }
  13585. };
  13586. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13587. var getter = attrHandle[ name ] || jQuery.find.attr;
  13588. attrHandle[ name ] = function( elem, name, isXML ) {
  13589. var ret, handle,
  13590. lowercaseName = name.toLowerCase();
  13591. if ( !isXML ) {
  13592. // Avoid an infinite loop by temporarily removing this function from the getter
  13593. handle = attrHandle[ lowercaseName ];
  13594. attrHandle[ lowercaseName ] = ret;
  13595. ret = getter( elem, name, isXML ) != null ?
  13596. lowercaseName :
  13597. null;
  13598. attrHandle[ lowercaseName ] = handle;
  13599. }
  13600. return ret;
  13601. };
  13602. } );
  13603. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13604. rclickable = /^(?:a|area)$/i;
  13605. jQuery.fn.extend( {
  13606. prop: function( name, value ) {
  13607. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13608. },
  13609. removeProp: function( name ) {
  13610. return this.each( function() {
  13611. delete this[ jQuery.propFix[ name ] || name ];
  13612. } );
  13613. }
  13614. } );
  13615. jQuery.extend( {
  13616. prop: function( elem, name, value ) {
  13617. var ret, hooks,
  13618. nType = elem.nodeType;
  13619. // Don't get/set properties on text, comment and attribute nodes
  13620. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13621. return;
  13622. }
  13623. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13624. // Fix name and attach hooks
  13625. name = jQuery.propFix[ name ] || name;
  13626. hooks = jQuery.propHooks[ name ];
  13627. }
  13628. if ( value !== undefined ) {
  13629. if ( hooks && "set" in hooks &&
  13630. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13631. return ret;
  13632. }
  13633. return ( elem[ name ] = value );
  13634. }
  13635. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13636. return ret;
  13637. }
  13638. return elem[ name ];
  13639. },
  13640. propHooks: {
  13641. tabIndex: {
  13642. get: function( elem ) {
  13643. // Support: IE <=9 - 11 only
  13644. // elem.tabIndex doesn't always return the
  13645. // correct value when it hasn't been explicitly set
  13646. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13647. // Use proper attribute retrieval(#12072)
  13648. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13649. if ( tabindex ) {
  13650. return parseInt( tabindex, 10 );
  13651. }
  13652. if (
  13653. rfocusable.test( elem.nodeName ) ||
  13654. rclickable.test( elem.nodeName ) &&
  13655. elem.href
  13656. ) {
  13657. return 0;
  13658. }
  13659. return -1;
  13660. }
  13661. }
  13662. },
  13663. propFix: {
  13664. "for": "htmlFor",
  13665. "class": "className"
  13666. }
  13667. } );
  13668. // Support: IE <=11 only
  13669. // Accessing the selectedIndex property
  13670. // forces the browser to respect setting selected
  13671. // on the option
  13672. // The getter ensures a default option is selected
  13673. // when in an optgroup
  13674. // eslint rule "no-unused-expressions" is disabled for this code
  13675. // since it considers such accessions noop
  13676. if ( !support.optSelected ) {
  13677. jQuery.propHooks.selected = {
  13678. get: function( elem ) {
  13679. /* eslint no-unused-expressions: "off" */
  13680. var parent = elem.parentNode;
  13681. if ( parent && parent.parentNode ) {
  13682. parent.parentNode.selectedIndex;
  13683. }
  13684. return null;
  13685. },
  13686. set: function( elem ) {
  13687. /* eslint no-unused-expressions: "off" */
  13688. var parent = elem.parentNode;
  13689. if ( parent ) {
  13690. parent.selectedIndex;
  13691. if ( parent.parentNode ) {
  13692. parent.parentNode.selectedIndex;
  13693. }
  13694. }
  13695. }
  13696. };
  13697. }
  13698. jQuery.each( [
  13699. "tabIndex",
  13700. "readOnly",
  13701. "maxLength",
  13702. "cellSpacing",
  13703. "cellPadding",
  13704. "rowSpan",
  13705. "colSpan",
  13706. "useMap",
  13707. "frameBorder",
  13708. "contentEditable"
  13709. ], function() {
  13710. jQuery.propFix[ this.toLowerCase() ] = this;
  13711. } );
  13712. // Strip and collapse whitespace according to HTML spec
  13713. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13714. function stripAndCollapse( value ) {
  13715. var tokens = value.match( rnothtmlwhite ) || [];
  13716. return tokens.join( " " );
  13717. }
  13718. function getClass( elem ) {
  13719. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13720. }
  13721. function classesToArray( value ) {
  13722. if ( Array.isArray( value ) ) {
  13723. return value;
  13724. }
  13725. if ( typeof value === "string" ) {
  13726. return value.match( rnothtmlwhite ) || [];
  13727. }
  13728. return [];
  13729. }
  13730. jQuery.fn.extend( {
  13731. addClass: function( value ) {
  13732. var classes, elem, cur, curValue, clazz, j, finalValue,
  13733. i = 0;
  13734. if ( isFunction( value ) ) {
  13735. return this.each( function( j ) {
  13736. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13737. } );
  13738. }
  13739. classes = classesToArray( value );
  13740. if ( classes.length ) {
  13741. while ( ( elem = this[ i++ ] ) ) {
  13742. curValue = getClass( elem );
  13743. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13744. if ( cur ) {
  13745. j = 0;
  13746. while ( ( clazz = classes[ j++ ] ) ) {
  13747. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13748. cur += clazz + " ";
  13749. }
  13750. }
  13751. // Only assign if different to avoid unneeded rendering.
  13752. finalValue = stripAndCollapse( cur );
  13753. if ( curValue !== finalValue ) {
  13754. elem.setAttribute( "class", finalValue );
  13755. }
  13756. }
  13757. }
  13758. }
  13759. return this;
  13760. },
  13761. removeClass: function( value ) {
  13762. var classes, elem, cur, curValue, clazz, j, finalValue,
  13763. i = 0;
  13764. if ( isFunction( value ) ) {
  13765. return this.each( function( j ) {
  13766. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13767. } );
  13768. }
  13769. if ( !arguments.length ) {
  13770. return this.attr( "class", "" );
  13771. }
  13772. classes = classesToArray( value );
  13773. if ( classes.length ) {
  13774. while ( ( elem = this[ i++ ] ) ) {
  13775. curValue = getClass( elem );
  13776. // This expression is here for better compressibility (see addClass)
  13777. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13778. if ( cur ) {
  13779. j = 0;
  13780. while ( ( clazz = classes[ j++ ] ) ) {
  13781. // Remove *all* instances
  13782. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13783. cur = cur.replace( " " + clazz + " ", " " );
  13784. }
  13785. }
  13786. // Only assign if different to avoid unneeded rendering.
  13787. finalValue = stripAndCollapse( cur );
  13788. if ( curValue !== finalValue ) {
  13789. elem.setAttribute( "class", finalValue );
  13790. }
  13791. }
  13792. }
  13793. }
  13794. return this;
  13795. },
  13796. toggleClass: function( value, stateVal ) {
  13797. var type = typeof value,
  13798. isValidValue = type === "string" || Array.isArray( value );
  13799. if ( typeof stateVal === "boolean" && isValidValue ) {
  13800. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13801. }
  13802. if ( isFunction( value ) ) {
  13803. return this.each( function( i ) {
  13804. jQuery( this ).toggleClass(
  13805. value.call( this, i, getClass( this ), stateVal ),
  13806. stateVal
  13807. );
  13808. } );
  13809. }
  13810. return this.each( function() {
  13811. var className, i, self, classNames;
  13812. if ( isValidValue ) {
  13813. // Toggle individual class names
  13814. i = 0;
  13815. self = jQuery( this );
  13816. classNames = classesToArray( value );
  13817. while ( ( className = classNames[ i++ ] ) ) {
  13818. // Check each className given, space separated list
  13819. if ( self.hasClass( className ) ) {
  13820. self.removeClass( className );
  13821. } else {
  13822. self.addClass( className );
  13823. }
  13824. }
  13825. // Toggle whole class name
  13826. } else if ( value === undefined || type === "boolean" ) {
  13827. className = getClass( this );
  13828. if ( className ) {
  13829. // Store className if set
  13830. dataPriv.set( this, "__className__", className );
  13831. }
  13832. // If the element has a class name or if we're passed `false`,
  13833. // then remove the whole classname (if there was one, the above saved it).
  13834. // Otherwise bring back whatever was previously saved (if anything),
  13835. // falling back to the empty string if nothing was stored.
  13836. if ( this.setAttribute ) {
  13837. this.setAttribute( "class",
  13838. className || value === false ?
  13839. "" :
  13840. dataPriv.get( this, "__className__" ) || ""
  13841. );
  13842. }
  13843. }
  13844. } );
  13845. },
  13846. hasClass: function( selector ) {
  13847. var className, elem,
  13848. i = 0;
  13849. className = " " + selector + " ";
  13850. while ( ( elem = this[ i++ ] ) ) {
  13851. if ( elem.nodeType === 1 &&
  13852. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13853. return true;
  13854. }
  13855. }
  13856. return false;
  13857. }
  13858. } );
  13859. var rreturn = /\r/g;
  13860. jQuery.fn.extend( {
  13861. val: function( value ) {
  13862. var hooks, ret, valueIsFunction,
  13863. elem = this[ 0 ];
  13864. if ( !arguments.length ) {
  13865. if ( elem ) {
  13866. hooks = jQuery.valHooks[ elem.type ] ||
  13867. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13868. if ( hooks &&
  13869. "get" in hooks &&
  13870. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13871. ) {
  13872. return ret;
  13873. }
  13874. ret = elem.value;
  13875. // Handle most common string cases
  13876. if ( typeof ret === "string" ) {
  13877. return ret.replace( rreturn, "" );
  13878. }
  13879. // Handle cases where value is null/undef or number
  13880. return ret == null ? "" : ret;
  13881. }
  13882. return;
  13883. }
  13884. valueIsFunction = isFunction( value );
  13885. return this.each( function( i ) {
  13886. var val;
  13887. if ( this.nodeType !== 1 ) {
  13888. return;
  13889. }
  13890. if ( valueIsFunction ) {
  13891. val = value.call( this, i, jQuery( this ).val() );
  13892. } else {
  13893. val = value;
  13894. }
  13895. // Treat null/undefined as ""; convert numbers to string
  13896. if ( val == null ) {
  13897. val = "";
  13898. } else if ( typeof val === "number" ) {
  13899. val += "";
  13900. } else if ( Array.isArray( val ) ) {
  13901. val = jQuery.map( val, function( value ) {
  13902. return value == null ? "" : value + "";
  13903. } );
  13904. }
  13905. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13906. // If set returns undefined, fall back to normal setting
  13907. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13908. this.value = val;
  13909. }
  13910. } );
  13911. }
  13912. } );
  13913. jQuery.extend( {
  13914. valHooks: {
  13915. option: {
  13916. get: function( elem ) {
  13917. var val = jQuery.find.attr( elem, "value" );
  13918. return val != null ?
  13919. val :
  13920. // Support: IE <=10 - 11 only
  13921. // option.text throws exceptions (#14686, #14858)
  13922. // Strip and collapse whitespace
  13923. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13924. stripAndCollapse( jQuery.text( elem ) );
  13925. }
  13926. },
  13927. select: {
  13928. get: function( elem ) {
  13929. var value, option, i,
  13930. options = elem.options,
  13931. index = elem.selectedIndex,
  13932. one = elem.type === "select-one",
  13933. values = one ? null : [],
  13934. max = one ? index + 1 : options.length;
  13935. if ( index < 0 ) {
  13936. i = max;
  13937. } else {
  13938. i = one ? index : 0;
  13939. }
  13940. // Loop through all the selected options
  13941. for ( ; i < max; i++ ) {
  13942. option = options[ i ];
  13943. // Support: IE <=9 only
  13944. // IE8-9 doesn't update selected after form reset (#2551)
  13945. if ( ( option.selected || i === index ) &&
  13946. // Don't return options that are disabled or in a disabled optgroup
  13947. !option.disabled &&
  13948. ( !option.parentNode.disabled ||
  13949. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13950. // Get the specific value for the option
  13951. value = jQuery( option ).val();
  13952. // We don't need an array for one selects
  13953. if ( one ) {
  13954. return value;
  13955. }
  13956. // Multi-Selects return an array
  13957. values.push( value );
  13958. }
  13959. }
  13960. return values;
  13961. },
  13962. set: function( elem, value ) {
  13963. var optionSet, option,
  13964. options = elem.options,
  13965. values = jQuery.makeArray( value ),
  13966. i = options.length;
  13967. while ( i-- ) {
  13968. option = options[ i ];
  13969. /* eslint-disable no-cond-assign */
  13970. if ( option.selected =
  13971. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13972. ) {
  13973. optionSet = true;
  13974. }
  13975. /* eslint-enable no-cond-assign */
  13976. }
  13977. // Force browsers to behave consistently when non-matching value is set
  13978. if ( !optionSet ) {
  13979. elem.selectedIndex = -1;
  13980. }
  13981. return values;
  13982. }
  13983. }
  13984. }
  13985. } );
  13986. // Radios and checkboxes getter/setter
  13987. jQuery.each( [ "radio", "checkbox" ], function() {
  13988. jQuery.valHooks[ this ] = {
  13989. set: function( elem, value ) {
  13990. if ( Array.isArray( value ) ) {
  13991. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13992. }
  13993. }
  13994. };
  13995. if ( !support.checkOn ) {
  13996. jQuery.valHooks[ this ].get = function( elem ) {
  13997. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13998. };
  13999. }
  14000. } );
  14001. // Return jQuery for attributes-only inclusion
  14002. support.focusin = "onfocusin" in window;
  14003. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14004. stopPropagationCallback = function( e ) {
  14005. e.stopPropagation();
  14006. };
  14007. jQuery.extend( jQuery.event, {
  14008. trigger: function( event, data, elem, onlyHandlers ) {
  14009. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14010. eventPath = [ elem || document ],
  14011. type = hasOwn.call( event, "type" ) ? event.type : event,
  14012. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14013. cur = lastElement = tmp = elem = elem || document;
  14014. // Don't do events on text and comment nodes
  14015. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14016. return;
  14017. }
  14018. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14019. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14020. return;
  14021. }
  14022. if ( type.indexOf( "." ) > -1 ) {
  14023. // Namespaced trigger; create a regexp to match event type in handle()
  14024. namespaces = type.split( "." );
  14025. type = namespaces.shift();
  14026. namespaces.sort();
  14027. }
  14028. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14029. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14030. event = event[ jQuery.expando ] ?
  14031. event :
  14032. new jQuery.Event( type, typeof event === "object" && event );
  14033. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14034. event.isTrigger = onlyHandlers ? 2 : 3;
  14035. event.namespace = namespaces.join( "." );
  14036. event.rnamespace = event.namespace ?
  14037. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14038. null;
  14039. // Clean up the event in case it is being reused
  14040. event.result = undefined;
  14041. if ( !event.target ) {
  14042. event.target = elem;
  14043. }
  14044. // Clone any incoming data and prepend the event, creating the handler arg list
  14045. data = data == null ?
  14046. [ event ] :
  14047. jQuery.makeArray( data, [ event ] );
  14048. // Allow special events to draw outside the lines
  14049. special = jQuery.event.special[ type ] || {};
  14050. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14051. return;
  14052. }
  14053. // Determine event propagation path in advance, per W3C events spec (#9951)
  14054. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14055. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14056. bubbleType = special.delegateType || type;
  14057. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14058. cur = cur.parentNode;
  14059. }
  14060. for ( ; cur; cur = cur.parentNode ) {
  14061. eventPath.push( cur );
  14062. tmp = cur;
  14063. }
  14064. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14065. if ( tmp === ( elem.ownerDocument || document ) ) {
  14066. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14067. }
  14068. }
  14069. // Fire handlers on the event path
  14070. i = 0;
  14071. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14072. lastElement = cur;
  14073. event.type = i > 1 ?
  14074. bubbleType :
  14075. special.bindType || type;
  14076. // jQuery handler
  14077. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14078. dataPriv.get( cur, "handle" );
  14079. if ( handle ) {
  14080. handle.apply( cur, data );
  14081. }
  14082. // Native handler
  14083. handle = ontype && cur[ ontype ];
  14084. if ( handle && handle.apply && acceptData( cur ) ) {
  14085. event.result = handle.apply( cur, data );
  14086. if ( event.result === false ) {
  14087. event.preventDefault();
  14088. }
  14089. }
  14090. }
  14091. event.type = type;
  14092. // If nobody prevented the default action, do it now
  14093. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14094. if ( ( !special._default ||
  14095. special._default.apply( eventPath.pop(), data ) === false ) &&
  14096. acceptData( elem ) ) {
  14097. // Call a native DOM method on the target with the same name as the event.
  14098. // Don't do default actions on window, that's where global variables be (#6170)
  14099. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14100. // Don't re-trigger an onFOO event when we call its FOO() method
  14101. tmp = elem[ ontype ];
  14102. if ( tmp ) {
  14103. elem[ ontype ] = null;
  14104. }
  14105. // Prevent re-triggering of the same event, since we already bubbled it above
  14106. jQuery.event.triggered = type;
  14107. if ( event.isPropagationStopped() ) {
  14108. lastElement.addEventListener( type, stopPropagationCallback );
  14109. }
  14110. elem[ type ]();
  14111. if ( event.isPropagationStopped() ) {
  14112. lastElement.removeEventListener( type, stopPropagationCallback );
  14113. }
  14114. jQuery.event.triggered = undefined;
  14115. if ( tmp ) {
  14116. elem[ ontype ] = tmp;
  14117. }
  14118. }
  14119. }
  14120. }
  14121. return event.result;
  14122. },
  14123. // Piggyback on a donor event to simulate a different one
  14124. // Used only for `focus(in | out)` events
  14125. simulate: function( type, elem, event ) {
  14126. var e = jQuery.extend(
  14127. new jQuery.Event(),
  14128. event,
  14129. {
  14130. type: type,
  14131. isSimulated: true
  14132. }
  14133. );
  14134. jQuery.event.trigger( e, null, elem );
  14135. }
  14136. } );
  14137. jQuery.fn.extend( {
  14138. trigger: function( type, data ) {
  14139. return this.each( function() {
  14140. jQuery.event.trigger( type, data, this );
  14141. } );
  14142. },
  14143. triggerHandler: function( type, data ) {
  14144. var elem = this[ 0 ];
  14145. if ( elem ) {
  14146. return jQuery.event.trigger( type, data, elem, true );
  14147. }
  14148. }
  14149. } );
  14150. // Support: Firefox <=44
  14151. // Firefox doesn't have focus(in | out) events
  14152. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14153. //
  14154. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14155. // focus(in | out) events fire after focus & blur events,
  14156. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14157. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14158. if ( !support.focusin ) {
  14159. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14160. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14161. var handler = function( event ) {
  14162. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14163. };
  14164. jQuery.event.special[ fix ] = {
  14165. setup: function() {
  14166. var doc = this.ownerDocument || this,
  14167. attaches = dataPriv.access( doc, fix );
  14168. if ( !attaches ) {
  14169. doc.addEventListener( orig, handler, true );
  14170. }
  14171. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14172. },
  14173. teardown: function() {
  14174. var doc = this.ownerDocument || this,
  14175. attaches = dataPriv.access( doc, fix ) - 1;
  14176. if ( !attaches ) {
  14177. doc.removeEventListener( orig, handler, true );
  14178. dataPriv.remove( doc, fix );
  14179. } else {
  14180. dataPriv.access( doc, fix, attaches );
  14181. }
  14182. }
  14183. };
  14184. } );
  14185. }
  14186. var location = window.location;
  14187. var nonce = Date.now();
  14188. var rquery = ( /\?/ );
  14189. // Cross-browser xml parsing
  14190. jQuery.parseXML = function( data ) {
  14191. var xml;
  14192. if ( !data || typeof data !== "string" ) {
  14193. return null;
  14194. }
  14195. // Support: IE 9 - 11 only
  14196. // IE throws on parseFromString with invalid input.
  14197. try {
  14198. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14199. } catch ( e ) {
  14200. xml = undefined;
  14201. }
  14202. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14203. jQuery.error( "Invalid XML: " + data );
  14204. }
  14205. return xml;
  14206. };
  14207. var
  14208. rbracket = /\[\]$/,
  14209. rCRLF = /\r?\n/g,
  14210. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14211. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14212. function buildParams( prefix, obj, traditional, add ) {
  14213. var name;
  14214. if ( Array.isArray( obj ) ) {
  14215. // Serialize array item.
  14216. jQuery.each( obj, function( i, v ) {
  14217. if ( traditional || rbracket.test( prefix ) ) {
  14218. // Treat each array item as a scalar.
  14219. add( prefix, v );
  14220. } else {
  14221. // Item is non-scalar (array or object), encode its numeric index.
  14222. buildParams(
  14223. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14224. v,
  14225. traditional,
  14226. add
  14227. );
  14228. }
  14229. } );
  14230. } else if ( !traditional && toType( obj ) === "object" ) {
  14231. // Serialize object item.
  14232. for ( name in obj ) {
  14233. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14234. }
  14235. } else {
  14236. // Serialize scalar item.
  14237. add( prefix, obj );
  14238. }
  14239. }
  14240. // Serialize an array of form elements or a set of
  14241. // key/values into a query string
  14242. jQuery.param = function( a, traditional ) {
  14243. var prefix,
  14244. s = [],
  14245. add = function( key, valueOrFunction ) {
  14246. // If value is a function, invoke it and use its return value
  14247. var value = isFunction( valueOrFunction ) ?
  14248. valueOrFunction() :
  14249. valueOrFunction;
  14250. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14251. encodeURIComponent( value == null ? "" : value );
  14252. };
  14253. if ( a == null ) {
  14254. return "";
  14255. }
  14256. // If an array was passed in, assume that it is an array of form elements.
  14257. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14258. // Serialize the form elements
  14259. jQuery.each( a, function() {
  14260. add( this.name, this.value );
  14261. } );
  14262. } else {
  14263. // If traditional, encode the "old" way (the way 1.3.2 or older
  14264. // did it), otherwise encode params recursively.
  14265. for ( prefix in a ) {
  14266. buildParams( prefix, a[ prefix ], traditional, add );
  14267. }
  14268. }
  14269. // Return the resulting serialization
  14270. return s.join( "&" );
  14271. };
  14272. jQuery.fn.extend( {
  14273. serialize: function() {
  14274. return jQuery.param( this.serializeArray() );
  14275. },
  14276. serializeArray: function() {
  14277. return this.map( function() {
  14278. // Can add propHook for "elements" to filter or add form elements
  14279. var elements = jQuery.prop( this, "elements" );
  14280. return elements ? jQuery.makeArray( elements ) : this;
  14281. } )
  14282. .filter( function() {
  14283. var type = this.type;
  14284. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14285. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14286. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14287. ( this.checked || !rcheckableType.test( type ) );
  14288. } )
  14289. .map( function( i, elem ) {
  14290. var val = jQuery( this ).val();
  14291. if ( val == null ) {
  14292. return null;
  14293. }
  14294. if ( Array.isArray( val ) ) {
  14295. return jQuery.map( val, function( val ) {
  14296. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14297. } );
  14298. }
  14299. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14300. } ).get();
  14301. }
  14302. } );
  14303. var
  14304. r20 = /%20/g,
  14305. rhash = /#.*$/,
  14306. rantiCache = /([?&])_=[^&]*/,
  14307. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14308. // #7653, #8125, #8152: local protocol detection
  14309. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14310. rnoContent = /^(?:GET|HEAD)$/,
  14311. rprotocol = /^\/\//,
  14312. /* Prefilters
  14313. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14314. * 2) These are called:
  14315. * - BEFORE asking for a transport
  14316. * - AFTER param serialization (s.data is a string if s.processData is true)
  14317. * 3) key is the dataType
  14318. * 4) the catchall symbol "*" can be used
  14319. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14320. */
  14321. prefilters = {},
  14322. /* Transports bindings
  14323. * 1) key is the dataType
  14324. * 2) the catchall symbol "*" can be used
  14325. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14326. */
  14327. transports = {},
  14328. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14329. allTypes = "*/".concat( "*" ),
  14330. // Anchor tag for parsing the document origin
  14331. originAnchor = document.createElement( "a" );
  14332. originAnchor.href = location.href;
  14333. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14334. function addToPrefiltersOrTransports( structure ) {
  14335. // dataTypeExpression is optional and defaults to "*"
  14336. return function( dataTypeExpression, func ) {
  14337. if ( typeof dataTypeExpression !== "string" ) {
  14338. func = dataTypeExpression;
  14339. dataTypeExpression = "*";
  14340. }
  14341. var dataType,
  14342. i = 0,
  14343. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14344. if ( isFunction( func ) ) {
  14345. // For each dataType in the dataTypeExpression
  14346. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14347. // Prepend if requested
  14348. if ( dataType[ 0 ] === "+" ) {
  14349. dataType = dataType.slice( 1 ) || "*";
  14350. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14351. // Otherwise append
  14352. } else {
  14353. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14354. }
  14355. }
  14356. }
  14357. };
  14358. }
  14359. // Base inspection function for prefilters and transports
  14360. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14361. var inspected = {},
  14362. seekingTransport = ( structure === transports );
  14363. function inspect( dataType ) {
  14364. var selected;
  14365. inspected[ dataType ] = true;
  14366. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14367. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14368. if ( typeof dataTypeOrTransport === "string" &&
  14369. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14370. options.dataTypes.unshift( dataTypeOrTransport );
  14371. inspect( dataTypeOrTransport );
  14372. return false;
  14373. } else if ( seekingTransport ) {
  14374. return !( selected = dataTypeOrTransport );
  14375. }
  14376. } );
  14377. return selected;
  14378. }
  14379. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14380. }
  14381. // A special extend for ajax options
  14382. // that takes "flat" options (not to be deep extended)
  14383. // Fixes #9887
  14384. function ajaxExtend( target, src ) {
  14385. var key, deep,
  14386. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14387. for ( key in src ) {
  14388. if ( src[ key ] !== undefined ) {
  14389. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14390. }
  14391. }
  14392. if ( deep ) {
  14393. jQuery.extend( true, target, deep );
  14394. }
  14395. return target;
  14396. }
  14397. /* Handles responses to an ajax request:
  14398. * - finds the right dataType (mediates between content-type and expected dataType)
  14399. * - returns the corresponding response
  14400. */
  14401. function ajaxHandleResponses( s, jqXHR, responses ) {
  14402. var ct, type, finalDataType, firstDataType,
  14403. contents = s.contents,
  14404. dataTypes = s.dataTypes;
  14405. // Remove auto dataType and get content-type in the process
  14406. while ( dataTypes[ 0 ] === "*" ) {
  14407. dataTypes.shift();
  14408. if ( ct === undefined ) {
  14409. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14410. }
  14411. }
  14412. // Check if we're dealing with a known content-type
  14413. if ( ct ) {
  14414. for ( type in contents ) {
  14415. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14416. dataTypes.unshift( type );
  14417. break;
  14418. }
  14419. }
  14420. }
  14421. // Check to see if we have a response for the expected dataType
  14422. if ( dataTypes[ 0 ] in responses ) {
  14423. finalDataType = dataTypes[ 0 ];
  14424. } else {
  14425. // Try convertible dataTypes
  14426. for ( type in responses ) {
  14427. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14428. finalDataType = type;
  14429. break;
  14430. }
  14431. if ( !firstDataType ) {
  14432. firstDataType = type;
  14433. }
  14434. }
  14435. // Or just use first one
  14436. finalDataType = finalDataType || firstDataType;
  14437. }
  14438. // If we found a dataType
  14439. // We add the dataType to the list if needed
  14440. // and return the corresponding response
  14441. if ( finalDataType ) {
  14442. if ( finalDataType !== dataTypes[ 0 ] ) {
  14443. dataTypes.unshift( finalDataType );
  14444. }
  14445. return responses[ finalDataType ];
  14446. }
  14447. }
  14448. /* Chain conversions given the request and the original response
  14449. * Also sets the responseXXX fields on the jqXHR instance
  14450. */
  14451. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14452. var conv2, current, conv, tmp, prev,
  14453. converters = {},
  14454. // Work with a copy of dataTypes in case we need to modify it for conversion
  14455. dataTypes = s.dataTypes.slice();
  14456. // Create converters map with lowercased keys
  14457. if ( dataTypes[ 1 ] ) {
  14458. for ( conv in s.converters ) {
  14459. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14460. }
  14461. }
  14462. current = dataTypes.shift();
  14463. // Convert to each sequential dataType
  14464. while ( current ) {
  14465. if ( s.responseFields[ current ] ) {
  14466. jqXHR[ s.responseFields[ current ] ] = response;
  14467. }
  14468. // Apply the dataFilter if provided
  14469. if ( !prev && isSuccess && s.dataFilter ) {
  14470. response = s.dataFilter( response, s.dataType );
  14471. }
  14472. prev = current;
  14473. current = dataTypes.shift();
  14474. if ( current ) {
  14475. // There's only work to do if current dataType is non-auto
  14476. if ( current === "*" ) {
  14477. current = prev;
  14478. // Convert response if prev dataType is non-auto and differs from current
  14479. } else if ( prev !== "*" && prev !== current ) {
  14480. // Seek a direct converter
  14481. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14482. // If none found, seek a pair
  14483. if ( !conv ) {
  14484. for ( conv2 in converters ) {
  14485. // If conv2 outputs current
  14486. tmp = conv2.split( " " );
  14487. if ( tmp[ 1 ] === current ) {
  14488. // If prev can be converted to accepted input
  14489. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14490. converters[ "* " + tmp[ 0 ] ];
  14491. if ( conv ) {
  14492. // Condense equivalence converters
  14493. if ( conv === true ) {
  14494. conv = converters[ conv2 ];
  14495. // Otherwise, insert the intermediate dataType
  14496. } else if ( converters[ conv2 ] !== true ) {
  14497. current = tmp[ 0 ];
  14498. dataTypes.unshift( tmp[ 1 ] );
  14499. }
  14500. break;
  14501. }
  14502. }
  14503. }
  14504. }
  14505. // Apply converter (if not an equivalence)
  14506. if ( conv !== true ) {
  14507. // Unless errors are allowed to bubble, catch and return them
  14508. if ( conv && s.throws ) {
  14509. response = conv( response );
  14510. } else {
  14511. try {
  14512. response = conv( response );
  14513. } catch ( e ) {
  14514. return {
  14515. state: "parsererror",
  14516. error: conv ? e : "No conversion from " + prev + " to " + current
  14517. };
  14518. }
  14519. }
  14520. }
  14521. }
  14522. }
  14523. }
  14524. return { state: "success", data: response };
  14525. }
  14526. jQuery.extend( {
  14527. // Counter for holding the number of active queries
  14528. active: 0,
  14529. // Last-Modified header cache for next request
  14530. lastModified: {},
  14531. etag: {},
  14532. ajaxSettings: {
  14533. url: location.href,
  14534. type: "GET",
  14535. isLocal: rlocalProtocol.test( location.protocol ),
  14536. global: true,
  14537. processData: true,
  14538. async: true,
  14539. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14540. /*
  14541. timeout: 0,
  14542. data: null,
  14543. dataType: null,
  14544. username: null,
  14545. password: null,
  14546. cache: null,
  14547. throws: false,
  14548. traditional: false,
  14549. headers: {},
  14550. */
  14551. accepts: {
  14552. "*": allTypes,
  14553. text: "text/plain",
  14554. html: "text/html",
  14555. xml: "application/xml, text/xml",
  14556. json: "application/json, text/javascript"
  14557. },
  14558. contents: {
  14559. xml: /\bxml\b/,
  14560. html: /\bhtml/,
  14561. json: /\bjson\b/
  14562. },
  14563. responseFields: {
  14564. xml: "responseXML",
  14565. text: "responseText",
  14566. json: "responseJSON"
  14567. },
  14568. // Data converters
  14569. // Keys separate source (or catchall "*") and destination types with a single space
  14570. converters: {
  14571. // Convert anything to text
  14572. "* text": String,
  14573. // Text to html (true = no transformation)
  14574. "text html": true,
  14575. // Evaluate text as a json expression
  14576. "text json": JSON.parse,
  14577. // Parse text as xml
  14578. "text xml": jQuery.parseXML
  14579. },
  14580. // For options that shouldn't be deep extended:
  14581. // you can add your own custom options here if
  14582. // and when you create one that shouldn't be
  14583. // deep extended (see ajaxExtend)
  14584. flatOptions: {
  14585. url: true,
  14586. context: true
  14587. }
  14588. },
  14589. // Creates a full fledged settings object into target
  14590. // with both ajaxSettings and settings fields.
  14591. // If target is omitted, writes into ajaxSettings.
  14592. ajaxSetup: function( target, settings ) {
  14593. return settings ?
  14594. // Building a settings object
  14595. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14596. // Extending ajaxSettings
  14597. ajaxExtend( jQuery.ajaxSettings, target );
  14598. },
  14599. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14600. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14601. // Main method
  14602. ajax: function( url, options ) {
  14603. // If url is an object, simulate pre-1.5 signature
  14604. if ( typeof url === "object" ) {
  14605. options = url;
  14606. url = undefined;
  14607. }
  14608. // Force options to be an object
  14609. options = options || {};
  14610. var transport,
  14611. // URL without anti-cache param
  14612. cacheURL,
  14613. // Response headers
  14614. responseHeadersString,
  14615. responseHeaders,
  14616. // timeout handle
  14617. timeoutTimer,
  14618. // Url cleanup var
  14619. urlAnchor,
  14620. // Request state (becomes false upon send and true upon completion)
  14621. completed,
  14622. // To know if global events are to be dispatched
  14623. fireGlobals,
  14624. // Loop variable
  14625. i,
  14626. // uncached part of the url
  14627. uncached,
  14628. // Create the final options object
  14629. s = jQuery.ajaxSetup( {}, options ),
  14630. // Callbacks context
  14631. callbackContext = s.context || s,
  14632. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14633. globalEventContext = s.context &&
  14634. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14635. jQuery( callbackContext ) :
  14636. jQuery.event,
  14637. // Deferreds
  14638. deferred = jQuery.Deferred(),
  14639. completeDeferred = jQuery.Callbacks( "once memory" ),
  14640. // Status-dependent callbacks
  14641. statusCode = s.statusCode || {},
  14642. // Headers (they are sent all at once)
  14643. requestHeaders = {},
  14644. requestHeadersNames = {},
  14645. // Default abort message
  14646. strAbort = "canceled",
  14647. // Fake xhr
  14648. jqXHR = {
  14649. readyState: 0,
  14650. // Builds headers hashtable if needed
  14651. getResponseHeader: function( key ) {
  14652. var match;
  14653. if ( completed ) {
  14654. if ( !responseHeaders ) {
  14655. responseHeaders = {};
  14656. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14657. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14658. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14659. .concat( match[ 2 ] );
  14660. }
  14661. }
  14662. match = responseHeaders[ key.toLowerCase() + " " ];
  14663. }
  14664. return match == null ? null : match.join( ", " );
  14665. },
  14666. // Raw string
  14667. getAllResponseHeaders: function() {
  14668. return completed ? responseHeadersString : null;
  14669. },
  14670. // Caches the header
  14671. setRequestHeader: function( name, value ) {
  14672. if ( completed == null ) {
  14673. name = requestHeadersNames[ name.toLowerCase() ] =
  14674. requestHeadersNames[ name.toLowerCase() ] || name;
  14675. requestHeaders[ name ] = value;
  14676. }
  14677. return this;
  14678. },
  14679. // Overrides response content-type header
  14680. overrideMimeType: function( type ) {
  14681. if ( completed == null ) {
  14682. s.mimeType = type;
  14683. }
  14684. return this;
  14685. },
  14686. // Status-dependent callbacks
  14687. statusCode: function( map ) {
  14688. var code;
  14689. if ( map ) {
  14690. if ( completed ) {
  14691. // Execute the appropriate callbacks
  14692. jqXHR.always( map[ jqXHR.status ] );
  14693. } else {
  14694. // Lazy-add the new callbacks in a way that preserves old ones
  14695. for ( code in map ) {
  14696. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14697. }
  14698. }
  14699. }
  14700. return this;
  14701. },
  14702. // Cancel the request
  14703. abort: function( statusText ) {
  14704. var finalText = statusText || strAbort;
  14705. if ( transport ) {
  14706. transport.abort( finalText );
  14707. }
  14708. done( 0, finalText );
  14709. return this;
  14710. }
  14711. };
  14712. // Attach deferreds
  14713. deferred.promise( jqXHR );
  14714. // Add protocol if not provided (prefilters might expect it)
  14715. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14716. // We also use the url parameter if available
  14717. s.url = ( ( url || s.url || location.href ) + "" )
  14718. .replace( rprotocol, location.protocol + "//" );
  14719. // Alias method option to type as per ticket #12004
  14720. s.type = options.method || options.type || s.method || s.type;
  14721. // Extract dataTypes list
  14722. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14723. // A cross-domain request is in order when the origin doesn't match the current origin.
  14724. if ( s.crossDomain == null ) {
  14725. urlAnchor = document.createElement( "a" );
  14726. // Support: IE <=8 - 11, Edge 12 - 15
  14727. // IE throws exception on accessing the href property if url is malformed,
  14728. // e.g. http://example.com:80x/
  14729. try {
  14730. urlAnchor.href = s.url;
  14731. // Support: IE <=8 - 11 only
  14732. // Anchor's host property isn't correctly set when s.url is relative
  14733. urlAnchor.href = urlAnchor.href;
  14734. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14735. urlAnchor.protocol + "//" + urlAnchor.host;
  14736. } catch ( e ) {
  14737. // If there is an error parsing the URL, assume it is crossDomain,
  14738. // it can be rejected by the transport if it is invalid
  14739. s.crossDomain = true;
  14740. }
  14741. }
  14742. // Convert data if not already a string
  14743. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14744. s.data = jQuery.param( s.data, s.traditional );
  14745. }
  14746. // Apply prefilters
  14747. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14748. // If request was aborted inside a prefilter, stop there
  14749. if ( completed ) {
  14750. return jqXHR;
  14751. }
  14752. // We can fire global events as of now if asked to
  14753. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14754. fireGlobals = jQuery.event && s.global;
  14755. // Watch for a new set of requests
  14756. if ( fireGlobals && jQuery.active++ === 0 ) {
  14757. jQuery.event.trigger( "ajaxStart" );
  14758. }
  14759. // Uppercase the type
  14760. s.type = s.type.toUpperCase();
  14761. // Determine if request has content
  14762. s.hasContent = !rnoContent.test( s.type );
  14763. // Save the URL in case we're toying with the If-Modified-Since
  14764. // and/or If-None-Match header later on
  14765. // Remove hash to simplify url manipulation
  14766. cacheURL = s.url.replace( rhash, "" );
  14767. // More options handling for requests with no content
  14768. if ( !s.hasContent ) {
  14769. // Remember the hash so we can put it back
  14770. uncached = s.url.slice( cacheURL.length );
  14771. // If data is available and should be processed, append data to url
  14772. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14773. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14774. // #9682: remove data so that it's not used in an eventual retry
  14775. delete s.data;
  14776. }
  14777. // Add or update anti-cache param if needed
  14778. if ( s.cache === false ) {
  14779. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14780. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14781. }
  14782. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14783. s.url = cacheURL + uncached;
  14784. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14785. } else if ( s.data && s.processData &&
  14786. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14787. s.data = s.data.replace( r20, "+" );
  14788. }
  14789. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14790. if ( s.ifModified ) {
  14791. if ( jQuery.lastModified[ cacheURL ] ) {
  14792. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14793. }
  14794. if ( jQuery.etag[ cacheURL ] ) {
  14795. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14796. }
  14797. }
  14798. // Set the correct header, if data is being sent
  14799. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14800. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14801. }
  14802. // Set the Accepts header for the server, depending on the dataType
  14803. jqXHR.setRequestHeader(
  14804. "Accept",
  14805. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14806. s.accepts[ s.dataTypes[ 0 ] ] +
  14807. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14808. s.accepts[ "*" ]
  14809. );
  14810. // Check for headers option
  14811. for ( i in s.headers ) {
  14812. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14813. }
  14814. // Allow custom headers/mimetypes and early abort
  14815. if ( s.beforeSend &&
  14816. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14817. // Abort if not done already and return
  14818. return jqXHR.abort();
  14819. }
  14820. // Aborting is no longer a cancellation
  14821. strAbort = "abort";
  14822. // Install callbacks on deferreds
  14823. completeDeferred.add( s.complete );
  14824. jqXHR.done( s.success );
  14825. jqXHR.fail( s.error );
  14826. // Get transport
  14827. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14828. // If no transport, we auto-abort
  14829. if ( !transport ) {
  14830. done( -1, "No Transport" );
  14831. } else {
  14832. jqXHR.readyState = 1;
  14833. // Send global event
  14834. if ( fireGlobals ) {
  14835. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14836. }
  14837. // If request was aborted inside ajaxSend, stop there
  14838. if ( completed ) {
  14839. return jqXHR;
  14840. }
  14841. // Timeout
  14842. if ( s.async && s.timeout > 0 ) {
  14843. timeoutTimer = window.setTimeout( function() {
  14844. jqXHR.abort( "timeout" );
  14845. }, s.timeout );
  14846. }
  14847. try {
  14848. completed = false;
  14849. transport.send( requestHeaders, done );
  14850. } catch ( e ) {
  14851. // Rethrow post-completion exceptions
  14852. if ( completed ) {
  14853. throw e;
  14854. }
  14855. // Propagate others as results
  14856. done( -1, e );
  14857. }
  14858. }
  14859. // Callback for when everything is done
  14860. function done( status, nativeStatusText, responses, headers ) {
  14861. var isSuccess, success, error, response, modified,
  14862. statusText = nativeStatusText;
  14863. // Ignore repeat invocations
  14864. if ( completed ) {
  14865. return;
  14866. }
  14867. completed = true;
  14868. // Clear timeout if it exists
  14869. if ( timeoutTimer ) {
  14870. window.clearTimeout( timeoutTimer );
  14871. }
  14872. // Dereference transport for early garbage collection
  14873. // (no matter how long the jqXHR object will be used)
  14874. transport = undefined;
  14875. // Cache response headers
  14876. responseHeadersString = headers || "";
  14877. // Set readyState
  14878. jqXHR.readyState = status > 0 ? 4 : 0;
  14879. // Determine if successful
  14880. isSuccess = status >= 200 && status < 300 || status === 304;
  14881. // Get response data
  14882. if ( responses ) {
  14883. response = ajaxHandleResponses( s, jqXHR, responses );
  14884. }
  14885. // Convert no matter what (that way responseXXX fields are always set)
  14886. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14887. // If successful, handle type chaining
  14888. if ( isSuccess ) {
  14889. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14890. if ( s.ifModified ) {
  14891. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14892. if ( modified ) {
  14893. jQuery.lastModified[ cacheURL ] = modified;
  14894. }
  14895. modified = jqXHR.getResponseHeader( "etag" );
  14896. if ( modified ) {
  14897. jQuery.etag[ cacheURL ] = modified;
  14898. }
  14899. }
  14900. // if no content
  14901. if ( status === 204 || s.type === "HEAD" ) {
  14902. statusText = "nocontent";
  14903. // if not modified
  14904. } else if ( status === 304 ) {
  14905. statusText = "notmodified";
  14906. // If we have data, let's convert it
  14907. } else {
  14908. statusText = response.state;
  14909. success = response.data;
  14910. error = response.error;
  14911. isSuccess = !error;
  14912. }
  14913. } else {
  14914. // Extract error from statusText and normalize for non-aborts
  14915. error = statusText;
  14916. if ( status || !statusText ) {
  14917. statusText = "error";
  14918. if ( status < 0 ) {
  14919. status = 0;
  14920. }
  14921. }
  14922. }
  14923. // Set data for the fake xhr object
  14924. jqXHR.status = status;
  14925. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14926. // Success/Error
  14927. if ( isSuccess ) {
  14928. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14929. } else {
  14930. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14931. }
  14932. // Status-dependent callbacks
  14933. jqXHR.statusCode( statusCode );
  14934. statusCode = undefined;
  14935. if ( fireGlobals ) {
  14936. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14937. [ jqXHR, s, isSuccess ? success : error ] );
  14938. }
  14939. // Complete
  14940. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14941. if ( fireGlobals ) {
  14942. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14943. // Handle the global AJAX counter
  14944. if ( !( --jQuery.active ) ) {
  14945. jQuery.event.trigger( "ajaxStop" );
  14946. }
  14947. }
  14948. }
  14949. return jqXHR;
  14950. },
  14951. getJSON: function( url, data, callback ) {
  14952. return jQuery.get( url, data, callback, "json" );
  14953. },
  14954. getScript: function( url, callback ) {
  14955. return jQuery.get( url, undefined, callback, "script" );
  14956. }
  14957. } );
  14958. jQuery.each( [ "get", "post" ], function( i, method ) {
  14959. jQuery[ method ] = function( url, data, callback, type ) {
  14960. // Shift arguments if data argument was omitted
  14961. if ( isFunction( data ) ) {
  14962. type = type || callback;
  14963. callback = data;
  14964. data = undefined;
  14965. }
  14966. // The url can be an options object (which then must have .url)
  14967. return jQuery.ajax( jQuery.extend( {
  14968. url: url,
  14969. type: method,
  14970. dataType: type,
  14971. data: data,
  14972. success: callback
  14973. }, jQuery.isPlainObject( url ) && url ) );
  14974. };
  14975. } );
  14976. jQuery._evalUrl = function( url, options ) {
  14977. return jQuery.ajax( {
  14978. url: url,
  14979. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14980. type: "GET",
  14981. dataType: "script",
  14982. cache: true,
  14983. async: false,
  14984. global: false,
  14985. // Only evaluate the response if it is successful (gh-4126)
  14986. // dataFilter is not invoked for failure responses, so using it instead
  14987. // of the default converter is kludgy but it works.
  14988. converters: {
  14989. "text script": function() {}
  14990. },
  14991. dataFilter: function( response ) {
  14992. jQuery.globalEval( response, options );
  14993. }
  14994. } );
  14995. };
  14996. jQuery.fn.extend( {
  14997. wrapAll: function( html ) {
  14998. var wrap;
  14999. if ( this[ 0 ] ) {
  15000. if ( isFunction( html ) ) {
  15001. html = html.call( this[ 0 ] );
  15002. }
  15003. // The elements to wrap the target around
  15004. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15005. if ( this[ 0 ].parentNode ) {
  15006. wrap.insertBefore( this[ 0 ] );
  15007. }
  15008. wrap.map( function() {
  15009. var elem = this;
  15010. while ( elem.firstElementChild ) {
  15011. elem = elem.firstElementChild;
  15012. }
  15013. return elem;
  15014. } ).append( this );
  15015. }
  15016. return this;
  15017. },
  15018. wrapInner: function( html ) {
  15019. if ( isFunction( html ) ) {
  15020. return this.each( function( i ) {
  15021. jQuery( this ).wrapInner( html.call( this, i ) );
  15022. } );
  15023. }
  15024. return this.each( function() {
  15025. var self = jQuery( this ),
  15026. contents = self.contents();
  15027. if ( contents.length ) {
  15028. contents.wrapAll( html );
  15029. } else {
  15030. self.append( html );
  15031. }
  15032. } );
  15033. },
  15034. wrap: function( html ) {
  15035. var htmlIsFunction = isFunction( html );
  15036. return this.each( function( i ) {
  15037. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15038. } );
  15039. },
  15040. unwrap: function( selector ) {
  15041. this.parent( selector ).not( "body" ).each( function() {
  15042. jQuery( this ).replaceWith( this.childNodes );
  15043. } );
  15044. return this;
  15045. }
  15046. } );
  15047. jQuery.expr.pseudos.hidden = function( elem ) {
  15048. return !jQuery.expr.pseudos.visible( elem );
  15049. };
  15050. jQuery.expr.pseudos.visible = function( elem ) {
  15051. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15052. };
  15053. jQuery.ajaxSettings.xhr = function() {
  15054. try {
  15055. return new window.XMLHttpRequest();
  15056. } catch ( e ) {}
  15057. };
  15058. var xhrSuccessStatus = {
  15059. // File protocol always yields status code 0, assume 200
  15060. 0: 200,
  15061. // Support: IE <=9 only
  15062. // #1450: sometimes IE returns 1223 when it should be 204
  15063. 1223: 204
  15064. },
  15065. xhrSupported = jQuery.ajaxSettings.xhr();
  15066. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15067. support.ajax = xhrSupported = !!xhrSupported;
  15068. jQuery.ajaxTransport( function( options ) {
  15069. var callback, errorCallback;
  15070. // Cross domain only allowed if supported through XMLHttpRequest
  15071. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15072. return {
  15073. send: function( headers, complete ) {
  15074. var i,
  15075. xhr = options.xhr();
  15076. xhr.open(
  15077. options.type,
  15078. options.url,
  15079. options.async,
  15080. options.username,
  15081. options.password
  15082. );
  15083. // Apply custom fields if provided
  15084. if ( options.xhrFields ) {
  15085. for ( i in options.xhrFields ) {
  15086. xhr[ i ] = options.xhrFields[ i ];
  15087. }
  15088. }
  15089. // Override mime type if needed
  15090. if ( options.mimeType && xhr.overrideMimeType ) {
  15091. xhr.overrideMimeType( options.mimeType );
  15092. }
  15093. // X-Requested-With header
  15094. // For cross-domain requests, seeing as conditions for a preflight are
  15095. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15096. // (it can always be set on a per-request basis or even using ajaxSetup)
  15097. // For same-domain requests, won't change header if already provided.
  15098. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15099. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15100. }
  15101. // Set headers
  15102. for ( i in headers ) {
  15103. xhr.setRequestHeader( i, headers[ i ] );
  15104. }
  15105. // Callback
  15106. callback = function( type ) {
  15107. return function() {
  15108. if ( callback ) {
  15109. callback = errorCallback = xhr.onload =
  15110. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15111. xhr.onreadystatechange = null;
  15112. if ( type === "abort" ) {
  15113. xhr.abort();
  15114. } else if ( type === "error" ) {
  15115. // Support: IE <=9 only
  15116. // On a manual native abort, IE9 throws
  15117. // errors on any property access that is not readyState
  15118. if ( typeof xhr.status !== "number" ) {
  15119. complete( 0, "error" );
  15120. } else {
  15121. complete(
  15122. // File: protocol always yields status 0; see #8605, #14207
  15123. xhr.status,
  15124. xhr.statusText
  15125. );
  15126. }
  15127. } else {
  15128. complete(
  15129. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15130. xhr.statusText,
  15131. // Support: IE <=9 only
  15132. // IE9 has no XHR2 but throws on binary (trac-11426)
  15133. // For XHR2 non-text, let the caller handle it (gh-2498)
  15134. ( xhr.responseType || "text" ) !== "text" ||
  15135. typeof xhr.responseText !== "string" ?
  15136. { binary: xhr.response } :
  15137. { text: xhr.responseText },
  15138. xhr.getAllResponseHeaders()
  15139. );
  15140. }
  15141. }
  15142. };
  15143. };
  15144. // Listen to events
  15145. xhr.onload = callback();
  15146. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15147. // Support: IE 9 only
  15148. // Use onreadystatechange to replace onabort
  15149. // to handle uncaught aborts
  15150. if ( xhr.onabort !== undefined ) {
  15151. xhr.onabort = errorCallback;
  15152. } else {
  15153. xhr.onreadystatechange = function() {
  15154. // Check readyState before timeout as it changes
  15155. if ( xhr.readyState === 4 ) {
  15156. // Allow onerror to be called first,
  15157. // but that will not handle a native abort
  15158. // Also, save errorCallback to a variable
  15159. // as xhr.onerror cannot be accessed
  15160. window.setTimeout( function() {
  15161. if ( callback ) {
  15162. errorCallback();
  15163. }
  15164. } );
  15165. }
  15166. };
  15167. }
  15168. // Create the abort callback
  15169. callback = callback( "abort" );
  15170. try {
  15171. // Do send the request (this may raise an exception)
  15172. xhr.send( options.hasContent && options.data || null );
  15173. } catch ( e ) {
  15174. // #14683: Only rethrow if this hasn't been notified as an error yet
  15175. if ( callback ) {
  15176. throw e;
  15177. }
  15178. }
  15179. },
  15180. abort: function() {
  15181. if ( callback ) {
  15182. callback();
  15183. }
  15184. }
  15185. };
  15186. }
  15187. } );
  15188. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15189. jQuery.ajaxPrefilter( function( s ) {
  15190. if ( s.crossDomain ) {
  15191. s.contents.script = false;
  15192. }
  15193. } );
  15194. // Install script dataType
  15195. jQuery.ajaxSetup( {
  15196. accepts: {
  15197. script: "text/javascript, application/javascript, " +
  15198. "application/ecmascript, application/x-ecmascript"
  15199. },
  15200. contents: {
  15201. script: /\b(?:java|ecma)script\b/
  15202. },
  15203. converters: {
  15204. "text script": function( text ) {
  15205. jQuery.globalEval( text );
  15206. return text;
  15207. }
  15208. }
  15209. } );
  15210. // Handle cache's special case and crossDomain
  15211. jQuery.ajaxPrefilter( "script", function( s ) {
  15212. if ( s.cache === undefined ) {
  15213. s.cache = false;
  15214. }
  15215. if ( s.crossDomain ) {
  15216. s.type = "GET";
  15217. }
  15218. } );
  15219. // Bind script tag hack transport
  15220. jQuery.ajaxTransport( "script", function( s ) {
  15221. // This transport only deals with cross domain or forced-by-attrs requests
  15222. if ( s.crossDomain || s.scriptAttrs ) {
  15223. var script, callback;
  15224. return {
  15225. send: function( _, complete ) {
  15226. script = jQuery( "<script>" )
  15227. .attr( s.scriptAttrs || {} )
  15228. .prop( { charset: s.scriptCharset, src: s.url } )
  15229. .on( "load error", callback = function( evt ) {
  15230. script.remove();
  15231. callback = null;
  15232. if ( evt ) {
  15233. complete( evt.type === "error" ? 404 : 200, evt.type );
  15234. }
  15235. } );
  15236. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15237. document.head.appendChild( script[ 0 ] );
  15238. },
  15239. abort: function() {
  15240. if ( callback ) {
  15241. callback();
  15242. }
  15243. }
  15244. };
  15245. }
  15246. } );
  15247. var oldCallbacks = [],
  15248. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15249. // Default jsonp settings
  15250. jQuery.ajaxSetup( {
  15251. jsonp: "callback",
  15252. jsonpCallback: function() {
  15253. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15254. this[ callback ] = true;
  15255. return callback;
  15256. }
  15257. } );
  15258. // Detect, normalize options and install callbacks for jsonp requests
  15259. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15260. var callbackName, overwritten, responseContainer,
  15261. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15262. "url" :
  15263. typeof s.data === "string" &&
  15264. ( s.contentType || "" )
  15265. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15266. rjsonp.test( s.data ) && "data"
  15267. );
  15268. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15269. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15270. // Get callback name, remembering preexisting value associated with it
  15271. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15272. s.jsonpCallback() :
  15273. s.jsonpCallback;
  15274. // Insert callback into url or form data
  15275. if ( jsonProp ) {
  15276. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15277. } else if ( s.jsonp !== false ) {
  15278. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15279. }
  15280. // Use data converter to retrieve json after script execution
  15281. s.converters[ "script json" ] = function() {
  15282. if ( !responseContainer ) {
  15283. jQuery.error( callbackName + " was not called" );
  15284. }
  15285. return responseContainer[ 0 ];
  15286. };
  15287. // Force json dataType
  15288. s.dataTypes[ 0 ] = "json";
  15289. // Install callback
  15290. overwritten = window[ callbackName ];
  15291. window[ callbackName ] = function() {
  15292. responseContainer = arguments;
  15293. };
  15294. // Clean-up function (fires after converters)
  15295. jqXHR.always( function() {
  15296. // If previous value didn't exist - remove it
  15297. if ( overwritten === undefined ) {
  15298. jQuery( window ).removeProp( callbackName );
  15299. // Otherwise restore preexisting value
  15300. } else {
  15301. window[ callbackName ] = overwritten;
  15302. }
  15303. // Save back as free
  15304. if ( s[ callbackName ] ) {
  15305. // Make sure that re-using the options doesn't screw things around
  15306. s.jsonpCallback = originalSettings.jsonpCallback;
  15307. // Save the callback name for future use
  15308. oldCallbacks.push( callbackName );
  15309. }
  15310. // Call if it was a function and we have a response
  15311. if ( responseContainer && isFunction( overwritten ) ) {
  15312. overwritten( responseContainer[ 0 ] );
  15313. }
  15314. responseContainer = overwritten = undefined;
  15315. } );
  15316. // Delegate to script
  15317. return "script";
  15318. }
  15319. } );
  15320. // Support: Safari 8 only
  15321. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15322. // collapse sibling forms: the second one becomes a child of the first one.
  15323. // Because of that, this security measure has to be disabled in Safari 8.
  15324. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15325. support.createHTMLDocument = ( function() {
  15326. var body = document.implementation.createHTMLDocument( "" ).body;
  15327. body.innerHTML = "<form></form><form></form>";
  15328. return body.childNodes.length === 2;
  15329. } )();
  15330. // Argument "data" should be string of html
  15331. // context (optional): If specified, the fragment will be created in this context,
  15332. // defaults to document
  15333. // keepScripts (optional): If true, will include scripts passed in the html string
  15334. jQuery.parseHTML = function( data, context, keepScripts ) {
  15335. if ( typeof data !== "string" ) {
  15336. return [];
  15337. }
  15338. if ( typeof context === "boolean" ) {
  15339. keepScripts = context;
  15340. context = false;
  15341. }
  15342. var base, parsed, scripts;
  15343. if ( !context ) {
  15344. // Stop scripts or inline event handlers from being executed immediately
  15345. // by using document.implementation
  15346. if ( support.createHTMLDocument ) {
  15347. context = document.implementation.createHTMLDocument( "" );
  15348. // Set the base href for the created document
  15349. // so any parsed elements with URLs
  15350. // are based on the document's URL (gh-2965)
  15351. base = context.createElement( "base" );
  15352. base.href = document.location.href;
  15353. context.head.appendChild( base );
  15354. } else {
  15355. context = document;
  15356. }
  15357. }
  15358. parsed = rsingleTag.exec( data );
  15359. scripts = !keepScripts && [];
  15360. // Single tag
  15361. if ( parsed ) {
  15362. return [ context.createElement( parsed[ 1 ] ) ];
  15363. }
  15364. parsed = buildFragment( [ data ], context, scripts );
  15365. if ( scripts && scripts.length ) {
  15366. jQuery( scripts ).remove();
  15367. }
  15368. return jQuery.merge( [], parsed.childNodes );
  15369. };
  15370. /**
  15371. * Load a url into a page
  15372. */
  15373. jQuery.fn.load = function( url, params, callback ) {
  15374. var selector, type, response,
  15375. self = this,
  15376. off = url.indexOf( " " );
  15377. if ( off > -1 ) {
  15378. selector = stripAndCollapse( url.slice( off ) );
  15379. url = url.slice( 0, off );
  15380. }
  15381. // If it's a function
  15382. if ( isFunction( params ) ) {
  15383. // We assume that it's the callback
  15384. callback = params;
  15385. params = undefined;
  15386. // Otherwise, build a param string
  15387. } else if ( params && typeof params === "object" ) {
  15388. type = "POST";
  15389. }
  15390. // If we have elements to modify, make the request
  15391. if ( self.length > 0 ) {
  15392. jQuery.ajax( {
  15393. url: url,
  15394. // If "type" variable is undefined, then "GET" method will be used.
  15395. // Make value of this field explicit since
  15396. // user can override it through ajaxSetup method
  15397. type: type || "GET",
  15398. dataType: "html",
  15399. data: params
  15400. } ).done( function( responseText ) {
  15401. // Save response for use in complete callback
  15402. response = arguments;
  15403. self.html( selector ?
  15404. // If a selector was specified, locate the right elements in a dummy div
  15405. // Exclude scripts to avoid IE 'Permission Denied' errors
  15406. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15407. // Otherwise use the full result
  15408. responseText );
  15409. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15410. // but they are ignored because response was set above.
  15411. // If it fails, this function gets "jqXHR", "status", "error"
  15412. } ).always( callback && function( jqXHR, status ) {
  15413. self.each( function() {
  15414. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15415. } );
  15416. } );
  15417. }
  15418. return this;
  15419. };
  15420. // Attach a bunch of functions for handling common AJAX events
  15421. jQuery.each( [
  15422. "ajaxStart",
  15423. "ajaxStop",
  15424. "ajaxComplete",
  15425. "ajaxError",
  15426. "ajaxSuccess",
  15427. "ajaxSend"
  15428. ], function( i, type ) {
  15429. jQuery.fn[ type ] = function( fn ) {
  15430. return this.on( type, fn );
  15431. };
  15432. } );
  15433. jQuery.expr.pseudos.animated = function( elem ) {
  15434. return jQuery.grep( jQuery.timers, function( fn ) {
  15435. return elem === fn.elem;
  15436. } ).length;
  15437. };
  15438. jQuery.offset = {
  15439. setOffset: function( elem, options, i ) {
  15440. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15441. position = jQuery.css( elem, "position" ),
  15442. curElem = jQuery( elem ),
  15443. props = {};
  15444. // Set position first, in-case top/left are set even on static elem
  15445. if ( position === "static" ) {
  15446. elem.style.position = "relative";
  15447. }
  15448. curOffset = curElem.offset();
  15449. curCSSTop = jQuery.css( elem, "top" );
  15450. curCSSLeft = jQuery.css( elem, "left" );
  15451. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15452. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15453. // Need to be able to calculate position if either
  15454. // top or left is auto and position is either absolute or fixed
  15455. if ( calculatePosition ) {
  15456. curPosition = curElem.position();
  15457. curTop = curPosition.top;
  15458. curLeft = curPosition.left;
  15459. } else {
  15460. curTop = parseFloat( curCSSTop ) || 0;
  15461. curLeft = parseFloat( curCSSLeft ) || 0;
  15462. }
  15463. if ( isFunction( options ) ) {
  15464. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15465. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15466. }
  15467. if ( options.top != null ) {
  15468. props.top = ( options.top - curOffset.top ) + curTop;
  15469. }
  15470. if ( options.left != null ) {
  15471. props.left = ( options.left - curOffset.left ) + curLeft;
  15472. }
  15473. if ( "using" in options ) {
  15474. options.using.call( elem, props );
  15475. } else {
  15476. curElem.css( props );
  15477. }
  15478. }
  15479. };
  15480. jQuery.fn.extend( {
  15481. // offset() relates an element's border box to the document origin
  15482. offset: function( options ) {
  15483. // Preserve chaining for setter
  15484. if ( arguments.length ) {
  15485. return options === undefined ?
  15486. this :
  15487. this.each( function( i ) {
  15488. jQuery.offset.setOffset( this, options, i );
  15489. } );
  15490. }
  15491. var rect, win,
  15492. elem = this[ 0 ];
  15493. if ( !elem ) {
  15494. return;
  15495. }
  15496. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15497. // Support: IE <=11 only
  15498. // Running getBoundingClientRect on a
  15499. // disconnected node in IE throws an error
  15500. if ( !elem.getClientRects().length ) {
  15501. return { top: 0, left: 0 };
  15502. }
  15503. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15504. rect = elem.getBoundingClientRect();
  15505. win = elem.ownerDocument.defaultView;
  15506. return {
  15507. top: rect.top + win.pageYOffset,
  15508. left: rect.left + win.pageXOffset
  15509. };
  15510. },
  15511. // position() relates an element's margin box to its offset parent's padding box
  15512. // This corresponds to the behavior of CSS absolute positioning
  15513. position: function() {
  15514. if ( !this[ 0 ] ) {
  15515. return;
  15516. }
  15517. var offsetParent, offset, doc,
  15518. elem = this[ 0 ],
  15519. parentOffset = { top: 0, left: 0 };
  15520. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15521. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15522. // Assume position:fixed implies availability of getBoundingClientRect
  15523. offset = elem.getBoundingClientRect();
  15524. } else {
  15525. offset = this.offset();
  15526. // Account for the *real* offset parent, which can be the document or its root element
  15527. // when a statically positioned element is identified
  15528. doc = elem.ownerDocument;
  15529. offsetParent = elem.offsetParent || doc.documentElement;
  15530. while ( offsetParent &&
  15531. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15532. jQuery.css( offsetParent, "position" ) === "static" ) {
  15533. offsetParent = offsetParent.parentNode;
  15534. }
  15535. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15536. // Incorporate borders into its offset, since they are outside its content origin
  15537. parentOffset = jQuery( offsetParent ).offset();
  15538. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15539. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15540. }
  15541. }
  15542. // Subtract parent offsets and element margins
  15543. return {
  15544. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15545. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15546. };
  15547. },
  15548. // This method will return documentElement in the following cases:
  15549. // 1) For the element inside the iframe without offsetParent, this method will return
  15550. // documentElement of the parent window
  15551. // 2) For the hidden or detached element
  15552. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15553. //
  15554. // but those exceptions were never presented as a real life use-cases
  15555. // and might be considered as more preferable results.
  15556. //
  15557. // This logic, however, is not guaranteed and can change at any point in the future
  15558. offsetParent: function() {
  15559. return this.map( function() {
  15560. var offsetParent = this.offsetParent;
  15561. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15562. offsetParent = offsetParent.offsetParent;
  15563. }
  15564. return offsetParent || documentElement;
  15565. } );
  15566. }
  15567. } );
  15568. // Create scrollLeft and scrollTop methods
  15569. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15570. var top = "pageYOffset" === prop;
  15571. jQuery.fn[ method ] = function( val ) {
  15572. return access( this, function( elem, method, val ) {
  15573. // Coalesce documents and windows
  15574. var win;
  15575. if ( isWindow( elem ) ) {
  15576. win = elem;
  15577. } else if ( elem.nodeType === 9 ) {
  15578. win = elem.defaultView;
  15579. }
  15580. if ( val === undefined ) {
  15581. return win ? win[ prop ] : elem[ method ];
  15582. }
  15583. if ( win ) {
  15584. win.scrollTo(
  15585. !top ? val : win.pageXOffset,
  15586. top ? val : win.pageYOffset
  15587. );
  15588. } else {
  15589. elem[ method ] = val;
  15590. }
  15591. }, method, val, arguments.length );
  15592. };
  15593. } );
  15594. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15595. // Add the top/left cssHooks using jQuery.fn.position
  15596. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15597. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15598. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15599. // rather than make the css module depend on the offset module, just check for it here
  15600. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15601. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15602. function( elem, computed ) {
  15603. if ( computed ) {
  15604. computed = curCSS( elem, prop );
  15605. // If curCSS returns percentage, fallback to offset
  15606. return rnumnonpx.test( computed ) ?
  15607. jQuery( elem ).position()[ prop ] + "px" :
  15608. computed;
  15609. }
  15610. }
  15611. );
  15612. } );
  15613. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15614. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15615. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15616. function( defaultExtra, funcName ) {
  15617. // Margin is only for outerHeight, outerWidth
  15618. jQuery.fn[ funcName ] = function( margin, value ) {
  15619. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15620. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15621. return access( this, function( elem, type, value ) {
  15622. var doc;
  15623. if ( isWindow( elem ) ) {
  15624. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15625. return funcName.indexOf( "outer" ) === 0 ?
  15626. elem[ "inner" + name ] :
  15627. elem.document.documentElement[ "client" + name ];
  15628. }
  15629. // Get document width or height
  15630. if ( elem.nodeType === 9 ) {
  15631. doc = elem.documentElement;
  15632. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15633. // whichever is greatest
  15634. return Math.max(
  15635. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15636. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15637. doc[ "client" + name ]
  15638. );
  15639. }
  15640. return value === undefined ?
  15641. // Get width or height on the element, requesting but not forcing parseFloat
  15642. jQuery.css( elem, type, extra ) :
  15643. // Set width or height on the element
  15644. jQuery.style( elem, type, value, extra );
  15645. }, type, chainable ? margin : undefined, chainable );
  15646. };
  15647. } );
  15648. } );
  15649. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15650. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15651. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15652. function( i, name ) {
  15653. // Handle event binding
  15654. jQuery.fn[ name ] = function( data, fn ) {
  15655. return arguments.length > 0 ?
  15656. this.on( name, null, data, fn ) :
  15657. this.trigger( name );
  15658. };
  15659. } );
  15660. jQuery.fn.extend( {
  15661. hover: function( fnOver, fnOut ) {
  15662. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15663. }
  15664. } );
  15665. jQuery.fn.extend( {
  15666. bind: function( types, data, fn ) {
  15667. return this.on( types, null, data, fn );
  15668. },
  15669. unbind: function( types, fn ) {
  15670. return this.off( types, null, fn );
  15671. },
  15672. delegate: function( selector, types, data, fn ) {
  15673. return this.on( types, selector, data, fn );
  15674. },
  15675. undelegate: function( selector, types, fn ) {
  15676. // ( namespace ) or ( selector, types [, fn] )
  15677. return arguments.length === 1 ?
  15678. this.off( selector, "**" ) :
  15679. this.off( types, selector || "**", fn );
  15680. }
  15681. } );
  15682. // Bind a function to a context, optionally partially applying any
  15683. // arguments.
  15684. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15685. // However, it is not slated for removal any time soon
  15686. jQuery.proxy = function( fn, context ) {
  15687. var tmp, args, proxy;
  15688. if ( typeof context === "string" ) {
  15689. tmp = fn[ context ];
  15690. context = fn;
  15691. fn = tmp;
  15692. }
  15693. // Quick check to determine if target is callable, in the spec
  15694. // this throws a TypeError, but we will just return undefined.
  15695. if ( !isFunction( fn ) ) {
  15696. return undefined;
  15697. }
  15698. // Simulated bind
  15699. args = slice.call( arguments, 2 );
  15700. proxy = function() {
  15701. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15702. };
  15703. // Set the guid of unique handler to the same of original handler, so it can be removed
  15704. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15705. return proxy;
  15706. };
  15707. jQuery.holdReady = function( hold ) {
  15708. if ( hold ) {
  15709. jQuery.readyWait++;
  15710. } else {
  15711. jQuery.ready( true );
  15712. }
  15713. };
  15714. jQuery.isArray = Array.isArray;
  15715. jQuery.parseJSON = JSON.parse;
  15716. jQuery.nodeName = nodeName;
  15717. jQuery.isFunction = isFunction;
  15718. jQuery.isWindow = isWindow;
  15719. jQuery.camelCase = camelCase;
  15720. jQuery.type = toType;
  15721. jQuery.now = Date.now;
  15722. jQuery.isNumeric = function( obj ) {
  15723. // As of jQuery 3.0, isNumeric is limited to
  15724. // strings and numbers (primitives or objects)
  15725. // that can be coerced to finite numbers (gh-2662)
  15726. var type = jQuery.type( obj );
  15727. return ( type === "number" || type === "string" ) &&
  15728. // parseFloat NaNs numeric-cast false positives ("")
  15729. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15730. // subtraction forces infinities to NaN
  15731. !isNaN( obj - parseFloat( obj ) );
  15732. };
  15733. // Register as a named AMD module, since jQuery can be concatenated with other
  15734. // files that may use define, but not via a proper concatenation script that
  15735. // understands anonymous AMD modules. A named AMD is safest and most robust
  15736. // way to register. Lowercase jquery is used because AMD module names are
  15737. // derived from file names, and jQuery is normally delivered in a lowercase
  15738. // file name. Do this after creating the global so that if an AMD module wants
  15739. // to call noConflict to hide this version of jQuery, it will work.
  15740. // Note that for maximum portability, libraries that are not jQuery should
  15741. // declare themselves as anonymous modules, and avoid setting a global if an
  15742. // AMD loader is present. jQuery is a special case. For more information, see
  15743. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15744. if ( true ) {
  15745. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15746. return jQuery;
  15747. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15748. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15749. }
  15750. var
  15751. // Map over jQuery in case of overwrite
  15752. _jQuery = window.jQuery,
  15753. // Map over the $ in case of overwrite
  15754. _$ = window.$;
  15755. jQuery.noConflict = function( deep ) {
  15756. if ( window.$ === jQuery ) {
  15757. window.$ = _$;
  15758. }
  15759. if ( deep && window.jQuery === jQuery ) {
  15760. window.jQuery = _jQuery;
  15761. }
  15762. return jQuery;
  15763. };
  15764. // Expose jQuery and $ identifiers, even in AMD
  15765. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15766. // and CommonJS for browser emulators (#13566)
  15767. if ( !noGlobal ) {
  15768. window.jQuery = window.$ = jQuery;
  15769. }
  15770. return jQuery;
  15771. } );
  15772. /***/ }),
  15773. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15774. /*!************************************************!*\
  15775. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15776. \************************************************/
  15777. /*! exports provided: default */
  15778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15779. "use strict";
  15780. __webpack_require__.r(__webpack_exports__);
  15781. var classCallCheck = function (instance, Constructor) {
  15782. if (!(instance instanceof Constructor)) {
  15783. throw new TypeError("Cannot call a class as a function");
  15784. }
  15785. };
  15786. var createClass = function () {
  15787. function defineProperties(target, props) {
  15788. for (var i = 0; i < props.length; i++) {
  15789. var descriptor = props[i];
  15790. descriptor.enumerable = descriptor.enumerable || false;
  15791. descriptor.configurable = true;
  15792. if ("value" in descriptor) descriptor.writable = true;
  15793. Object.defineProperty(target, descriptor.key, descriptor);
  15794. }
  15795. }
  15796. return function (Constructor, protoProps, staticProps) {
  15797. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15798. if (staticProps) defineProperties(Constructor, staticProps);
  15799. return Constructor;
  15800. };
  15801. }();
  15802. var _extends = Object.assign || function (target) {
  15803. for (var i = 1; i < arguments.length; i++) {
  15804. var source = arguments[i];
  15805. for (var key in source) {
  15806. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15807. target[key] = source[key];
  15808. }
  15809. }
  15810. }
  15811. return target;
  15812. };
  15813. var inherits = function (subClass, superClass) {
  15814. if (typeof superClass !== "function" && superClass !== null) {
  15815. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15816. }
  15817. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15818. constructor: {
  15819. value: subClass,
  15820. enumerable: false,
  15821. writable: true,
  15822. configurable: true
  15823. }
  15824. });
  15825. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15826. };
  15827. var possibleConstructorReturn = function (self, call) {
  15828. if (!self) {
  15829. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15830. }
  15831. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15832. };
  15833. var Connector = function () {
  15834. /**
  15835. * Create a new class instance.
  15836. */
  15837. function Connector(options) {
  15838. classCallCheck(this, Connector);
  15839. /**
  15840. * Default connector options.
  15841. */
  15842. this._defaultOptions = {
  15843. auth: {
  15844. headers: {}
  15845. },
  15846. authEndpoint: '/broadcasting/auth',
  15847. broadcaster: 'pusher',
  15848. csrfToken: null,
  15849. host: null,
  15850. key: null,
  15851. namespace: 'App.Events'
  15852. };
  15853. this.setOptions(options);
  15854. this.connect();
  15855. }
  15856. /**
  15857. * Merge the custom options with the defaults.
  15858. */
  15859. createClass(Connector, [{
  15860. key: 'setOptions',
  15861. value: function setOptions(options) {
  15862. this.options = _extends(this._defaultOptions, options);
  15863. if (this.csrfToken()) {
  15864. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15865. }
  15866. return options;
  15867. }
  15868. /**
  15869. * Extract the CSRF token from the page.
  15870. */
  15871. }, {
  15872. key: 'csrfToken',
  15873. value: function csrfToken() {
  15874. var selector = void 0;
  15875. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15876. return window['Laravel'].csrfToken;
  15877. } else if (this.options.csrfToken) {
  15878. return this.options.csrfToken;
  15879. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15880. return selector.getAttribute('content');
  15881. }
  15882. return null;
  15883. }
  15884. }]);
  15885. return Connector;
  15886. }();
  15887. /**
  15888. * This class represents a basic channel.
  15889. */
  15890. var Channel = function () {
  15891. function Channel() {
  15892. classCallCheck(this, Channel);
  15893. }
  15894. createClass(Channel, [{
  15895. key: 'listenForWhisper',
  15896. /**
  15897. * Listen for a whisper event on the channel instance.
  15898. */
  15899. value: function listenForWhisper(event, callback) {
  15900. return this.listen('.client-' + event, callback);
  15901. }
  15902. /**
  15903. * Listen for an event on the channel instance.
  15904. */
  15905. }, {
  15906. key: 'notification',
  15907. value: function notification(callback) {
  15908. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15909. }
  15910. /**
  15911. * Stop listening for a whispser event on the channel instance.
  15912. */
  15913. }, {
  15914. key: 'stopListeningForWhisper',
  15915. value: function stopListeningForWhisper(event) {
  15916. return this.stopListening('.client-' + event);
  15917. }
  15918. }]);
  15919. return Channel;
  15920. }();
  15921. /**
  15922. * Event name formatter
  15923. */
  15924. var EventFormatter = function () {
  15925. /**
  15926. * Create a new class instance.
  15927. */
  15928. function EventFormatter(namespace) {
  15929. classCallCheck(this, EventFormatter);
  15930. this.setNamespace(namespace);
  15931. }
  15932. /**
  15933. * Format the given event name.
  15934. */
  15935. createClass(EventFormatter, [{
  15936. key: 'format',
  15937. value: function format(event) {
  15938. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15939. return event.substr(1);
  15940. } else if (this.namespace) {
  15941. event = this.namespace + '.' + event;
  15942. }
  15943. return event.replace(/\./g, '\\');
  15944. }
  15945. /**
  15946. * Set the event namespace.
  15947. */
  15948. }, {
  15949. key: 'setNamespace',
  15950. value: function setNamespace(value) {
  15951. this.namespace = value;
  15952. }
  15953. }]);
  15954. return EventFormatter;
  15955. }();
  15956. /**
  15957. * This class represents a Pusher channel.
  15958. */
  15959. var PusherChannel = function (_Channel) {
  15960. inherits(PusherChannel, _Channel);
  15961. /**
  15962. * Create a new class instance.
  15963. */
  15964. function PusherChannel(pusher, name, options) {
  15965. classCallCheck(this, PusherChannel);
  15966. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15967. _this.name = name;
  15968. _this.pusher = pusher;
  15969. _this.options = options;
  15970. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15971. _this.subscribe();
  15972. return _this;
  15973. }
  15974. /**
  15975. * Subscribe to a Pusher channel.
  15976. */
  15977. createClass(PusherChannel, [{
  15978. key: 'subscribe',
  15979. value: function subscribe() {
  15980. this.subscription = this.pusher.subscribe(this.name);
  15981. }
  15982. /**
  15983. * Unsubscribe from a Pusher channel.
  15984. */
  15985. }, {
  15986. key: 'unsubscribe',
  15987. value: function unsubscribe() {
  15988. this.pusher.unsubscribe(this.name);
  15989. }
  15990. /**
  15991. * Listen for an event on the channel instance.
  15992. */
  15993. }, {
  15994. key: 'listen',
  15995. value: function listen(event, callback) {
  15996. this.on(this.eventFormatter.format(event), callback);
  15997. return this;
  15998. }
  15999. /**
  16000. * Stop listening for an event on the channel instance.
  16001. */
  16002. }, {
  16003. key: 'stopListening',
  16004. value: function stopListening(event) {
  16005. this.subscription.unbind(this.eventFormatter.format(event));
  16006. return this;
  16007. }
  16008. /**
  16009. * Bind a channel to an event.
  16010. */
  16011. }, {
  16012. key: 'on',
  16013. value: function on(event, callback) {
  16014. this.subscription.bind(event, callback);
  16015. return this;
  16016. }
  16017. }]);
  16018. return PusherChannel;
  16019. }(Channel);
  16020. /**
  16021. * This class represents a Pusher private channel.
  16022. */
  16023. var PusherPrivateChannel = function (_PusherChannel) {
  16024. inherits(PusherPrivateChannel, _PusherChannel);
  16025. function PusherPrivateChannel() {
  16026. classCallCheck(this, PusherPrivateChannel);
  16027. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16028. }
  16029. createClass(PusherPrivateChannel, [{
  16030. key: 'whisper',
  16031. /**
  16032. * Trigger client event on the channel.
  16033. */
  16034. value: function whisper(eventName, data) {
  16035. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16036. return this;
  16037. }
  16038. }]);
  16039. return PusherPrivateChannel;
  16040. }(PusherChannel);
  16041. /**
  16042. * This class represents a Pusher presence channel.
  16043. */
  16044. var PusherPresenceChannel = function (_PusherChannel) {
  16045. inherits(PusherPresenceChannel, _PusherChannel);
  16046. function PusherPresenceChannel() {
  16047. classCallCheck(this, PusherPresenceChannel);
  16048. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16049. }
  16050. createClass(PusherPresenceChannel, [{
  16051. key: 'here',
  16052. /**
  16053. * Register a callback to be called anytime the member list changes.
  16054. */
  16055. value: function here(callback) {
  16056. this.on('pusher:subscription_succeeded', function (data) {
  16057. callback(Object.keys(data.members).map(function (k) {
  16058. return data.members[k];
  16059. }));
  16060. });
  16061. return this;
  16062. }
  16063. /**
  16064. * Listen for someone joining the channel.
  16065. */
  16066. }, {
  16067. key: 'joining',
  16068. value: function joining(callback) {
  16069. this.on('pusher:member_added', function (member) {
  16070. callback(member.info);
  16071. });
  16072. return this;
  16073. }
  16074. /**
  16075. * Listen for someone leaving the channel.
  16076. */
  16077. }, {
  16078. key: 'leaving',
  16079. value: function leaving(callback) {
  16080. this.on('pusher:member_removed', function (member) {
  16081. callback(member.info);
  16082. });
  16083. return this;
  16084. }
  16085. /**
  16086. * Trigger client event on the channel.
  16087. */
  16088. }, {
  16089. key: 'whisper',
  16090. value: function whisper(eventName, data) {
  16091. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16092. return this;
  16093. }
  16094. }]);
  16095. return PusherPresenceChannel;
  16096. }(PusherChannel);
  16097. /**
  16098. * This class represents a Socket.io channel.
  16099. */
  16100. var SocketIoChannel = function (_Channel) {
  16101. inherits(SocketIoChannel, _Channel);
  16102. /**
  16103. * Create a new class instance.
  16104. */
  16105. function SocketIoChannel(socket, name, options) {
  16106. classCallCheck(this, SocketIoChannel);
  16107. /**
  16108. * The event callbacks applied to the channel.
  16109. */
  16110. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16111. _this.events = {};
  16112. _this.name = name;
  16113. _this.socket = socket;
  16114. _this.options = options;
  16115. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16116. _this.subscribe();
  16117. _this.configureReconnector();
  16118. return _this;
  16119. }
  16120. /**
  16121. * Subscribe to a Socket.io channel.
  16122. */
  16123. createClass(SocketIoChannel, [{
  16124. key: 'subscribe',
  16125. value: function subscribe() {
  16126. this.socket.emit('subscribe', {
  16127. channel: this.name,
  16128. auth: this.options.auth || {}
  16129. });
  16130. }
  16131. /**
  16132. * Unsubscribe from channel and ubind event callbacks.
  16133. */
  16134. }, {
  16135. key: 'unsubscribe',
  16136. value: function unsubscribe() {
  16137. this.unbind();
  16138. this.socket.emit('unsubscribe', {
  16139. channel: this.name,
  16140. auth: this.options.auth || {}
  16141. });
  16142. }
  16143. /**
  16144. * Listen for an event on the channel instance.
  16145. */
  16146. }, {
  16147. key: 'listen',
  16148. value: function listen(event, callback) {
  16149. this.on(this.eventFormatter.format(event), callback);
  16150. return this;
  16151. }
  16152. /**
  16153. * Stop listening for an event on the channel instance.
  16154. */
  16155. }, {
  16156. key: 'stopListening',
  16157. value: function stopListening(event) {
  16158. var name = this.eventFormatter.format(event);
  16159. this.socket.removeListener(name);
  16160. delete this.events[name];
  16161. return this;
  16162. }
  16163. /**
  16164. * Bind the channel's socket to an event and store the callback.
  16165. */
  16166. }, {
  16167. key: 'on',
  16168. value: function on(event, callback) {
  16169. var _this2 = this;
  16170. var listener = function listener(channel, data) {
  16171. if (_this2.name == channel) {
  16172. callback(data);
  16173. }
  16174. };
  16175. this.socket.on(event, listener);
  16176. this.bind(event, listener);
  16177. }
  16178. /**
  16179. * Attach a 'reconnect' listener and bind the event.
  16180. */
  16181. }, {
  16182. key: 'configureReconnector',
  16183. value: function configureReconnector() {
  16184. var _this3 = this;
  16185. var listener = function listener() {
  16186. _this3.subscribe();
  16187. };
  16188. this.socket.on('reconnect', listener);
  16189. this.bind('reconnect', listener);
  16190. }
  16191. /**
  16192. * Bind the channel's socket to an event and store the callback.
  16193. */
  16194. }, {
  16195. key: 'bind',
  16196. value: function bind(event, callback) {
  16197. this.events[event] = this.events[event] || [];
  16198. this.events[event].push(callback);
  16199. }
  16200. /**
  16201. * Unbind the channel's socket from all stored event callbacks.
  16202. */
  16203. }, {
  16204. key: 'unbind',
  16205. value: function unbind() {
  16206. var _this4 = this;
  16207. Object.keys(this.events).forEach(function (event) {
  16208. _this4.events[event].forEach(function (callback) {
  16209. _this4.socket.removeListener(event, callback);
  16210. });
  16211. delete _this4.events[event];
  16212. });
  16213. }
  16214. }]);
  16215. return SocketIoChannel;
  16216. }(Channel);
  16217. /**
  16218. * This class represents a Socket.io presence channel.
  16219. */
  16220. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16221. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16222. function SocketIoPrivateChannel() {
  16223. classCallCheck(this, SocketIoPrivateChannel);
  16224. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16225. }
  16226. createClass(SocketIoPrivateChannel, [{
  16227. key: 'whisper',
  16228. /**
  16229. * Trigger client event on the channel.
  16230. */
  16231. value: function whisper(eventName, data) {
  16232. this.socket.emit('client event', {
  16233. channel: this.name,
  16234. event: 'client-' + eventName,
  16235. data: data
  16236. });
  16237. return this;
  16238. }
  16239. }]);
  16240. return SocketIoPrivateChannel;
  16241. }(SocketIoChannel);
  16242. /**
  16243. * This class represents a Socket.io presence channel.
  16244. */
  16245. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16246. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16247. function SocketIoPresenceChannel() {
  16248. classCallCheck(this, SocketIoPresenceChannel);
  16249. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16250. }
  16251. createClass(SocketIoPresenceChannel, [{
  16252. key: 'here',
  16253. /**
  16254. * Register a callback to be called anytime the member list changes.
  16255. */
  16256. value: function here(callback) {
  16257. this.on('presence:subscribed', function (members) {
  16258. callback(members.map(function (m) {
  16259. return m.user_info;
  16260. }));
  16261. });
  16262. return this;
  16263. }
  16264. /**
  16265. * Listen for someone joining the channel.
  16266. */
  16267. }, {
  16268. key: 'joining',
  16269. value: function joining(callback) {
  16270. this.on('presence:joining', function (member) {
  16271. return callback(member.user_info);
  16272. });
  16273. return this;
  16274. }
  16275. /**
  16276. * Listen for someone leaving the channel.
  16277. */
  16278. }, {
  16279. key: 'leaving',
  16280. value: function leaving(callback) {
  16281. this.on('presence:leaving', function (member) {
  16282. return callback(member.user_info);
  16283. });
  16284. return this;
  16285. }
  16286. }]);
  16287. return SocketIoPresenceChannel;
  16288. }(SocketIoPrivateChannel);
  16289. /**
  16290. * This class represents a null channel.
  16291. */
  16292. var NullChannel = function (_Channel) {
  16293. inherits(NullChannel, _Channel);
  16294. function NullChannel() {
  16295. classCallCheck(this, NullChannel);
  16296. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16297. }
  16298. createClass(NullChannel, [{
  16299. key: 'subscribe',
  16300. /**
  16301. * Subscribe to a channel.
  16302. */
  16303. value: function subscribe() {}
  16304. //
  16305. /**
  16306. * Unsubscribe from a channel.
  16307. */
  16308. }, {
  16309. key: 'unsubscribe',
  16310. value: function unsubscribe() {}
  16311. //
  16312. /**
  16313. * Listen for an event on the channel instance.
  16314. */
  16315. }, {
  16316. key: 'listen',
  16317. value: function listen(event, callback) {
  16318. return this;
  16319. }
  16320. /**
  16321. * Stop listening for an event on the channel instance.
  16322. */
  16323. }, {
  16324. key: 'stopListening',
  16325. value: function stopListening(event) {
  16326. return this;
  16327. }
  16328. /**
  16329. * Bind a channel to an event.
  16330. */
  16331. }, {
  16332. key: 'on',
  16333. value: function on(event, callback) {
  16334. return this;
  16335. }
  16336. }]);
  16337. return NullChannel;
  16338. }(Channel);
  16339. /**
  16340. * This class represents a null private channel.
  16341. */
  16342. var NullPrivateChannel = function (_NullChannel) {
  16343. inherits(NullPrivateChannel, _NullChannel);
  16344. function NullPrivateChannel() {
  16345. classCallCheck(this, NullPrivateChannel);
  16346. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16347. }
  16348. createClass(NullPrivateChannel, [{
  16349. key: 'whisper',
  16350. /**
  16351. * Trigger client event on the channel.
  16352. */
  16353. value: function whisper(eventName, data) {
  16354. return this;
  16355. }
  16356. }]);
  16357. return NullPrivateChannel;
  16358. }(NullChannel);
  16359. /**
  16360. * This class represents a null presence channel.
  16361. */
  16362. var NullPresenceChannel = function (_NullChannel) {
  16363. inherits(NullPresenceChannel, _NullChannel);
  16364. function NullPresenceChannel() {
  16365. classCallCheck(this, NullPresenceChannel);
  16366. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16367. }
  16368. createClass(NullPresenceChannel, [{
  16369. key: 'here',
  16370. /**
  16371. * Register a callback to be called anytime the member list changes.
  16372. */
  16373. value: function here(callback) {
  16374. return this;
  16375. }
  16376. /**
  16377. * Listen for someone joining the channel.
  16378. */
  16379. }, {
  16380. key: 'joining',
  16381. value: function joining(callback) {
  16382. return this;
  16383. }
  16384. /**
  16385. * Listen for someone leaving the channel.
  16386. */
  16387. }, {
  16388. key: 'leaving',
  16389. value: function leaving(callback) {
  16390. return this;
  16391. }
  16392. /**
  16393. * Trigger client event on the channel.
  16394. */
  16395. }, {
  16396. key: 'whisper',
  16397. value: function whisper(eventName, data) {
  16398. return this;
  16399. }
  16400. }]);
  16401. return NullPresenceChannel;
  16402. }(NullChannel);
  16403. /**
  16404. * This class creates a connector to Pusher.
  16405. */
  16406. var PusherConnector = function (_Connector) {
  16407. inherits(PusherConnector, _Connector);
  16408. function PusherConnector() {
  16409. classCallCheck(this, PusherConnector);
  16410. /**
  16411. * All of the subscribed channel names.
  16412. */
  16413. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16414. _this.channels = {};
  16415. return _this;
  16416. }
  16417. /**
  16418. * Create a fresh Pusher connection.
  16419. */
  16420. createClass(PusherConnector, [{
  16421. key: 'connect',
  16422. value: function connect() {
  16423. if (typeof this.options.client !== 'undefined') {
  16424. this.pusher = this.options.client;
  16425. } else {
  16426. this.pusher = new Pusher(this.options.key, this.options);
  16427. }
  16428. }
  16429. /**
  16430. * Listen for an event on a channel instance.
  16431. */
  16432. }, {
  16433. key: 'listen',
  16434. value: function listen(name, event, callback) {
  16435. return this.channel(name).listen(event, callback);
  16436. }
  16437. /**
  16438. * Get a channel instance by name.
  16439. */
  16440. }, {
  16441. key: 'channel',
  16442. value: function channel(name) {
  16443. if (!this.channels[name]) {
  16444. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16445. }
  16446. return this.channels[name];
  16447. }
  16448. /**
  16449. * Get a private channel instance by name.
  16450. */
  16451. }, {
  16452. key: 'privateChannel',
  16453. value: function privateChannel(name) {
  16454. if (!this.channels['private-' + name]) {
  16455. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16456. }
  16457. return this.channels['private-' + name];
  16458. }
  16459. /**
  16460. * Get a presence channel instance by name.
  16461. */
  16462. }, {
  16463. key: 'presenceChannel',
  16464. value: function presenceChannel(name) {
  16465. if (!this.channels['presence-' + name]) {
  16466. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16467. }
  16468. return this.channels['presence-' + name];
  16469. }
  16470. /**
  16471. * Leave the given channel, as well as its private and presence variants.
  16472. */
  16473. }, {
  16474. key: 'leave',
  16475. value: function leave(name) {
  16476. var _this2 = this;
  16477. var channels = [name, 'private-' + name, 'presence-' + name];
  16478. channels.forEach(function (name, index) {
  16479. _this2.leaveChannel(name);
  16480. });
  16481. }
  16482. /**
  16483. * Leave the given channel.
  16484. */
  16485. }, {
  16486. key: 'leaveChannel',
  16487. value: function leaveChannel(name) {
  16488. if (this.channels[name]) {
  16489. this.channels[name].unsubscribe();
  16490. delete this.channels[name];
  16491. }
  16492. }
  16493. /**
  16494. * Get the socket ID for the connection.
  16495. */
  16496. }, {
  16497. key: 'socketId',
  16498. value: function socketId() {
  16499. return this.pusher.connection.socket_id;
  16500. }
  16501. /**
  16502. * Disconnect Pusher connection.
  16503. */
  16504. }, {
  16505. key: 'disconnect',
  16506. value: function disconnect() {
  16507. this.pusher.disconnect();
  16508. }
  16509. }]);
  16510. return PusherConnector;
  16511. }(Connector);
  16512. /**
  16513. * This class creates a connnector to a Socket.io server.
  16514. */
  16515. var SocketIoConnector = function (_Connector) {
  16516. inherits(SocketIoConnector, _Connector);
  16517. function SocketIoConnector() {
  16518. classCallCheck(this, SocketIoConnector);
  16519. /**
  16520. * All of the subscribed channel names.
  16521. */
  16522. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16523. _this.channels = {};
  16524. return _this;
  16525. }
  16526. /**
  16527. * Create a fresh Socket.io connection.
  16528. */
  16529. createClass(SocketIoConnector, [{
  16530. key: 'connect',
  16531. value: function connect() {
  16532. var io = this.getSocketIO();
  16533. this.socket = io(this.options.host, this.options);
  16534. return this.socket;
  16535. }
  16536. /**
  16537. * Get socket.io module from global scope or options.
  16538. */
  16539. }, {
  16540. key: 'getSocketIO',
  16541. value: function getSocketIO() {
  16542. if (typeof this.options.client !== 'undefined') {
  16543. return this.options.client;
  16544. }
  16545. if (typeof io !== 'undefined') {
  16546. return io;
  16547. }
  16548. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16549. }
  16550. /**
  16551. * Listen for an event on a channel instance.
  16552. */
  16553. }, {
  16554. key: 'listen',
  16555. value: function listen(name, event, callback) {
  16556. return this.channel(name).listen(event, callback);
  16557. }
  16558. /**
  16559. * Get a channel instance by name.
  16560. */
  16561. }, {
  16562. key: 'channel',
  16563. value: function channel(name) {
  16564. if (!this.channels[name]) {
  16565. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16566. }
  16567. return this.channels[name];
  16568. }
  16569. /**
  16570. * Get a private channel instance by name.
  16571. */
  16572. }, {
  16573. key: 'privateChannel',
  16574. value: function privateChannel(name) {
  16575. if (!this.channels['private-' + name]) {
  16576. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16577. }
  16578. return this.channels['private-' + name];
  16579. }
  16580. /**
  16581. * Get a presence channel instance by name.
  16582. */
  16583. }, {
  16584. key: 'presenceChannel',
  16585. value: function presenceChannel(name) {
  16586. if (!this.channels['presence-' + name]) {
  16587. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16588. }
  16589. return this.channels['presence-' + name];
  16590. }
  16591. /**
  16592. * Leave the given channel, as well as its private and presence variants.
  16593. */
  16594. }, {
  16595. key: 'leave',
  16596. value: function leave(name) {
  16597. var _this2 = this;
  16598. var channels = [name, 'private-' + name, 'presence-' + name];
  16599. channels.forEach(function (name) {
  16600. _this2.leaveChannel(name);
  16601. });
  16602. }
  16603. /**
  16604. * Leave the given channel.
  16605. */
  16606. }, {
  16607. key: 'leaveChannel',
  16608. value: function leaveChannel(name) {
  16609. if (this.channels[name]) {
  16610. this.channels[name].unsubscribe();
  16611. delete this.channels[name];
  16612. }
  16613. }
  16614. /**
  16615. * Get the socket ID for the connection.
  16616. */
  16617. }, {
  16618. key: 'socketId',
  16619. value: function socketId() {
  16620. return this.socket.id;
  16621. }
  16622. /**
  16623. * Disconnect Socketio connection.
  16624. */
  16625. }, {
  16626. key: 'disconnect',
  16627. value: function disconnect() {
  16628. this.socket.disconnect();
  16629. }
  16630. }]);
  16631. return SocketIoConnector;
  16632. }(Connector);
  16633. /**
  16634. * This class creates a null connector.
  16635. */
  16636. var NullConnector = function (_Connector) {
  16637. inherits(NullConnector, _Connector);
  16638. function NullConnector() {
  16639. classCallCheck(this, NullConnector);
  16640. /**
  16641. * All of the subscribed channel names.
  16642. */
  16643. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16644. _this.channels = {};
  16645. return _this;
  16646. }
  16647. /**
  16648. * Create a fresh connection.
  16649. */
  16650. createClass(NullConnector, [{
  16651. key: 'connect',
  16652. value: function connect() {}
  16653. //
  16654. /**
  16655. * Listen for an event on a channel instance.
  16656. */
  16657. }, {
  16658. key: 'listen',
  16659. value: function listen(name, event, callback) {
  16660. return new NullChannel();
  16661. }
  16662. /**
  16663. * Get a channel instance by name.
  16664. */
  16665. }, {
  16666. key: 'channel',
  16667. value: function channel(name) {
  16668. return new NullChannel();
  16669. }
  16670. /**
  16671. * Get a private channel instance by name.
  16672. */
  16673. }, {
  16674. key: 'privateChannel',
  16675. value: function privateChannel(name) {
  16676. return new NullPrivateChannel();
  16677. }
  16678. /**
  16679. * Get a presence channel instance by name.
  16680. */
  16681. }, {
  16682. key: 'presenceChannel',
  16683. value: function presenceChannel(name) {
  16684. return new NullPresenceChannel();
  16685. }
  16686. /**
  16687. * Leave the given channel, as well as its private and presence variants.
  16688. */
  16689. }, {
  16690. key: 'leave',
  16691. value: function leave(name) {}
  16692. //
  16693. /**
  16694. * Leave the given channel.
  16695. */
  16696. }, {
  16697. key: 'leaveChannel',
  16698. value: function leaveChannel(name) {}
  16699. //
  16700. /**
  16701. * Get the socket ID for the connection.
  16702. */
  16703. }, {
  16704. key: 'socketId',
  16705. value: function socketId() {
  16706. return 'fake-socket-id';
  16707. }
  16708. /**
  16709. * Disconnect the connection.
  16710. */
  16711. }, {
  16712. key: 'disconnect',
  16713. value: function disconnect() {
  16714. //
  16715. }
  16716. }]);
  16717. return NullConnector;
  16718. }(Connector);
  16719. /**
  16720. * This class is the primary API for interacting with broadcasting.
  16721. */
  16722. var Echo = function () {
  16723. /**
  16724. * Create a new class instance.
  16725. */
  16726. function Echo(options) {
  16727. classCallCheck(this, Echo);
  16728. this.options = options;
  16729. this.connect();
  16730. if (!this.options.withoutInterceptors) {
  16731. this.registerInterceptors();
  16732. }
  16733. }
  16734. /**
  16735. * Get a channel instance by name.
  16736. */
  16737. createClass(Echo, [{
  16738. key: 'channel',
  16739. value: function channel(_channel) {
  16740. return this.connector.channel(_channel);
  16741. }
  16742. /**
  16743. * Create a new connection.
  16744. */
  16745. }, {
  16746. key: 'connect',
  16747. value: function connect() {
  16748. if (this.options.broadcaster == 'pusher') {
  16749. this.connector = new PusherConnector(this.options);
  16750. } else if (this.options.broadcaster == 'socket.io') {
  16751. this.connector = new SocketIoConnector(this.options);
  16752. } else if (this.options.broadcaster == 'null') {
  16753. this.connector = new NullConnector(this.options);
  16754. } else if (typeof this.options.broadcaster == 'function') {
  16755. this.connector = new this.options.broadcaster(this.options);
  16756. }
  16757. }
  16758. /**
  16759. * Disconnect from the Echo server.
  16760. */
  16761. }, {
  16762. key: 'disconnect',
  16763. value: function disconnect() {
  16764. this.connector.disconnect();
  16765. }
  16766. /**
  16767. * Get a presence channel instance by name.
  16768. */
  16769. }, {
  16770. key: 'join',
  16771. value: function join(channel) {
  16772. return this.connector.presenceChannel(channel);
  16773. }
  16774. /**
  16775. * Leave the given channel, as well as its private and presence variants.
  16776. */
  16777. }, {
  16778. key: 'leave',
  16779. value: function leave(channel) {
  16780. this.connector.leave(channel);
  16781. }
  16782. /**
  16783. * Leave the given channel.
  16784. */
  16785. }, {
  16786. key: 'leaveChannel',
  16787. value: function leaveChannel(channel) {
  16788. this.connector.leaveChannel(channel);
  16789. }
  16790. /**
  16791. * Listen for an event on a channel instance.
  16792. */
  16793. }, {
  16794. key: 'listen',
  16795. value: function listen(channel, event, callback) {
  16796. return this.connector.listen(channel, event, callback);
  16797. }
  16798. /**
  16799. * Get a private channel instance by name.
  16800. */
  16801. }, {
  16802. key: 'private',
  16803. value: function _private(channel) {
  16804. return this.connector.privateChannel(channel);
  16805. }
  16806. /**
  16807. * Get the Socket ID for the connection.
  16808. */
  16809. }, {
  16810. key: 'socketId',
  16811. value: function socketId() {
  16812. return this.connector.socketId();
  16813. }
  16814. /**
  16815. * Register 3rd party request interceptiors. These are used to automatically
  16816. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16817. */
  16818. }, {
  16819. key: 'registerInterceptors',
  16820. value: function registerInterceptors() {
  16821. if (typeof Vue === 'function' && Vue.http) {
  16822. this.registerVueRequestInterceptor();
  16823. }
  16824. if (typeof axios === 'function') {
  16825. this.registerAxiosRequestInterceptor();
  16826. }
  16827. if (typeof jQuery === 'function') {
  16828. this.registerjQueryAjaxSetup();
  16829. }
  16830. }
  16831. /**
  16832. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16833. */
  16834. }, {
  16835. key: 'registerVueRequestInterceptor',
  16836. value: function registerVueRequestInterceptor() {
  16837. var _this = this;
  16838. Vue.http.interceptors.push(function (request, next) {
  16839. if (_this.socketId()) {
  16840. request.headers.set('X-Socket-ID', _this.socketId());
  16841. }
  16842. next();
  16843. });
  16844. }
  16845. /**
  16846. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16847. */
  16848. }, {
  16849. key: 'registerAxiosRequestInterceptor',
  16850. value: function registerAxiosRequestInterceptor() {
  16851. var _this2 = this;
  16852. axios.interceptors.request.use(function (config) {
  16853. if (_this2.socketId()) {
  16854. config.headers['X-Socket-Id'] = _this2.socketId();
  16855. }
  16856. return config;
  16857. });
  16858. }
  16859. /**
  16860. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16861. */
  16862. }, {
  16863. key: 'registerjQueryAjaxSetup',
  16864. value: function registerjQueryAjaxSetup() {
  16865. var _this3 = this;
  16866. if (typeof jQuery.ajax != 'undefined') {
  16867. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16868. if (_this3.socketId()) {
  16869. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16870. }
  16871. });
  16872. }
  16873. }
  16874. }]);
  16875. return Echo;
  16876. }();
  16877. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16878. /***/ }),
  16879. /***/ "./node_modules/lodash/lodash.js":
  16880. /*!***************************************!*\
  16881. !*** ./node_modules/lodash/lodash.js ***!
  16882. \***************************************/
  16883. /*! no static exports found */
  16884. /***/ (function(module, exports, __webpack_require__) {
  16885. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16886. * @license
  16887. * Lodash <https://lodash.com/>
  16888. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16889. * Released under MIT license <https://lodash.com/license>
  16890. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16891. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16892. */
  16893. ;(function() {
  16894. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16895. var undefined;
  16896. /** Used as the semantic version number. */
  16897. var VERSION = '4.17.15';
  16898. /** Used as the size to enable large array optimizations. */
  16899. var LARGE_ARRAY_SIZE = 200;
  16900. /** Error message constants. */
  16901. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16902. FUNC_ERROR_TEXT = 'Expected a function';
  16903. /** Used to stand-in for `undefined` hash values. */
  16904. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16905. /** Used as the maximum memoize cache size. */
  16906. var MAX_MEMOIZE_SIZE = 500;
  16907. /** Used as the internal argument placeholder. */
  16908. var PLACEHOLDER = '__lodash_placeholder__';
  16909. /** Used to compose bitmasks for cloning. */
  16910. var CLONE_DEEP_FLAG = 1,
  16911. CLONE_FLAT_FLAG = 2,
  16912. CLONE_SYMBOLS_FLAG = 4;
  16913. /** Used to compose bitmasks for value comparisons. */
  16914. var COMPARE_PARTIAL_FLAG = 1,
  16915. COMPARE_UNORDERED_FLAG = 2;
  16916. /** Used to compose bitmasks for function metadata. */
  16917. var WRAP_BIND_FLAG = 1,
  16918. WRAP_BIND_KEY_FLAG = 2,
  16919. WRAP_CURRY_BOUND_FLAG = 4,
  16920. WRAP_CURRY_FLAG = 8,
  16921. WRAP_CURRY_RIGHT_FLAG = 16,
  16922. WRAP_PARTIAL_FLAG = 32,
  16923. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16924. WRAP_ARY_FLAG = 128,
  16925. WRAP_REARG_FLAG = 256,
  16926. WRAP_FLIP_FLAG = 512;
  16927. /** Used as default options for `_.truncate`. */
  16928. var DEFAULT_TRUNC_LENGTH = 30,
  16929. DEFAULT_TRUNC_OMISSION = '...';
  16930. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16931. var HOT_COUNT = 800,
  16932. HOT_SPAN = 16;
  16933. /** Used to indicate the type of lazy iteratees. */
  16934. var LAZY_FILTER_FLAG = 1,
  16935. LAZY_MAP_FLAG = 2,
  16936. LAZY_WHILE_FLAG = 3;
  16937. /** Used as references for various `Number` constants. */
  16938. var INFINITY = 1 / 0,
  16939. MAX_SAFE_INTEGER = 9007199254740991,
  16940. MAX_INTEGER = 1.7976931348623157e+308,
  16941. NAN = 0 / 0;
  16942. /** Used as references for the maximum length and index of an array. */
  16943. var MAX_ARRAY_LENGTH = 4294967295,
  16944. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16945. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16946. /** Used to associate wrap methods with their bit flags. */
  16947. var wrapFlags = [
  16948. ['ary', WRAP_ARY_FLAG],
  16949. ['bind', WRAP_BIND_FLAG],
  16950. ['bindKey', WRAP_BIND_KEY_FLAG],
  16951. ['curry', WRAP_CURRY_FLAG],
  16952. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16953. ['flip', WRAP_FLIP_FLAG],
  16954. ['partial', WRAP_PARTIAL_FLAG],
  16955. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16956. ['rearg', WRAP_REARG_FLAG]
  16957. ];
  16958. /** `Object#toString` result references. */
  16959. var argsTag = '[object Arguments]',
  16960. arrayTag = '[object Array]',
  16961. asyncTag = '[object AsyncFunction]',
  16962. boolTag = '[object Boolean]',
  16963. dateTag = '[object Date]',
  16964. domExcTag = '[object DOMException]',
  16965. errorTag = '[object Error]',
  16966. funcTag = '[object Function]',
  16967. genTag = '[object GeneratorFunction]',
  16968. mapTag = '[object Map]',
  16969. numberTag = '[object Number]',
  16970. nullTag = '[object Null]',
  16971. objectTag = '[object Object]',
  16972. promiseTag = '[object Promise]',
  16973. proxyTag = '[object Proxy]',
  16974. regexpTag = '[object RegExp]',
  16975. setTag = '[object Set]',
  16976. stringTag = '[object String]',
  16977. symbolTag = '[object Symbol]',
  16978. undefinedTag = '[object Undefined]',
  16979. weakMapTag = '[object WeakMap]',
  16980. weakSetTag = '[object WeakSet]';
  16981. var arrayBufferTag = '[object ArrayBuffer]',
  16982. dataViewTag = '[object DataView]',
  16983. float32Tag = '[object Float32Array]',
  16984. float64Tag = '[object Float64Array]',
  16985. int8Tag = '[object Int8Array]',
  16986. int16Tag = '[object Int16Array]',
  16987. int32Tag = '[object Int32Array]',
  16988. uint8Tag = '[object Uint8Array]',
  16989. uint8ClampedTag = '[object Uint8ClampedArray]',
  16990. uint16Tag = '[object Uint16Array]',
  16991. uint32Tag = '[object Uint32Array]';
  16992. /** Used to match empty string literals in compiled template source. */
  16993. var reEmptyStringLeading = /\b__p \+= '';/g,
  16994. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16995. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16996. /** Used to match HTML entities and HTML characters. */
  16997. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16998. reUnescapedHtml = /[&<>"']/g,
  16999. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17000. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17001. /** Used to match template delimiters. */
  17002. var reEscape = /<%-([\s\S]+?)%>/g,
  17003. reEvaluate = /<%([\s\S]+?)%>/g,
  17004. reInterpolate = /<%=([\s\S]+?)%>/g;
  17005. /** Used to match property names within property paths. */
  17006. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17007. reIsPlainProp = /^\w*$/,
  17008. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17009. /**
  17010. * Used to match `RegExp`
  17011. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17012. */
  17013. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17014. reHasRegExpChar = RegExp(reRegExpChar.source);
  17015. /** Used to match leading and trailing whitespace. */
  17016. var reTrim = /^\s+|\s+$/g,
  17017. reTrimStart = /^\s+/,
  17018. reTrimEnd = /\s+$/;
  17019. /** Used to match wrap detail comments. */
  17020. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17021. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17022. reSplitDetails = /,? & /;
  17023. /** Used to match words composed of alphanumeric characters. */
  17024. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17025. /** Used to match backslashes in property paths. */
  17026. var reEscapeChar = /\\(\\)?/g;
  17027. /**
  17028. * Used to match
  17029. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17030. */
  17031. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17032. /** Used to match `RegExp` flags from their coerced string values. */
  17033. var reFlags = /\w*$/;
  17034. /** Used to detect bad signed hexadecimal string values. */
  17035. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17036. /** Used to detect binary string values. */
  17037. var reIsBinary = /^0b[01]+$/i;
  17038. /** Used to detect host constructors (Safari). */
  17039. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17040. /** Used to detect octal string values. */
  17041. var reIsOctal = /^0o[0-7]+$/i;
  17042. /** Used to detect unsigned integer values. */
  17043. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17044. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17045. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17046. /** Used to ensure capturing order of template delimiters. */
  17047. var reNoMatch = /($^)/;
  17048. /** Used to match unescaped characters in compiled string literals. */
  17049. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17050. /** Used to compose unicode character classes. */
  17051. var rsAstralRange = '\\ud800-\\udfff',
  17052. rsComboMarksRange = '\\u0300-\\u036f',
  17053. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17054. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17055. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17056. rsDingbatRange = '\\u2700-\\u27bf',
  17057. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17058. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17059. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17060. rsPunctuationRange = '\\u2000-\\u206f',
  17061. 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',
  17062. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17063. rsVarRange = '\\ufe0e\\ufe0f',
  17064. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17065. /** Used to compose unicode capture groups. */
  17066. var rsApos = "['\u2019]",
  17067. rsAstral = '[' + rsAstralRange + ']',
  17068. rsBreak = '[' + rsBreakRange + ']',
  17069. rsCombo = '[' + rsComboRange + ']',
  17070. rsDigits = '\\d+',
  17071. rsDingbat = '[' + rsDingbatRange + ']',
  17072. rsLower = '[' + rsLowerRange + ']',
  17073. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17074. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17075. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17076. rsNonAstral = '[^' + rsAstralRange + ']',
  17077. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17078. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17079. rsUpper = '[' + rsUpperRange + ']',
  17080. rsZWJ = '\\u200d';
  17081. /** Used to compose unicode regexes. */
  17082. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17083. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17084. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17085. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17086. reOptMod = rsModifier + '?',
  17087. rsOptVar = '[' + rsVarRange + ']?',
  17088. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17089. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17090. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17091. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17092. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17093. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17094. /** Used to match apostrophes. */
  17095. var reApos = RegExp(rsApos, 'g');
  17096. /**
  17097. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17098. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17099. */
  17100. var reComboMark = RegExp(rsCombo, 'g');
  17101. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17102. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17103. /** Used to match complex or compound words. */
  17104. var reUnicodeWord = RegExp([
  17105. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17106. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17107. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17108. rsUpper + '+' + rsOptContrUpper,
  17109. rsOrdUpper,
  17110. rsOrdLower,
  17111. rsDigits,
  17112. rsEmoji
  17113. ].join('|'), 'g');
  17114. /** 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/). */
  17115. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17116. /** Used to detect strings that need a more robust regexp to match words. */
  17117. 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 ]/;
  17118. /** Used to assign default `context` object properties. */
  17119. var contextProps = [
  17120. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17121. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17122. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17123. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17124. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17125. ];
  17126. /** Used to make template sourceURLs easier to identify. */
  17127. var templateCounter = -1;
  17128. /** Used to identify `toStringTag` values of typed arrays. */
  17129. var typedArrayTags = {};
  17130. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17131. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17132. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17133. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17134. typedArrayTags[uint32Tag] = true;
  17135. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17136. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17137. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17138. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17139. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17140. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17141. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17142. typedArrayTags[weakMapTag] = false;
  17143. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17144. var cloneableTags = {};
  17145. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17146. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17147. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17148. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17149. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17150. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17151. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17152. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17153. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17154. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17155. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17156. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17157. cloneableTags[weakMapTag] = false;
  17158. /** Used to map Latin Unicode letters to basic Latin letters. */
  17159. var deburredLetters = {
  17160. // Latin-1 Supplement block.
  17161. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17162. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17163. '\xc7': 'C', '\xe7': 'c',
  17164. '\xd0': 'D', '\xf0': 'd',
  17165. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17166. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17167. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17168. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17169. '\xd1': 'N', '\xf1': 'n',
  17170. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17171. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17172. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17173. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17174. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17175. '\xc6': 'Ae', '\xe6': 'ae',
  17176. '\xde': 'Th', '\xfe': 'th',
  17177. '\xdf': 'ss',
  17178. // Latin Extended-A block.
  17179. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17180. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17181. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17182. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17183. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17184. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17185. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17186. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17187. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17188. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17189. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17190. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17191. '\u0134': 'J', '\u0135': 'j',
  17192. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17193. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17194. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17195. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17196. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17197. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17198. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17199. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17200. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17201. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17202. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17203. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17204. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17205. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17206. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17207. '\u0174': 'W', '\u0175': 'w',
  17208. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17209. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17210. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17211. '\u0132': 'IJ', '\u0133': 'ij',
  17212. '\u0152': 'Oe', '\u0153': 'oe',
  17213. '\u0149': "'n", '\u017f': 's'
  17214. };
  17215. /** Used to map characters to HTML entities. */
  17216. var htmlEscapes = {
  17217. '&': '&amp;',
  17218. '<': '&lt;',
  17219. '>': '&gt;',
  17220. '"': '&quot;',
  17221. "'": '&#39;'
  17222. };
  17223. /** Used to map HTML entities to characters. */
  17224. var htmlUnescapes = {
  17225. '&amp;': '&',
  17226. '&lt;': '<',
  17227. '&gt;': '>',
  17228. '&quot;': '"',
  17229. '&#39;': "'"
  17230. };
  17231. /** Used to escape characters for inclusion in compiled string literals. */
  17232. var stringEscapes = {
  17233. '\\': '\\',
  17234. "'": "'",
  17235. '\n': 'n',
  17236. '\r': 'r',
  17237. '\u2028': 'u2028',
  17238. '\u2029': 'u2029'
  17239. };
  17240. /** Built-in method references without a dependency on `root`. */
  17241. var freeParseFloat = parseFloat,
  17242. freeParseInt = parseInt;
  17243. /** Detect free variable `global` from Node.js. */
  17244. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17245. /** Detect free variable `self`. */
  17246. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17247. /** Used as a reference to the global object. */
  17248. var root = freeGlobal || freeSelf || Function('return this')();
  17249. /** Detect free variable `exports`. */
  17250. var freeExports = true && exports && !exports.nodeType && exports;
  17251. /** Detect free variable `module`. */
  17252. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17253. /** Detect the popular CommonJS extension `module.exports`. */
  17254. var moduleExports = freeModule && freeModule.exports === freeExports;
  17255. /** Detect free variable `process` from Node.js. */
  17256. var freeProcess = moduleExports && freeGlobal.process;
  17257. /** Used to access faster Node.js helpers. */
  17258. var nodeUtil = (function() {
  17259. try {
  17260. // Use `util.types` for Node.js 10+.
  17261. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17262. if (types) {
  17263. return types;
  17264. }
  17265. // Legacy `process.binding('util')` for Node.js < 10.
  17266. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17267. } catch (e) {}
  17268. }());
  17269. /* Node.js helper references. */
  17270. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17271. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17272. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17273. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17274. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17275. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17276. /*--------------------------------------------------------------------------*/
  17277. /**
  17278. * A faster alternative to `Function#apply`, this function invokes `func`
  17279. * with the `this` binding of `thisArg` and the arguments of `args`.
  17280. *
  17281. * @private
  17282. * @param {Function} func The function to invoke.
  17283. * @param {*} thisArg The `this` binding of `func`.
  17284. * @param {Array} args The arguments to invoke `func` with.
  17285. * @returns {*} Returns the result of `func`.
  17286. */
  17287. function apply(func, thisArg, args) {
  17288. switch (args.length) {
  17289. case 0: return func.call(thisArg);
  17290. case 1: return func.call(thisArg, args[0]);
  17291. case 2: return func.call(thisArg, args[0], args[1]);
  17292. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17293. }
  17294. return func.apply(thisArg, args);
  17295. }
  17296. /**
  17297. * A specialized version of `baseAggregator` for arrays.
  17298. *
  17299. * @private
  17300. * @param {Array} [array] The array to iterate over.
  17301. * @param {Function} setter The function to set `accumulator` values.
  17302. * @param {Function} iteratee The iteratee to transform keys.
  17303. * @param {Object} accumulator The initial aggregated object.
  17304. * @returns {Function} Returns `accumulator`.
  17305. */
  17306. function arrayAggregator(array, setter, iteratee, accumulator) {
  17307. var index = -1,
  17308. length = array == null ? 0 : array.length;
  17309. while (++index < length) {
  17310. var value = array[index];
  17311. setter(accumulator, value, iteratee(value), array);
  17312. }
  17313. return accumulator;
  17314. }
  17315. /**
  17316. * A specialized version of `_.forEach` for arrays without support for
  17317. * iteratee shorthands.
  17318. *
  17319. * @private
  17320. * @param {Array} [array] The array to iterate over.
  17321. * @param {Function} iteratee The function invoked per iteration.
  17322. * @returns {Array} Returns `array`.
  17323. */
  17324. function arrayEach(array, iteratee) {
  17325. var index = -1,
  17326. length = array == null ? 0 : array.length;
  17327. while (++index < length) {
  17328. if (iteratee(array[index], index, array) === false) {
  17329. break;
  17330. }
  17331. }
  17332. return array;
  17333. }
  17334. /**
  17335. * A specialized version of `_.forEachRight` for arrays without support for
  17336. * iteratee shorthands.
  17337. *
  17338. * @private
  17339. * @param {Array} [array] The array to iterate over.
  17340. * @param {Function} iteratee The function invoked per iteration.
  17341. * @returns {Array} Returns `array`.
  17342. */
  17343. function arrayEachRight(array, iteratee) {
  17344. var length = array == null ? 0 : array.length;
  17345. while (length--) {
  17346. if (iteratee(array[length], length, array) === false) {
  17347. break;
  17348. }
  17349. }
  17350. return array;
  17351. }
  17352. /**
  17353. * A specialized version of `_.every` for arrays without support for
  17354. * iteratee shorthands.
  17355. *
  17356. * @private
  17357. * @param {Array} [array] The array to iterate over.
  17358. * @param {Function} predicate The function invoked per iteration.
  17359. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17360. * else `false`.
  17361. */
  17362. function arrayEvery(array, predicate) {
  17363. var index = -1,
  17364. length = array == null ? 0 : array.length;
  17365. while (++index < length) {
  17366. if (!predicate(array[index], index, array)) {
  17367. return false;
  17368. }
  17369. }
  17370. return true;
  17371. }
  17372. /**
  17373. * A specialized version of `_.filter` for arrays without support for
  17374. * iteratee shorthands.
  17375. *
  17376. * @private
  17377. * @param {Array} [array] The array to iterate over.
  17378. * @param {Function} predicate The function invoked per iteration.
  17379. * @returns {Array} Returns the new filtered array.
  17380. */
  17381. function arrayFilter(array, predicate) {
  17382. var index = -1,
  17383. length = array == null ? 0 : array.length,
  17384. resIndex = 0,
  17385. result = [];
  17386. while (++index < length) {
  17387. var value = array[index];
  17388. if (predicate(value, index, array)) {
  17389. result[resIndex++] = value;
  17390. }
  17391. }
  17392. return result;
  17393. }
  17394. /**
  17395. * A specialized version of `_.includes` for arrays without support for
  17396. * specifying an index to search from.
  17397. *
  17398. * @private
  17399. * @param {Array} [array] The array to inspect.
  17400. * @param {*} target The value to search for.
  17401. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17402. */
  17403. function arrayIncludes(array, value) {
  17404. var length = array == null ? 0 : array.length;
  17405. return !!length && baseIndexOf(array, value, 0) > -1;
  17406. }
  17407. /**
  17408. * This function is like `arrayIncludes` except that it accepts a comparator.
  17409. *
  17410. * @private
  17411. * @param {Array} [array] The array to inspect.
  17412. * @param {*} target The value to search for.
  17413. * @param {Function} comparator The comparator invoked per element.
  17414. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17415. */
  17416. function arrayIncludesWith(array, value, comparator) {
  17417. var index = -1,
  17418. length = array == null ? 0 : array.length;
  17419. while (++index < length) {
  17420. if (comparator(value, array[index])) {
  17421. return true;
  17422. }
  17423. }
  17424. return false;
  17425. }
  17426. /**
  17427. * A specialized version of `_.map` for arrays without support for iteratee
  17428. * shorthands.
  17429. *
  17430. * @private
  17431. * @param {Array} [array] The array to iterate over.
  17432. * @param {Function} iteratee The function invoked per iteration.
  17433. * @returns {Array} Returns the new mapped array.
  17434. */
  17435. function arrayMap(array, iteratee) {
  17436. var index = -1,
  17437. length = array == null ? 0 : array.length,
  17438. result = Array(length);
  17439. while (++index < length) {
  17440. result[index] = iteratee(array[index], index, array);
  17441. }
  17442. return result;
  17443. }
  17444. /**
  17445. * Appends the elements of `values` to `array`.
  17446. *
  17447. * @private
  17448. * @param {Array} array The array to modify.
  17449. * @param {Array} values The values to append.
  17450. * @returns {Array} Returns `array`.
  17451. */
  17452. function arrayPush(array, values) {
  17453. var index = -1,
  17454. length = values.length,
  17455. offset = array.length;
  17456. while (++index < length) {
  17457. array[offset + index] = values[index];
  17458. }
  17459. return array;
  17460. }
  17461. /**
  17462. * A specialized version of `_.reduce` for arrays without support for
  17463. * iteratee shorthands.
  17464. *
  17465. * @private
  17466. * @param {Array} [array] The array to iterate over.
  17467. * @param {Function} iteratee The function invoked per iteration.
  17468. * @param {*} [accumulator] The initial value.
  17469. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17470. * the initial value.
  17471. * @returns {*} Returns the accumulated value.
  17472. */
  17473. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17474. var index = -1,
  17475. length = array == null ? 0 : array.length;
  17476. if (initAccum && length) {
  17477. accumulator = array[++index];
  17478. }
  17479. while (++index < length) {
  17480. accumulator = iteratee(accumulator, array[index], index, array);
  17481. }
  17482. return accumulator;
  17483. }
  17484. /**
  17485. * A specialized version of `_.reduceRight` for arrays without support for
  17486. * iteratee shorthands.
  17487. *
  17488. * @private
  17489. * @param {Array} [array] The array to iterate over.
  17490. * @param {Function} iteratee The function invoked per iteration.
  17491. * @param {*} [accumulator] The initial value.
  17492. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17493. * the initial value.
  17494. * @returns {*} Returns the accumulated value.
  17495. */
  17496. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17497. var length = array == null ? 0 : array.length;
  17498. if (initAccum && length) {
  17499. accumulator = array[--length];
  17500. }
  17501. while (length--) {
  17502. accumulator = iteratee(accumulator, array[length], length, array);
  17503. }
  17504. return accumulator;
  17505. }
  17506. /**
  17507. * A specialized version of `_.some` for arrays without support for iteratee
  17508. * shorthands.
  17509. *
  17510. * @private
  17511. * @param {Array} [array] The array to iterate over.
  17512. * @param {Function} predicate The function invoked per iteration.
  17513. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17514. * else `false`.
  17515. */
  17516. function arraySome(array, predicate) {
  17517. var index = -1,
  17518. length = array == null ? 0 : array.length;
  17519. while (++index < length) {
  17520. if (predicate(array[index], index, array)) {
  17521. return true;
  17522. }
  17523. }
  17524. return false;
  17525. }
  17526. /**
  17527. * Gets the size of an ASCII `string`.
  17528. *
  17529. * @private
  17530. * @param {string} string The string inspect.
  17531. * @returns {number} Returns the string size.
  17532. */
  17533. var asciiSize = baseProperty('length');
  17534. /**
  17535. * Converts an ASCII `string` to an array.
  17536. *
  17537. * @private
  17538. * @param {string} string The string to convert.
  17539. * @returns {Array} Returns the converted array.
  17540. */
  17541. function asciiToArray(string) {
  17542. return string.split('');
  17543. }
  17544. /**
  17545. * Splits an ASCII `string` into an array of its words.
  17546. *
  17547. * @private
  17548. * @param {string} The string to inspect.
  17549. * @returns {Array} Returns the words of `string`.
  17550. */
  17551. function asciiWords(string) {
  17552. return string.match(reAsciiWord) || [];
  17553. }
  17554. /**
  17555. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17556. * without support for iteratee shorthands, which iterates over `collection`
  17557. * using `eachFunc`.
  17558. *
  17559. * @private
  17560. * @param {Array|Object} collection The collection to inspect.
  17561. * @param {Function} predicate The function invoked per iteration.
  17562. * @param {Function} eachFunc The function to iterate over `collection`.
  17563. * @returns {*} Returns the found element or its key, else `undefined`.
  17564. */
  17565. function baseFindKey(collection, predicate, eachFunc) {
  17566. var result;
  17567. eachFunc(collection, function(value, key, collection) {
  17568. if (predicate(value, key, collection)) {
  17569. result = key;
  17570. return false;
  17571. }
  17572. });
  17573. return result;
  17574. }
  17575. /**
  17576. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17577. * support for iteratee shorthands.
  17578. *
  17579. * @private
  17580. * @param {Array} array The array to inspect.
  17581. * @param {Function} predicate The function invoked per iteration.
  17582. * @param {number} fromIndex The index to search from.
  17583. * @param {boolean} [fromRight] Specify iterating from right to left.
  17584. * @returns {number} Returns the index of the matched value, else `-1`.
  17585. */
  17586. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17587. var length = array.length,
  17588. index = fromIndex + (fromRight ? 1 : -1);
  17589. while ((fromRight ? index-- : ++index < length)) {
  17590. if (predicate(array[index], index, array)) {
  17591. return index;
  17592. }
  17593. }
  17594. return -1;
  17595. }
  17596. /**
  17597. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17598. *
  17599. * @private
  17600. * @param {Array} array The array to inspect.
  17601. * @param {*} value The value to search for.
  17602. * @param {number} fromIndex The index to search from.
  17603. * @returns {number} Returns the index of the matched value, else `-1`.
  17604. */
  17605. function baseIndexOf(array, value, fromIndex) {
  17606. return value === value
  17607. ? strictIndexOf(array, value, fromIndex)
  17608. : baseFindIndex(array, baseIsNaN, fromIndex);
  17609. }
  17610. /**
  17611. * This function is like `baseIndexOf` except that it accepts a comparator.
  17612. *
  17613. * @private
  17614. * @param {Array} array The array to inspect.
  17615. * @param {*} value The value to search for.
  17616. * @param {number} fromIndex The index to search from.
  17617. * @param {Function} comparator The comparator invoked per element.
  17618. * @returns {number} Returns the index of the matched value, else `-1`.
  17619. */
  17620. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17621. var index = fromIndex - 1,
  17622. length = array.length;
  17623. while (++index < length) {
  17624. if (comparator(array[index], value)) {
  17625. return index;
  17626. }
  17627. }
  17628. return -1;
  17629. }
  17630. /**
  17631. * The base implementation of `_.isNaN` without support for number objects.
  17632. *
  17633. * @private
  17634. * @param {*} value The value to check.
  17635. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17636. */
  17637. function baseIsNaN(value) {
  17638. return value !== value;
  17639. }
  17640. /**
  17641. * The base implementation of `_.mean` and `_.meanBy` without support for
  17642. * iteratee shorthands.
  17643. *
  17644. * @private
  17645. * @param {Array} array The array to iterate over.
  17646. * @param {Function} iteratee The function invoked per iteration.
  17647. * @returns {number} Returns the mean.
  17648. */
  17649. function baseMean(array, iteratee) {
  17650. var length = array == null ? 0 : array.length;
  17651. return length ? (baseSum(array, iteratee) / length) : NAN;
  17652. }
  17653. /**
  17654. * The base implementation of `_.property` without support for deep paths.
  17655. *
  17656. * @private
  17657. * @param {string} key The key of the property to get.
  17658. * @returns {Function} Returns the new accessor function.
  17659. */
  17660. function baseProperty(key) {
  17661. return function(object) {
  17662. return object == null ? undefined : object[key];
  17663. };
  17664. }
  17665. /**
  17666. * The base implementation of `_.propertyOf` without support for deep paths.
  17667. *
  17668. * @private
  17669. * @param {Object} object The object to query.
  17670. * @returns {Function} Returns the new accessor function.
  17671. */
  17672. function basePropertyOf(object) {
  17673. return function(key) {
  17674. return object == null ? undefined : object[key];
  17675. };
  17676. }
  17677. /**
  17678. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17679. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17680. *
  17681. * @private
  17682. * @param {Array|Object} collection The collection to iterate over.
  17683. * @param {Function} iteratee The function invoked per iteration.
  17684. * @param {*} accumulator The initial value.
  17685. * @param {boolean} initAccum Specify using the first or last element of
  17686. * `collection` as the initial value.
  17687. * @param {Function} eachFunc The function to iterate over `collection`.
  17688. * @returns {*} Returns the accumulated value.
  17689. */
  17690. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17691. eachFunc(collection, function(value, index, collection) {
  17692. accumulator = initAccum
  17693. ? (initAccum = false, value)
  17694. : iteratee(accumulator, value, index, collection);
  17695. });
  17696. return accumulator;
  17697. }
  17698. /**
  17699. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17700. * sort order of `array` and replaces criteria objects with their corresponding
  17701. * values.
  17702. *
  17703. * @private
  17704. * @param {Array} array The array to sort.
  17705. * @param {Function} comparer The function to define sort order.
  17706. * @returns {Array} Returns `array`.
  17707. */
  17708. function baseSortBy(array, comparer) {
  17709. var length = array.length;
  17710. array.sort(comparer);
  17711. while (length--) {
  17712. array[length] = array[length].value;
  17713. }
  17714. return array;
  17715. }
  17716. /**
  17717. * The base implementation of `_.sum` and `_.sumBy` without support for
  17718. * iteratee shorthands.
  17719. *
  17720. * @private
  17721. * @param {Array} array The array to iterate over.
  17722. * @param {Function} iteratee The function invoked per iteration.
  17723. * @returns {number} Returns the sum.
  17724. */
  17725. function baseSum(array, iteratee) {
  17726. var result,
  17727. index = -1,
  17728. length = array.length;
  17729. while (++index < length) {
  17730. var current = iteratee(array[index]);
  17731. if (current !== undefined) {
  17732. result = result === undefined ? current : (result + current);
  17733. }
  17734. }
  17735. return result;
  17736. }
  17737. /**
  17738. * The base implementation of `_.times` without support for iteratee shorthands
  17739. * or max array length checks.
  17740. *
  17741. * @private
  17742. * @param {number} n The number of times to invoke `iteratee`.
  17743. * @param {Function} iteratee The function invoked per iteration.
  17744. * @returns {Array} Returns the array of results.
  17745. */
  17746. function baseTimes(n, iteratee) {
  17747. var index = -1,
  17748. result = Array(n);
  17749. while (++index < n) {
  17750. result[index] = iteratee(index);
  17751. }
  17752. return result;
  17753. }
  17754. /**
  17755. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17756. * of key-value pairs for `object` corresponding to the property names of `props`.
  17757. *
  17758. * @private
  17759. * @param {Object} object The object to query.
  17760. * @param {Array} props The property names to get values for.
  17761. * @returns {Object} Returns the key-value pairs.
  17762. */
  17763. function baseToPairs(object, props) {
  17764. return arrayMap(props, function(key) {
  17765. return [key, object[key]];
  17766. });
  17767. }
  17768. /**
  17769. * The base implementation of `_.unary` without support for storing metadata.
  17770. *
  17771. * @private
  17772. * @param {Function} func The function to cap arguments for.
  17773. * @returns {Function} Returns the new capped function.
  17774. */
  17775. function baseUnary(func) {
  17776. return function(value) {
  17777. return func(value);
  17778. };
  17779. }
  17780. /**
  17781. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17782. * array of `object` property values corresponding to the property names
  17783. * of `props`.
  17784. *
  17785. * @private
  17786. * @param {Object} object The object to query.
  17787. * @param {Array} props The property names to get values for.
  17788. * @returns {Object} Returns the array of property values.
  17789. */
  17790. function baseValues(object, props) {
  17791. return arrayMap(props, function(key) {
  17792. return object[key];
  17793. });
  17794. }
  17795. /**
  17796. * Checks if a `cache` value for `key` exists.
  17797. *
  17798. * @private
  17799. * @param {Object} cache The cache to query.
  17800. * @param {string} key The key of the entry to check.
  17801. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17802. */
  17803. function cacheHas(cache, key) {
  17804. return cache.has(key);
  17805. }
  17806. /**
  17807. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17808. * that is not found in the character symbols.
  17809. *
  17810. * @private
  17811. * @param {Array} strSymbols The string symbols to inspect.
  17812. * @param {Array} chrSymbols The character symbols to find.
  17813. * @returns {number} Returns the index of the first unmatched string symbol.
  17814. */
  17815. function charsStartIndex(strSymbols, chrSymbols) {
  17816. var index = -1,
  17817. length = strSymbols.length;
  17818. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17819. return index;
  17820. }
  17821. /**
  17822. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17823. * that is not found in the character symbols.
  17824. *
  17825. * @private
  17826. * @param {Array} strSymbols The string symbols to inspect.
  17827. * @param {Array} chrSymbols The character symbols to find.
  17828. * @returns {number} Returns the index of the last unmatched string symbol.
  17829. */
  17830. function charsEndIndex(strSymbols, chrSymbols) {
  17831. var index = strSymbols.length;
  17832. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17833. return index;
  17834. }
  17835. /**
  17836. * Gets the number of `placeholder` occurrences in `array`.
  17837. *
  17838. * @private
  17839. * @param {Array} array The array to inspect.
  17840. * @param {*} placeholder The placeholder to search for.
  17841. * @returns {number} Returns the placeholder count.
  17842. */
  17843. function countHolders(array, placeholder) {
  17844. var length = array.length,
  17845. result = 0;
  17846. while (length--) {
  17847. if (array[length] === placeholder) {
  17848. ++result;
  17849. }
  17850. }
  17851. return result;
  17852. }
  17853. /**
  17854. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17855. * letters to basic Latin letters.
  17856. *
  17857. * @private
  17858. * @param {string} letter The matched letter to deburr.
  17859. * @returns {string} Returns the deburred letter.
  17860. */
  17861. var deburrLetter = basePropertyOf(deburredLetters);
  17862. /**
  17863. * Used by `_.escape` to convert characters to HTML entities.
  17864. *
  17865. * @private
  17866. * @param {string} chr The matched character to escape.
  17867. * @returns {string} Returns the escaped character.
  17868. */
  17869. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17870. /**
  17871. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17872. *
  17873. * @private
  17874. * @param {string} chr The matched character to escape.
  17875. * @returns {string} Returns the escaped character.
  17876. */
  17877. function escapeStringChar(chr) {
  17878. return '\\' + stringEscapes[chr];
  17879. }
  17880. /**
  17881. * Gets the value at `key` of `object`.
  17882. *
  17883. * @private
  17884. * @param {Object} [object] The object to query.
  17885. * @param {string} key The key of the property to get.
  17886. * @returns {*} Returns the property value.
  17887. */
  17888. function getValue(object, key) {
  17889. return object == null ? undefined : object[key];
  17890. }
  17891. /**
  17892. * Checks if `string` contains Unicode symbols.
  17893. *
  17894. * @private
  17895. * @param {string} string The string to inspect.
  17896. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17897. */
  17898. function hasUnicode(string) {
  17899. return reHasUnicode.test(string);
  17900. }
  17901. /**
  17902. * Checks if `string` contains a word composed of Unicode symbols.
  17903. *
  17904. * @private
  17905. * @param {string} string The string to inspect.
  17906. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17907. */
  17908. function hasUnicodeWord(string) {
  17909. return reHasUnicodeWord.test(string);
  17910. }
  17911. /**
  17912. * Converts `iterator` to an array.
  17913. *
  17914. * @private
  17915. * @param {Object} iterator The iterator to convert.
  17916. * @returns {Array} Returns the converted array.
  17917. */
  17918. function iteratorToArray(iterator) {
  17919. var data,
  17920. result = [];
  17921. while (!(data = iterator.next()).done) {
  17922. result.push(data.value);
  17923. }
  17924. return result;
  17925. }
  17926. /**
  17927. * Converts `map` to its key-value pairs.
  17928. *
  17929. * @private
  17930. * @param {Object} map The map to convert.
  17931. * @returns {Array} Returns the key-value pairs.
  17932. */
  17933. function mapToArray(map) {
  17934. var index = -1,
  17935. result = Array(map.size);
  17936. map.forEach(function(value, key) {
  17937. result[++index] = [key, value];
  17938. });
  17939. return result;
  17940. }
  17941. /**
  17942. * Creates a unary function that invokes `func` with its argument transformed.
  17943. *
  17944. * @private
  17945. * @param {Function} func The function to wrap.
  17946. * @param {Function} transform The argument transform.
  17947. * @returns {Function} Returns the new function.
  17948. */
  17949. function overArg(func, transform) {
  17950. return function(arg) {
  17951. return func(transform(arg));
  17952. };
  17953. }
  17954. /**
  17955. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17956. * and returns an array of their indexes.
  17957. *
  17958. * @private
  17959. * @param {Array} array The array to modify.
  17960. * @param {*} placeholder The placeholder to replace.
  17961. * @returns {Array} Returns the new array of placeholder indexes.
  17962. */
  17963. function replaceHolders(array, placeholder) {
  17964. var index = -1,
  17965. length = array.length,
  17966. resIndex = 0,
  17967. result = [];
  17968. while (++index < length) {
  17969. var value = array[index];
  17970. if (value === placeholder || value === PLACEHOLDER) {
  17971. array[index] = PLACEHOLDER;
  17972. result[resIndex++] = index;
  17973. }
  17974. }
  17975. return result;
  17976. }
  17977. /**
  17978. * Converts `set` to an array of its values.
  17979. *
  17980. * @private
  17981. * @param {Object} set The set to convert.
  17982. * @returns {Array} Returns the values.
  17983. */
  17984. function setToArray(set) {
  17985. var index = -1,
  17986. result = Array(set.size);
  17987. set.forEach(function(value) {
  17988. result[++index] = value;
  17989. });
  17990. return result;
  17991. }
  17992. /**
  17993. * Converts `set` to its value-value pairs.
  17994. *
  17995. * @private
  17996. * @param {Object} set The set to convert.
  17997. * @returns {Array} Returns the value-value pairs.
  17998. */
  17999. function setToPairs(set) {
  18000. var index = -1,
  18001. result = Array(set.size);
  18002. set.forEach(function(value) {
  18003. result[++index] = [value, value];
  18004. });
  18005. return result;
  18006. }
  18007. /**
  18008. * A specialized version of `_.indexOf` which performs strict equality
  18009. * comparisons of values, i.e. `===`.
  18010. *
  18011. * @private
  18012. * @param {Array} array The array to inspect.
  18013. * @param {*} value The value to search for.
  18014. * @param {number} fromIndex The index to search from.
  18015. * @returns {number} Returns the index of the matched value, else `-1`.
  18016. */
  18017. function strictIndexOf(array, value, fromIndex) {
  18018. var index = fromIndex - 1,
  18019. length = array.length;
  18020. while (++index < length) {
  18021. if (array[index] === value) {
  18022. return index;
  18023. }
  18024. }
  18025. return -1;
  18026. }
  18027. /**
  18028. * A specialized version of `_.lastIndexOf` which performs strict equality
  18029. * comparisons of values, i.e. `===`.
  18030. *
  18031. * @private
  18032. * @param {Array} array The array to inspect.
  18033. * @param {*} value The value to search for.
  18034. * @param {number} fromIndex The index to search from.
  18035. * @returns {number} Returns the index of the matched value, else `-1`.
  18036. */
  18037. function strictLastIndexOf(array, value, fromIndex) {
  18038. var index = fromIndex + 1;
  18039. while (index--) {
  18040. if (array[index] === value) {
  18041. return index;
  18042. }
  18043. }
  18044. return index;
  18045. }
  18046. /**
  18047. * Gets the number of symbols in `string`.
  18048. *
  18049. * @private
  18050. * @param {string} string The string to inspect.
  18051. * @returns {number} Returns the string size.
  18052. */
  18053. function stringSize(string) {
  18054. return hasUnicode(string)
  18055. ? unicodeSize(string)
  18056. : asciiSize(string);
  18057. }
  18058. /**
  18059. * Converts `string` to an array.
  18060. *
  18061. * @private
  18062. * @param {string} string The string to convert.
  18063. * @returns {Array} Returns the converted array.
  18064. */
  18065. function stringToArray(string) {
  18066. return hasUnicode(string)
  18067. ? unicodeToArray(string)
  18068. : asciiToArray(string);
  18069. }
  18070. /**
  18071. * Used by `_.unescape` to convert HTML entities to characters.
  18072. *
  18073. * @private
  18074. * @param {string} chr The matched character to unescape.
  18075. * @returns {string} Returns the unescaped character.
  18076. */
  18077. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18078. /**
  18079. * Gets the size of a Unicode `string`.
  18080. *
  18081. * @private
  18082. * @param {string} string The string inspect.
  18083. * @returns {number} Returns the string size.
  18084. */
  18085. function unicodeSize(string) {
  18086. var result = reUnicode.lastIndex = 0;
  18087. while (reUnicode.test(string)) {
  18088. ++result;
  18089. }
  18090. return result;
  18091. }
  18092. /**
  18093. * Converts a Unicode `string` to an array.
  18094. *
  18095. * @private
  18096. * @param {string} string The string to convert.
  18097. * @returns {Array} Returns the converted array.
  18098. */
  18099. function unicodeToArray(string) {
  18100. return string.match(reUnicode) || [];
  18101. }
  18102. /**
  18103. * Splits a Unicode `string` into an array of its words.
  18104. *
  18105. * @private
  18106. * @param {string} The string to inspect.
  18107. * @returns {Array} Returns the words of `string`.
  18108. */
  18109. function unicodeWords(string) {
  18110. return string.match(reUnicodeWord) || [];
  18111. }
  18112. /*--------------------------------------------------------------------------*/
  18113. /**
  18114. * Create a new pristine `lodash` function using the `context` object.
  18115. *
  18116. * @static
  18117. * @memberOf _
  18118. * @since 1.1.0
  18119. * @category Util
  18120. * @param {Object} [context=root] The context object.
  18121. * @returns {Function} Returns a new `lodash` function.
  18122. * @example
  18123. *
  18124. * _.mixin({ 'foo': _.constant('foo') });
  18125. *
  18126. * var lodash = _.runInContext();
  18127. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18128. *
  18129. * _.isFunction(_.foo);
  18130. * // => true
  18131. * _.isFunction(_.bar);
  18132. * // => false
  18133. *
  18134. * lodash.isFunction(lodash.foo);
  18135. * // => false
  18136. * lodash.isFunction(lodash.bar);
  18137. * // => true
  18138. *
  18139. * // Create a suped-up `defer` in Node.js.
  18140. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18141. */
  18142. var runInContext = (function runInContext(context) {
  18143. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18144. /** Built-in constructor references. */
  18145. var Array = context.Array,
  18146. Date = context.Date,
  18147. Error = context.Error,
  18148. Function = context.Function,
  18149. Math = context.Math,
  18150. Object = context.Object,
  18151. RegExp = context.RegExp,
  18152. String = context.String,
  18153. TypeError = context.TypeError;
  18154. /** Used for built-in method references. */
  18155. var arrayProto = Array.prototype,
  18156. funcProto = Function.prototype,
  18157. objectProto = Object.prototype;
  18158. /** Used to detect overreaching core-js shims. */
  18159. var coreJsData = context['__core-js_shared__'];
  18160. /** Used to resolve the decompiled source of functions. */
  18161. var funcToString = funcProto.toString;
  18162. /** Used to check objects for own properties. */
  18163. var hasOwnProperty = objectProto.hasOwnProperty;
  18164. /** Used to generate unique IDs. */
  18165. var idCounter = 0;
  18166. /** Used to detect methods masquerading as native. */
  18167. var maskSrcKey = (function() {
  18168. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18169. return uid ? ('Symbol(src)_1.' + uid) : '';
  18170. }());
  18171. /**
  18172. * Used to resolve the
  18173. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18174. * of values.
  18175. */
  18176. var nativeObjectToString = objectProto.toString;
  18177. /** Used to infer the `Object` constructor. */
  18178. var objectCtorString = funcToString.call(Object);
  18179. /** Used to restore the original `_` reference in `_.noConflict`. */
  18180. var oldDash = root._;
  18181. /** Used to detect if a method is native. */
  18182. var reIsNative = RegExp('^' +
  18183. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18184. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18185. );
  18186. /** Built-in value references. */
  18187. var Buffer = moduleExports ? context.Buffer : undefined,
  18188. Symbol = context.Symbol,
  18189. Uint8Array = context.Uint8Array,
  18190. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18191. getPrototype = overArg(Object.getPrototypeOf, Object),
  18192. objectCreate = Object.create,
  18193. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18194. splice = arrayProto.splice,
  18195. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18196. symIterator = Symbol ? Symbol.iterator : undefined,
  18197. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18198. var defineProperty = (function() {
  18199. try {
  18200. var func = getNative(Object, 'defineProperty');
  18201. func({}, '', {});
  18202. return func;
  18203. } catch (e) {}
  18204. }());
  18205. /** Mocked built-ins. */
  18206. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18207. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18208. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18209. /* Built-in method references for those with the same name as other `lodash` methods. */
  18210. var nativeCeil = Math.ceil,
  18211. nativeFloor = Math.floor,
  18212. nativeGetSymbols = Object.getOwnPropertySymbols,
  18213. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18214. nativeIsFinite = context.isFinite,
  18215. nativeJoin = arrayProto.join,
  18216. nativeKeys = overArg(Object.keys, Object),
  18217. nativeMax = Math.max,
  18218. nativeMin = Math.min,
  18219. nativeNow = Date.now,
  18220. nativeParseInt = context.parseInt,
  18221. nativeRandom = Math.random,
  18222. nativeReverse = arrayProto.reverse;
  18223. /* Built-in method references that are verified to be native. */
  18224. var DataView = getNative(context, 'DataView'),
  18225. Map = getNative(context, 'Map'),
  18226. Promise = getNative(context, 'Promise'),
  18227. Set = getNative(context, 'Set'),
  18228. WeakMap = getNative(context, 'WeakMap'),
  18229. nativeCreate = getNative(Object, 'create');
  18230. /** Used to store function metadata. */
  18231. var metaMap = WeakMap && new WeakMap;
  18232. /** Used to lookup unminified function names. */
  18233. var realNames = {};
  18234. /** Used to detect maps, sets, and weakmaps. */
  18235. var dataViewCtorString = toSource(DataView),
  18236. mapCtorString = toSource(Map),
  18237. promiseCtorString = toSource(Promise),
  18238. setCtorString = toSource(Set),
  18239. weakMapCtorString = toSource(WeakMap);
  18240. /** Used to convert symbols to primitives and strings. */
  18241. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18242. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18243. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18244. /*------------------------------------------------------------------------*/
  18245. /**
  18246. * Creates a `lodash` object which wraps `value` to enable implicit method
  18247. * chain sequences. Methods that operate on and return arrays, collections,
  18248. * and functions can be chained together. Methods that retrieve a single value
  18249. * or may return a primitive value will automatically end the chain sequence
  18250. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18251. * with `_#value`.
  18252. *
  18253. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18254. * enabled using `_.chain`.
  18255. *
  18256. * The execution of chained methods is lazy, that is, it's deferred until
  18257. * `_#value` is implicitly or explicitly called.
  18258. *
  18259. * Lazy evaluation allows several methods to support shortcut fusion.
  18260. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18261. * the creation of intermediate arrays and can greatly reduce the number of
  18262. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18263. * fusion if the section is applied to an array and iteratees accept only
  18264. * one argument. The heuristic for whether a section qualifies for shortcut
  18265. * fusion is subject to change.
  18266. *
  18267. * Chaining is supported in custom builds as long as the `_#value` method is
  18268. * directly or indirectly included in the build.
  18269. *
  18270. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18271. *
  18272. * The wrapper `Array` methods are:
  18273. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18274. *
  18275. * The wrapper `String` methods are:
  18276. * `replace` and `split`
  18277. *
  18278. * The wrapper methods that support shortcut fusion are:
  18279. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18280. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18281. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18282. *
  18283. * The chainable wrapper methods are:
  18284. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18285. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18286. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18287. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18288. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18289. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18290. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18291. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18292. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18293. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18294. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18295. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18296. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18297. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18298. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18299. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18300. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18301. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18302. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18303. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18304. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18305. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18306. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18307. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18308. *
  18309. * The wrapper methods that are **not** chainable by default are:
  18310. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18311. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18312. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18313. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18314. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18315. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18316. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18317. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18318. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18319. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18320. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18321. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18322. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18323. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18324. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18325. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18326. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18327. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18328. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18329. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18330. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18331. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18332. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18333. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18334. * `upperFirst`, `value`, and `words`
  18335. *
  18336. * @name _
  18337. * @constructor
  18338. * @category Seq
  18339. * @param {*} value The value to wrap in a `lodash` instance.
  18340. * @returns {Object} Returns the new `lodash` wrapper instance.
  18341. * @example
  18342. *
  18343. * function square(n) {
  18344. * return n * n;
  18345. * }
  18346. *
  18347. * var wrapped = _([1, 2, 3]);
  18348. *
  18349. * // Returns an unwrapped value.
  18350. * wrapped.reduce(_.add);
  18351. * // => 6
  18352. *
  18353. * // Returns a wrapped value.
  18354. * var squares = wrapped.map(square);
  18355. *
  18356. * _.isArray(squares);
  18357. * // => false
  18358. *
  18359. * _.isArray(squares.value());
  18360. * // => true
  18361. */
  18362. function lodash(value) {
  18363. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18364. if (value instanceof LodashWrapper) {
  18365. return value;
  18366. }
  18367. if (hasOwnProperty.call(value, '__wrapped__')) {
  18368. return wrapperClone(value);
  18369. }
  18370. }
  18371. return new LodashWrapper(value);
  18372. }
  18373. /**
  18374. * The base implementation of `_.create` without support for assigning
  18375. * properties to the created object.
  18376. *
  18377. * @private
  18378. * @param {Object} proto The object to inherit from.
  18379. * @returns {Object} Returns the new object.
  18380. */
  18381. var baseCreate = (function() {
  18382. function object() {}
  18383. return function(proto) {
  18384. if (!isObject(proto)) {
  18385. return {};
  18386. }
  18387. if (objectCreate) {
  18388. return objectCreate(proto);
  18389. }
  18390. object.prototype = proto;
  18391. var result = new object;
  18392. object.prototype = undefined;
  18393. return result;
  18394. };
  18395. }());
  18396. /**
  18397. * The function whose prototype chain sequence wrappers inherit from.
  18398. *
  18399. * @private
  18400. */
  18401. function baseLodash() {
  18402. // No operation performed.
  18403. }
  18404. /**
  18405. * The base constructor for creating `lodash` wrapper objects.
  18406. *
  18407. * @private
  18408. * @param {*} value The value to wrap.
  18409. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18410. */
  18411. function LodashWrapper(value, chainAll) {
  18412. this.__wrapped__ = value;
  18413. this.__actions__ = [];
  18414. this.__chain__ = !!chainAll;
  18415. this.__index__ = 0;
  18416. this.__values__ = undefined;
  18417. }
  18418. /**
  18419. * By default, the template delimiters used by lodash are like those in
  18420. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18421. * following template settings to use alternative delimiters.
  18422. *
  18423. * @static
  18424. * @memberOf _
  18425. * @type {Object}
  18426. */
  18427. lodash.templateSettings = {
  18428. /**
  18429. * Used to detect `data` property values to be HTML-escaped.
  18430. *
  18431. * @memberOf _.templateSettings
  18432. * @type {RegExp}
  18433. */
  18434. 'escape': reEscape,
  18435. /**
  18436. * Used to detect code to be evaluated.
  18437. *
  18438. * @memberOf _.templateSettings
  18439. * @type {RegExp}
  18440. */
  18441. 'evaluate': reEvaluate,
  18442. /**
  18443. * Used to detect `data` property values to inject.
  18444. *
  18445. * @memberOf _.templateSettings
  18446. * @type {RegExp}
  18447. */
  18448. 'interpolate': reInterpolate,
  18449. /**
  18450. * Used to reference the data object in the template text.
  18451. *
  18452. * @memberOf _.templateSettings
  18453. * @type {string}
  18454. */
  18455. 'variable': '',
  18456. /**
  18457. * Used to import variables into the compiled template.
  18458. *
  18459. * @memberOf _.templateSettings
  18460. * @type {Object}
  18461. */
  18462. 'imports': {
  18463. /**
  18464. * A reference to the `lodash` function.
  18465. *
  18466. * @memberOf _.templateSettings.imports
  18467. * @type {Function}
  18468. */
  18469. '_': lodash
  18470. }
  18471. };
  18472. // Ensure wrappers are instances of `baseLodash`.
  18473. lodash.prototype = baseLodash.prototype;
  18474. lodash.prototype.constructor = lodash;
  18475. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18476. LodashWrapper.prototype.constructor = LodashWrapper;
  18477. /*------------------------------------------------------------------------*/
  18478. /**
  18479. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18480. *
  18481. * @private
  18482. * @constructor
  18483. * @param {*} value The value to wrap.
  18484. */
  18485. function LazyWrapper(value) {
  18486. this.__wrapped__ = value;
  18487. this.__actions__ = [];
  18488. this.__dir__ = 1;
  18489. this.__filtered__ = false;
  18490. this.__iteratees__ = [];
  18491. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18492. this.__views__ = [];
  18493. }
  18494. /**
  18495. * Creates a clone of the lazy wrapper object.
  18496. *
  18497. * @private
  18498. * @name clone
  18499. * @memberOf LazyWrapper
  18500. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18501. */
  18502. function lazyClone() {
  18503. var result = new LazyWrapper(this.__wrapped__);
  18504. result.__actions__ = copyArray(this.__actions__);
  18505. result.__dir__ = this.__dir__;
  18506. result.__filtered__ = this.__filtered__;
  18507. result.__iteratees__ = copyArray(this.__iteratees__);
  18508. result.__takeCount__ = this.__takeCount__;
  18509. result.__views__ = copyArray(this.__views__);
  18510. return result;
  18511. }
  18512. /**
  18513. * Reverses the direction of lazy iteration.
  18514. *
  18515. * @private
  18516. * @name reverse
  18517. * @memberOf LazyWrapper
  18518. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18519. */
  18520. function lazyReverse() {
  18521. if (this.__filtered__) {
  18522. var result = new LazyWrapper(this);
  18523. result.__dir__ = -1;
  18524. result.__filtered__ = true;
  18525. } else {
  18526. result = this.clone();
  18527. result.__dir__ *= -1;
  18528. }
  18529. return result;
  18530. }
  18531. /**
  18532. * Extracts the unwrapped value from its lazy wrapper.
  18533. *
  18534. * @private
  18535. * @name value
  18536. * @memberOf LazyWrapper
  18537. * @returns {*} Returns the unwrapped value.
  18538. */
  18539. function lazyValue() {
  18540. var array = this.__wrapped__.value(),
  18541. dir = this.__dir__,
  18542. isArr = isArray(array),
  18543. isRight = dir < 0,
  18544. arrLength = isArr ? array.length : 0,
  18545. view = getView(0, arrLength, this.__views__),
  18546. start = view.start,
  18547. end = view.end,
  18548. length = end - start,
  18549. index = isRight ? end : (start - 1),
  18550. iteratees = this.__iteratees__,
  18551. iterLength = iteratees.length,
  18552. resIndex = 0,
  18553. takeCount = nativeMin(length, this.__takeCount__);
  18554. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18555. return baseWrapperValue(array, this.__actions__);
  18556. }
  18557. var result = [];
  18558. outer:
  18559. while (length-- && resIndex < takeCount) {
  18560. index += dir;
  18561. var iterIndex = -1,
  18562. value = array[index];
  18563. while (++iterIndex < iterLength) {
  18564. var data = iteratees[iterIndex],
  18565. iteratee = data.iteratee,
  18566. type = data.type,
  18567. computed = iteratee(value);
  18568. if (type == LAZY_MAP_FLAG) {
  18569. value = computed;
  18570. } else if (!computed) {
  18571. if (type == LAZY_FILTER_FLAG) {
  18572. continue outer;
  18573. } else {
  18574. break outer;
  18575. }
  18576. }
  18577. }
  18578. result[resIndex++] = value;
  18579. }
  18580. return result;
  18581. }
  18582. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18583. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18584. LazyWrapper.prototype.constructor = LazyWrapper;
  18585. /*------------------------------------------------------------------------*/
  18586. /**
  18587. * Creates a hash object.
  18588. *
  18589. * @private
  18590. * @constructor
  18591. * @param {Array} [entries] The key-value pairs to cache.
  18592. */
  18593. function Hash(entries) {
  18594. var index = -1,
  18595. length = entries == null ? 0 : entries.length;
  18596. this.clear();
  18597. while (++index < length) {
  18598. var entry = entries[index];
  18599. this.set(entry[0], entry[1]);
  18600. }
  18601. }
  18602. /**
  18603. * Removes all key-value entries from the hash.
  18604. *
  18605. * @private
  18606. * @name clear
  18607. * @memberOf Hash
  18608. */
  18609. function hashClear() {
  18610. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18611. this.size = 0;
  18612. }
  18613. /**
  18614. * Removes `key` and its value from the hash.
  18615. *
  18616. * @private
  18617. * @name delete
  18618. * @memberOf Hash
  18619. * @param {Object} hash The hash to modify.
  18620. * @param {string} key The key of the value to remove.
  18621. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18622. */
  18623. function hashDelete(key) {
  18624. var result = this.has(key) && delete this.__data__[key];
  18625. this.size -= result ? 1 : 0;
  18626. return result;
  18627. }
  18628. /**
  18629. * Gets the hash value for `key`.
  18630. *
  18631. * @private
  18632. * @name get
  18633. * @memberOf Hash
  18634. * @param {string} key The key of the value to get.
  18635. * @returns {*} Returns the entry value.
  18636. */
  18637. function hashGet(key) {
  18638. var data = this.__data__;
  18639. if (nativeCreate) {
  18640. var result = data[key];
  18641. return result === HASH_UNDEFINED ? undefined : result;
  18642. }
  18643. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18644. }
  18645. /**
  18646. * Checks if a hash value for `key` exists.
  18647. *
  18648. * @private
  18649. * @name has
  18650. * @memberOf Hash
  18651. * @param {string} key The key of the entry to check.
  18652. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18653. */
  18654. function hashHas(key) {
  18655. var data = this.__data__;
  18656. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18657. }
  18658. /**
  18659. * Sets the hash `key` to `value`.
  18660. *
  18661. * @private
  18662. * @name set
  18663. * @memberOf Hash
  18664. * @param {string} key The key of the value to set.
  18665. * @param {*} value The value to set.
  18666. * @returns {Object} Returns the hash instance.
  18667. */
  18668. function hashSet(key, value) {
  18669. var data = this.__data__;
  18670. this.size += this.has(key) ? 0 : 1;
  18671. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18672. return this;
  18673. }
  18674. // Add methods to `Hash`.
  18675. Hash.prototype.clear = hashClear;
  18676. Hash.prototype['delete'] = hashDelete;
  18677. Hash.prototype.get = hashGet;
  18678. Hash.prototype.has = hashHas;
  18679. Hash.prototype.set = hashSet;
  18680. /*------------------------------------------------------------------------*/
  18681. /**
  18682. * Creates an list cache object.
  18683. *
  18684. * @private
  18685. * @constructor
  18686. * @param {Array} [entries] The key-value pairs to cache.
  18687. */
  18688. function ListCache(entries) {
  18689. var index = -1,
  18690. length = entries == null ? 0 : entries.length;
  18691. this.clear();
  18692. while (++index < length) {
  18693. var entry = entries[index];
  18694. this.set(entry[0], entry[1]);
  18695. }
  18696. }
  18697. /**
  18698. * Removes all key-value entries from the list cache.
  18699. *
  18700. * @private
  18701. * @name clear
  18702. * @memberOf ListCache
  18703. */
  18704. function listCacheClear() {
  18705. this.__data__ = [];
  18706. this.size = 0;
  18707. }
  18708. /**
  18709. * Removes `key` and its value from the list cache.
  18710. *
  18711. * @private
  18712. * @name delete
  18713. * @memberOf ListCache
  18714. * @param {string} key The key of the value to remove.
  18715. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18716. */
  18717. function listCacheDelete(key) {
  18718. var data = this.__data__,
  18719. index = assocIndexOf(data, key);
  18720. if (index < 0) {
  18721. return false;
  18722. }
  18723. var lastIndex = data.length - 1;
  18724. if (index == lastIndex) {
  18725. data.pop();
  18726. } else {
  18727. splice.call(data, index, 1);
  18728. }
  18729. --this.size;
  18730. return true;
  18731. }
  18732. /**
  18733. * Gets the list cache value for `key`.
  18734. *
  18735. * @private
  18736. * @name get
  18737. * @memberOf ListCache
  18738. * @param {string} key The key of the value to get.
  18739. * @returns {*} Returns the entry value.
  18740. */
  18741. function listCacheGet(key) {
  18742. var data = this.__data__,
  18743. index = assocIndexOf(data, key);
  18744. return index < 0 ? undefined : data[index][1];
  18745. }
  18746. /**
  18747. * Checks if a list cache value for `key` exists.
  18748. *
  18749. * @private
  18750. * @name has
  18751. * @memberOf ListCache
  18752. * @param {string} key The key of the entry to check.
  18753. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18754. */
  18755. function listCacheHas(key) {
  18756. return assocIndexOf(this.__data__, key) > -1;
  18757. }
  18758. /**
  18759. * Sets the list cache `key` to `value`.
  18760. *
  18761. * @private
  18762. * @name set
  18763. * @memberOf ListCache
  18764. * @param {string} key The key of the value to set.
  18765. * @param {*} value The value to set.
  18766. * @returns {Object} Returns the list cache instance.
  18767. */
  18768. function listCacheSet(key, value) {
  18769. var data = this.__data__,
  18770. index = assocIndexOf(data, key);
  18771. if (index < 0) {
  18772. ++this.size;
  18773. data.push([key, value]);
  18774. } else {
  18775. data[index][1] = value;
  18776. }
  18777. return this;
  18778. }
  18779. // Add methods to `ListCache`.
  18780. ListCache.prototype.clear = listCacheClear;
  18781. ListCache.prototype['delete'] = listCacheDelete;
  18782. ListCache.prototype.get = listCacheGet;
  18783. ListCache.prototype.has = listCacheHas;
  18784. ListCache.prototype.set = listCacheSet;
  18785. /*------------------------------------------------------------------------*/
  18786. /**
  18787. * Creates a map cache object to store key-value pairs.
  18788. *
  18789. * @private
  18790. * @constructor
  18791. * @param {Array} [entries] The key-value pairs to cache.
  18792. */
  18793. function MapCache(entries) {
  18794. var index = -1,
  18795. length = entries == null ? 0 : entries.length;
  18796. this.clear();
  18797. while (++index < length) {
  18798. var entry = entries[index];
  18799. this.set(entry[0], entry[1]);
  18800. }
  18801. }
  18802. /**
  18803. * Removes all key-value entries from the map.
  18804. *
  18805. * @private
  18806. * @name clear
  18807. * @memberOf MapCache
  18808. */
  18809. function mapCacheClear() {
  18810. this.size = 0;
  18811. this.__data__ = {
  18812. 'hash': new Hash,
  18813. 'map': new (Map || ListCache),
  18814. 'string': new Hash
  18815. };
  18816. }
  18817. /**
  18818. * Removes `key` and its value from the map.
  18819. *
  18820. * @private
  18821. * @name delete
  18822. * @memberOf MapCache
  18823. * @param {string} key The key of the value to remove.
  18824. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18825. */
  18826. function mapCacheDelete(key) {
  18827. var result = getMapData(this, key)['delete'](key);
  18828. this.size -= result ? 1 : 0;
  18829. return result;
  18830. }
  18831. /**
  18832. * Gets the map value for `key`.
  18833. *
  18834. * @private
  18835. * @name get
  18836. * @memberOf MapCache
  18837. * @param {string} key The key of the value to get.
  18838. * @returns {*} Returns the entry value.
  18839. */
  18840. function mapCacheGet(key) {
  18841. return getMapData(this, key).get(key);
  18842. }
  18843. /**
  18844. * Checks if a map value for `key` exists.
  18845. *
  18846. * @private
  18847. * @name has
  18848. * @memberOf MapCache
  18849. * @param {string} key The key of the entry to check.
  18850. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18851. */
  18852. function mapCacheHas(key) {
  18853. return getMapData(this, key).has(key);
  18854. }
  18855. /**
  18856. * Sets the map `key` to `value`.
  18857. *
  18858. * @private
  18859. * @name set
  18860. * @memberOf MapCache
  18861. * @param {string} key The key of the value to set.
  18862. * @param {*} value The value to set.
  18863. * @returns {Object} Returns the map cache instance.
  18864. */
  18865. function mapCacheSet(key, value) {
  18866. var data = getMapData(this, key),
  18867. size = data.size;
  18868. data.set(key, value);
  18869. this.size += data.size == size ? 0 : 1;
  18870. return this;
  18871. }
  18872. // Add methods to `MapCache`.
  18873. MapCache.prototype.clear = mapCacheClear;
  18874. MapCache.prototype['delete'] = mapCacheDelete;
  18875. MapCache.prototype.get = mapCacheGet;
  18876. MapCache.prototype.has = mapCacheHas;
  18877. MapCache.prototype.set = mapCacheSet;
  18878. /*------------------------------------------------------------------------*/
  18879. /**
  18880. *
  18881. * Creates an array cache object to store unique values.
  18882. *
  18883. * @private
  18884. * @constructor
  18885. * @param {Array} [values] The values to cache.
  18886. */
  18887. function SetCache(values) {
  18888. var index = -1,
  18889. length = values == null ? 0 : values.length;
  18890. this.__data__ = new MapCache;
  18891. while (++index < length) {
  18892. this.add(values[index]);
  18893. }
  18894. }
  18895. /**
  18896. * Adds `value` to the array cache.
  18897. *
  18898. * @private
  18899. * @name add
  18900. * @memberOf SetCache
  18901. * @alias push
  18902. * @param {*} value The value to cache.
  18903. * @returns {Object} Returns the cache instance.
  18904. */
  18905. function setCacheAdd(value) {
  18906. this.__data__.set(value, HASH_UNDEFINED);
  18907. return this;
  18908. }
  18909. /**
  18910. * Checks if `value` is in the array cache.
  18911. *
  18912. * @private
  18913. * @name has
  18914. * @memberOf SetCache
  18915. * @param {*} value The value to search for.
  18916. * @returns {number} Returns `true` if `value` is found, else `false`.
  18917. */
  18918. function setCacheHas(value) {
  18919. return this.__data__.has(value);
  18920. }
  18921. // Add methods to `SetCache`.
  18922. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18923. SetCache.prototype.has = setCacheHas;
  18924. /*------------------------------------------------------------------------*/
  18925. /**
  18926. * Creates a stack cache object to store key-value pairs.
  18927. *
  18928. * @private
  18929. * @constructor
  18930. * @param {Array} [entries] The key-value pairs to cache.
  18931. */
  18932. function Stack(entries) {
  18933. var data = this.__data__ = new ListCache(entries);
  18934. this.size = data.size;
  18935. }
  18936. /**
  18937. * Removes all key-value entries from the stack.
  18938. *
  18939. * @private
  18940. * @name clear
  18941. * @memberOf Stack
  18942. */
  18943. function stackClear() {
  18944. this.__data__ = new ListCache;
  18945. this.size = 0;
  18946. }
  18947. /**
  18948. * Removes `key` and its value from the stack.
  18949. *
  18950. * @private
  18951. * @name delete
  18952. * @memberOf Stack
  18953. * @param {string} key The key of the value to remove.
  18954. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18955. */
  18956. function stackDelete(key) {
  18957. var data = this.__data__,
  18958. result = data['delete'](key);
  18959. this.size = data.size;
  18960. return result;
  18961. }
  18962. /**
  18963. * Gets the stack value for `key`.
  18964. *
  18965. * @private
  18966. * @name get
  18967. * @memberOf Stack
  18968. * @param {string} key The key of the value to get.
  18969. * @returns {*} Returns the entry value.
  18970. */
  18971. function stackGet(key) {
  18972. return this.__data__.get(key);
  18973. }
  18974. /**
  18975. * Checks if a stack value for `key` exists.
  18976. *
  18977. * @private
  18978. * @name has
  18979. * @memberOf Stack
  18980. * @param {string} key The key of the entry to check.
  18981. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18982. */
  18983. function stackHas(key) {
  18984. return this.__data__.has(key);
  18985. }
  18986. /**
  18987. * Sets the stack `key` to `value`.
  18988. *
  18989. * @private
  18990. * @name set
  18991. * @memberOf Stack
  18992. * @param {string} key The key of the value to set.
  18993. * @param {*} value The value to set.
  18994. * @returns {Object} Returns the stack cache instance.
  18995. */
  18996. function stackSet(key, value) {
  18997. var data = this.__data__;
  18998. if (data instanceof ListCache) {
  18999. var pairs = data.__data__;
  19000. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19001. pairs.push([key, value]);
  19002. this.size = ++data.size;
  19003. return this;
  19004. }
  19005. data = this.__data__ = new MapCache(pairs);
  19006. }
  19007. data.set(key, value);
  19008. this.size = data.size;
  19009. return this;
  19010. }
  19011. // Add methods to `Stack`.
  19012. Stack.prototype.clear = stackClear;
  19013. Stack.prototype['delete'] = stackDelete;
  19014. Stack.prototype.get = stackGet;
  19015. Stack.prototype.has = stackHas;
  19016. Stack.prototype.set = stackSet;
  19017. /*------------------------------------------------------------------------*/
  19018. /**
  19019. * Creates an array of the enumerable property names of the array-like `value`.
  19020. *
  19021. * @private
  19022. * @param {*} value The value to query.
  19023. * @param {boolean} inherited Specify returning inherited property names.
  19024. * @returns {Array} Returns the array of property names.
  19025. */
  19026. function arrayLikeKeys(value, inherited) {
  19027. var isArr = isArray(value),
  19028. isArg = !isArr && isArguments(value),
  19029. isBuff = !isArr && !isArg && isBuffer(value),
  19030. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19031. skipIndexes = isArr || isArg || isBuff || isType,
  19032. result = skipIndexes ? baseTimes(value.length, String) : [],
  19033. length = result.length;
  19034. for (var key in value) {
  19035. if ((inherited || hasOwnProperty.call(value, key)) &&
  19036. !(skipIndexes && (
  19037. // Safari 9 has enumerable `arguments.length` in strict mode.
  19038. key == 'length' ||
  19039. // Node.js 0.10 has enumerable non-index properties on buffers.
  19040. (isBuff && (key == 'offset' || key == 'parent')) ||
  19041. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19042. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19043. // Skip index properties.
  19044. isIndex(key, length)
  19045. ))) {
  19046. result.push(key);
  19047. }
  19048. }
  19049. return result;
  19050. }
  19051. /**
  19052. * A specialized version of `_.sample` for arrays.
  19053. *
  19054. * @private
  19055. * @param {Array} array The array to sample.
  19056. * @returns {*} Returns the random element.
  19057. */
  19058. function arraySample(array) {
  19059. var length = array.length;
  19060. return length ? array[baseRandom(0, length - 1)] : undefined;
  19061. }
  19062. /**
  19063. * A specialized version of `_.sampleSize` for arrays.
  19064. *
  19065. * @private
  19066. * @param {Array} array The array to sample.
  19067. * @param {number} n The number of elements to sample.
  19068. * @returns {Array} Returns the random elements.
  19069. */
  19070. function arraySampleSize(array, n) {
  19071. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19072. }
  19073. /**
  19074. * A specialized version of `_.shuffle` for arrays.
  19075. *
  19076. * @private
  19077. * @param {Array} array The array to shuffle.
  19078. * @returns {Array} Returns the new shuffled array.
  19079. */
  19080. function arrayShuffle(array) {
  19081. return shuffleSelf(copyArray(array));
  19082. }
  19083. /**
  19084. * This function is like `assignValue` except that it doesn't assign
  19085. * `undefined` values.
  19086. *
  19087. * @private
  19088. * @param {Object} object The object to modify.
  19089. * @param {string} key The key of the property to assign.
  19090. * @param {*} value The value to assign.
  19091. */
  19092. function assignMergeValue(object, key, value) {
  19093. if ((value !== undefined && !eq(object[key], value)) ||
  19094. (value === undefined && !(key in object))) {
  19095. baseAssignValue(object, key, value);
  19096. }
  19097. }
  19098. /**
  19099. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19100. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19101. * for equality comparisons.
  19102. *
  19103. * @private
  19104. * @param {Object} object The object to modify.
  19105. * @param {string} key The key of the property to assign.
  19106. * @param {*} value The value to assign.
  19107. */
  19108. function assignValue(object, key, value) {
  19109. var objValue = object[key];
  19110. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19111. (value === undefined && !(key in object))) {
  19112. baseAssignValue(object, key, value);
  19113. }
  19114. }
  19115. /**
  19116. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19117. *
  19118. * @private
  19119. * @param {Array} array The array to inspect.
  19120. * @param {*} key The key to search for.
  19121. * @returns {number} Returns the index of the matched value, else `-1`.
  19122. */
  19123. function assocIndexOf(array, key) {
  19124. var length = array.length;
  19125. while (length--) {
  19126. if (eq(array[length][0], key)) {
  19127. return length;
  19128. }
  19129. }
  19130. return -1;
  19131. }
  19132. /**
  19133. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19134. * by `iteratee` and values set by `setter`.
  19135. *
  19136. * @private
  19137. * @param {Array|Object} collection The collection to iterate over.
  19138. * @param {Function} setter The function to set `accumulator` values.
  19139. * @param {Function} iteratee The iteratee to transform keys.
  19140. * @param {Object} accumulator The initial aggregated object.
  19141. * @returns {Function} Returns `accumulator`.
  19142. */
  19143. function baseAggregator(collection, setter, iteratee, accumulator) {
  19144. baseEach(collection, function(value, key, collection) {
  19145. setter(accumulator, value, iteratee(value), collection);
  19146. });
  19147. return accumulator;
  19148. }
  19149. /**
  19150. * The base implementation of `_.assign` without support for multiple sources
  19151. * or `customizer` functions.
  19152. *
  19153. * @private
  19154. * @param {Object} object The destination object.
  19155. * @param {Object} source The source object.
  19156. * @returns {Object} Returns `object`.
  19157. */
  19158. function baseAssign(object, source) {
  19159. return object && copyObject(source, keys(source), object);
  19160. }
  19161. /**
  19162. * The base implementation of `_.assignIn` without support for multiple sources
  19163. * or `customizer` functions.
  19164. *
  19165. * @private
  19166. * @param {Object} object The destination object.
  19167. * @param {Object} source The source object.
  19168. * @returns {Object} Returns `object`.
  19169. */
  19170. function baseAssignIn(object, source) {
  19171. return object && copyObject(source, keysIn(source), object);
  19172. }
  19173. /**
  19174. * The base implementation of `assignValue` and `assignMergeValue` without
  19175. * value checks.
  19176. *
  19177. * @private
  19178. * @param {Object} object The object to modify.
  19179. * @param {string} key The key of the property to assign.
  19180. * @param {*} value The value to assign.
  19181. */
  19182. function baseAssignValue(object, key, value) {
  19183. if (key == '__proto__' && defineProperty) {
  19184. defineProperty(object, key, {
  19185. 'configurable': true,
  19186. 'enumerable': true,
  19187. 'value': value,
  19188. 'writable': true
  19189. });
  19190. } else {
  19191. object[key] = value;
  19192. }
  19193. }
  19194. /**
  19195. * The base implementation of `_.at` without support for individual paths.
  19196. *
  19197. * @private
  19198. * @param {Object} object The object to iterate over.
  19199. * @param {string[]} paths The property paths to pick.
  19200. * @returns {Array} Returns the picked elements.
  19201. */
  19202. function baseAt(object, paths) {
  19203. var index = -1,
  19204. length = paths.length,
  19205. result = Array(length),
  19206. skip = object == null;
  19207. while (++index < length) {
  19208. result[index] = skip ? undefined : get(object, paths[index]);
  19209. }
  19210. return result;
  19211. }
  19212. /**
  19213. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19214. *
  19215. * @private
  19216. * @param {number} number The number to clamp.
  19217. * @param {number} [lower] The lower bound.
  19218. * @param {number} upper The upper bound.
  19219. * @returns {number} Returns the clamped number.
  19220. */
  19221. function baseClamp(number, lower, upper) {
  19222. if (number === number) {
  19223. if (upper !== undefined) {
  19224. number = number <= upper ? number : upper;
  19225. }
  19226. if (lower !== undefined) {
  19227. number = number >= lower ? number : lower;
  19228. }
  19229. }
  19230. return number;
  19231. }
  19232. /**
  19233. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19234. * traversed objects.
  19235. *
  19236. * @private
  19237. * @param {*} value The value to clone.
  19238. * @param {boolean} bitmask The bitmask flags.
  19239. * 1 - Deep clone
  19240. * 2 - Flatten inherited properties
  19241. * 4 - Clone symbols
  19242. * @param {Function} [customizer] The function to customize cloning.
  19243. * @param {string} [key] The key of `value`.
  19244. * @param {Object} [object] The parent object of `value`.
  19245. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19246. * @returns {*} Returns the cloned value.
  19247. */
  19248. function baseClone(value, bitmask, customizer, key, object, stack) {
  19249. var result,
  19250. isDeep = bitmask & CLONE_DEEP_FLAG,
  19251. isFlat = bitmask & CLONE_FLAT_FLAG,
  19252. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19253. if (customizer) {
  19254. result = object ? customizer(value, key, object, stack) : customizer(value);
  19255. }
  19256. if (result !== undefined) {
  19257. return result;
  19258. }
  19259. if (!isObject(value)) {
  19260. return value;
  19261. }
  19262. var isArr = isArray(value);
  19263. if (isArr) {
  19264. result = initCloneArray(value);
  19265. if (!isDeep) {
  19266. return copyArray(value, result);
  19267. }
  19268. } else {
  19269. var tag = getTag(value),
  19270. isFunc = tag == funcTag || tag == genTag;
  19271. if (isBuffer(value)) {
  19272. return cloneBuffer(value, isDeep);
  19273. }
  19274. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19275. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19276. if (!isDeep) {
  19277. return isFlat
  19278. ? copySymbolsIn(value, baseAssignIn(result, value))
  19279. : copySymbols(value, baseAssign(result, value));
  19280. }
  19281. } else {
  19282. if (!cloneableTags[tag]) {
  19283. return object ? value : {};
  19284. }
  19285. result = initCloneByTag(value, tag, isDeep);
  19286. }
  19287. }
  19288. // Check for circular references and return its corresponding clone.
  19289. stack || (stack = new Stack);
  19290. var stacked = stack.get(value);
  19291. if (stacked) {
  19292. return stacked;
  19293. }
  19294. stack.set(value, result);
  19295. if (isSet(value)) {
  19296. value.forEach(function(subValue) {
  19297. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19298. });
  19299. } else if (isMap(value)) {
  19300. value.forEach(function(subValue, key) {
  19301. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19302. });
  19303. }
  19304. var keysFunc = isFull
  19305. ? (isFlat ? getAllKeysIn : getAllKeys)
  19306. : (isFlat ? keysIn : keys);
  19307. var props = isArr ? undefined : keysFunc(value);
  19308. arrayEach(props || value, function(subValue, key) {
  19309. if (props) {
  19310. key = subValue;
  19311. subValue = value[key];
  19312. }
  19313. // Recursively populate clone (susceptible to call stack limits).
  19314. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19315. });
  19316. return result;
  19317. }
  19318. /**
  19319. * The base implementation of `_.conforms` which doesn't clone `source`.
  19320. *
  19321. * @private
  19322. * @param {Object} source The object of property predicates to conform to.
  19323. * @returns {Function} Returns the new spec function.
  19324. */
  19325. function baseConforms(source) {
  19326. var props = keys(source);
  19327. return function(object) {
  19328. return baseConformsTo(object, source, props);
  19329. };
  19330. }
  19331. /**
  19332. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19333. *
  19334. * @private
  19335. * @param {Object} object The object to inspect.
  19336. * @param {Object} source The object of property predicates to conform to.
  19337. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19338. */
  19339. function baseConformsTo(object, source, props) {
  19340. var length = props.length;
  19341. if (object == null) {
  19342. return !length;
  19343. }
  19344. object = Object(object);
  19345. while (length--) {
  19346. var key = props[length],
  19347. predicate = source[key],
  19348. value = object[key];
  19349. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19350. return false;
  19351. }
  19352. }
  19353. return true;
  19354. }
  19355. /**
  19356. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19357. * to provide to `func`.
  19358. *
  19359. * @private
  19360. * @param {Function} func The function to delay.
  19361. * @param {number} wait The number of milliseconds to delay invocation.
  19362. * @param {Array} args The arguments to provide to `func`.
  19363. * @returns {number|Object} Returns the timer id or timeout object.
  19364. */
  19365. function baseDelay(func, wait, args) {
  19366. if (typeof func != 'function') {
  19367. throw new TypeError(FUNC_ERROR_TEXT);
  19368. }
  19369. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19370. }
  19371. /**
  19372. * The base implementation of methods like `_.difference` without support
  19373. * for excluding multiple arrays or iteratee shorthands.
  19374. *
  19375. * @private
  19376. * @param {Array} array The array to inspect.
  19377. * @param {Array} values The values to exclude.
  19378. * @param {Function} [iteratee] The iteratee invoked per element.
  19379. * @param {Function} [comparator] The comparator invoked per element.
  19380. * @returns {Array} Returns the new array of filtered values.
  19381. */
  19382. function baseDifference(array, values, iteratee, comparator) {
  19383. var index = -1,
  19384. includes = arrayIncludes,
  19385. isCommon = true,
  19386. length = array.length,
  19387. result = [],
  19388. valuesLength = values.length;
  19389. if (!length) {
  19390. return result;
  19391. }
  19392. if (iteratee) {
  19393. values = arrayMap(values, baseUnary(iteratee));
  19394. }
  19395. if (comparator) {
  19396. includes = arrayIncludesWith;
  19397. isCommon = false;
  19398. }
  19399. else if (values.length >= LARGE_ARRAY_SIZE) {
  19400. includes = cacheHas;
  19401. isCommon = false;
  19402. values = new SetCache(values);
  19403. }
  19404. outer:
  19405. while (++index < length) {
  19406. var value = array[index],
  19407. computed = iteratee == null ? value : iteratee(value);
  19408. value = (comparator || value !== 0) ? value : 0;
  19409. if (isCommon && computed === computed) {
  19410. var valuesIndex = valuesLength;
  19411. while (valuesIndex--) {
  19412. if (values[valuesIndex] === computed) {
  19413. continue outer;
  19414. }
  19415. }
  19416. result.push(value);
  19417. }
  19418. else if (!includes(values, computed, comparator)) {
  19419. result.push(value);
  19420. }
  19421. }
  19422. return result;
  19423. }
  19424. /**
  19425. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19426. *
  19427. * @private
  19428. * @param {Array|Object} collection The collection to iterate over.
  19429. * @param {Function} iteratee The function invoked per iteration.
  19430. * @returns {Array|Object} Returns `collection`.
  19431. */
  19432. var baseEach = createBaseEach(baseForOwn);
  19433. /**
  19434. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19435. *
  19436. * @private
  19437. * @param {Array|Object} collection The collection to iterate over.
  19438. * @param {Function} iteratee The function invoked per iteration.
  19439. * @returns {Array|Object} Returns `collection`.
  19440. */
  19441. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19442. /**
  19443. * The base implementation of `_.every` without support for iteratee shorthands.
  19444. *
  19445. * @private
  19446. * @param {Array|Object} collection The collection to iterate over.
  19447. * @param {Function} predicate The function invoked per iteration.
  19448. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19449. * else `false`
  19450. */
  19451. function baseEvery(collection, predicate) {
  19452. var result = true;
  19453. baseEach(collection, function(value, index, collection) {
  19454. result = !!predicate(value, index, collection);
  19455. return result;
  19456. });
  19457. return result;
  19458. }
  19459. /**
  19460. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19461. * `comparator` to determine the extremum value.
  19462. *
  19463. * @private
  19464. * @param {Array} array The array to iterate over.
  19465. * @param {Function} iteratee The iteratee invoked per iteration.
  19466. * @param {Function} comparator The comparator used to compare values.
  19467. * @returns {*} Returns the extremum value.
  19468. */
  19469. function baseExtremum(array, iteratee, comparator) {
  19470. var index = -1,
  19471. length = array.length;
  19472. while (++index < length) {
  19473. var value = array[index],
  19474. current = iteratee(value);
  19475. if (current != null && (computed === undefined
  19476. ? (current === current && !isSymbol(current))
  19477. : comparator(current, computed)
  19478. )) {
  19479. var computed = current,
  19480. result = value;
  19481. }
  19482. }
  19483. return result;
  19484. }
  19485. /**
  19486. * The base implementation of `_.fill` without an iteratee call guard.
  19487. *
  19488. * @private
  19489. * @param {Array} array The array to fill.
  19490. * @param {*} value The value to fill `array` with.
  19491. * @param {number} [start=0] The start position.
  19492. * @param {number} [end=array.length] The end position.
  19493. * @returns {Array} Returns `array`.
  19494. */
  19495. function baseFill(array, value, start, end) {
  19496. var length = array.length;
  19497. start = toInteger(start);
  19498. if (start < 0) {
  19499. start = -start > length ? 0 : (length + start);
  19500. }
  19501. end = (end === undefined || end > length) ? length : toInteger(end);
  19502. if (end < 0) {
  19503. end += length;
  19504. }
  19505. end = start > end ? 0 : toLength(end);
  19506. while (start < end) {
  19507. array[start++] = value;
  19508. }
  19509. return array;
  19510. }
  19511. /**
  19512. * The base implementation of `_.filter` without support for iteratee shorthands.
  19513. *
  19514. * @private
  19515. * @param {Array|Object} collection The collection to iterate over.
  19516. * @param {Function} predicate The function invoked per iteration.
  19517. * @returns {Array} Returns the new filtered array.
  19518. */
  19519. function baseFilter(collection, predicate) {
  19520. var result = [];
  19521. baseEach(collection, function(value, index, collection) {
  19522. if (predicate(value, index, collection)) {
  19523. result.push(value);
  19524. }
  19525. });
  19526. return result;
  19527. }
  19528. /**
  19529. * The base implementation of `_.flatten` with support for restricting flattening.
  19530. *
  19531. * @private
  19532. * @param {Array} array The array to flatten.
  19533. * @param {number} depth The maximum recursion depth.
  19534. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19535. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19536. * @param {Array} [result=[]] The initial result value.
  19537. * @returns {Array} Returns the new flattened array.
  19538. */
  19539. function baseFlatten(array, depth, predicate, isStrict, result) {
  19540. var index = -1,
  19541. length = array.length;
  19542. predicate || (predicate = isFlattenable);
  19543. result || (result = []);
  19544. while (++index < length) {
  19545. var value = array[index];
  19546. if (depth > 0 && predicate(value)) {
  19547. if (depth > 1) {
  19548. // Recursively flatten arrays (susceptible to call stack limits).
  19549. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19550. } else {
  19551. arrayPush(result, value);
  19552. }
  19553. } else if (!isStrict) {
  19554. result[result.length] = value;
  19555. }
  19556. }
  19557. return result;
  19558. }
  19559. /**
  19560. * The base implementation of `baseForOwn` which iterates over `object`
  19561. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19562. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19563. *
  19564. * @private
  19565. * @param {Object} object The object to iterate over.
  19566. * @param {Function} iteratee The function invoked per iteration.
  19567. * @param {Function} keysFunc The function to get the keys of `object`.
  19568. * @returns {Object} Returns `object`.
  19569. */
  19570. var baseFor = createBaseFor();
  19571. /**
  19572. * This function is like `baseFor` except that it iterates over properties
  19573. * in the opposite order.
  19574. *
  19575. * @private
  19576. * @param {Object} object The object to iterate over.
  19577. * @param {Function} iteratee The function invoked per iteration.
  19578. * @param {Function} keysFunc The function to get the keys of `object`.
  19579. * @returns {Object} Returns `object`.
  19580. */
  19581. var baseForRight = createBaseFor(true);
  19582. /**
  19583. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19584. *
  19585. * @private
  19586. * @param {Object} object The object to iterate over.
  19587. * @param {Function} iteratee The function invoked per iteration.
  19588. * @returns {Object} Returns `object`.
  19589. */
  19590. function baseForOwn(object, iteratee) {
  19591. return object && baseFor(object, iteratee, keys);
  19592. }
  19593. /**
  19594. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19595. *
  19596. * @private
  19597. * @param {Object} object The object to iterate over.
  19598. * @param {Function} iteratee The function invoked per iteration.
  19599. * @returns {Object} Returns `object`.
  19600. */
  19601. function baseForOwnRight(object, iteratee) {
  19602. return object && baseForRight(object, iteratee, keys);
  19603. }
  19604. /**
  19605. * The base implementation of `_.functions` which creates an array of
  19606. * `object` function property names filtered from `props`.
  19607. *
  19608. * @private
  19609. * @param {Object} object The object to inspect.
  19610. * @param {Array} props The property names to filter.
  19611. * @returns {Array} Returns the function names.
  19612. */
  19613. function baseFunctions(object, props) {
  19614. return arrayFilter(props, function(key) {
  19615. return isFunction(object[key]);
  19616. });
  19617. }
  19618. /**
  19619. * The base implementation of `_.get` without support for default values.
  19620. *
  19621. * @private
  19622. * @param {Object} object The object to query.
  19623. * @param {Array|string} path The path of the property to get.
  19624. * @returns {*} Returns the resolved value.
  19625. */
  19626. function baseGet(object, path) {
  19627. path = castPath(path, object);
  19628. var index = 0,
  19629. length = path.length;
  19630. while (object != null && index < length) {
  19631. object = object[toKey(path[index++])];
  19632. }
  19633. return (index && index == length) ? object : undefined;
  19634. }
  19635. /**
  19636. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19637. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19638. * symbols of `object`.
  19639. *
  19640. * @private
  19641. * @param {Object} object The object to query.
  19642. * @param {Function} keysFunc The function to get the keys of `object`.
  19643. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19644. * @returns {Array} Returns the array of property names and symbols.
  19645. */
  19646. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19647. var result = keysFunc(object);
  19648. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19649. }
  19650. /**
  19651. * The base implementation of `getTag` without fallbacks for buggy environments.
  19652. *
  19653. * @private
  19654. * @param {*} value The value to query.
  19655. * @returns {string} Returns the `toStringTag`.
  19656. */
  19657. function baseGetTag(value) {
  19658. if (value == null) {
  19659. return value === undefined ? undefinedTag : nullTag;
  19660. }
  19661. return (symToStringTag && symToStringTag in Object(value))
  19662. ? getRawTag(value)
  19663. : objectToString(value);
  19664. }
  19665. /**
  19666. * The base implementation of `_.gt` which doesn't coerce arguments.
  19667. *
  19668. * @private
  19669. * @param {*} value The value to compare.
  19670. * @param {*} other The other value to compare.
  19671. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19672. * else `false`.
  19673. */
  19674. function baseGt(value, other) {
  19675. return value > other;
  19676. }
  19677. /**
  19678. * The base implementation of `_.has` without support for deep paths.
  19679. *
  19680. * @private
  19681. * @param {Object} [object] The object to query.
  19682. * @param {Array|string} key The key to check.
  19683. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19684. */
  19685. function baseHas(object, key) {
  19686. return object != null && hasOwnProperty.call(object, key);
  19687. }
  19688. /**
  19689. * The base implementation of `_.hasIn` without support for deep paths.
  19690. *
  19691. * @private
  19692. * @param {Object} [object] The object to query.
  19693. * @param {Array|string} key The key to check.
  19694. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19695. */
  19696. function baseHasIn(object, key) {
  19697. return object != null && key in Object(object);
  19698. }
  19699. /**
  19700. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19701. *
  19702. * @private
  19703. * @param {number} number The number to check.
  19704. * @param {number} start The start of the range.
  19705. * @param {number} end The end of the range.
  19706. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19707. */
  19708. function baseInRange(number, start, end) {
  19709. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19710. }
  19711. /**
  19712. * The base implementation of methods like `_.intersection`, without support
  19713. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19714. *
  19715. * @private
  19716. * @param {Array} arrays The arrays to inspect.
  19717. * @param {Function} [iteratee] The iteratee invoked per element.
  19718. * @param {Function} [comparator] The comparator invoked per element.
  19719. * @returns {Array} Returns the new array of shared values.
  19720. */
  19721. function baseIntersection(arrays, iteratee, comparator) {
  19722. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19723. length = arrays[0].length,
  19724. othLength = arrays.length,
  19725. othIndex = othLength,
  19726. caches = Array(othLength),
  19727. maxLength = Infinity,
  19728. result = [];
  19729. while (othIndex--) {
  19730. var array = arrays[othIndex];
  19731. if (othIndex && iteratee) {
  19732. array = arrayMap(array, baseUnary(iteratee));
  19733. }
  19734. maxLength = nativeMin(array.length, maxLength);
  19735. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19736. ? new SetCache(othIndex && array)
  19737. : undefined;
  19738. }
  19739. array = arrays[0];
  19740. var index = -1,
  19741. seen = caches[0];
  19742. outer:
  19743. while (++index < length && result.length < maxLength) {
  19744. var value = array[index],
  19745. computed = iteratee ? iteratee(value) : value;
  19746. value = (comparator || value !== 0) ? value : 0;
  19747. if (!(seen
  19748. ? cacheHas(seen, computed)
  19749. : includes(result, computed, comparator)
  19750. )) {
  19751. othIndex = othLength;
  19752. while (--othIndex) {
  19753. var cache = caches[othIndex];
  19754. if (!(cache
  19755. ? cacheHas(cache, computed)
  19756. : includes(arrays[othIndex], computed, comparator))
  19757. ) {
  19758. continue outer;
  19759. }
  19760. }
  19761. if (seen) {
  19762. seen.push(computed);
  19763. }
  19764. result.push(value);
  19765. }
  19766. }
  19767. return result;
  19768. }
  19769. /**
  19770. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19771. * `object` with values transformed by `iteratee` and set by `setter`.
  19772. *
  19773. * @private
  19774. * @param {Object} object The object to iterate over.
  19775. * @param {Function} setter The function to set `accumulator` values.
  19776. * @param {Function} iteratee The iteratee to transform values.
  19777. * @param {Object} accumulator The initial inverted object.
  19778. * @returns {Function} Returns `accumulator`.
  19779. */
  19780. function baseInverter(object, setter, iteratee, accumulator) {
  19781. baseForOwn(object, function(value, key, object) {
  19782. setter(accumulator, iteratee(value), key, object);
  19783. });
  19784. return accumulator;
  19785. }
  19786. /**
  19787. * The base implementation of `_.invoke` without support for individual
  19788. * method arguments.
  19789. *
  19790. * @private
  19791. * @param {Object} object The object to query.
  19792. * @param {Array|string} path The path of the method to invoke.
  19793. * @param {Array} args The arguments to invoke the method with.
  19794. * @returns {*} Returns the result of the invoked method.
  19795. */
  19796. function baseInvoke(object, path, args) {
  19797. path = castPath(path, object);
  19798. object = parent(object, path);
  19799. var func = object == null ? object : object[toKey(last(path))];
  19800. return func == null ? undefined : apply(func, object, args);
  19801. }
  19802. /**
  19803. * The base implementation of `_.isArguments`.
  19804. *
  19805. * @private
  19806. * @param {*} value The value to check.
  19807. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19808. */
  19809. function baseIsArguments(value) {
  19810. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19811. }
  19812. /**
  19813. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19814. *
  19815. * @private
  19816. * @param {*} value The value to check.
  19817. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19818. */
  19819. function baseIsArrayBuffer(value) {
  19820. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19821. }
  19822. /**
  19823. * The base implementation of `_.isDate` without Node.js optimizations.
  19824. *
  19825. * @private
  19826. * @param {*} value The value to check.
  19827. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19828. */
  19829. function baseIsDate(value) {
  19830. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19831. }
  19832. /**
  19833. * The base implementation of `_.isEqual` which supports partial comparisons
  19834. * and tracks traversed objects.
  19835. *
  19836. * @private
  19837. * @param {*} value The value to compare.
  19838. * @param {*} other The other value to compare.
  19839. * @param {boolean} bitmask The bitmask flags.
  19840. * 1 - Unordered comparison
  19841. * 2 - Partial comparison
  19842. * @param {Function} [customizer] The function to customize comparisons.
  19843. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19844. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19845. */
  19846. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19847. if (value === other) {
  19848. return true;
  19849. }
  19850. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19851. return value !== value && other !== other;
  19852. }
  19853. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19854. }
  19855. /**
  19856. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19857. * deep comparisons and tracks traversed objects enabling objects with circular
  19858. * references to be compared.
  19859. *
  19860. * @private
  19861. * @param {Object} object The object to compare.
  19862. * @param {Object} other The other object to compare.
  19863. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19864. * @param {Function} customizer The function to customize comparisons.
  19865. * @param {Function} equalFunc The function to determine equivalents of values.
  19866. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19867. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19868. */
  19869. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19870. var objIsArr = isArray(object),
  19871. othIsArr = isArray(other),
  19872. objTag = objIsArr ? arrayTag : getTag(object),
  19873. othTag = othIsArr ? arrayTag : getTag(other);
  19874. objTag = objTag == argsTag ? objectTag : objTag;
  19875. othTag = othTag == argsTag ? objectTag : othTag;
  19876. var objIsObj = objTag == objectTag,
  19877. othIsObj = othTag == objectTag,
  19878. isSameTag = objTag == othTag;
  19879. if (isSameTag && isBuffer(object)) {
  19880. if (!isBuffer(other)) {
  19881. return false;
  19882. }
  19883. objIsArr = true;
  19884. objIsObj = false;
  19885. }
  19886. if (isSameTag && !objIsObj) {
  19887. stack || (stack = new Stack);
  19888. return (objIsArr || isTypedArray(object))
  19889. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19890. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19891. }
  19892. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19893. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19894. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19895. if (objIsWrapped || othIsWrapped) {
  19896. var objUnwrapped = objIsWrapped ? object.value() : object,
  19897. othUnwrapped = othIsWrapped ? other.value() : other;
  19898. stack || (stack = new Stack);
  19899. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19900. }
  19901. }
  19902. if (!isSameTag) {
  19903. return false;
  19904. }
  19905. stack || (stack = new Stack);
  19906. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19907. }
  19908. /**
  19909. * The base implementation of `_.isMap` without Node.js optimizations.
  19910. *
  19911. * @private
  19912. * @param {*} value The value to check.
  19913. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19914. */
  19915. function baseIsMap(value) {
  19916. return isObjectLike(value) && getTag(value) == mapTag;
  19917. }
  19918. /**
  19919. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19920. *
  19921. * @private
  19922. * @param {Object} object The object to inspect.
  19923. * @param {Object} source The object of property values to match.
  19924. * @param {Array} matchData The property names, values, and compare flags to match.
  19925. * @param {Function} [customizer] The function to customize comparisons.
  19926. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19927. */
  19928. function baseIsMatch(object, source, matchData, customizer) {
  19929. var index = matchData.length,
  19930. length = index,
  19931. noCustomizer = !customizer;
  19932. if (object == null) {
  19933. return !length;
  19934. }
  19935. object = Object(object);
  19936. while (index--) {
  19937. var data = matchData[index];
  19938. if ((noCustomizer && data[2])
  19939. ? data[1] !== object[data[0]]
  19940. : !(data[0] in object)
  19941. ) {
  19942. return false;
  19943. }
  19944. }
  19945. while (++index < length) {
  19946. data = matchData[index];
  19947. var key = data[0],
  19948. objValue = object[key],
  19949. srcValue = data[1];
  19950. if (noCustomizer && data[2]) {
  19951. if (objValue === undefined && !(key in object)) {
  19952. return false;
  19953. }
  19954. } else {
  19955. var stack = new Stack;
  19956. if (customizer) {
  19957. var result = customizer(objValue, srcValue, key, object, source, stack);
  19958. }
  19959. if (!(result === undefined
  19960. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19961. : result
  19962. )) {
  19963. return false;
  19964. }
  19965. }
  19966. }
  19967. return true;
  19968. }
  19969. /**
  19970. * The base implementation of `_.isNative` without bad shim checks.
  19971. *
  19972. * @private
  19973. * @param {*} value The value to check.
  19974. * @returns {boolean} Returns `true` if `value` is a native function,
  19975. * else `false`.
  19976. */
  19977. function baseIsNative(value) {
  19978. if (!isObject(value) || isMasked(value)) {
  19979. return false;
  19980. }
  19981. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19982. return pattern.test(toSource(value));
  19983. }
  19984. /**
  19985. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19986. *
  19987. * @private
  19988. * @param {*} value The value to check.
  19989. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19990. */
  19991. function baseIsRegExp(value) {
  19992. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19993. }
  19994. /**
  19995. * The base implementation of `_.isSet` without Node.js optimizations.
  19996. *
  19997. * @private
  19998. * @param {*} value The value to check.
  19999. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20000. */
  20001. function baseIsSet(value) {
  20002. return isObjectLike(value) && getTag(value) == setTag;
  20003. }
  20004. /**
  20005. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20006. *
  20007. * @private
  20008. * @param {*} value The value to check.
  20009. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20010. */
  20011. function baseIsTypedArray(value) {
  20012. return isObjectLike(value) &&
  20013. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20014. }
  20015. /**
  20016. * The base implementation of `_.iteratee`.
  20017. *
  20018. * @private
  20019. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20020. * @returns {Function} Returns the iteratee.
  20021. */
  20022. function baseIteratee(value) {
  20023. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20024. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20025. if (typeof value == 'function') {
  20026. return value;
  20027. }
  20028. if (value == null) {
  20029. return identity;
  20030. }
  20031. if (typeof value == 'object') {
  20032. return isArray(value)
  20033. ? baseMatchesProperty(value[0], value[1])
  20034. : baseMatches(value);
  20035. }
  20036. return property(value);
  20037. }
  20038. /**
  20039. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20040. *
  20041. * @private
  20042. * @param {Object} object The object to query.
  20043. * @returns {Array} Returns the array of property names.
  20044. */
  20045. function baseKeys(object) {
  20046. if (!isPrototype(object)) {
  20047. return nativeKeys(object);
  20048. }
  20049. var result = [];
  20050. for (var key in Object(object)) {
  20051. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20052. result.push(key);
  20053. }
  20054. }
  20055. return result;
  20056. }
  20057. /**
  20058. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20059. *
  20060. * @private
  20061. * @param {Object} object The object to query.
  20062. * @returns {Array} Returns the array of property names.
  20063. */
  20064. function baseKeysIn(object) {
  20065. if (!isObject(object)) {
  20066. return nativeKeysIn(object);
  20067. }
  20068. var isProto = isPrototype(object),
  20069. result = [];
  20070. for (var key in object) {
  20071. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20072. result.push(key);
  20073. }
  20074. }
  20075. return result;
  20076. }
  20077. /**
  20078. * The base implementation of `_.lt` which doesn't coerce arguments.
  20079. *
  20080. * @private
  20081. * @param {*} value The value to compare.
  20082. * @param {*} other The other value to compare.
  20083. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20084. * else `false`.
  20085. */
  20086. function baseLt(value, other) {
  20087. return value < other;
  20088. }
  20089. /**
  20090. * The base implementation of `_.map` without support for iteratee shorthands.
  20091. *
  20092. * @private
  20093. * @param {Array|Object} collection The collection to iterate over.
  20094. * @param {Function} iteratee The function invoked per iteration.
  20095. * @returns {Array} Returns the new mapped array.
  20096. */
  20097. function baseMap(collection, iteratee) {
  20098. var index = -1,
  20099. result = isArrayLike(collection) ? Array(collection.length) : [];
  20100. baseEach(collection, function(value, key, collection) {
  20101. result[++index] = iteratee(value, key, collection);
  20102. });
  20103. return result;
  20104. }
  20105. /**
  20106. * The base implementation of `_.matches` which doesn't clone `source`.
  20107. *
  20108. * @private
  20109. * @param {Object} source The object of property values to match.
  20110. * @returns {Function} Returns the new spec function.
  20111. */
  20112. function baseMatches(source) {
  20113. var matchData = getMatchData(source);
  20114. if (matchData.length == 1 && matchData[0][2]) {
  20115. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20116. }
  20117. return function(object) {
  20118. return object === source || baseIsMatch(object, source, matchData);
  20119. };
  20120. }
  20121. /**
  20122. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20123. *
  20124. * @private
  20125. * @param {string} path The path of the property to get.
  20126. * @param {*} srcValue The value to match.
  20127. * @returns {Function} Returns the new spec function.
  20128. */
  20129. function baseMatchesProperty(path, srcValue) {
  20130. if (isKey(path) && isStrictComparable(srcValue)) {
  20131. return matchesStrictComparable(toKey(path), srcValue);
  20132. }
  20133. return function(object) {
  20134. var objValue = get(object, path);
  20135. return (objValue === undefined && objValue === srcValue)
  20136. ? hasIn(object, path)
  20137. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20138. };
  20139. }
  20140. /**
  20141. * The base implementation of `_.merge` without support for multiple sources.
  20142. *
  20143. * @private
  20144. * @param {Object} object The destination object.
  20145. * @param {Object} source The source object.
  20146. * @param {number} srcIndex The index of `source`.
  20147. * @param {Function} [customizer] The function to customize merged values.
  20148. * @param {Object} [stack] Tracks traversed source values and their merged
  20149. * counterparts.
  20150. */
  20151. function baseMerge(object, source, srcIndex, customizer, stack) {
  20152. if (object === source) {
  20153. return;
  20154. }
  20155. baseFor(source, function(srcValue, key) {
  20156. stack || (stack = new Stack);
  20157. if (isObject(srcValue)) {
  20158. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20159. }
  20160. else {
  20161. var newValue = customizer
  20162. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20163. : undefined;
  20164. if (newValue === undefined) {
  20165. newValue = srcValue;
  20166. }
  20167. assignMergeValue(object, key, newValue);
  20168. }
  20169. }, keysIn);
  20170. }
  20171. /**
  20172. * A specialized version of `baseMerge` for arrays and objects which performs
  20173. * deep merges and tracks traversed objects enabling objects with circular
  20174. * references to be merged.
  20175. *
  20176. * @private
  20177. * @param {Object} object The destination object.
  20178. * @param {Object} source The source object.
  20179. * @param {string} key The key of the value to merge.
  20180. * @param {number} srcIndex The index of `source`.
  20181. * @param {Function} mergeFunc The function to merge values.
  20182. * @param {Function} [customizer] The function to customize assigned values.
  20183. * @param {Object} [stack] Tracks traversed source values and their merged
  20184. * counterparts.
  20185. */
  20186. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20187. var objValue = safeGet(object, key),
  20188. srcValue = safeGet(source, key),
  20189. stacked = stack.get(srcValue);
  20190. if (stacked) {
  20191. assignMergeValue(object, key, stacked);
  20192. return;
  20193. }
  20194. var newValue = customizer
  20195. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20196. : undefined;
  20197. var isCommon = newValue === undefined;
  20198. if (isCommon) {
  20199. var isArr = isArray(srcValue),
  20200. isBuff = !isArr && isBuffer(srcValue),
  20201. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20202. newValue = srcValue;
  20203. if (isArr || isBuff || isTyped) {
  20204. if (isArray(objValue)) {
  20205. newValue = objValue;
  20206. }
  20207. else if (isArrayLikeObject(objValue)) {
  20208. newValue = copyArray(objValue);
  20209. }
  20210. else if (isBuff) {
  20211. isCommon = false;
  20212. newValue = cloneBuffer(srcValue, true);
  20213. }
  20214. else if (isTyped) {
  20215. isCommon = false;
  20216. newValue = cloneTypedArray(srcValue, true);
  20217. }
  20218. else {
  20219. newValue = [];
  20220. }
  20221. }
  20222. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20223. newValue = objValue;
  20224. if (isArguments(objValue)) {
  20225. newValue = toPlainObject(objValue);
  20226. }
  20227. else if (!isObject(objValue) || isFunction(objValue)) {
  20228. newValue = initCloneObject(srcValue);
  20229. }
  20230. }
  20231. else {
  20232. isCommon = false;
  20233. }
  20234. }
  20235. if (isCommon) {
  20236. // Recursively merge objects and arrays (susceptible to call stack limits).
  20237. stack.set(srcValue, newValue);
  20238. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20239. stack['delete'](srcValue);
  20240. }
  20241. assignMergeValue(object, key, newValue);
  20242. }
  20243. /**
  20244. * The base implementation of `_.nth` which doesn't coerce arguments.
  20245. *
  20246. * @private
  20247. * @param {Array} array The array to query.
  20248. * @param {number} n The index of the element to return.
  20249. * @returns {*} Returns the nth element of `array`.
  20250. */
  20251. function baseNth(array, n) {
  20252. var length = array.length;
  20253. if (!length) {
  20254. return;
  20255. }
  20256. n += n < 0 ? length : 0;
  20257. return isIndex(n, length) ? array[n] : undefined;
  20258. }
  20259. /**
  20260. * The base implementation of `_.orderBy` without param guards.
  20261. *
  20262. * @private
  20263. * @param {Array|Object} collection The collection to iterate over.
  20264. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20265. * @param {string[]} orders The sort orders of `iteratees`.
  20266. * @returns {Array} Returns the new sorted array.
  20267. */
  20268. function baseOrderBy(collection, iteratees, orders) {
  20269. var index = -1;
  20270. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20271. var result = baseMap(collection, function(value, key, collection) {
  20272. var criteria = arrayMap(iteratees, function(iteratee) {
  20273. return iteratee(value);
  20274. });
  20275. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20276. });
  20277. return baseSortBy(result, function(object, other) {
  20278. return compareMultiple(object, other, orders);
  20279. });
  20280. }
  20281. /**
  20282. * The base implementation of `_.pick` without support for individual
  20283. * property identifiers.
  20284. *
  20285. * @private
  20286. * @param {Object} object The source object.
  20287. * @param {string[]} paths The property paths to pick.
  20288. * @returns {Object} Returns the new object.
  20289. */
  20290. function basePick(object, paths) {
  20291. return basePickBy(object, paths, function(value, path) {
  20292. return hasIn(object, path);
  20293. });
  20294. }
  20295. /**
  20296. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20297. *
  20298. * @private
  20299. * @param {Object} object The source object.
  20300. * @param {string[]} paths The property paths to pick.
  20301. * @param {Function} predicate The function invoked per property.
  20302. * @returns {Object} Returns the new object.
  20303. */
  20304. function basePickBy(object, paths, predicate) {
  20305. var index = -1,
  20306. length = paths.length,
  20307. result = {};
  20308. while (++index < length) {
  20309. var path = paths[index],
  20310. value = baseGet(object, path);
  20311. if (predicate(value, path)) {
  20312. baseSet(result, castPath(path, object), value);
  20313. }
  20314. }
  20315. return result;
  20316. }
  20317. /**
  20318. * A specialized version of `baseProperty` which supports deep paths.
  20319. *
  20320. * @private
  20321. * @param {Array|string} path The path of the property to get.
  20322. * @returns {Function} Returns the new accessor function.
  20323. */
  20324. function basePropertyDeep(path) {
  20325. return function(object) {
  20326. return baseGet(object, path);
  20327. };
  20328. }
  20329. /**
  20330. * The base implementation of `_.pullAllBy` without support for iteratee
  20331. * shorthands.
  20332. *
  20333. * @private
  20334. * @param {Array} array The array to modify.
  20335. * @param {Array} values The values to remove.
  20336. * @param {Function} [iteratee] The iteratee invoked per element.
  20337. * @param {Function} [comparator] The comparator invoked per element.
  20338. * @returns {Array} Returns `array`.
  20339. */
  20340. function basePullAll(array, values, iteratee, comparator) {
  20341. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20342. index = -1,
  20343. length = values.length,
  20344. seen = array;
  20345. if (array === values) {
  20346. values = copyArray(values);
  20347. }
  20348. if (iteratee) {
  20349. seen = arrayMap(array, baseUnary(iteratee));
  20350. }
  20351. while (++index < length) {
  20352. var fromIndex = 0,
  20353. value = values[index],
  20354. computed = iteratee ? iteratee(value) : value;
  20355. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20356. if (seen !== array) {
  20357. splice.call(seen, fromIndex, 1);
  20358. }
  20359. splice.call(array, fromIndex, 1);
  20360. }
  20361. }
  20362. return array;
  20363. }
  20364. /**
  20365. * The base implementation of `_.pullAt` without support for individual
  20366. * indexes or capturing the removed elements.
  20367. *
  20368. * @private
  20369. * @param {Array} array The array to modify.
  20370. * @param {number[]} indexes The indexes of elements to remove.
  20371. * @returns {Array} Returns `array`.
  20372. */
  20373. function basePullAt(array, indexes) {
  20374. var length = array ? indexes.length : 0,
  20375. lastIndex = length - 1;
  20376. while (length--) {
  20377. var index = indexes[length];
  20378. if (length == lastIndex || index !== previous) {
  20379. var previous = index;
  20380. if (isIndex(index)) {
  20381. splice.call(array, index, 1);
  20382. } else {
  20383. baseUnset(array, index);
  20384. }
  20385. }
  20386. }
  20387. return array;
  20388. }
  20389. /**
  20390. * The base implementation of `_.random` without support for returning
  20391. * floating-point numbers.
  20392. *
  20393. * @private
  20394. * @param {number} lower The lower bound.
  20395. * @param {number} upper The upper bound.
  20396. * @returns {number} Returns the random number.
  20397. */
  20398. function baseRandom(lower, upper) {
  20399. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20400. }
  20401. /**
  20402. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20403. * coerce arguments.
  20404. *
  20405. * @private
  20406. * @param {number} start The start of the range.
  20407. * @param {number} end The end of the range.
  20408. * @param {number} step The value to increment or decrement by.
  20409. * @param {boolean} [fromRight] Specify iterating from right to left.
  20410. * @returns {Array} Returns the range of numbers.
  20411. */
  20412. function baseRange(start, end, step, fromRight) {
  20413. var index = -1,
  20414. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20415. result = Array(length);
  20416. while (length--) {
  20417. result[fromRight ? length : ++index] = start;
  20418. start += step;
  20419. }
  20420. return result;
  20421. }
  20422. /**
  20423. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20424. *
  20425. * @private
  20426. * @param {string} string The string to repeat.
  20427. * @param {number} n The number of times to repeat the string.
  20428. * @returns {string} Returns the repeated string.
  20429. */
  20430. function baseRepeat(string, n) {
  20431. var result = '';
  20432. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20433. return result;
  20434. }
  20435. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20436. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20437. do {
  20438. if (n % 2) {
  20439. result += string;
  20440. }
  20441. n = nativeFloor(n / 2);
  20442. if (n) {
  20443. string += string;
  20444. }
  20445. } while (n);
  20446. return result;
  20447. }
  20448. /**
  20449. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20450. *
  20451. * @private
  20452. * @param {Function} func The function to apply a rest parameter to.
  20453. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20454. * @returns {Function} Returns the new function.
  20455. */
  20456. function baseRest(func, start) {
  20457. return setToString(overRest(func, start, identity), func + '');
  20458. }
  20459. /**
  20460. * The base implementation of `_.sample`.
  20461. *
  20462. * @private
  20463. * @param {Array|Object} collection The collection to sample.
  20464. * @returns {*} Returns the random element.
  20465. */
  20466. function baseSample(collection) {
  20467. return arraySample(values(collection));
  20468. }
  20469. /**
  20470. * The base implementation of `_.sampleSize` without param guards.
  20471. *
  20472. * @private
  20473. * @param {Array|Object} collection The collection to sample.
  20474. * @param {number} n The number of elements to sample.
  20475. * @returns {Array} Returns the random elements.
  20476. */
  20477. function baseSampleSize(collection, n) {
  20478. var array = values(collection);
  20479. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20480. }
  20481. /**
  20482. * The base implementation of `_.set`.
  20483. *
  20484. * @private
  20485. * @param {Object} object The object to modify.
  20486. * @param {Array|string} path The path of the property to set.
  20487. * @param {*} value The value to set.
  20488. * @param {Function} [customizer] The function to customize path creation.
  20489. * @returns {Object} Returns `object`.
  20490. */
  20491. function baseSet(object, path, value, customizer) {
  20492. if (!isObject(object)) {
  20493. return object;
  20494. }
  20495. path = castPath(path, object);
  20496. var index = -1,
  20497. length = path.length,
  20498. lastIndex = length - 1,
  20499. nested = object;
  20500. while (nested != null && ++index < length) {
  20501. var key = toKey(path[index]),
  20502. newValue = value;
  20503. if (index != lastIndex) {
  20504. var objValue = nested[key];
  20505. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20506. if (newValue === undefined) {
  20507. newValue = isObject(objValue)
  20508. ? objValue
  20509. : (isIndex(path[index + 1]) ? [] : {});
  20510. }
  20511. }
  20512. assignValue(nested, key, newValue);
  20513. nested = nested[key];
  20514. }
  20515. return object;
  20516. }
  20517. /**
  20518. * The base implementation of `setData` without support for hot loop shorting.
  20519. *
  20520. * @private
  20521. * @param {Function} func The function to associate metadata with.
  20522. * @param {*} data The metadata.
  20523. * @returns {Function} Returns `func`.
  20524. */
  20525. var baseSetData = !metaMap ? identity : function(func, data) {
  20526. metaMap.set(func, data);
  20527. return func;
  20528. };
  20529. /**
  20530. * The base implementation of `setToString` without support for hot loop shorting.
  20531. *
  20532. * @private
  20533. * @param {Function} func The function to modify.
  20534. * @param {Function} string The `toString` result.
  20535. * @returns {Function} Returns `func`.
  20536. */
  20537. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20538. return defineProperty(func, 'toString', {
  20539. 'configurable': true,
  20540. 'enumerable': false,
  20541. 'value': constant(string),
  20542. 'writable': true
  20543. });
  20544. };
  20545. /**
  20546. * The base implementation of `_.shuffle`.
  20547. *
  20548. * @private
  20549. * @param {Array|Object} collection The collection to shuffle.
  20550. * @returns {Array} Returns the new shuffled array.
  20551. */
  20552. function baseShuffle(collection) {
  20553. return shuffleSelf(values(collection));
  20554. }
  20555. /**
  20556. * The base implementation of `_.slice` without an iteratee call guard.
  20557. *
  20558. * @private
  20559. * @param {Array} array The array to slice.
  20560. * @param {number} [start=0] The start position.
  20561. * @param {number} [end=array.length] The end position.
  20562. * @returns {Array} Returns the slice of `array`.
  20563. */
  20564. function baseSlice(array, start, end) {
  20565. var index = -1,
  20566. length = array.length;
  20567. if (start < 0) {
  20568. start = -start > length ? 0 : (length + start);
  20569. }
  20570. end = end > length ? length : end;
  20571. if (end < 0) {
  20572. end += length;
  20573. }
  20574. length = start > end ? 0 : ((end - start) >>> 0);
  20575. start >>>= 0;
  20576. var result = Array(length);
  20577. while (++index < length) {
  20578. result[index] = array[index + start];
  20579. }
  20580. return result;
  20581. }
  20582. /**
  20583. * The base implementation of `_.some` without support for iteratee shorthands.
  20584. *
  20585. * @private
  20586. * @param {Array|Object} collection The collection to iterate over.
  20587. * @param {Function} predicate The function invoked per iteration.
  20588. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20589. * else `false`.
  20590. */
  20591. function baseSome(collection, predicate) {
  20592. var result;
  20593. baseEach(collection, function(value, index, collection) {
  20594. result = predicate(value, index, collection);
  20595. return !result;
  20596. });
  20597. return !!result;
  20598. }
  20599. /**
  20600. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20601. * performs a binary search of `array` to determine the index at which `value`
  20602. * should be inserted into `array` in order to maintain its sort order.
  20603. *
  20604. * @private
  20605. * @param {Array} array The sorted array to inspect.
  20606. * @param {*} value The value to evaluate.
  20607. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20608. * @returns {number} Returns the index at which `value` should be inserted
  20609. * into `array`.
  20610. */
  20611. function baseSortedIndex(array, value, retHighest) {
  20612. var low = 0,
  20613. high = array == null ? low : array.length;
  20614. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20615. while (low < high) {
  20616. var mid = (low + high) >>> 1,
  20617. computed = array[mid];
  20618. if (computed !== null && !isSymbol(computed) &&
  20619. (retHighest ? (computed <= value) : (computed < value))) {
  20620. low = mid + 1;
  20621. } else {
  20622. high = mid;
  20623. }
  20624. }
  20625. return high;
  20626. }
  20627. return baseSortedIndexBy(array, value, identity, retHighest);
  20628. }
  20629. /**
  20630. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20631. * which invokes `iteratee` for `value` and each element of `array` to compute
  20632. * their sort ranking. The iteratee is invoked with one argument; (value).
  20633. *
  20634. * @private
  20635. * @param {Array} array The sorted array to inspect.
  20636. * @param {*} value The value to evaluate.
  20637. * @param {Function} iteratee The iteratee invoked per element.
  20638. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20639. * @returns {number} Returns the index at which `value` should be inserted
  20640. * into `array`.
  20641. */
  20642. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20643. value = iteratee(value);
  20644. var low = 0,
  20645. high = array == null ? 0 : array.length,
  20646. valIsNaN = value !== value,
  20647. valIsNull = value === null,
  20648. valIsSymbol = isSymbol(value),
  20649. valIsUndefined = value === undefined;
  20650. while (low < high) {
  20651. var mid = nativeFloor((low + high) / 2),
  20652. computed = iteratee(array[mid]),
  20653. othIsDefined = computed !== undefined,
  20654. othIsNull = computed === null,
  20655. othIsReflexive = computed === computed,
  20656. othIsSymbol = isSymbol(computed);
  20657. if (valIsNaN) {
  20658. var setLow = retHighest || othIsReflexive;
  20659. } else if (valIsUndefined) {
  20660. setLow = othIsReflexive && (retHighest || othIsDefined);
  20661. } else if (valIsNull) {
  20662. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20663. } else if (valIsSymbol) {
  20664. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20665. } else if (othIsNull || othIsSymbol) {
  20666. setLow = false;
  20667. } else {
  20668. setLow = retHighest ? (computed <= value) : (computed < value);
  20669. }
  20670. if (setLow) {
  20671. low = mid + 1;
  20672. } else {
  20673. high = mid;
  20674. }
  20675. }
  20676. return nativeMin(high, MAX_ARRAY_INDEX);
  20677. }
  20678. /**
  20679. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20680. * support for iteratee shorthands.
  20681. *
  20682. * @private
  20683. * @param {Array} array The array to inspect.
  20684. * @param {Function} [iteratee] The iteratee invoked per element.
  20685. * @returns {Array} Returns the new duplicate free array.
  20686. */
  20687. function baseSortedUniq(array, iteratee) {
  20688. var index = -1,
  20689. length = array.length,
  20690. resIndex = 0,
  20691. result = [];
  20692. while (++index < length) {
  20693. var value = array[index],
  20694. computed = iteratee ? iteratee(value) : value;
  20695. if (!index || !eq(computed, seen)) {
  20696. var seen = computed;
  20697. result[resIndex++] = value === 0 ? 0 : value;
  20698. }
  20699. }
  20700. return result;
  20701. }
  20702. /**
  20703. * The base implementation of `_.toNumber` which doesn't ensure correct
  20704. * conversions of binary, hexadecimal, or octal string values.
  20705. *
  20706. * @private
  20707. * @param {*} value The value to process.
  20708. * @returns {number} Returns the number.
  20709. */
  20710. function baseToNumber(value) {
  20711. if (typeof value == 'number') {
  20712. return value;
  20713. }
  20714. if (isSymbol(value)) {
  20715. return NAN;
  20716. }
  20717. return +value;
  20718. }
  20719. /**
  20720. * The base implementation of `_.toString` which doesn't convert nullish
  20721. * values to empty strings.
  20722. *
  20723. * @private
  20724. * @param {*} value The value to process.
  20725. * @returns {string} Returns the string.
  20726. */
  20727. function baseToString(value) {
  20728. // Exit early for strings to avoid a performance hit in some environments.
  20729. if (typeof value == 'string') {
  20730. return value;
  20731. }
  20732. if (isArray(value)) {
  20733. // Recursively convert values (susceptible to call stack limits).
  20734. return arrayMap(value, baseToString) + '';
  20735. }
  20736. if (isSymbol(value)) {
  20737. return symbolToString ? symbolToString.call(value) : '';
  20738. }
  20739. var result = (value + '');
  20740. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20741. }
  20742. /**
  20743. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20744. *
  20745. * @private
  20746. * @param {Array} array The array to inspect.
  20747. * @param {Function} [iteratee] The iteratee invoked per element.
  20748. * @param {Function} [comparator] The comparator invoked per element.
  20749. * @returns {Array} Returns the new duplicate free array.
  20750. */
  20751. function baseUniq(array, iteratee, comparator) {
  20752. var index = -1,
  20753. includes = arrayIncludes,
  20754. length = array.length,
  20755. isCommon = true,
  20756. result = [],
  20757. seen = result;
  20758. if (comparator) {
  20759. isCommon = false;
  20760. includes = arrayIncludesWith;
  20761. }
  20762. else if (length >= LARGE_ARRAY_SIZE) {
  20763. var set = iteratee ? null : createSet(array);
  20764. if (set) {
  20765. return setToArray(set);
  20766. }
  20767. isCommon = false;
  20768. includes = cacheHas;
  20769. seen = new SetCache;
  20770. }
  20771. else {
  20772. seen = iteratee ? [] : result;
  20773. }
  20774. outer:
  20775. while (++index < length) {
  20776. var value = array[index],
  20777. computed = iteratee ? iteratee(value) : value;
  20778. value = (comparator || value !== 0) ? value : 0;
  20779. if (isCommon && computed === computed) {
  20780. var seenIndex = seen.length;
  20781. while (seenIndex--) {
  20782. if (seen[seenIndex] === computed) {
  20783. continue outer;
  20784. }
  20785. }
  20786. if (iteratee) {
  20787. seen.push(computed);
  20788. }
  20789. result.push(value);
  20790. }
  20791. else if (!includes(seen, computed, comparator)) {
  20792. if (seen !== result) {
  20793. seen.push(computed);
  20794. }
  20795. result.push(value);
  20796. }
  20797. }
  20798. return result;
  20799. }
  20800. /**
  20801. * The base implementation of `_.unset`.
  20802. *
  20803. * @private
  20804. * @param {Object} object The object to modify.
  20805. * @param {Array|string} path The property path to unset.
  20806. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20807. */
  20808. function baseUnset(object, path) {
  20809. path = castPath(path, object);
  20810. object = parent(object, path);
  20811. return object == null || delete object[toKey(last(path))];
  20812. }
  20813. /**
  20814. * The base implementation of `_.update`.
  20815. *
  20816. * @private
  20817. * @param {Object} object The object to modify.
  20818. * @param {Array|string} path The path of the property to update.
  20819. * @param {Function} updater The function to produce the updated value.
  20820. * @param {Function} [customizer] The function to customize path creation.
  20821. * @returns {Object} Returns `object`.
  20822. */
  20823. function baseUpdate(object, path, updater, customizer) {
  20824. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20825. }
  20826. /**
  20827. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20828. * without support for iteratee shorthands.
  20829. *
  20830. * @private
  20831. * @param {Array} array The array to query.
  20832. * @param {Function} predicate The function invoked per iteration.
  20833. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20834. * @param {boolean} [fromRight] Specify iterating from right to left.
  20835. * @returns {Array} Returns the slice of `array`.
  20836. */
  20837. function baseWhile(array, predicate, isDrop, fromRight) {
  20838. var length = array.length,
  20839. index = fromRight ? length : -1;
  20840. while ((fromRight ? index-- : ++index < length) &&
  20841. predicate(array[index], index, array)) {}
  20842. return isDrop
  20843. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20844. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20845. }
  20846. /**
  20847. * The base implementation of `wrapperValue` which returns the result of
  20848. * performing a sequence of actions on the unwrapped `value`, where each
  20849. * successive action is supplied the return value of the previous.
  20850. *
  20851. * @private
  20852. * @param {*} value The unwrapped value.
  20853. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20854. * @returns {*} Returns the resolved value.
  20855. */
  20856. function baseWrapperValue(value, actions) {
  20857. var result = value;
  20858. if (result instanceof LazyWrapper) {
  20859. result = result.value();
  20860. }
  20861. return arrayReduce(actions, function(result, action) {
  20862. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20863. }, result);
  20864. }
  20865. /**
  20866. * The base implementation of methods like `_.xor`, without support for
  20867. * iteratee shorthands, that accepts an array of arrays to inspect.
  20868. *
  20869. * @private
  20870. * @param {Array} arrays The arrays to inspect.
  20871. * @param {Function} [iteratee] The iteratee invoked per element.
  20872. * @param {Function} [comparator] The comparator invoked per element.
  20873. * @returns {Array} Returns the new array of values.
  20874. */
  20875. function baseXor(arrays, iteratee, comparator) {
  20876. var length = arrays.length;
  20877. if (length < 2) {
  20878. return length ? baseUniq(arrays[0]) : [];
  20879. }
  20880. var index = -1,
  20881. result = Array(length);
  20882. while (++index < length) {
  20883. var array = arrays[index],
  20884. othIndex = -1;
  20885. while (++othIndex < length) {
  20886. if (othIndex != index) {
  20887. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20888. }
  20889. }
  20890. }
  20891. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20892. }
  20893. /**
  20894. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20895. *
  20896. * @private
  20897. * @param {Array} props The property identifiers.
  20898. * @param {Array} values The property values.
  20899. * @param {Function} assignFunc The function to assign values.
  20900. * @returns {Object} Returns the new object.
  20901. */
  20902. function baseZipObject(props, values, assignFunc) {
  20903. var index = -1,
  20904. length = props.length,
  20905. valsLength = values.length,
  20906. result = {};
  20907. while (++index < length) {
  20908. var value = index < valsLength ? values[index] : undefined;
  20909. assignFunc(result, props[index], value);
  20910. }
  20911. return result;
  20912. }
  20913. /**
  20914. * Casts `value` to an empty array if it's not an array like object.
  20915. *
  20916. * @private
  20917. * @param {*} value The value to inspect.
  20918. * @returns {Array|Object} Returns the cast array-like object.
  20919. */
  20920. function castArrayLikeObject(value) {
  20921. return isArrayLikeObject(value) ? value : [];
  20922. }
  20923. /**
  20924. * Casts `value` to `identity` if it's not a function.
  20925. *
  20926. * @private
  20927. * @param {*} value The value to inspect.
  20928. * @returns {Function} Returns cast function.
  20929. */
  20930. function castFunction(value) {
  20931. return typeof value == 'function' ? value : identity;
  20932. }
  20933. /**
  20934. * Casts `value` to a path array if it's not one.
  20935. *
  20936. * @private
  20937. * @param {*} value The value to inspect.
  20938. * @param {Object} [object] The object to query keys on.
  20939. * @returns {Array} Returns the cast property path array.
  20940. */
  20941. function castPath(value, object) {
  20942. if (isArray(value)) {
  20943. return value;
  20944. }
  20945. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20946. }
  20947. /**
  20948. * A `baseRest` alias which can be replaced with `identity` by module
  20949. * replacement plugins.
  20950. *
  20951. * @private
  20952. * @type {Function}
  20953. * @param {Function} func The function to apply a rest parameter to.
  20954. * @returns {Function} Returns the new function.
  20955. */
  20956. var castRest = baseRest;
  20957. /**
  20958. * Casts `array` to a slice if it's needed.
  20959. *
  20960. * @private
  20961. * @param {Array} array The array to inspect.
  20962. * @param {number} start The start position.
  20963. * @param {number} [end=array.length] The end position.
  20964. * @returns {Array} Returns the cast slice.
  20965. */
  20966. function castSlice(array, start, end) {
  20967. var length = array.length;
  20968. end = end === undefined ? length : end;
  20969. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20970. }
  20971. /**
  20972. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20973. *
  20974. * @private
  20975. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20976. */
  20977. var clearTimeout = ctxClearTimeout || function(id) {
  20978. return root.clearTimeout(id);
  20979. };
  20980. /**
  20981. * Creates a clone of `buffer`.
  20982. *
  20983. * @private
  20984. * @param {Buffer} buffer The buffer to clone.
  20985. * @param {boolean} [isDeep] Specify a deep clone.
  20986. * @returns {Buffer} Returns the cloned buffer.
  20987. */
  20988. function cloneBuffer(buffer, isDeep) {
  20989. if (isDeep) {
  20990. return buffer.slice();
  20991. }
  20992. var length = buffer.length,
  20993. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20994. buffer.copy(result);
  20995. return result;
  20996. }
  20997. /**
  20998. * Creates a clone of `arrayBuffer`.
  20999. *
  21000. * @private
  21001. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21002. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21003. */
  21004. function cloneArrayBuffer(arrayBuffer) {
  21005. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21006. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21007. return result;
  21008. }
  21009. /**
  21010. * Creates a clone of `dataView`.
  21011. *
  21012. * @private
  21013. * @param {Object} dataView The data view to clone.
  21014. * @param {boolean} [isDeep] Specify a deep clone.
  21015. * @returns {Object} Returns the cloned data view.
  21016. */
  21017. function cloneDataView(dataView, isDeep) {
  21018. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21019. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21020. }
  21021. /**
  21022. * Creates a clone of `regexp`.
  21023. *
  21024. * @private
  21025. * @param {Object} regexp The regexp to clone.
  21026. * @returns {Object} Returns the cloned regexp.
  21027. */
  21028. function cloneRegExp(regexp) {
  21029. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21030. result.lastIndex = regexp.lastIndex;
  21031. return result;
  21032. }
  21033. /**
  21034. * Creates a clone of the `symbol` object.
  21035. *
  21036. * @private
  21037. * @param {Object} symbol The symbol object to clone.
  21038. * @returns {Object} Returns the cloned symbol object.
  21039. */
  21040. function cloneSymbol(symbol) {
  21041. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21042. }
  21043. /**
  21044. * Creates a clone of `typedArray`.
  21045. *
  21046. * @private
  21047. * @param {Object} typedArray The typed array to clone.
  21048. * @param {boolean} [isDeep] Specify a deep clone.
  21049. * @returns {Object} Returns the cloned typed array.
  21050. */
  21051. function cloneTypedArray(typedArray, isDeep) {
  21052. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21053. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21054. }
  21055. /**
  21056. * Compares values to sort them in ascending order.
  21057. *
  21058. * @private
  21059. * @param {*} value The value to compare.
  21060. * @param {*} other The other value to compare.
  21061. * @returns {number} Returns the sort order indicator for `value`.
  21062. */
  21063. function compareAscending(value, other) {
  21064. if (value !== other) {
  21065. var valIsDefined = value !== undefined,
  21066. valIsNull = value === null,
  21067. valIsReflexive = value === value,
  21068. valIsSymbol = isSymbol(value);
  21069. var othIsDefined = other !== undefined,
  21070. othIsNull = other === null,
  21071. othIsReflexive = other === other,
  21072. othIsSymbol = isSymbol(other);
  21073. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21074. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21075. (valIsNull && othIsDefined && othIsReflexive) ||
  21076. (!valIsDefined && othIsReflexive) ||
  21077. !valIsReflexive) {
  21078. return 1;
  21079. }
  21080. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21081. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21082. (othIsNull && valIsDefined && valIsReflexive) ||
  21083. (!othIsDefined && valIsReflexive) ||
  21084. !othIsReflexive) {
  21085. return -1;
  21086. }
  21087. }
  21088. return 0;
  21089. }
  21090. /**
  21091. * Used by `_.orderBy` to compare multiple properties of a value to another
  21092. * and stable sort them.
  21093. *
  21094. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21095. * specify an order of "desc" for descending or "asc" for ascending sort order
  21096. * of corresponding values.
  21097. *
  21098. * @private
  21099. * @param {Object} object The object to compare.
  21100. * @param {Object} other The other object to compare.
  21101. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21102. * @returns {number} Returns the sort order indicator for `object`.
  21103. */
  21104. function compareMultiple(object, other, orders) {
  21105. var index = -1,
  21106. objCriteria = object.criteria,
  21107. othCriteria = other.criteria,
  21108. length = objCriteria.length,
  21109. ordersLength = orders.length;
  21110. while (++index < length) {
  21111. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21112. if (result) {
  21113. if (index >= ordersLength) {
  21114. return result;
  21115. }
  21116. var order = orders[index];
  21117. return result * (order == 'desc' ? -1 : 1);
  21118. }
  21119. }
  21120. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21121. // that causes it, under certain circumstances, to provide the same value for
  21122. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21123. // for more details.
  21124. //
  21125. // This also ensures a stable sort in V8 and other engines.
  21126. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21127. return object.index - other.index;
  21128. }
  21129. /**
  21130. * Creates an array that is the composition of partially applied arguments,
  21131. * placeholders, and provided arguments into a single array of arguments.
  21132. *
  21133. * @private
  21134. * @param {Array} args The provided arguments.
  21135. * @param {Array} partials The arguments to prepend to those provided.
  21136. * @param {Array} holders The `partials` placeholder indexes.
  21137. * @params {boolean} [isCurried] Specify composing for a curried function.
  21138. * @returns {Array} Returns the new array of composed arguments.
  21139. */
  21140. function composeArgs(args, partials, holders, isCurried) {
  21141. var argsIndex = -1,
  21142. argsLength = args.length,
  21143. holdersLength = holders.length,
  21144. leftIndex = -1,
  21145. leftLength = partials.length,
  21146. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21147. result = Array(leftLength + rangeLength),
  21148. isUncurried = !isCurried;
  21149. while (++leftIndex < leftLength) {
  21150. result[leftIndex] = partials[leftIndex];
  21151. }
  21152. while (++argsIndex < holdersLength) {
  21153. if (isUncurried || argsIndex < argsLength) {
  21154. result[holders[argsIndex]] = args[argsIndex];
  21155. }
  21156. }
  21157. while (rangeLength--) {
  21158. result[leftIndex++] = args[argsIndex++];
  21159. }
  21160. return result;
  21161. }
  21162. /**
  21163. * This function is like `composeArgs` except that the arguments composition
  21164. * is tailored for `_.partialRight`.
  21165. *
  21166. * @private
  21167. * @param {Array} args The provided arguments.
  21168. * @param {Array} partials The arguments to append to those provided.
  21169. * @param {Array} holders The `partials` placeholder indexes.
  21170. * @params {boolean} [isCurried] Specify composing for a curried function.
  21171. * @returns {Array} Returns the new array of composed arguments.
  21172. */
  21173. function composeArgsRight(args, partials, holders, isCurried) {
  21174. var argsIndex = -1,
  21175. argsLength = args.length,
  21176. holdersIndex = -1,
  21177. holdersLength = holders.length,
  21178. rightIndex = -1,
  21179. rightLength = partials.length,
  21180. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21181. result = Array(rangeLength + rightLength),
  21182. isUncurried = !isCurried;
  21183. while (++argsIndex < rangeLength) {
  21184. result[argsIndex] = args[argsIndex];
  21185. }
  21186. var offset = argsIndex;
  21187. while (++rightIndex < rightLength) {
  21188. result[offset + rightIndex] = partials[rightIndex];
  21189. }
  21190. while (++holdersIndex < holdersLength) {
  21191. if (isUncurried || argsIndex < argsLength) {
  21192. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21193. }
  21194. }
  21195. return result;
  21196. }
  21197. /**
  21198. * Copies the values of `source` to `array`.
  21199. *
  21200. * @private
  21201. * @param {Array} source The array to copy values from.
  21202. * @param {Array} [array=[]] The array to copy values to.
  21203. * @returns {Array} Returns `array`.
  21204. */
  21205. function copyArray(source, array) {
  21206. var index = -1,
  21207. length = source.length;
  21208. array || (array = Array(length));
  21209. while (++index < length) {
  21210. array[index] = source[index];
  21211. }
  21212. return array;
  21213. }
  21214. /**
  21215. * Copies properties of `source` to `object`.
  21216. *
  21217. * @private
  21218. * @param {Object} source The object to copy properties from.
  21219. * @param {Array} props The property identifiers to copy.
  21220. * @param {Object} [object={}] The object to copy properties to.
  21221. * @param {Function} [customizer] The function to customize copied values.
  21222. * @returns {Object} Returns `object`.
  21223. */
  21224. function copyObject(source, props, object, customizer) {
  21225. var isNew = !object;
  21226. object || (object = {});
  21227. var index = -1,
  21228. length = props.length;
  21229. while (++index < length) {
  21230. var key = props[index];
  21231. var newValue = customizer
  21232. ? customizer(object[key], source[key], key, object, source)
  21233. : undefined;
  21234. if (newValue === undefined) {
  21235. newValue = source[key];
  21236. }
  21237. if (isNew) {
  21238. baseAssignValue(object, key, newValue);
  21239. } else {
  21240. assignValue(object, key, newValue);
  21241. }
  21242. }
  21243. return object;
  21244. }
  21245. /**
  21246. * Copies own symbols of `source` to `object`.
  21247. *
  21248. * @private
  21249. * @param {Object} source The object to copy symbols from.
  21250. * @param {Object} [object={}] The object to copy symbols to.
  21251. * @returns {Object} Returns `object`.
  21252. */
  21253. function copySymbols(source, object) {
  21254. return copyObject(source, getSymbols(source), object);
  21255. }
  21256. /**
  21257. * Copies own and inherited symbols of `source` to `object`.
  21258. *
  21259. * @private
  21260. * @param {Object} source The object to copy symbols from.
  21261. * @param {Object} [object={}] The object to copy symbols to.
  21262. * @returns {Object} Returns `object`.
  21263. */
  21264. function copySymbolsIn(source, object) {
  21265. return copyObject(source, getSymbolsIn(source), object);
  21266. }
  21267. /**
  21268. * Creates a function like `_.groupBy`.
  21269. *
  21270. * @private
  21271. * @param {Function} setter The function to set accumulator values.
  21272. * @param {Function} [initializer] The accumulator object initializer.
  21273. * @returns {Function} Returns the new aggregator function.
  21274. */
  21275. function createAggregator(setter, initializer) {
  21276. return function(collection, iteratee) {
  21277. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21278. accumulator = initializer ? initializer() : {};
  21279. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21280. };
  21281. }
  21282. /**
  21283. * Creates a function like `_.assign`.
  21284. *
  21285. * @private
  21286. * @param {Function} assigner The function to assign values.
  21287. * @returns {Function} Returns the new assigner function.
  21288. */
  21289. function createAssigner(assigner) {
  21290. return baseRest(function(object, sources) {
  21291. var index = -1,
  21292. length = sources.length,
  21293. customizer = length > 1 ? sources[length - 1] : undefined,
  21294. guard = length > 2 ? sources[2] : undefined;
  21295. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21296. ? (length--, customizer)
  21297. : undefined;
  21298. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21299. customizer = length < 3 ? undefined : customizer;
  21300. length = 1;
  21301. }
  21302. object = Object(object);
  21303. while (++index < length) {
  21304. var source = sources[index];
  21305. if (source) {
  21306. assigner(object, source, index, customizer);
  21307. }
  21308. }
  21309. return object;
  21310. });
  21311. }
  21312. /**
  21313. * Creates a `baseEach` or `baseEachRight` function.
  21314. *
  21315. * @private
  21316. * @param {Function} eachFunc The function to iterate over a collection.
  21317. * @param {boolean} [fromRight] Specify iterating from right to left.
  21318. * @returns {Function} Returns the new base function.
  21319. */
  21320. function createBaseEach(eachFunc, fromRight) {
  21321. return function(collection, iteratee) {
  21322. if (collection == null) {
  21323. return collection;
  21324. }
  21325. if (!isArrayLike(collection)) {
  21326. return eachFunc(collection, iteratee);
  21327. }
  21328. var length = collection.length,
  21329. index = fromRight ? length : -1,
  21330. iterable = Object(collection);
  21331. while ((fromRight ? index-- : ++index < length)) {
  21332. if (iteratee(iterable[index], index, iterable) === false) {
  21333. break;
  21334. }
  21335. }
  21336. return collection;
  21337. };
  21338. }
  21339. /**
  21340. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21341. *
  21342. * @private
  21343. * @param {boolean} [fromRight] Specify iterating from right to left.
  21344. * @returns {Function} Returns the new base function.
  21345. */
  21346. function createBaseFor(fromRight) {
  21347. return function(object, iteratee, keysFunc) {
  21348. var index = -1,
  21349. iterable = Object(object),
  21350. props = keysFunc(object),
  21351. length = props.length;
  21352. while (length--) {
  21353. var key = props[fromRight ? length : ++index];
  21354. if (iteratee(iterable[key], key, iterable) === false) {
  21355. break;
  21356. }
  21357. }
  21358. return object;
  21359. };
  21360. }
  21361. /**
  21362. * Creates a function that wraps `func` to invoke it with the optional `this`
  21363. * binding of `thisArg`.
  21364. *
  21365. * @private
  21366. * @param {Function} func The function to wrap.
  21367. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21368. * @param {*} [thisArg] The `this` binding of `func`.
  21369. * @returns {Function} Returns the new wrapped function.
  21370. */
  21371. function createBind(func, bitmask, thisArg) {
  21372. var isBind = bitmask & WRAP_BIND_FLAG,
  21373. Ctor = createCtor(func);
  21374. function wrapper() {
  21375. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21376. return fn.apply(isBind ? thisArg : this, arguments);
  21377. }
  21378. return wrapper;
  21379. }
  21380. /**
  21381. * Creates a function like `_.lowerFirst`.
  21382. *
  21383. * @private
  21384. * @param {string} methodName The name of the `String` case method to use.
  21385. * @returns {Function} Returns the new case function.
  21386. */
  21387. function createCaseFirst(methodName) {
  21388. return function(string) {
  21389. string = toString(string);
  21390. var strSymbols = hasUnicode(string)
  21391. ? stringToArray(string)
  21392. : undefined;
  21393. var chr = strSymbols
  21394. ? strSymbols[0]
  21395. : string.charAt(0);
  21396. var trailing = strSymbols
  21397. ? castSlice(strSymbols, 1).join('')
  21398. : string.slice(1);
  21399. return chr[methodName]() + trailing;
  21400. };
  21401. }
  21402. /**
  21403. * Creates a function like `_.camelCase`.
  21404. *
  21405. * @private
  21406. * @param {Function} callback The function to combine each word.
  21407. * @returns {Function} Returns the new compounder function.
  21408. */
  21409. function createCompounder(callback) {
  21410. return function(string) {
  21411. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21412. };
  21413. }
  21414. /**
  21415. * Creates a function that produces an instance of `Ctor` regardless of
  21416. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21417. *
  21418. * @private
  21419. * @param {Function} Ctor The constructor to wrap.
  21420. * @returns {Function} Returns the new wrapped function.
  21421. */
  21422. function createCtor(Ctor) {
  21423. return function() {
  21424. // Use a `switch` statement to work with class constructors. See
  21425. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21426. // for more details.
  21427. var args = arguments;
  21428. switch (args.length) {
  21429. case 0: return new Ctor;
  21430. case 1: return new Ctor(args[0]);
  21431. case 2: return new Ctor(args[0], args[1]);
  21432. case 3: return new Ctor(args[0], args[1], args[2]);
  21433. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21434. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21435. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21436. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21437. }
  21438. var thisBinding = baseCreate(Ctor.prototype),
  21439. result = Ctor.apply(thisBinding, args);
  21440. // Mimic the constructor's `return` behavior.
  21441. // See https://es5.github.io/#x13.2.2 for more details.
  21442. return isObject(result) ? result : thisBinding;
  21443. };
  21444. }
  21445. /**
  21446. * Creates a function that wraps `func` to enable currying.
  21447. *
  21448. * @private
  21449. * @param {Function} func The function to wrap.
  21450. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21451. * @param {number} arity The arity of `func`.
  21452. * @returns {Function} Returns the new wrapped function.
  21453. */
  21454. function createCurry(func, bitmask, arity) {
  21455. var Ctor = createCtor(func);
  21456. function wrapper() {
  21457. var length = arguments.length,
  21458. args = Array(length),
  21459. index = length,
  21460. placeholder = getHolder(wrapper);
  21461. while (index--) {
  21462. args[index] = arguments[index];
  21463. }
  21464. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21465. ? []
  21466. : replaceHolders(args, placeholder);
  21467. length -= holders.length;
  21468. if (length < arity) {
  21469. return createRecurry(
  21470. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21471. args, holders, undefined, undefined, arity - length);
  21472. }
  21473. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21474. return apply(fn, this, args);
  21475. }
  21476. return wrapper;
  21477. }
  21478. /**
  21479. * Creates a `_.find` or `_.findLast` function.
  21480. *
  21481. * @private
  21482. * @param {Function} findIndexFunc The function to find the collection index.
  21483. * @returns {Function} Returns the new find function.
  21484. */
  21485. function createFind(findIndexFunc) {
  21486. return function(collection, predicate, fromIndex) {
  21487. var iterable = Object(collection);
  21488. if (!isArrayLike(collection)) {
  21489. var iteratee = getIteratee(predicate, 3);
  21490. collection = keys(collection);
  21491. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21492. }
  21493. var index = findIndexFunc(collection, predicate, fromIndex);
  21494. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21495. };
  21496. }
  21497. /**
  21498. * Creates a `_.flow` or `_.flowRight` function.
  21499. *
  21500. * @private
  21501. * @param {boolean} [fromRight] Specify iterating from right to left.
  21502. * @returns {Function} Returns the new flow function.
  21503. */
  21504. function createFlow(fromRight) {
  21505. return flatRest(function(funcs) {
  21506. var length = funcs.length,
  21507. index = length,
  21508. prereq = LodashWrapper.prototype.thru;
  21509. if (fromRight) {
  21510. funcs.reverse();
  21511. }
  21512. while (index--) {
  21513. var func = funcs[index];
  21514. if (typeof func != 'function') {
  21515. throw new TypeError(FUNC_ERROR_TEXT);
  21516. }
  21517. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21518. var wrapper = new LodashWrapper([], true);
  21519. }
  21520. }
  21521. index = wrapper ? index : length;
  21522. while (++index < length) {
  21523. func = funcs[index];
  21524. var funcName = getFuncName(func),
  21525. data = funcName == 'wrapper' ? getData(func) : undefined;
  21526. if (data && isLaziable(data[0]) &&
  21527. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21528. !data[4].length && data[9] == 1
  21529. ) {
  21530. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21531. } else {
  21532. wrapper = (func.length == 1 && isLaziable(func))
  21533. ? wrapper[funcName]()
  21534. : wrapper.thru(func);
  21535. }
  21536. }
  21537. return function() {
  21538. var args = arguments,
  21539. value = args[0];
  21540. if (wrapper && args.length == 1 && isArray(value)) {
  21541. return wrapper.plant(value).value();
  21542. }
  21543. var index = 0,
  21544. result = length ? funcs[index].apply(this, args) : value;
  21545. while (++index < length) {
  21546. result = funcs[index].call(this, result);
  21547. }
  21548. return result;
  21549. };
  21550. });
  21551. }
  21552. /**
  21553. * Creates a function that wraps `func` to invoke it with optional `this`
  21554. * binding of `thisArg`, partial application, and currying.
  21555. *
  21556. * @private
  21557. * @param {Function|string} func The function or method name to wrap.
  21558. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21559. * @param {*} [thisArg] The `this` binding of `func`.
  21560. * @param {Array} [partials] The arguments to prepend to those provided to
  21561. * the new function.
  21562. * @param {Array} [holders] The `partials` placeholder indexes.
  21563. * @param {Array} [partialsRight] The arguments to append to those provided
  21564. * to the new function.
  21565. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21566. * @param {Array} [argPos] The argument positions of the new function.
  21567. * @param {number} [ary] The arity cap of `func`.
  21568. * @param {number} [arity] The arity of `func`.
  21569. * @returns {Function} Returns the new wrapped function.
  21570. */
  21571. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21572. var isAry = bitmask & WRAP_ARY_FLAG,
  21573. isBind = bitmask & WRAP_BIND_FLAG,
  21574. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21575. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21576. isFlip = bitmask & WRAP_FLIP_FLAG,
  21577. Ctor = isBindKey ? undefined : createCtor(func);
  21578. function wrapper() {
  21579. var length = arguments.length,
  21580. args = Array(length),
  21581. index = length;
  21582. while (index--) {
  21583. args[index] = arguments[index];
  21584. }
  21585. if (isCurried) {
  21586. var placeholder = getHolder(wrapper),
  21587. holdersCount = countHolders(args, placeholder);
  21588. }
  21589. if (partials) {
  21590. args = composeArgs(args, partials, holders, isCurried);
  21591. }
  21592. if (partialsRight) {
  21593. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21594. }
  21595. length -= holdersCount;
  21596. if (isCurried && length < arity) {
  21597. var newHolders = replaceHolders(args, placeholder);
  21598. return createRecurry(
  21599. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21600. args, newHolders, argPos, ary, arity - length
  21601. );
  21602. }
  21603. var thisBinding = isBind ? thisArg : this,
  21604. fn = isBindKey ? thisBinding[func] : func;
  21605. length = args.length;
  21606. if (argPos) {
  21607. args = reorder(args, argPos);
  21608. } else if (isFlip && length > 1) {
  21609. args.reverse();
  21610. }
  21611. if (isAry && ary < length) {
  21612. args.length = ary;
  21613. }
  21614. if (this && this !== root && this instanceof wrapper) {
  21615. fn = Ctor || createCtor(fn);
  21616. }
  21617. return fn.apply(thisBinding, args);
  21618. }
  21619. return wrapper;
  21620. }
  21621. /**
  21622. * Creates a function like `_.invertBy`.
  21623. *
  21624. * @private
  21625. * @param {Function} setter The function to set accumulator values.
  21626. * @param {Function} toIteratee The function to resolve iteratees.
  21627. * @returns {Function} Returns the new inverter function.
  21628. */
  21629. function createInverter(setter, toIteratee) {
  21630. return function(object, iteratee) {
  21631. return baseInverter(object, setter, toIteratee(iteratee), {});
  21632. };
  21633. }
  21634. /**
  21635. * Creates a function that performs a mathematical operation on two values.
  21636. *
  21637. * @private
  21638. * @param {Function} operator The function to perform the operation.
  21639. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21640. * @returns {Function} Returns the new mathematical operation function.
  21641. */
  21642. function createMathOperation(operator, defaultValue) {
  21643. return function(value, other) {
  21644. var result;
  21645. if (value === undefined && other === undefined) {
  21646. return defaultValue;
  21647. }
  21648. if (value !== undefined) {
  21649. result = value;
  21650. }
  21651. if (other !== undefined) {
  21652. if (result === undefined) {
  21653. return other;
  21654. }
  21655. if (typeof value == 'string' || typeof other == 'string') {
  21656. value = baseToString(value);
  21657. other = baseToString(other);
  21658. } else {
  21659. value = baseToNumber(value);
  21660. other = baseToNumber(other);
  21661. }
  21662. result = operator(value, other);
  21663. }
  21664. return result;
  21665. };
  21666. }
  21667. /**
  21668. * Creates a function like `_.over`.
  21669. *
  21670. * @private
  21671. * @param {Function} arrayFunc The function to iterate over iteratees.
  21672. * @returns {Function} Returns the new over function.
  21673. */
  21674. function createOver(arrayFunc) {
  21675. return flatRest(function(iteratees) {
  21676. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21677. return baseRest(function(args) {
  21678. var thisArg = this;
  21679. return arrayFunc(iteratees, function(iteratee) {
  21680. return apply(iteratee, thisArg, args);
  21681. });
  21682. });
  21683. });
  21684. }
  21685. /**
  21686. * Creates the padding for `string` based on `length`. The `chars` string
  21687. * is truncated if the number of characters exceeds `length`.
  21688. *
  21689. * @private
  21690. * @param {number} length The padding length.
  21691. * @param {string} [chars=' '] The string used as padding.
  21692. * @returns {string} Returns the padding for `string`.
  21693. */
  21694. function createPadding(length, chars) {
  21695. chars = chars === undefined ? ' ' : baseToString(chars);
  21696. var charsLength = chars.length;
  21697. if (charsLength < 2) {
  21698. return charsLength ? baseRepeat(chars, length) : chars;
  21699. }
  21700. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21701. return hasUnicode(chars)
  21702. ? castSlice(stringToArray(result), 0, length).join('')
  21703. : result.slice(0, length);
  21704. }
  21705. /**
  21706. * Creates a function that wraps `func` to invoke it with the `this` binding
  21707. * of `thisArg` and `partials` prepended to the arguments it receives.
  21708. *
  21709. * @private
  21710. * @param {Function} func The function to wrap.
  21711. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21712. * @param {*} thisArg The `this` binding of `func`.
  21713. * @param {Array} partials The arguments to prepend to those provided to
  21714. * the new function.
  21715. * @returns {Function} Returns the new wrapped function.
  21716. */
  21717. function createPartial(func, bitmask, thisArg, partials) {
  21718. var isBind = bitmask & WRAP_BIND_FLAG,
  21719. Ctor = createCtor(func);
  21720. function wrapper() {
  21721. var argsIndex = -1,
  21722. argsLength = arguments.length,
  21723. leftIndex = -1,
  21724. leftLength = partials.length,
  21725. args = Array(leftLength + argsLength),
  21726. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21727. while (++leftIndex < leftLength) {
  21728. args[leftIndex] = partials[leftIndex];
  21729. }
  21730. while (argsLength--) {
  21731. args[leftIndex++] = arguments[++argsIndex];
  21732. }
  21733. return apply(fn, isBind ? thisArg : this, args);
  21734. }
  21735. return wrapper;
  21736. }
  21737. /**
  21738. * Creates a `_.range` or `_.rangeRight` function.
  21739. *
  21740. * @private
  21741. * @param {boolean} [fromRight] Specify iterating from right to left.
  21742. * @returns {Function} Returns the new range function.
  21743. */
  21744. function createRange(fromRight) {
  21745. return function(start, end, step) {
  21746. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21747. end = step = undefined;
  21748. }
  21749. // Ensure the sign of `-0` is preserved.
  21750. start = toFinite(start);
  21751. if (end === undefined) {
  21752. end = start;
  21753. start = 0;
  21754. } else {
  21755. end = toFinite(end);
  21756. }
  21757. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21758. return baseRange(start, end, step, fromRight);
  21759. };
  21760. }
  21761. /**
  21762. * Creates a function that performs a relational operation on two values.
  21763. *
  21764. * @private
  21765. * @param {Function} operator The function to perform the operation.
  21766. * @returns {Function} Returns the new relational operation function.
  21767. */
  21768. function createRelationalOperation(operator) {
  21769. return function(value, other) {
  21770. if (!(typeof value == 'string' && typeof other == 'string')) {
  21771. value = toNumber(value);
  21772. other = toNumber(other);
  21773. }
  21774. return operator(value, other);
  21775. };
  21776. }
  21777. /**
  21778. * Creates a function that wraps `func` to continue currying.
  21779. *
  21780. * @private
  21781. * @param {Function} func The function to wrap.
  21782. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21783. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21784. * @param {*} placeholder The placeholder value.
  21785. * @param {*} [thisArg] The `this` binding of `func`.
  21786. * @param {Array} [partials] The arguments to prepend to those provided to
  21787. * the new function.
  21788. * @param {Array} [holders] The `partials` placeholder indexes.
  21789. * @param {Array} [argPos] The argument positions of the new function.
  21790. * @param {number} [ary] The arity cap of `func`.
  21791. * @param {number} [arity] The arity of `func`.
  21792. * @returns {Function} Returns the new wrapped function.
  21793. */
  21794. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21795. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21796. newHolders = isCurry ? holders : undefined,
  21797. newHoldersRight = isCurry ? undefined : holders,
  21798. newPartials = isCurry ? partials : undefined,
  21799. newPartialsRight = isCurry ? undefined : partials;
  21800. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21801. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21802. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21803. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21804. }
  21805. var newData = [
  21806. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21807. newHoldersRight, argPos, ary, arity
  21808. ];
  21809. var result = wrapFunc.apply(undefined, newData);
  21810. if (isLaziable(func)) {
  21811. setData(result, newData);
  21812. }
  21813. result.placeholder = placeholder;
  21814. return setWrapToString(result, func, bitmask);
  21815. }
  21816. /**
  21817. * Creates a function like `_.round`.
  21818. *
  21819. * @private
  21820. * @param {string} methodName The name of the `Math` method to use when rounding.
  21821. * @returns {Function} Returns the new round function.
  21822. */
  21823. function createRound(methodName) {
  21824. var func = Math[methodName];
  21825. return function(number, precision) {
  21826. number = toNumber(number);
  21827. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21828. if (precision && nativeIsFinite(number)) {
  21829. // Shift with exponential notation to avoid floating-point issues.
  21830. // See [MDN](https://mdn.io/round#Examples) for more details.
  21831. var pair = (toString(number) + 'e').split('e'),
  21832. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21833. pair = (toString(value) + 'e').split('e');
  21834. return +(pair[0] + 'e' + (+pair[1] - precision));
  21835. }
  21836. return func(number);
  21837. };
  21838. }
  21839. /**
  21840. * Creates a set object of `values`.
  21841. *
  21842. * @private
  21843. * @param {Array} values The values to add to the set.
  21844. * @returns {Object} Returns the new set.
  21845. */
  21846. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21847. return new Set(values);
  21848. };
  21849. /**
  21850. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21851. *
  21852. * @private
  21853. * @param {Function} keysFunc The function to get the keys of a given object.
  21854. * @returns {Function} Returns the new pairs function.
  21855. */
  21856. function createToPairs(keysFunc) {
  21857. return function(object) {
  21858. var tag = getTag(object);
  21859. if (tag == mapTag) {
  21860. return mapToArray(object);
  21861. }
  21862. if (tag == setTag) {
  21863. return setToPairs(object);
  21864. }
  21865. return baseToPairs(object, keysFunc(object));
  21866. };
  21867. }
  21868. /**
  21869. * Creates a function that either curries or invokes `func` with optional
  21870. * `this` binding and partially applied arguments.
  21871. *
  21872. * @private
  21873. * @param {Function|string} func The function or method name to wrap.
  21874. * @param {number} bitmask The bitmask flags.
  21875. * 1 - `_.bind`
  21876. * 2 - `_.bindKey`
  21877. * 4 - `_.curry` or `_.curryRight` of a bound function
  21878. * 8 - `_.curry`
  21879. * 16 - `_.curryRight`
  21880. * 32 - `_.partial`
  21881. * 64 - `_.partialRight`
  21882. * 128 - `_.rearg`
  21883. * 256 - `_.ary`
  21884. * 512 - `_.flip`
  21885. * @param {*} [thisArg] The `this` binding of `func`.
  21886. * @param {Array} [partials] The arguments to be partially applied.
  21887. * @param {Array} [holders] The `partials` placeholder indexes.
  21888. * @param {Array} [argPos] The argument positions of the new function.
  21889. * @param {number} [ary] The arity cap of `func`.
  21890. * @param {number} [arity] The arity of `func`.
  21891. * @returns {Function} Returns the new wrapped function.
  21892. */
  21893. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21894. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21895. if (!isBindKey && typeof func != 'function') {
  21896. throw new TypeError(FUNC_ERROR_TEXT);
  21897. }
  21898. var length = partials ? partials.length : 0;
  21899. if (!length) {
  21900. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21901. partials = holders = undefined;
  21902. }
  21903. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21904. arity = arity === undefined ? arity : toInteger(arity);
  21905. length -= holders ? holders.length : 0;
  21906. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21907. var partialsRight = partials,
  21908. holdersRight = holders;
  21909. partials = holders = undefined;
  21910. }
  21911. var data = isBindKey ? undefined : getData(func);
  21912. var newData = [
  21913. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21914. argPos, ary, arity
  21915. ];
  21916. if (data) {
  21917. mergeData(newData, data);
  21918. }
  21919. func = newData[0];
  21920. bitmask = newData[1];
  21921. thisArg = newData[2];
  21922. partials = newData[3];
  21923. holders = newData[4];
  21924. arity = newData[9] = newData[9] === undefined
  21925. ? (isBindKey ? 0 : func.length)
  21926. : nativeMax(newData[9] - length, 0);
  21927. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21928. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21929. }
  21930. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21931. var result = createBind(func, bitmask, thisArg);
  21932. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21933. result = createCurry(func, bitmask, arity);
  21934. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21935. result = createPartial(func, bitmask, thisArg, partials);
  21936. } else {
  21937. result = createHybrid.apply(undefined, newData);
  21938. }
  21939. var setter = data ? baseSetData : setData;
  21940. return setWrapToString(setter(result, newData), func, bitmask);
  21941. }
  21942. /**
  21943. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21944. * of source objects to the destination object for all destination properties
  21945. * that resolve to `undefined`.
  21946. *
  21947. * @private
  21948. * @param {*} objValue The destination value.
  21949. * @param {*} srcValue The source value.
  21950. * @param {string} key The key of the property to assign.
  21951. * @param {Object} object The parent object of `objValue`.
  21952. * @returns {*} Returns the value to assign.
  21953. */
  21954. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21955. if (objValue === undefined ||
  21956. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21957. return srcValue;
  21958. }
  21959. return objValue;
  21960. }
  21961. /**
  21962. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21963. * objects into destination objects that are passed thru.
  21964. *
  21965. * @private
  21966. * @param {*} objValue The destination value.
  21967. * @param {*} srcValue The source value.
  21968. * @param {string} key The key of the property to merge.
  21969. * @param {Object} object The parent object of `objValue`.
  21970. * @param {Object} source The parent object of `srcValue`.
  21971. * @param {Object} [stack] Tracks traversed source values and their merged
  21972. * counterparts.
  21973. * @returns {*} Returns the value to assign.
  21974. */
  21975. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21976. if (isObject(objValue) && isObject(srcValue)) {
  21977. // Recursively merge objects and arrays (susceptible to call stack limits).
  21978. stack.set(srcValue, objValue);
  21979. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21980. stack['delete'](srcValue);
  21981. }
  21982. return objValue;
  21983. }
  21984. /**
  21985. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21986. * objects.
  21987. *
  21988. * @private
  21989. * @param {*} value The value to inspect.
  21990. * @param {string} key The key of the property to inspect.
  21991. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21992. */
  21993. function customOmitClone(value) {
  21994. return isPlainObject(value) ? undefined : value;
  21995. }
  21996. /**
  21997. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21998. * partial deep comparisons.
  21999. *
  22000. * @private
  22001. * @param {Array} array The array to compare.
  22002. * @param {Array} other The other array to compare.
  22003. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22004. * @param {Function} customizer The function to customize comparisons.
  22005. * @param {Function} equalFunc The function to determine equivalents of values.
  22006. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22007. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22008. */
  22009. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22010. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22011. arrLength = array.length,
  22012. othLength = other.length;
  22013. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22014. return false;
  22015. }
  22016. // Assume cyclic values are equal.
  22017. var stacked = stack.get(array);
  22018. if (stacked && stack.get(other)) {
  22019. return stacked == other;
  22020. }
  22021. var index = -1,
  22022. result = true,
  22023. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22024. stack.set(array, other);
  22025. stack.set(other, array);
  22026. // Ignore non-index properties.
  22027. while (++index < arrLength) {
  22028. var arrValue = array[index],
  22029. othValue = other[index];
  22030. if (customizer) {
  22031. var compared = isPartial
  22032. ? customizer(othValue, arrValue, index, other, array, stack)
  22033. : customizer(arrValue, othValue, index, array, other, stack);
  22034. }
  22035. if (compared !== undefined) {
  22036. if (compared) {
  22037. continue;
  22038. }
  22039. result = false;
  22040. break;
  22041. }
  22042. // Recursively compare arrays (susceptible to call stack limits).
  22043. if (seen) {
  22044. if (!arraySome(other, function(othValue, othIndex) {
  22045. if (!cacheHas(seen, othIndex) &&
  22046. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22047. return seen.push(othIndex);
  22048. }
  22049. })) {
  22050. result = false;
  22051. break;
  22052. }
  22053. } else if (!(
  22054. arrValue === othValue ||
  22055. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22056. )) {
  22057. result = false;
  22058. break;
  22059. }
  22060. }
  22061. stack['delete'](array);
  22062. stack['delete'](other);
  22063. return result;
  22064. }
  22065. /**
  22066. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22067. * the same `toStringTag`.
  22068. *
  22069. * **Note:** This function only supports comparing values with tags of
  22070. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22071. *
  22072. * @private
  22073. * @param {Object} object The object to compare.
  22074. * @param {Object} other The other object to compare.
  22075. * @param {string} tag The `toStringTag` of the objects to compare.
  22076. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22077. * @param {Function} customizer The function to customize comparisons.
  22078. * @param {Function} equalFunc The function to determine equivalents of values.
  22079. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22080. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22081. */
  22082. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22083. switch (tag) {
  22084. case dataViewTag:
  22085. if ((object.byteLength != other.byteLength) ||
  22086. (object.byteOffset != other.byteOffset)) {
  22087. return false;
  22088. }
  22089. object = object.buffer;
  22090. other = other.buffer;
  22091. case arrayBufferTag:
  22092. if ((object.byteLength != other.byteLength) ||
  22093. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22094. return false;
  22095. }
  22096. return true;
  22097. case boolTag:
  22098. case dateTag:
  22099. case numberTag:
  22100. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22101. // Invalid dates are coerced to `NaN`.
  22102. return eq(+object, +other);
  22103. case errorTag:
  22104. return object.name == other.name && object.message == other.message;
  22105. case regexpTag:
  22106. case stringTag:
  22107. // Coerce regexes to strings and treat strings, primitives and objects,
  22108. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22109. // for more details.
  22110. return object == (other + '');
  22111. case mapTag:
  22112. var convert = mapToArray;
  22113. case setTag:
  22114. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22115. convert || (convert = setToArray);
  22116. if (object.size != other.size && !isPartial) {
  22117. return false;
  22118. }
  22119. // Assume cyclic values are equal.
  22120. var stacked = stack.get(object);
  22121. if (stacked) {
  22122. return stacked == other;
  22123. }
  22124. bitmask |= COMPARE_UNORDERED_FLAG;
  22125. // Recursively compare objects (susceptible to call stack limits).
  22126. stack.set(object, other);
  22127. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22128. stack['delete'](object);
  22129. return result;
  22130. case symbolTag:
  22131. if (symbolValueOf) {
  22132. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22133. }
  22134. }
  22135. return false;
  22136. }
  22137. /**
  22138. * A specialized version of `baseIsEqualDeep` for objects with support for
  22139. * partial deep comparisons.
  22140. *
  22141. * @private
  22142. * @param {Object} object The object to compare.
  22143. * @param {Object} other The other object to compare.
  22144. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22145. * @param {Function} customizer The function to customize comparisons.
  22146. * @param {Function} equalFunc The function to determine equivalents of values.
  22147. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22148. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22149. */
  22150. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22151. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22152. objProps = getAllKeys(object),
  22153. objLength = objProps.length,
  22154. othProps = getAllKeys(other),
  22155. othLength = othProps.length;
  22156. if (objLength != othLength && !isPartial) {
  22157. return false;
  22158. }
  22159. var index = objLength;
  22160. while (index--) {
  22161. var key = objProps[index];
  22162. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22163. return false;
  22164. }
  22165. }
  22166. // Assume cyclic values are equal.
  22167. var stacked = stack.get(object);
  22168. if (stacked && stack.get(other)) {
  22169. return stacked == other;
  22170. }
  22171. var result = true;
  22172. stack.set(object, other);
  22173. stack.set(other, object);
  22174. var skipCtor = isPartial;
  22175. while (++index < objLength) {
  22176. key = objProps[index];
  22177. var objValue = object[key],
  22178. othValue = other[key];
  22179. if (customizer) {
  22180. var compared = isPartial
  22181. ? customizer(othValue, objValue, key, other, object, stack)
  22182. : customizer(objValue, othValue, key, object, other, stack);
  22183. }
  22184. // Recursively compare objects (susceptible to call stack limits).
  22185. if (!(compared === undefined
  22186. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22187. : compared
  22188. )) {
  22189. result = false;
  22190. break;
  22191. }
  22192. skipCtor || (skipCtor = key == 'constructor');
  22193. }
  22194. if (result && !skipCtor) {
  22195. var objCtor = object.constructor,
  22196. othCtor = other.constructor;
  22197. // Non `Object` object instances with different constructors are not equal.
  22198. if (objCtor != othCtor &&
  22199. ('constructor' in object && 'constructor' in other) &&
  22200. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22201. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22202. result = false;
  22203. }
  22204. }
  22205. stack['delete'](object);
  22206. stack['delete'](other);
  22207. return result;
  22208. }
  22209. /**
  22210. * A specialized version of `baseRest` which flattens the rest array.
  22211. *
  22212. * @private
  22213. * @param {Function} func The function to apply a rest parameter to.
  22214. * @returns {Function} Returns the new function.
  22215. */
  22216. function flatRest(func) {
  22217. return setToString(overRest(func, undefined, flatten), func + '');
  22218. }
  22219. /**
  22220. * Creates an array of own enumerable property names and symbols of `object`.
  22221. *
  22222. * @private
  22223. * @param {Object} object The object to query.
  22224. * @returns {Array} Returns the array of property names and symbols.
  22225. */
  22226. function getAllKeys(object) {
  22227. return baseGetAllKeys(object, keys, getSymbols);
  22228. }
  22229. /**
  22230. * Creates an array of own and inherited enumerable property names and
  22231. * symbols of `object`.
  22232. *
  22233. * @private
  22234. * @param {Object} object The object to query.
  22235. * @returns {Array} Returns the array of property names and symbols.
  22236. */
  22237. function getAllKeysIn(object) {
  22238. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22239. }
  22240. /**
  22241. * Gets metadata for `func`.
  22242. *
  22243. * @private
  22244. * @param {Function} func The function to query.
  22245. * @returns {*} Returns the metadata for `func`.
  22246. */
  22247. var getData = !metaMap ? noop : function(func) {
  22248. return metaMap.get(func);
  22249. };
  22250. /**
  22251. * Gets the name of `func`.
  22252. *
  22253. * @private
  22254. * @param {Function} func The function to query.
  22255. * @returns {string} Returns the function name.
  22256. */
  22257. function getFuncName(func) {
  22258. var result = (func.name + ''),
  22259. array = realNames[result],
  22260. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22261. while (length--) {
  22262. var data = array[length],
  22263. otherFunc = data.func;
  22264. if (otherFunc == null || otherFunc == func) {
  22265. return data.name;
  22266. }
  22267. }
  22268. return result;
  22269. }
  22270. /**
  22271. * Gets the argument placeholder value for `func`.
  22272. *
  22273. * @private
  22274. * @param {Function} func The function to inspect.
  22275. * @returns {*} Returns the placeholder value.
  22276. */
  22277. function getHolder(func) {
  22278. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22279. return object.placeholder;
  22280. }
  22281. /**
  22282. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22283. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22284. * If arguments are provided, the chosen function is invoked with them and
  22285. * its result is returned.
  22286. *
  22287. * @private
  22288. * @param {*} [value] The value to convert to an iteratee.
  22289. * @param {number} [arity] The arity of the created iteratee.
  22290. * @returns {Function} Returns the chosen function or its result.
  22291. */
  22292. function getIteratee() {
  22293. var result = lodash.iteratee || iteratee;
  22294. result = result === iteratee ? baseIteratee : result;
  22295. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22296. }
  22297. /**
  22298. * Gets the data for `map`.
  22299. *
  22300. * @private
  22301. * @param {Object} map The map to query.
  22302. * @param {string} key The reference key.
  22303. * @returns {*} Returns the map data.
  22304. */
  22305. function getMapData(map, key) {
  22306. var data = map.__data__;
  22307. return isKeyable(key)
  22308. ? data[typeof key == 'string' ? 'string' : 'hash']
  22309. : data.map;
  22310. }
  22311. /**
  22312. * Gets the property names, values, and compare flags of `object`.
  22313. *
  22314. * @private
  22315. * @param {Object} object The object to query.
  22316. * @returns {Array} Returns the match data of `object`.
  22317. */
  22318. function getMatchData(object) {
  22319. var result = keys(object),
  22320. length = result.length;
  22321. while (length--) {
  22322. var key = result[length],
  22323. value = object[key];
  22324. result[length] = [key, value, isStrictComparable(value)];
  22325. }
  22326. return result;
  22327. }
  22328. /**
  22329. * Gets the native function at `key` of `object`.
  22330. *
  22331. * @private
  22332. * @param {Object} object The object to query.
  22333. * @param {string} key The key of the method to get.
  22334. * @returns {*} Returns the function if it's native, else `undefined`.
  22335. */
  22336. function getNative(object, key) {
  22337. var value = getValue(object, key);
  22338. return baseIsNative(value) ? value : undefined;
  22339. }
  22340. /**
  22341. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22342. *
  22343. * @private
  22344. * @param {*} value The value to query.
  22345. * @returns {string} Returns the raw `toStringTag`.
  22346. */
  22347. function getRawTag(value) {
  22348. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22349. tag = value[symToStringTag];
  22350. try {
  22351. value[symToStringTag] = undefined;
  22352. var unmasked = true;
  22353. } catch (e) {}
  22354. var result = nativeObjectToString.call(value);
  22355. if (unmasked) {
  22356. if (isOwn) {
  22357. value[symToStringTag] = tag;
  22358. } else {
  22359. delete value[symToStringTag];
  22360. }
  22361. }
  22362. return result;
  22363. }
  22364. /**
  22365. * Creates an array of the own enumerable symbols of `object`.
  22366. *
  22367. * @private
  22368. * @param {Object} object The object to query.
  22369. * @returns {Array} Returns the array of symbols.
  22370. */
  22371. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22372. if (object == null) {
  22373. return [];
  22374. }
  22375. object = Object(object);
  22376. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22377. return propertyIsEnumerable.call(object, symbol);
  22378. });
  22379. };
  22380. /**
  22381. * Creates an array of the own and inherited enumerable symbols of `object`.
  22382. *
  22383. * @private
  22384. * @param {Object} object The object to query.
  22385. * @returns {Array} Returns the array of symbols.
  22386. */
  22387. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22388. var result = [];
  22389. while (object) {
  22390. arrayPush(result, getSymbols(object));
  22391. object = getPrototype(object);
  22392. }
  22393. return result;
  22394. };
  22395. /**
  22396. * Gets the `toStringTag` of `value`.
  22397. *
  22398. * @private
  22399. * @param {*} value The value to query.
  22400. * @returns {string} Returns the `toStringTag`.
  22401. */
  22402. var getTag = baseGetTag;
  22403. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22404. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22405. (Map && getTag(new Map) != mapTag) ||
  22406. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22407. (Set && getTag(new Set) != setTag) ||
  22408. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22409. getTag = function(value) {
  22410. var result = baseGetTag(value),
  22411. Ctor = result == objectTag ? value.constructor : undefined,
  22412. ctorString = Ctor ? toSource(Ctor) : '';
  22413. if (ctorString) {
  22414. switch (ctorString) {
  22415. case dataViewCtorString: return dataViewTag;
  22416. case mapCtorString: return mapTag;
  22417. case promiseCtorString: return promiseTag;
  22418. case setCtorString: return setTag;
  22419. case weakMapCtorString: return weakMapTag;
  22420. }
  22421. }
  22422. return result;
  22423. };
  22424. }
  22425. /**
  22426. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22427. *
  22428. * @private
  22429. * @param {number} start The start of the view.
  22430. * @param {number} end The end of the view.
  22431. * @param {Array} transforms The transformations to apply to the view.
  22432. * @returns {Object} Returns an object containing the `start` and `end`
  22433. * positions of the view.
  22434. */
  22435. function getView(start, end, transforms) {
  22436. var index = -1,
  22437. length = transforms.length;
  22438. while (++index < length) {
  22439. var data = transforms[index],
  22440. size = data.size;
  22441. switch (data.type) {
  22442. case 'drop': start += size; break;
  22443. case 'dropRight': end -= size; break;
  22444. case 'take': end = nativeMin(end, start + size); break;
  22445. case 'takeRight': start = nativeMax(start, end - size); break;
  22446. }
  22447. }
  22448. return { 'start': start, 'end': end };
  22449. }
  22450. /**
  22451. * Extracts wrapper details from the `source` body comment.
  22452. *
  22453. * @private
  22454. * @param {string} source The source to inspect.
  22455. * @returns {Array} Returns the wrapper details.
  22456. */
  22457. function getWrapDetails(source) {
  22458. var match = source.match(reWrapDetails);
  22459. return match ? match[1].split(reSplitDetails) : [];
  22460. }
  22461. /**
  22462. * Checks if `path` exists on `object`.
  22463. *
  22464. * @private
  22465. * @param {Object} object The object to query.
  22466. * @param {Array|string} path The path to check.
  22467. * @param {Function} hasFunc The function to check properties.
  22468. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22469. */
  22470. function hasPath(object, path, hasFunc) {
  22471. path = castPath(path, object);
  22472. var index = -1,
  22473. length = path.length,
  22474. result = false;
  22475. while (++index < length) {
  22476. var key = toKey(path[index]);
  22477. if (!(result = object != null && hasFunc(object, key))) {
  22478. break;
  22479. }
  22480. object = object[key];
  22481. }
  22482. if (result || ++index != length) {
  22483. return result;
  22484. }
  22485. length = object == null ? 0 : object.length;
  22486. return !!length && isLength(length) && isIndex(key, length) &&
  22487. (isArray(object) || isArguments(object));
  22488. }
  22489. /**
  22490. * Initializes an array clone.
  22491. *
  22492. * @private
  22493. * @param {Array} array The array to clone.
  22494. * @returns {Array} Returns the initialized clone.
  22495. */
  22496. function initCloneArray(array) {
  22497. var length = array.length,
  22498. result = new array.constructor(length);
  22499. // Add properties assigned by `RegExp#exec`.
  22500. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22501. result.index = array.index;
  22502. result.input = array.input;
  22503. }
  22504. return result;
  22505. }
  22506. /**
  22507. * Initializes an object clone.
  22508. *
  22509. * @private
  22510. * @param {Object} object The object to clone.
  22511. * @returns {Object} Returns the initialized clone.
  22512. */
  22513. function initCloneObject(object) {
  22514. return (typeof object.constructor == 'function' && !isPrototype(object))
  22515. ? baseCreate(getPrototype(object))
  22516. : {};
  22517. }
  22518. /**
  22519. * Initializes an object clone based on its `toStringTag`.
  22520. *
  22521. * **Note:** This function only supports cloning values with tags of
  22522. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22523. *
  22524. * @private
  22525. * @param {Object} object The object to clone.
  22526. * @param {string} tag The `toStringTag` of the object to clone.
  22527. * @param {boolean} [isDeep] Specify a deep clone.
  22528. * @returns {Object} Returns the initialized clone.
  22529. */
  22530. function initCloneByTag(object, tag, isDeep) {
  22531. var Ctor = object.constructor;
  22532. switch (tag) {
  22533. case arrayBufferTag:
  22534. return cloneArrayBuffer(object);
  22535. case boolTag:
  22536. case dateTag:
  22537. return new Ctor(+object);
  22538. case dataViewTag:
  22539. return cloneDataView(object, isDeep);
  22540. case float32Tag: case float64Tag:
  22541. case int8Tag: case int16Tag: case int32Tag:
  22542. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22543. return cloneTypedArray(object, isDeep);
  22544. case mapTag:
  22545. return new Ctor;
  22546. case numberTag:
  22547. case stringTag:
  22548. return new Ctor(object);
  22549. case regexpTag:
  22550. return cloneRegExp(object);
  22551. case setTag:
  22552. return new Ctor;
  22553. case symbolTag:
  22554. return cloneSymbol(object);
  22555. }
  22556. }
  22557. /**
  22558. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22559. *
  22560. * @private
  22561. * @param {string} source The source to modify.
  22562. * @returns {Array} details The details to insert.
  22563. * @returns {string} Returns the modified source.
  22564. */
  22565. function insertWrapDetails(source, details) {
  22566. var length = details.length;
  22567. if (!length) {
  22568. return source;
  22569. }
  22570. var lastIndex = length - 1;
  22571. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22572. details = details.join(length > 2 ? ', ' : ' ');
  22573. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22574. }
  22575. /**
  22576. * Checks if `value` is a flattenable `arguments` object or array.
  22577. *
  22578. * @private
  22579. * @param {*} value The value to check.
  22580. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22581. */
  22582. function isFlattenable(value) {
  22583. return isArray(value) || isArguments(value) ||
  22584. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22585. }
  22586. /**
  22587. * Checks if `value` is a valid array-like index.
  22588. *
  22589. * @private
  22590. * @param {*} value The value to check.
  22591. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22592. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22593. */
  22594. function isIndex(value, length) {
  22595. var type = typeof value;
  22596. length = length == null ? MAX_SAFE_INTEGER : length;
  22597. return !!length &&
  22598. (type == 'number' ||
  22599. (type != 'symbol' && reIsUint.test(value))) &&
  22600. (value > -1 && value % 1 == 0 && value < length);
  22601. }
  22602. /**
  22603. * Checks if the given arguments are from an iteratee call.
  22604. *
  22605. * @private
  22606. * @param {*} value The potential iteratee value argument.
  22607. * @param {*} index The potential iteratee index or key argument.
  22608. * @param {*} object The potential iteratee object argument.
  22609. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22610. * else `false`.
  22611. */
  22612. function isIterateeCall(value, index, object) {
  22613. if (!isObject(object)) {
  22614. return false;
  22615. }
  22616. var type = typeof index;
  22617. if (type == 'number'
  22618. ? (isArrayLike(object) && isIndex(index, object.length))
  22619. : (type == 'string' && index in object)
  22620. ) {
  22621. return eq(object[index], value);
  22622. }
  22623. return false;
  22624. }
  22625. /**
  22626. * Checks if `value` is a property name and not a property path.
  22627. *
  22628. * @private
  22629. * @param {*} value The value to check.
  22630. * @param {Object} [object] The object to query keys on.
  22631. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22632. */
  22633. function isKey(value, object) {
  22634. if (isArray(value)) {
  22635. return false;
  22636. }
  22637. var type = typeof value;
  22638. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22639. value == null || isSymbol(value)) {
  22640. return true;
  22641. }
  22642. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22643. (object != null && value in Object(object));
  22644. }
  22645. /**
  22646. * Checks if `value` is suitable for use as unique object key.
  22647. *
  22648. * @private
  22649. * @param {*} value The value to check.
  22650. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22651. */
  22652. function isKeyable(value) {
  22653. var type = typeof value;
  22654. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22655. ? (value !== '__proto__')
  22656. : (value === null);
  22657. }
  22658. /**
  22659. * Checks if `func` has a lazy counterpart.
  22660. *
  22661. * @private
  22662. * @param {Function} func The function to check.
  22663. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22664. * else `false`.
  22665. */
  22666. function isLaziable(func) {
  22667. var funcName = getFuncName(func),
  22668. other = lodash[funcName];
  22669. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22670. return false;
  22671. }
  22672. if (func === other) {
  22673. return true;
  22674. }
  22675. var data = getData(other);
  22676. return !!data && func === data[0];
  22677. }
  22678. /**
  22679. * Checks if `func` has its source masked.
  22680. *
  22681. * @private
  22682. * @param {Function} func The function to check.
  22683. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22684. */
  22685. function isMasked(func) {
  22686. return !!maskSrcKey && (maskSrcKey in func);
  22687. }
  22688. /**
  22689. * Checks if `func` is capable of being masked.
  22690. *
  22691. * @private
  22692. * @param {*} value The value to check.
  22693. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22694. */
  22695. var isMaskable = coreJsData ? isFunction : stubFalse;
  22696. /**
  22697. * Checks if `value` is likely a prototype object.
  22698. *
  22699. * @private
  22700. * @param {*} value The value to check.
  22701. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22702. */
  22703. function isPrototype(value) {
  22704. var Ctor = value && value.constructor,
  22705. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22706. return value === proto;
  22707. }
  22708. /**
  22709. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22710. *
  22711. * @private
  22712. * @param {*} value The value to check.
  22713. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22714. * equality comparisons, else `false`.
  22715. */
  22716. function isStrictComparable(value) {
  22717. return value === value && !isObject(value);
  22718. }
  22719. /**
  22720. * A specialized version of `matchesProperty` for source values suitable
  22721. * for strict equality comparisons, i.e. `===`.
  22722. *
  22723. * @private
  22724. * @param {string} key The key of the property to get.
  22725. * @param {*} srcValue The value to match.
  22726. * @returns {Function} Returns the new spec function.
  22727. */
  22728. function matchesStrictComparable(key, srcValue) {
  22729. return function(object) {
  22730. if (object == null) {
  22731. return false;
  22732. }
  22733. return object[key] === srcValue &&
  22734. (srcValue !== undefined || (key in Object(object)));
  22735. };
  22736. }
  22737. /**
  22738. * A specialized version of `_.memoize` which clears the memoized function's
  22739. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22740. *
  22741. * @private
  22742. * @param {Function} func The function to have its output memoized.
  22743. * @returns {Function} Returns the new memoized function.
  22744. */
  22745. function memoizeCapped(func) {
  22746. var result = memoize(func, function(key) {
  22747. if (cache.size === MAX_MEMOIZE_SIZE) {
  22748. cache.clear();
  22749. }
  22750. return key;
  22751. });
  22752. var cache = result.cache;
  22753. return result;
  22754. }
  22755. /**
  22756. * Merges the function metadata of `source` into `data`.
  22757. *
  22758. * Merging metadata reduces the number of wrappers used to invoke a function.
  22759. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22760. * may be applied regardless of execution order. Methods like `_.ary` and
  22761. * `_.rearg` modify function arguments, making the order in which they are
  22762. * executed important, preventing the merging of metadata. However, we make
  22763. * an exception for a safe combined case where curried functions have `_.ary`
  22764. * and or `_.rearg` applied.
  22765. *
  22766. * @private
  22767. * @param {Array} data The destination metadata.
  22768. * @param {Array} source The source metadata.
  22769. * @returns {Array} Returns `data`.
  22770. */
  22771. function mergeData(data, source) {
  22772. var bitmask = data[1],
  22773. srcBitmask = source[1],
  22774. newBitmask = bitmask | srcBitmask,
  22775. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22776. var isCombo =
  22777. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22778. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22779. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22780. // Exit early if metadata can't be merged.
  22781. if (!(isCommon || isCombo)) {
  22782. return data;
  22783. }
  22784. // Use source `thisArg` if available.
  22785. if (srcBitmask & WRAP_BIND_FLAG) {
  22786. data[2] = source[2];
  22787. // Set when currying a bound function.
  22788. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22789. }
  22790. // Compose partial arguments.
  22791. var value = source[3];
  22792. if (value) {
  22793. var partials = data[3];
  22794. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22795. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22796. }
  22797. // Compose partial right arguments.
  22798. value = source[5];
  22799. if (value) {
  22800. partials = data[5];
  22801. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22802. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22803. }
  22804. // Use source `argPos` if available.
  22805. value = source[7];
  22806. if (value) {
  22807. data[7] = value;
  22808. }
  22809. // Use source `ary` if it's smaller.
  22810. if (srcBitmask & WRAP_ARY_FLAG) {
  22811. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22812. }
  22813. // Use source `arity` if one is not provided.
  22814. if (data[9] == null) {
  22815. data[9] = source[9];
  22816. }
  22817. // Use source `func` and merge bitmasks.
  22818. data[0] = source[0];
  22819. data[1] = newBitmask;
  22820. return data;
  22821. }
  22822. /**
  22823. * This function is like
  22824. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22825. * except that it includes inherited enumerable properties.
  22826. *
  22827. * @private
  22828. * @param {Object} object The object to query.
  22829. * @returns {Array} Returns the array of property names.
  22830. */
  22831. function nativeKeysIn(object) {
  22832. var result = [];
  22833. if (object != null) {
  22834. for (var key in Object(object)) {
  22835. result.push(key);
  22836. }
  22837. }
  22838. return result;
  22839. }
  22840. /**
  22841. * Converts `value` to a string using `Object.prototype.toString`.
  22842. *
  22843. * @private
  22844. * @param {*} value The value to convert.
  22845. * @returns {string} Returns the converted string.
  22846. */
  22847. function objectToString(value) {
  22848. return nativeObjectToString.call(value);
  22849. }
  22850. /**
  22851. * A specialized version of `baseRest` which transforms the rest array.
  22852. *
  22853. * @private
  22854. * @param {Function} func The function to apply a rest parameter to.
  22855. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22856. * @param {Function} transform The rest array transform.
  22857. * @returns {Function} Returns the new function.
  22858. */
  22859. function overRest(func, start, transform) {
  22860. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22861. return function() {
  22862. var args = arguments,
  22863. index = -1,
  22864. length = nativeMax(args.length - start, 0),
  22865. array = Array(length);
  22866. while (++index < length) {
  22867. array[index] = args[start + index];
  22868. }
  22869. index = -1;
  22870. var otherArgs = Array(start + 1);
  22871. while (++index < start) {
  22872. otherArgs[index] = args[index];
  22873. }
  22874. otherArgs[start] = transform(array);
  22875. return apply(func, this, otherArgs);
  22876. };
  22877. }
  22878. /**
  22879. * Gets the parent value at `path` of `object`.
  22880. *
  22881. * @private
  22882. * @param {Object} object The object to query.
  22883. * @param {Array} path The path to get the parent value of.
  22884. * @returns {*} Returns the parent value.
  22885. */
  22886. function parent(object, path) {
  22887. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22888. }
  22889. /**
  22890. * Reorder `array` according to the specified indexes where the element at
  22891. * the first index is assigned as the first element, the element at
  22892. * the second index is assigned as the second element, and so on.
  22893. *
  22894. * @private
  22895. * @param {Array} array The array to reorder.
  22896. * @param {Array} indexes The arranged array indexes.
  22897. * @returns {Array} Returns `array`.
  22898. */
  22899. function reorder(array, indexes) {
  22900. var arrLength = array.length,
  22901. length = nativeMin(indexes.length, arrLength),
  22902. oldArray = copyArray(array);
  22903. while (length--) {
  22904. var index = indexes[length];
  22905. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22906. }
  22907. return array;
  22908. }
  22909. /**
  22910. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22911. *
  22912. * @private
  22913. * @param {Object} object The object to query.
  22914. * @param {string} key The key of the property to get.
  22915. * @returns {*} Returns the property value.
  22916. */
  22917. function safeGet(object, key) {
  22918. if (key === 'constructor' && typeof object[key] === 'function') {
  22919. return;
  22920. }
  22921. if (key == '__proto__') {
  22922. return;
  22923. }
  22924. return object[key];
  22925. }
  22926. /**
  22927. * Sets metadata for `func`.
  22928. *
  22929. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22930. * period of time, it will trip its breaker and transition to an identity
  22931. * function to avoid garbage collection pauses in V8. See
  22932. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22933. * for more details.
  22934. *
  22935. * @private
  22936. * @param {Function} func The function to associate metadata with.
  22937. * @param {*} data The metadata.
  22938. * @returns {Function} Returns `func`.
  22939. */
  22940. var setData = shortOut(baseSetData);
  22941. /**
  22942. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22943. *
  22944. * @private
  22945. * @param {Function} func The function to delay.
  22946. * @param {number} wait The number of milliseconds to delay invocation.
  22947. * @returns {number|Object} Returns the timer id or timeout object.
  22948. */
  22949. var setTimeout = ctxSetTimeout || function(func, wait) {
  22950. return root.setTimeout(func, wait);
  22951. };
  22952. /**
  22953. * Sets the `toString` method of `func` to return `string`.
  22954. *
  22955. * @private
  22956. * @param {Function} func The function to modify.
  22957. * @param {Function} string The `toString` result.
  22958. * @returns {Function} Returns `func`.
  22959. */
  22960. var setToString = shortOut(baseSetToString);
  22961. /**
  22962. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22963. * with wrapper details in a comment at the top of the source body.
  22964. *
  22965. * @private
  22966. * @param {Function} wrapper The function to modify.
  22967. * @param {Function} reference The reference function.
  22968. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22969. * @returns {Function} Returns `wrapper`.
  22970. */
  22971. function setWrapToString(wrapper, reference, bitmask) {
  22972. var source = (reference + '');
  22973. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22974. }
  22975. /**
  22976. * Creates a function that'll short out and invoke `identity` instead
  22977. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22978. * milliseconds.
  22979. *
  22980. * @private
  22981. * @param {Function} func The function to restrict.
  22982. * @returns {Function} Returns the new shortable function.
  22983. */
  22984. function shortOut(func) {
  22985. var count = 0,
  22986. lastCalled = 0;
  22987. return function() {
  22988. var stamp = nativeNow(),
  22989. remaining = HOT_SPAN - (stamp - lastCalled);
  22990. lastCalled = stamp;
  22991. if (remaining > 0) {
  22992. if (++count >= HOT_COUNT) {
  22993. return arguments[0];
  22994. }
  22995. } else {
  22996. count = 0;
  22997. }
  22998. return func.apply(undefined, arguments);
  22999. };
  23000. }
  23001. /**
  23002. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23003. *
  23004. * @private
  23005. * @param {Array} array The array to shuffle.
  23006. * @param {number} [size=array.length] The size of `array`.
  23007. * @returns {Array} Returns `array`.
  23008. */
  23009. function shuffleSelf(array, size) {
  23010. var index = -1,
  23011. length = array.length,
  23012. lastIndex = length - 1;
  23013. size = size === undefined ? length : size;
  23014. while (++index < size) {
  23015. var rand = baseRandom(index, lastIndex),
  23016. value = array[rand];
  23017. array[rand] = array[index];
  23018. array[index] = value;
  23019. }
  23020. array.length = size;
  23021. return array;
  23022. }
  23023. /**
  23024. * Converts `string` to a property path array.
  23025. *
  23026. * @private
  23027. * @param {string} string The string to convert.
  23028. * @returns {Array} Returns the property path array.
  23029. */
  23030. var stringToPath = memoizeCapped(function(string) {
  23031. var result = [];
  23032. if (string.charCodeAt(0) === 46 /* . */) {
  23033. result.push('');
  23034. }
  23035. string.replace(rePropName, function(match, number, quote, subString) {
  23036. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23037. });
  23038. return result;
  23039. });
  23040. /**
  23041. * Converts `value` to a string key if it's not a string or symbol.
  23042. *
  23043. * @private
  23044. * @param {*} value The value to inspect.
  23045. * @returns {string|symbol} Returns the key.
  23046. */
  23047. function toKey(value) {
  23048. if (typeof value == 'string' || isSymbol(value)) {
  23049. return value;
  23050. }
  23051. var result = (value + '');
  23052. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23053. }
  23054. /**
  23055. * Converts `func` to its source code.
  23056. *
  23057. * @private
  23058. * @param {Function} func The function to convert.
  23059. * @returns {string} Returns the source code.
  23060. */
  23061. function toSource(func) {
  23062. if (func != null) {
  23063. try {
  23064. return funcToString.call(func);
  23065. } catch (e) {}
  23066. try {
  23067. return (func + '');
  23068. } catch (e) {}
  23069. }
  23070. return '';
  23071. }
  23072. /**
  23073. * Updates wrapper `details` based on `bitmask` flags.
  23074. *
  23075. * @private
  23076. * @returns {Array} details The details to modify.
  23077. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23078. * @returns {Array} Returns `details`.
  23079. */
  23080. function updateWrapDetails(details, bitmask) {
  23081. arrayEach(wrapFlags, function(pair) {
  23082. var value = '_.' + pair[0];
  23083. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23084. details.push(value);
  23085. }
  23086. });
  23087. return details.sort();
  23088. }
  23089. /**
  23090. * Creates a clone of `wrapper`.
  23091. *
  23092. * @private
  23093. * @param {Object} wrapper The wrapper to clone.
  23094. * @returns {Object} Returns the cloned wrapper.
  23095. */
  23096. function wrapperClone(wrapper) {
  23097. if (wrapper instanceof LazyWrapper) {
  23098. return wrapper.clone();
  23099. }
  23100. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23101. result.__actions__ = copyArray(wrapper.__actions__);
  23102. result.__index__ = wrapper.__index__;
  23103. result.__values__ = wrapper.__values__;
  23104. return result;
  23105. }
  23106. /*------------------------------------------------------------------------*/
  23107. /**
  23108. * Creates an array of elements split into groups the length of `size`.
  23109. * If `array` can't be split evenly, the final chunk will be the remaining
  23110. * elements.
  23111. *
  23112. * @static
  23113. * @memberOf _
  23114. * @since 3.0.0
  23115. * @category Array
  23116. * @param {Array} array The array to process.
  23117. * @param {number} [size=1] The length of each chunk
  23118. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23119. * @returns {Array} Returns the new array of chunks.
  23120. * @example
  23121. *
  23122. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23123. * // => [['a', 'b'], ['c', 'd']]
  23124. *
  23125. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23126. * // => [['a', 'b', 'c'], ['d']]
  23127. */
  23128. function chunk(array, size, guard) {
  23129. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23130. size = 1;
  23131. } else {
  23132. size = nativeMax(toInteger(size), 0);
  23133. }
  23134. var length = array == null ? 0 : array.length;
  23135. if (!length || size < 1) {
  23136. return [];
  23137. }
  23138. var index = 0,
  23139. resIndex = 0,
  23140. result = Array(nativeCeil(length / size));
  23141. while (index < length) {
  23142. result[resIndex++] = baseSlice(array, index, (index += size));
  23143. }
  23144. return result;
  23145. }
  23146. /**
  23147. * Creates an array with all falsey values removed. The values `false`, `null`,
  23148. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23149. *
  23150. * @static
  23151. * @memberOf _
  23152. * @since 0.1.0
  23153. * @category Array
  23154. * @param {Array} array The array to compact.
  23155. * @returns {Array} Returns the new array of filtered values.
  23156. * @example
  23157. *
  23158. * _.compact([0, 1, false, 2, '', 3]);
  23159. * // => [1, 2, 3]
  23160. */
  23161. function compact(array) {
  23162. var index = -1,
  23163. length = array == null ? 0 : array.length,
  23164. resIndex = 0,
  23165. result = [];
  23166. while (++index < length) {
  23167. var value = array[index];
  23168. if (value) {
  23169. result[resIndex++] = value;
  23170. }
  23171. }
  23172. return result;
  23173. }
  23174. /**
  23175. * Creates a new array concatenating `array` with any additional arrays
  23176. * and/or values.
  23177. *
  23178. * @static
  23179. * @memberOf _
  23180. * @since 4.0.0
  23181. * @category Array
  23182. * @param {Array} array The array to concatenate.
  23183. * @param {...*} [values] The values to concatenate.
  23184. * @returns {Array} Returns the new concatenated array.
  23185. * @example
  23186. *
  23187. * var array = [1];
  23188. * var other = _.concat(array, 2, [3], [[4]]);
  23189. *
  23190. * console.log(other);
  23191. * // => [1, 2, 3, [4]]
  23192. *
  23193. * console.log(array);
  23194. * // => [1]
  23195. */
  23196. function concat() {
  23197. var length = arguments.length;
  23198. if (!length) {
  23199. return [];
  23200. }
  23201. var args = Array(length - 1),
  23202. array = arguments[0],
  23203. index = length;
  23204. while (index--) {
  23205. args[index - 1] = arguments[index];
  23206. }
  23207. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23208. }
  23209. /**
  23210. * Creates an array of `array` values not included in the other given arrays
  23211. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23212. * for equality comparisons. The order and references of result values are
  23213. * determined by the first array.
  23214. *
  23215. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23216. *
  23217. * @static
  23218. * @memberOf _
  23219. * @since 0.1.0
  23220. * @category Array
  23221. * @param {Array} array The array to inspect.
  23222. * @param {...Array} [values] The values to exclude.
  23223. * @returns {Array} Returns the new array of filtered values.
  23224. * @see _.without, _.xor
  23225. * @example
  23226. *
  23227. * _.difference([2, 1], [2, 3]);
  23228. * // => [1]
  23229. */
  23230. var difference = baseRest(function(array, values) {
  23231. return isArrayLikeObject(array)
  23232. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23233. : [];
  23234. });
  23235. /**
  23236. * This method is like `_.difference` except that it accepts `iteratee` which
  23237. * is invoked for each element of `array` and `values` to generate the criterion
  23238. * by which they're compared. The order and references of result values are
  23239. * determined by the first array. The iteratee is invoked with one argument:
  23240. * (value).
  23241. *
  23242. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23243. *
  23244. * @static
  23245. * @memberOf _
  23246. * @since 4.0.0
  23247. * @category Array
  23248. * @param {Array} array The array to inspect.
  23249. * @param {...Array} [values] The values to exclude.
  23250. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23251. * @returns {Array} Returns the new array of filtered values.
  23252. * @example
  23253. *
  23254. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23255. * // => [1.2]
  23256. *
  23257. * // The `_.property` iteratee shorthand.
  23258. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23259. * // => [{ 'x': 2 }]
  23260. */
  23261. var differenceBy = baseRest(function(array, values) {
  23262. var iteratee = last(values);
  23263. if (isArrayLikeObject(iteratee)) {
  23264. iteratee = undefined;
  23265. }
  23266. return isArrayLikeObject(array)
  23267. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23268. : [];
  23269. });
  23270. /**
  23271. * This method is like `_.difference` except that it accepts `comparator`
  23272. * which is invoked to compare elements of `array` to `values`. The order and
  23273. * references of result values are determined by the first array. The comparator
  23274. * is invoked with two arguments: (arrVal, othVal).
  23275. *
  23276. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23277. *
  23278. * @static
  23279. * @memberOf _
  23280. * @since 4.0.0
  23281. * @category Array
  23282. * @param {Array} array The array to inspect.
  23283. * @param {...Array} [values] The values to exclude.
  23284. * @param {Function} [comparator] The comparator invoked per element.
  23285. * @returns {Array} Returns the new array of filtered values.
  23286. * @example
  23287. *
  23288. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23289. *
  23290. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23291. * // => [{ 'x': 2, 'y': 1 }]
  23292. */
  23293. var differenceWith = baseRest(function(array, values) {
  23294. var comparator = last(values);
  23295. if (isArrayLikeObject(comparator)) {
  23296. comparator = undefined;
  23297. }
  23298. return isArrayLikeObject(array)
  23299. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23300. : [];
  23301. });
  23302. /**
  23303. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23304. *
  23305. * @static
  23306. * @memberOf _
  23307. * @since 0.5.0
  23308. * @category Array
  23309. * @param {Array} array The array to query.
  23310. * @param {number} [n=1] The number of elements to drop.
  23311. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23312. * @returns {Array} Returns the slice of `array`.
  23313. * @example
  23314. *
  23315. * _.drop([1, 2, 3]);
  23316. * // => [2, 3]
  23317. *
  23318. * _.drop([1, 2, 3], 2);
  23319. * // => [3]
  23320. *
  23321. * _.drop([1, 2, 3], 5);
  23322. * // => []
  23323. *
  23324. * _.drop([1, 2, 3], 0);
  23325. * // => [1, 2, 3]
  23326. */
  23327. function drop(array, n, guard) {
  23328. var length = array == null ? 0 : array.length;
  23329. if (!length) {
  23330. return [];
  23331. }
  23332. n = (guard || n === undefined) ? 1 : toInteger(n);
  23333. return baseSlice(array, n < 0 ? 0 : n, length);
  23334. }
  23335. /**
  23336. * Creates a slice of `array` with `n` elements dropped from the end.
  23337. *
  23338. * @static
  23339. * @memberOf _
  23340. * @since 3.0.0
  23341. * @category Array
  23342. * @param {Array} array The array to query.
  23343. * @param {number} [n=1] The number of elements to drop.
  23344. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23345. * @returns {Array} Returns the slice of `array`.
  23346. * @example
  23347. *
  23348. * _.dropRight([1, 2, 3]);
  23349. * // => [1, 2]
  23350. *
  23351. * _.dropRight([1, 2, 3], 2);
  23352. * // => [1]
  23353. *
  23354. * _.dropRight([1, 2, 3], 5);
  23355. * // => []
  23356. *
  23357. * _.dropRight([1, 2, 3], 0);
  23358. * // => [1, 2, 3]
  23359. */
  23360. function dropRight(array, n, guard) {
  23361. var length = array == null ? 0 : array.length;
  23362. if (!length) {
  23363. return [];
  23364. }
  23365. n = (guard || n === undefined) ? 1 : toInteger(n);
  23366. n = length - n;
  23367. return baseSlice(array, 0, n < 0 ? 0 : n);
  23368. }
  23369. /**
  23370. * Creates a slice of `array` excluding elements dropped from the end.
  23371. * Elements are dropped until `predicate` returns falsey. The predicate is
  23372. * invoked with three arguments: (value, index, array).
  23373. *
  23374. * @static
  23375. * @memberOf _
  23376. * @since 3.0.0
  23377. * @category Array
  23378. * @param {Array} array The array to query.
  23379. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23380. * @returns {Array} Returns the slice of `array`.
  23381. * @example
  23382. *
  23383. * var users = [
  23384. * { 'user': 'barney', 'active': true },
  23385. * { 'user': 'fred', 'active': false },
  23386. * { 'user': 'pebbles', 'active': false }
  23387. * ];
  23388. *
  23389. * _.dropRightWhile(users, function(o) { return !o.active; });
  23390. * // => objects for ['barney']
  23391. *
  23392. * // The `_.matches` iteratee shorthand.
  23393. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23394. * // => objects for ['barney', 'fred']
  23395. *
  23396. * // The `_.matchesProperty` iteratee shorthand.
  23397. * _.dropRightWhile(users, ['active', false]);
  23398. * // => objects for ['barney']
  23399. *
  23400. * // The `_.property` iteratee shorthand.
  23401. * _.dropRightWhile(users, 'active');
  23402. * // => objects for ['barney', 'fred', 'pebbles']
  23403. */
  23404. function dropRightWhile(array, predicate) {
  23405. return (array && array.length)
  23406. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23407. : [];
  23408. }
  23409. /**
  23410. * Creates a slice of `array` excluding elements dropped from the beginning.
  23411. * Elements are dropped until `predicate` returns falsey. The predicate is
  23412. * invoked with three arguments: (value, index, array).
  23413. *
  23414. * @static
  23415. * @memberOf _
  23416. * @since 3.0.0
  23417. * @category Array
  23418. * @param {Array} array The array to query.
  23419. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23420. * @returns {Array} Returns the slice of `array`.
  23421. * @example
  23422. *
  23423. * var users = [
  23424. * { 'user': 'barney', 'active': false },
  23425. * { 'user': 'fred', 'active': false },
  23426. * { 'user': 'pebbles', 'active': true }
  23427. * ];
  23428. *
  23429. * _.dropWhile(users, function(o) { return !o.active; });
  23430. * // => objects for ['pebbles']
  23431. *
  23432. * // The `_.matches` iteratee shorthand.
  23433. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23434. * // => objects for ['fred', 'pebbles']
  23435. *
  23436. * // The `_.matchesProperty` iteratee shorthand.
  23437. * _.dropWhile(users, ['active', false]);
  23438. * // => objects for ['pebbles']
  23439. *
  23440. * // The `_.property` iteratee shorthand.
  23441. * _.dropWhile(users, 'active');
  23442. * // => objects for ['barney', 'fred', 'pebbles']
  23443. */
  23444. function dropWhile(array, predicate) {
  23445. return (array && array.length)
  23446. ? baseWhile(array, getIteratee(predicate, 3), true)
  23447. : [];
  23448. }
  23449. /**
  23450. * Fills elements of `array` with `value` from `start` up to, but not
  23451. * including, `end`.
  23452. *
  23453. * **Note:** This method mutates `array`.
  23454. *
  23455. * @static
  23456. * @memberOf _
  23457. * @since 3.2.0
  23458. * @category Array
  23459. * @param {Array} array The array to fill.
  23460. * @param {*} value The value to fill `array` with.
  23461. * @param {number} [start=0] The start position.
  23462. * @param {number} [end=array.length] The end position.
  23463. * @returns {Array} Returns `array`.
  23464. * @example
  23465. *
  23466. * var array = [1, 2, 3];
  23467. *
  23468. * _.fill(array, 'a');
  23469. * console.log(array);
  23470. * // => ['a', 'a', 'a']
  23471. *
  23472. * _.fill(Array(3), 2);
  23473. * // => [2, 2, 2]
  23474. *
  23475. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23476. * // => [4, '*', '*', 10]
  23477. */
  23478. function fill(array, value, start, end) {
  23479. var length = array == null ? 0 : array.length;
  23480. if (!length) {
  23481. return [];
  23482. }
  23483. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23484. start = 0;
  23485. end = length;
  23486. }
  23487. return baseFill(array, value, start, end);
  23488. }
  23489. /**
  23490. * This method is like `_.find` except that it returns the index of the first
  23491. * element `predicate` returns truthy for instead of the element itself.
  23492. *
  23493. * @static
  23494. * @memberOf _
  23495. * @since 1.1.0
  23496. * @category Array
  23497. * @param {Array} array The array to inspect.
  23498. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23499. * @param {number} [fromIndex=0] The index to search from.
  23500. * @returns {number} Returns the index of the found element, else `-1`.
  23501. * @example
  23502. *
  23503. * var users = [
  23504. * { 'user': 'barney', 'active': false },
  23505. * { 'user': 'fred', 'active': false },
  23506. * { 'user': 'pebbles', 'active': true }
  23507. * ];
  23508. *
  23509. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23510. * // => 0
  23511. *
  23512. * // The `_.matches` iteratee shorthand.
  23513. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23514. * // => 1
  23515. *
  23516. * // The `_.matchesProperty` iteratee shorthand.
  23517. * _.findIndex(users, ['active', false]);
  23518. * // => 0
  23519. *
  23520. * // The `_.property` iteratee shorthand.
  23521. * _.findIndex(users, 'active');
  23522. * // => 2
  23523. */
  23524. function findIndex(array, predicate, fromIndex) {
  23525. var length = array == null ? 0 : array.length;
  23526. if (!length) {
  23527. return -1;
  23528. }
  23529. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23530. if (index < 0) {
  23531. index = nativeMax(length + index, 0);
  23532. }
  23533. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23534. }
  23535. /**
  23536. * This method is like `_.findIndex` except that it iterates over elements
  23537. * of `collection` from right to left.
  23538. *
  23539. * @static
  23540. * @memberOf _
  23541. * @since 2.0.0
  23542. * @category Array
  23543. * @param {Array} array The array to inspect.
  23544. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23545. * @param {number} [fromIndex=array.length-1] The index to search from.
  23546. * @returns {number} Returns the index of the found element, else `-1`.
  23547. * @example
  23548. *
  23549. * var users = [
  23550. * { 'user': 'barney', 'active': true },
  23551. * { 'user': 'fred', 'active': false },
  23552. * { 'user': 'pebbles', 'active': false }
  23553. * ];
  23554. *
  23555. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23556. * // => 2
  23557. *
  23558. * // The `_.matches` iteratee shorthand.
  23559. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23560. * // => 0
  23561. *
  23562. * // The `_.matchesProperty` iteratee shorthand.
  23563. * _.findLastIndex(users, ['active', false]);
  23564. * // => 2
  23565. *
  23566. * // The `_.property` iteratee shorthand.
  23567. * _.findLastIndex(users, 'active');
  23568. * // => 0
  23569. */
  23570. function findLastIndex(array, predicate, fromIndex) {
  23571. var length = array == null ? 0 : array.length;
  23572. if (!length) {
  23573. return -1;
  23574. }
  23575. var index = length - 1;
  23576. if (fromIndex !== undefined) {
  23577. index = toInteger(fromIndex);
  23578. index = fromIndex < 0
  23579. ? nativeMax(length + index, 0)
  23580. : nativeMin(index, length - 1);
  23581. }
  23582. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23583. }
  23584. /**
  23585. * Flattens `array` a single level deep.
  23586. *
  23587. * @static
  23588. * @memberOf _
  23589. * @since 0.1.0
  23590. * @category Array
  23591. * @param {Array} array The array to flatten.
  23592. * @returns {Array} Returns the new flattened array.
  23593. * @example
  23594. *
  23595. * _.flatten([1, [2, [3, [4]], 5]]);
  23596. * // => [1, 2, [3, [4]], 5]
  23597. */
  23598. function flatten(array) {
  23599. var length = array == null ? 0 : array.length;
  23600. return length ? baseFlatten(array, 1) : [];
  23601. }
  23602. /**
  23603. * Recursively flattens `array`.
  23604. *
  23605. * @static
  23606. * @memberOf _
  23607. * @since 3.0.0
  23608. * @category Array
  23609. * @param {Array} array The array to flatten.
  23610. * @returns {Array} Returns the new flattened array.
  23611. * @example
  23612. *
  23613. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23614. * // => [1, 2, 3, 4, 5]
  23615. */
  23616. function flattenDeep(array) {
  23617. var length = array == null ? 0 : array.length;
  23618. return length ? baseFlatten(array, INFINITY) : [];
  23619. }
  23620. /**
  23621. * Recursively flatten `array` up to `depth` times.
  23622. *
  23623. * @static
  23624. * @memberOf _
  23625. * @since 4.4.0
  23626. * @category Array
  23627. * @param {Array} array The array to flatten.
  23628. * @param {number} [depth=1] The maximum recursion depth.
  23629. * @returns {Array} Returns the new flattened array.
  23630. * @example
  23631. *
  23632. * var array = [1, [2, [3, [4]], 5]];
  23633. *
  23634. * _.flattenDepth(array, 1);
  23635. * // => [1, 2, [3, [4]], 5]
  23636. *
  23637. * _.flattenDepth(array, 2);
  23638. * // => [1, 2, 3, [4], 5]
  23639. */
  23640. function flattenDepth(array, depth) {
  23641. var length = array == null ? 0 : array.length;
  23642. if (!length) {
  23643. return [];
  23644. }
  23645. depth = depth === undefined ? 1 : toInteger(depth);
  23646. return baseFlatten(array, depth);
  23647. }
  23648. /**
  23649. * The inverse of `_.toPairs`; this method returns an object composed
  23650. * from key-value `pairs`.
  23651. *
  23652. * @static
  23653. * @memberOf _
  23654. * @since 4.0.0
  23655. * @category Array
  23656. * @param {Array} pairs The key-value pairs.
  23657. * @returns {Object} Returns the new object.
  23658. * @example
  23659. *
  23660. * _.fromPairs([['a', 1], ['b', 2]]);
  23661. * // => { 'a': 1, 'b': 2 }
  23662. */
  23663. function fromPairs(pairs) {
  23664. var index = -1,
  23665. length = pairs == null ? 0 : pairs.length,
  23666. result = {};
  23667. while (++index < length) {
  23668. var pair = pairs[index];
  23669. result[pair[0]] = pair[1];
  23670. }
  23671. return result;
  23672. }
  23673. /**
  23674. * Gets the first element of `array`.
  23675. *
  23676. * @static
  23677. * @memberOf _
  23678. * @since 0.1.0
  23679. * @alias first
  23680. * @category Array
  23681. * @param {Array} array The array to query.
  23682. * @returns {*} Returns the first element of `array`.
  23683. * @example
  23684. *
  23685. * _.head([1, 2, 3]);
  23686. * // => 1
  23687. *
  23688. * _.head([]);
  23689. * // => undefined
  23690. */
  23691. function head(array) {
  23692. return (array && array.length) ? array[0] : undefined;
  23693. }
  23694. /**
  23695. * Gets the index at which the first occurrence of `value` is found in `array`
  23696. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23697. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23698. * offset from the end of `array`.
  23699. *
  23700. * @static
  23701. * @memberOf _
  23702. * @since 0.1.0
  23703. * @category Array
  23704. * @param {Array} array The array to inspect.
  23705. * @param {*} value The value to search for.
  23706. * @param {number} [fromIndex=0] The index to search from.
  23707. * @returns {number} Returns the index of the matched value, else `-1`.
  23708. * @example
  23709. *
  23710. * _.indexOf([1, 2, 1, 2], 2);
  23711. * // => 1
  23712. *
  23713. * // Search from the `fromIndex`.
  23714. * _.indexOf([1, 2, 1, 2], 2, 2);
  23715. * // => 3
  23716. */
  23717. function indexOf(array, value, fromIndex) {
  23718. var length = array == null ? 0 : array.length;
  23719. if (!length) {
  23720. return -1;
  23721. }
  23722. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23723. if (index < 0) {
  23724. index = nativeMax(length + index, 0);
  23725. }
  23726. return baseIndexOf(array, value, index);
  23727. }
  23728. /**
  23729. * Gets all but the last element of `array`.
  23730. *
  23731. * @static
  23732. * @memberOf _
  23733. * @since 0.1.0
  23734. * @category Array
  23735. * @param {Array} array The array to query.
  23736. * @returns {Array} Returns the slice of `array`.
  23737. * @example
  23738. *
  23739. * _.initial([1, 2, 3]);
  23740. * // => [1, 2]
  23741. */
  23742. function initial(array) {
  23743. var length = array == null ? 0 : array.length;
  23744. return length ? baseSlice(array, 0, -1) : [];
  23745. }
  23746. /**
  23747. * Creates an array of unique values that are included in all given arrays
  23748. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23749. * for equality comparisons. The order and references of result values are
  23750. * determined by the first array.
  23751. *
  23752. * @static
  23753. * @memberOf _
  23754. * @since 0.1.0
  23755. * @category Array
  23756. * @param {...Array} [arrays] The arrays to inspect.
  23757. * @returns {Array} Returns the new array of intersecting values.
  23758. * @example
  23759. *
  23760. * _.intersection([2, 1], [2, 3]);
  23761. * // => [2]
  23762. */
  23763. var intersection = baseRest(function(arrays) {
  23764. var mapped = arrayMap(arrays, castArrayLikeObject);
  23765. return (mapped.length && mapped[0] === arrays[0])
  23766. ? baseIntersection(mapped)
  23767. : [];
  23768. });
  23769. /**
  23770. * This method is like `_.intersection` except that it accepts `iteratee`
  23771. * which is invoked for each element of each `arrays` to generate the criterion
  23772. * by which they're compared. The order and references of result values are
  23773. * determined by the first array. The iteratee is invoked with one argument:
  23774. * (value).
  23775. *
  23776. * @static
  23777. * @memberOf _
  23778. * @since 4.0.0
  23779. * @category Array
  23780. * @param {...Array} [arrays] The arrays to inspect.
  23781. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23782. * @returns {Array} Returns the new array of intersecting values.
  23783. * @example
  23784. *
  23785. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23786. * // => [2.1]
  23787. *
  23788. * // The `_.property` iteratee shorthand.
  23789. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23790. * // => [{ 'x': 1 }]
  23791. */
  23792. var intersectionBy = baseRest(function(arrays) {
  23793. var iteratee = last(arrays),
  23794. mapped = arrayMap(arrays, castArrayLikeObject);
  23795. if (iteratee === last(mapped)) {
  23796. iteratee = undefined;
  23797. } else {
  23798. mapped.pop();
  23799. }
  23800. return (mapped.length && mapped[0] === arrays[0])
  23801. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23802. : [];
  23803. });
  23804. /**
  23805. * This method is like `_.intersection` except that it accepts `comparator`
  23806. * which is invoked to compare elements of `arrays`. The order and references
  23807. * of result values are determined by the first array. The comparator is
  23808. * invoked with two arguments: (arrVal, othVal).
  23809. *
  23810. * @static
  23811. * @memberOf _
  23812. * @since 4.0.0
  23813. * @category Array
  23814. * @param {...Array} [arrays] The arrays to inspect.
  23815. * @param {Function} [comparator] The comparator invoked per element.
  23816. * @returns {Array} Returns the new array of intersecting values.
  23817. * @example
  23818. *
  23819. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23820. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23821. *
  23822. * _.intersectionWith(objects, others, _.isEqual);
  23823. * // => [{ 'x': 1, 'y': 2 }]
  23824. */
  23825. var intersectionWith = baseRest(function(arrays) {
  23826. var comparator = last(arrays),
  23827. mapped = arrayMap(arrays, castArrayLikeObject);
  23828. comparator = typeof comparator == 'function' ? comparator : undefined;
  23829. if (comparator) {
  23830. mapped.pop();
  23831. }
  23832. return (mapped.length && mapped[0] === arrays[0])
  23833. ? baseIntersection(mapped, undefined, comparator)
  23834. : [];
  23835. });
  23836. /**
  23837. * Converts all elements in `array` into a string separated by `separator`.
  23838. *
  23839. * @static
  23840. * @memberOf _
  23841. * @since 4.0.0
  23842. * @category Array
  23843. * @param {Array} array The array to convert.
  23844. * @param {string} [separator=','] The element separator.
  23845. * @returns {string} Returns the joined string.
  23846. * @example
  23847. *
  23848. * _.join(['a', 'b', 'c'], '~');
  23849. * // => 'a~b~c'
  23850. */
  23851. function join(array, separator) {
  23852. return array == null ? '' : nativeJoin.call(array, separator);
  23853. }
  23854. /**
  23855. * Gets the last element of `array`.
  23856. *
  23857. * @static
  23858. * @memberOf _
  23859. * @since 0.1.0
  23860. * @category Array
  23861. * @param {Array} array The array to query.
  23862. * @returns {*} Returns the last element of `array`.
  23863. * @example
  23864. *
  23865. * _.last([1, 2, 3]);
  23866. * // => 3
  23867. */
  23868. function last(array) {
  23869. var length = array == null ? 0 : array.length;
  23870. return length ? array[length - 1] : undefined;
  23871. }
  23872. /**
  23873. * This method is like `_.indexOf` except that it iterates over elements of
  23874. * `array` from right to left.
  23875. *
  23876. * @static
  23877. * @memberOf _
  23878. * @since 0.1.0
  23879. * @category Array
  23880. * @param {Array} array The array to inspect.
  23881. * @param {*} value The value to search for.
  23882. * @param {number} [fromIndex=array.length-1] The index to search from.
  23883. * @returns {number} Returns the index of the matched value, else `-1`.
  23884. * @example
  23885. *
  23886. * _.lastIndexOf([1, 2, 1, 2], 2);
  23887. * // => 3
  23888. *
  23889. * // Search from the `fromIndex`.
  23890. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23891. * // => 1
  23892. */
  23893. function lastIndexOf(array, value, fromIndex) {
  23894. var length = array == null ? 0 : array.length;
  23895. if (!length) {
  23896. return -1;
  23897. }
  23898. var index = length;
  23899. if (fromIndex !== undefined) {
  23900. index = toInteger(fromIndex);
  23901. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23902. }
  23903. return value === value
  23904. ? strictLastIndexOf(array, value, index)
  23905. : baseFindIndex(array, baseIsNaN, index, true);
  23906. }
  23907. /**
  23908. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23909. * element from the end is returned.
  23910. *
  23911. * @static
  23912. * @memberOf _
  23913. * @since 4.11.0
  23914. * @category Array
  23915. * @param {Array} array The array to query.
  23916. * @param {number} [n=0] The index of the element to return.
  23917. * @returns {*} Returns the nth element of `array`.
  23918. * @example
  23919. *
  23920. * var array = ['a', 'b', 'c', 'd'];
  23921. *
  23922. * _.nth(array, 1);
  23923. * // => 'b'
  23924. *
  23925. * _.nth(array, -2);
  23926. * // => 'c';
  23927. */
  23928. function nth(array, n) {
  23929. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23930. }
  23931. /**
  23932. * Removes all given values from `array` using
  23933. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23934. * for equality comparisons.
  23935. *
  23936. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23937. * to remove elements from an array by predicate.
  23938. *
  23939. * @static
  23940. * @memberOf _
  23941. * @since 2.0.0
  23942. * @category Array
  23943. * @param {Array} array The array to modify.
  23944. * @param {...*} [values] The values to remove.
  23945. * @returns {Array} Returns `array`.
  23946. * @example
  23947. *
  23948. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23949. *
  23950. * _.pull(array, 'a', 'c');
  23951. * console.log(array);
  23952. * // => ['b', 'b']
  23953. */
  23954. var pull = baseRest(pullAll);
  23955. /**
  23956. * This method is like `_.pull` except that it accepts an array of values to remove.
  23957. *
  23958. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23959. *
  23960. * @static
  23961. * @memberOf _
  23962. * @since 4.0.0
  23963. * @category Array
  23964. * @param {Array} array The array to modify.
  23965. * @param {Array} values The values to remove.
  23966. * @returns {Array} Returns `array`.
  23967. * @example
  23968. *
  23969. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23970. *
  23971. * _.pullAll(array, ['a', 'c']);
  23972. * console.log(array);
  23973. * // => ['b', 'b']
  23974. */
  23975. function pullAll(array, values) {
  23976. return (array && array.length && values && values.length)
  23977. ? basePullAll(array, values)
  23978. : array;
  23979. }
  23980. /**
  23981. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23982. * invoked for each element of `array` and `values` to generate the criterion
  23983. * by which they're compared. The iteratee is invoked with one argument: (value).
  23984. *
  23985. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23986. *
  23987. * @static
  23988. * @memberOf _
  23989. * @since 4.0.0
  23990. * @category Array
  23991. * @param {Array} array The array to modify.
  23992. * @param {Array} values The values to remove.
  23993. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23994. * @returns {Array} Returns `array`.
  23995. * @example
  23996. *
  23997. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23998. *
  23999. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24000. * console.log(array);
  24001. * // => [{ 'x': 2 }]
  24002. */
  24003. function pullAllBy(array, values, iteratee) {
  24004. return (array && array.length && values && values.length)
  24005. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24006. : array;
  24007. }
  24008. /**
  24009. * This method is like `_.pullAll` except that it accepts `comparator` which
  24010. * is invoked to compare elements of `array` to `values`. The comparator is
  24011. * invoked with two arguments: (arrVal, othVal).
  24012. *
  24013. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24014. *
  24015. * @static
  24016. * @memberOf _
  24017. * @since 4.6.0
  24018. * @category Array
  24019. * @param {Array} array The array to modify.
  24020. * @param {Array} values The values to remove.
  24021. * @param {Function} [comparator] The comparator invoked per element.
  24022. * @returns {Array} Returns `array`.
  24023. * @example
  24024. *
  24025. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24026. *
  24027. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24028. * console.log(array);
  24029. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24030. */
  24031. function pullAllWith(array, values, comparator) {
  24032. return (array && array.length && values && values.length)
  24033. ? basePullAll(array, values, undefined, comparator)
  24034. : array;
  24035. }
  24036. /**
  24037. * Removes elements from `array` corresponding to `indexes` and returns an
  24038. * array of removed elements.
  24039. *
  24040. * **Note:** Unlike `_.at`, this method mutates `array`.
  24041. *
  24042. * @static
  24043. * @memberOf _
  24044. * @since 3.0.0
  24045. * @category Array
  24046. * @param {Array} array The array to modify.
  24047. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24048. * @returns {Array} Returns the new array of removed elements.
  24049. * @example
  24050. *
  24051. * var array = ['a', 'b', 'c', 'd'];
  24052. * var pulled = _.pullAt(array, [1, 3]);
  24053. *
  24054. * console.log(array);
  24055. * // => ['a', 'c']
  24056. *
  24057. * console.log(pulled);
  24058. * // => ['b', 'd']
  24059. */
  24060. var pullAt = flatRest(function(array, indexes) {
  24061. var length = array == null ? 0 : array.length,
  24062. result = baseAt(array, indexes);
  24063. basePullAt(array, arrayMap(indexes, function(index) {
  24064. return isIndex(index, length) ? +index : index;
  24065. }).sort(compareAscending));
  24066. return result;
  24067. });
  24068. /**
  24069. * Removes all elements from `array` that `predicate` returns truthy for
  24070. * and returns an array of the removed elements. The predicate is invoked
  24071. * with three arguments: (value, index, array).
  24072. *
  24073. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24074. * to pull elements from an array by value.
  24075. *
  24076. * @static
  24077. * @memberOf _
  24078. * @since 2.0.0
  24079. * @category Array
  24080. * @param {Array} array The array to modify.
  24081. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24082. * @returns {Array} Returns the new array of removed elements.
  24083. * @example
  24084. *
  24085. * var array = [1, 2, 3, 4];
  24086. * var evens = _.remove(array, function(n) {
  24087. * return n % 2 == 0;
  24088. * });
  24089. *
  24090. * console.log(array);
  24091. * // => [1, 3]
  24092. *
  24093. * console.log(evens);
  24094. * // => [2, 4]
  24095. */
  24096. function remove(array, predicate) {
  24097. var result = [];
  24098. if (!(array && array.length)) {
  24099. return result;
  24100. }
  24101. var index = -1,
  24102. indexes = [],
  24103. length = array.length;
  24104. predicate = getIteratee(predicate, 3);
  24105. while (++index < length) {
  24106. var value = array[index];
  24107. if (predicate(value, index, array)) {
  24108. result.push(value);
  24109. indexes.push(index);
  24110. }
  24111. }
  24112. basePullAt(array, indexes);
  24113. return result;
  24114. }
  24115. /**
  24116. * Reverses `array` so that the first element becomes the last, the second
  24117. * element becomes the second to last, and so on.
  24118. *
  24119. * **Note:** This method mutates `array` and is based on
  24120. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24121. *
  24122. * @static
  24123. * @memberOf _
  24124. * @since 4.0.0
  24125. * @category Array
  24126. * @param {Array} array The array to modify.
  24127. * @returns {Array} Returns `array`.
  24128. * @example
  24129. *
  24130. * var array = [1, 2, 3];
  24131. *
  24132. * _.reverse(array);
  24133. * // => [3, 2, 1]
  24134. *
  24135. * console.log(array);
  24136. * // => [3, 2, 1]
  24137. */
  24138. function reverse(array) {
  24139. return array == null ? array : nativeReverse.call(array);
  24140. }
  24141. /**
  24142. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24143. *
  24144. * **Note:** This method is used instead of
  24145. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24146. * returned.
  24147. *
  24148. * @static
  24149. * @memberOf _
  24150. * @since 3.0.0
  24151. * @category Array
  24152. * @param {Array} array The array to slice.
  24153. * @param {number} [start=0] The start position.
  24154. * @param {number} [end=array.length] The end position.
  24155. * @returns {Array} Returns the slice of `array`.
  24156. */
  24157. function slice(array, start, end) {
  24158. var length = array == null ? 0 : array.length;
  24159. if (!length) {
  24160. return [];
  24161. }
  24162. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24163. start = 0;
  24164. end = length;
  24165. }
  24166. else {
  24167. start = start == null ? 0 : toInteger(start);
  24168. end = end === undefined ? length : toInteger(end);
  24169. }
  24170. return baseSlice(array, start, end);
  24171. }
  24172. /**
  24173. * Uses a binary search to determine the lowest index at which `value`
  24174. * should be inserted into `array` in order to maintain its sort order.
  24175. *
  24176. * @static
  24177. * @memberOf _
  24178. * @since 0.1.0
  24179. * @category Array
  24180. * @param {Array} array The sorted array to inspect.
  24181. * @param {*} value The value to evaluate.
  24182. * @returns {number} Returns the index at which `value` should be inserted
  24183. * into `array`.
  24184. * @example
  24185. *
  24186. * _.sortedIndex([30, 50], 40);
  24187. * // => 1
  24188. */
  24189. function sortedIndex(array, value) {
  24190. return baseSortedIndex(array, value);
  24191. }
  24192. /**
  24193. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24194. * which is invoked for `value` and each element of `array` to compute their
  24195. * sort ranking. The iteratee is invoked with one argument: (value).
  24196. *
  24197. * @static
  24198. * @memberOf _
  24199. * @since 4.0.0
  24200. * @category Array
  24201. * @param {Array} array The sorted array to inspect.
  24202. * @param {*} value The value to evaluate.
  24203. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24204. * @returns {number} Returns the index at which `value` should be inserted
  24205. * into `array`.
  24206. * @example
  24207. *
  24208. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24209. *
  24210. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24211. * // => 0
  24212. *
  24213. * // The `_.property` iteratee shorthand.
  24214. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24215. * // => 0
  24216. */
  24217. function sortedIndexBy(array, value, iteratee) {
  24218. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24219. }
  24220. /**
  24221. * This method is like `_.indexOf` except that it performs a binary
  24222. * search on a sorted `array`.
  24223. *
  24224. * @static
  24225. * @memberOf _
  24226. * @since 4.0.0
  24227. * @category Array
  24228. * @param {Array} array The array to inspect.
  24229. * @param {*} value The value to search for.
  24230. * @returns {number} Returns the index of the matched value, else `-1`.
  24231. * @example
  24232. *
  24233. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24234. * // => 1
  24235. */
  24236. function sortedIndexOf(array, value) {
  24237. var length = array == null ? 0 : array.length;
  24238. if (length) {
  24239. var index = baseSortedIndex(array, value);
  24240. if (index < length && eq(array[index], value)) {
  24241. return index;
  24242. }
  24243. }
  24244. return -1;
  24245. }
  24246. /**
  24247. * This method is like `_.sortedIndex` except that it returns the highest
  24248. * index at which `value` should be inserted into `array` in order to
  24249. * maintain its sort order.
  24250. *
  24251. * @static
  24252. * @memberOf _
  24253. * @since 3.0.0
  24254. * @category Array
  24255. * @param {Array} array The sorted array to inspect.
  24256. * @param {*} value The value to evaluate.
  24257. * @returns {number} Returns the index at which `value` should be inserted
  24258. * into `array`.
  24259. * @example
  24260. *
  24261. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24262. * // => 4
  24263. */
  24264. function sortedLastIndex(array, value) {
  24265. return baseSortedIndex(array, value, true);
  24266. }
  24267. /**
  24268. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24269. * which is invoked for `value` and each element of `array` to compute their
  24270. * sort ranking. The iteratee is invoked with one argument: (value).
  24271. *
  24272. * @static
  24273. * @memberOf _
  24274. * @since 4.0.0
  24275. * @category Array
  24276. * @param {Array} array The sorted array to inspect.
  24277. * @param {*} value The value to evaluate.
  24278. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24279. * @returns {number} Returns the index at which `value` should be inserted
  24280. * into `array`.
  24281. * @example
  24282. *
  24283. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24284. *
  24285. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24286. * // => 1
  24287. *
  24288. * // The `_.property` iteratee shorthand.
  24289. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24290. * // => 1
  24291. */
  24292. function sortedLastIndexBy(array, value, iteratee) {
  24293. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24294. }
  24295. /**
  24296. * This method is like `_.lastIndexOf` except that it performs a binary
  24297. * search on a sorted `array`.
  24298. *
  24299. * @static
  24300. * @memberOf _
  24301. * @since 4.0.0
  24302. * @category Array
  24303. * @param {Array} array The array to inspect.
  24304. * @param {*} value The value to search for.
  24305. * @returns {number} Returns the index of the matched value, else `-1`.
  24306. * @example
  24307. *
  24308. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24309. * // => 3
  24310. */
  24311. function sortedLastIndexOf(array, value) {
  24312. var length = array == null ? 0 : array.length;
  24313. if (length) {
  24314. var index = baseSortedIndex(array, value, true) - 1;
  24315. if (eq(array[index], value)) {
  24316. return index;
  24317. }
  24318. }
  24319. return -1;
  24320. }
  24321. /**
  24322. * This method is like `_.uniq` except that it's designed and optimized
  24323. * for sorted arrays.
  24324. *
  24325. * @static
  24326. * @memberOf _
  24327. * @since 4.0.0
  24328. * @category Array
  24329. * @param {Array} array The array to inspect.
  24330. * @returns {Array} Returns the new duplicate free array.
  24331. * @example
  24332. *
  24333. * _.sortedUniq([1, 1, 2]);
  24334. * // => [1, 2]
  24335. */
  24336. function sortedUniq(array) {
  24337. return (array && array.length)
  24338. ? baseSortedUniq(array)
  24339. : [];
  24340. }
  24341. /**
  24342. * This method is like `_.uniqBy` except that it's designed and optimized
  24343. * for sorted arrays.
  24344. *
  24345. * @static
  24346. * @memberOf _
  24347. * @since 4.0.0
  24348. * @category Array
  24349. * @param {Array} array The array to inspect.
  24350. * @param {Function} [iteratee] The iteratee invoked per element.
  24351. * @returns {Array} Returns the new duplicate free array.
  24352. * @example
  24353. *
  24354. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24355. * // => [1.1, 2.3]
  24356. */
  24357. function sortedUniqBy(array, iteratee) {
  24358. return (array && array.length)
  24359. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24360. : [];
  24361. }
  24362. /**
  24363. * Gets all but the first element of `array`.
  24364. *
  24365. * @static
  24366. * @memberOf _
  24367. * @since 4.0.0
  24368. * @category Array
  24369. * @param {Array} array The array to query.
  24370. * @returns {Array} Returns the slice of `array`.
  24371. * @example
  24372. *
  24373. * _.tail([1, 2, 3]);
  24374. * // => [2, 3]
  24375. */
  24376. function tail(array) {
  24377. var length = array == null ? 0 : array.length;
  24378. return length ? baseSlice(array, 1, length) : [];
  24379. }
  24380. /**
  24381. * Creates a slice of `array` with `n` elements taken from the beginning.
  24382. *
  24383. * @static
  24384. * @memberOf _
  24385. * @since 0.1.0
  24386. * @category Array
  24387. * @param {Array} array The array to query.
  24388. * @param {number} [n=1] The number of elements to take.
  24389. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24390. * @returns {Array} Returns the slice of `array`.
  24391. * @example
  24392. *
  24393. * _.take([1, 2, 3]);
  24394. * // => [1]
  24395. *
  24396. * _.take([1, 2, 3], 2);
  24397. * // => [1, 2]
  24398. *
  24399. * _.take([1, 2, 3], 5);
  24400. * // => [1, 2, 3]
  24401. *
  24402. * _.take([1, 2, 3], 0);
  24403. * // => []
  24404. */
  24405. function take(array, n, guard) {
  24406. if (!(array && array.length)) {
  24407. return [];
  24408. }
  24409. n = (guard || n === undefined) ? 1 : toInteger(n);
  24410. return baseSlice(array, 0, n < 0 ? 0 : n);
  24411. }
  24412. /**
  24413. * Creates a slice of `array` with `n` elements taken from the end.
  24414. *
  24415. * @static
  24416. * @memberOf _
  24417. * @since 3.0.0
  24418. * @category Array
  24419. * @param {Array} array The array to query.
  24420. * @param {number} [n=1] The number of elements to take.
  24421. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24422. * @returns {Array} Returns the slice of `array`.
  24423. * @example
  24424. *
  24425. * _.takeRight([1, 2, 3]);
  24426. * // => [3]
  24427. *
  24428. * _.takeRight([1, 2, 3], 2);
  24429. * // => [2, 3]
  24430. *
  24431. * _.takeRight([1, 2, 3], 5);
  24432. * // => [1, 2, 3]
  24433. *
  24434. * _.takeRight([1, 2, 3], 0);
  24435. * // => []
  24436. */
  24437. function takeRight(array, n, guard) {
  24438. var length = array == null ? 0 : array.length;
  24439. if (!length) {
  24440. return [];
  24441. }
  24442. n = (guard || n === undefined) ? 1 : toInteger(n);
  24443. n = length - n;
  24444. return baseSlice(array, n < 0 ? 0 : n, length);
  24445. }
  24446. /**
  24447. * Creates a slice of `array` with elements taken from the end. Elements are
  24448. * taken until `predicate` returns falsey. The predicate is invoked with
  24449. * three arguments: (value, index, array).
  24450. *
  24451. * @static
  24452. * @memberOf _
  24453. * @since 3.0.0
  24454. * @category Array
  24455. * @param {Array} array The array to query.
  24456. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24457. * @returns {Array} Returns the slice of `array`.
  24458. * @example
  24459. *
  24460. * var users = [
  24461. * { 'user': 'barney', 'active': true },
  24462. * { 'user': 'fred', 'active': false },
  24463. * { 'user': 'pebbles', 'active': false }
  24464. * ];
  24465. *
  24466. * _.takeRightWhile(users, function(o) { return !o.active; });
  24467. * // => objects for ['fred', 'pebbles']
  24468. *
  24469. * // The `_.matches` iteratee shorthand.
  24470. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24471. * // => objects for ['pebbles']
  24472. *
  24473. * // The `_.matchesProperty` iteratee shorthand.
  24474. * _.takeRightWhile(users, ['active', false]);
  24475. * // => objects for ['fred', 'pebbles']
  24476. *
  24477. * // The `_.property` iteratee shorthand.
  24478. * _.takeRightWhile(users, 'active');
  24479. * // => []
  24480. */
  24481. function takeRightWhile(array, predicate) {
  24482. return (array && array.length)
  24483. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24484. : [];
  24485. }
  24486. /**
  24487. * Creates a slice of `array` with elements taken from the beginning. Elements
  24488. * are taken until `predicate` returns falsey. The predicate is invoked with
  24489. * three arguments: (value, index, array).
  24490. *
  24491. * @static
  24492. * @memberOf _
  24493. * @since 3.0.0
  24494. * @category Array
  24495. * @param {Array} array The array to query.
  24496. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24497. * @returns {Array} Returns the slice of `array`.
  24498. * @example
  24499. *
  24500. * var users = [
  24501. * { 'user': 'barney', 'active': false },
  24502. * { 'user': 'fred', 'active': false },
  24503. * { 'user': 'pebbles', 'active': true }
  24504. * ];
  24505. *
  24506. * _.takeWhile(users, function(o) { return !o.active; });
  24507. * // => objects for ['barney', 'fred']
  24508. *
  24509. * // The `_.matches` iteratee shorthand.
  24510. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24511. * // => objects for ['barney']
  24512. *
  24513. * // The `_.matchesProperty` iteratee shorthand.
  24514. * _.takeWhile(users, ['active', false]);
  24515. * // => objects for ['barney', 'fred']
  24516. *
  24517. * // The `_.property` iteratee shorthand.
  24518. * _.takeWhile(users, 'active');
  24519. * // => []
  24520. */
  24521. function takeWhile(array, predicate) {
  24522. return (array && array.length)
  24523. ? baseWhile(array, getIteratee(predicate, 3))
  24524. : [];
  24525. }
  24526. /**
  24527. * Creates an array of unique values, in order, from all given arrays using
  24528. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24529. * for equality comparisons.
  24530. *
  24531. * @static
  24532. * @memberOf _
  24533. * @since 0.1.0
  24534. * @category Array
  24535. * @param {...Array} [arrays] The arrays to inspect.
  24536. * @returns {Array} Returns the new array of combined values.
  24537. * @example
  24538. *
  24539. * _.union([2], [1, 2]);
  24540. * // => [2, 1]
  24541. */
  24542. var union = baseRest(function(arrays) {
  24543. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24544. });
  24545. /**
  24546. * This method is like `_.union` except that it accepts `iteratee` which is
  24547. * invoked for each element of each `arrays` to generate the criterion by
  24548. * which uniqueness is computed. Result values are chosen from the first
  24549. * array in which the value occurs. The iteratee is invoked with one argument:
  24550. * (value).
  24551. *
  24552. * @static
  24553. * @memberOf _
  24554. * @since 4.0.0
  24555. * @category Array
  24556. * @param {...Array} [arrays] The arrays to inspect.
  24557. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24558. * @returns {Array} Returns the new array of combined values.
  24559. * @example
  24560. *
  24561. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24562. * // => [2.1, 1.2]
  24563. *
  24564. * // The `_.property` iteratee shorthand.
  24565. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24566. * // => [{ 'x': 1 }, { 'x': 2 }]
  24567. */
  24568. var unionBy = baseRest(function(arrays) {
  24569. var iteratee = last(arrays);
  24570. if (isArrayLikeObject(iteratee)) {
  24571. iteratee = undefined;
  24572. }
  24573. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24574. });
  24575. /**
  24576. * This method is like `_.union` except that it accepts `comparator` which
  24577. * is invoked to compare elements of `arrays`. Result values are chosen from
  24578. * the first array in which the value occurs. The comparator is invoked
  24579. * with two arguments: (arrVal, othVal).
  24580. *
  24581. * @static
  24582. * @memberOf _
  24583. * @since 4.0.0
  24584. * @category Array
  24585. * @param {...Array} [arrays] The arrays to inspect.
  24586. * @param {Function} [comparator] The comparator invoked per element.
  24587. * @returns {Array} Returns the new array of combined values.
  24588. * @example
  24589. *
  24590. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24591. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24592. *
  24593. * _.unionWith(objects, others, _.isEqual);
  24594. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24595. */
  24596. var unionWith = baseRest(function(arrays) {
  24597. var comparator = last(arrays);
  24598. comparator = typeof comparator == 'function' ? comparator : undefined;
  24599. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24600. });
  24601. /**
  24602. * Creates a duplicate-free version of an array, using
  24603. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24604. * for equality comparisons, in which only the first occurrence of each element
  24605. * is kept. The order of result values is determined by the order they occur
  24606. * in the array.
  24607. *
  24608. * @static
  24609. * @memberOf _
  24610. * @since 0.1.0
  24611. * @category Array
  24612. * @param {Array} array The array to inspect.
  24613. * @returns {Array} Returns the new duplicate free array.
  24614. * @example
  24615. *
  24616. * _.uniq([2, 1, 2]);
  24617. * // => [2, 1]
  24618. */
  24619. function uniq(array) {
  24620. return (array && array.length) ? baseUniq(array) : [];
  24621. }
  24622. /**
  24623. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24624. * invoked for each element in `array` to generate the criterion by which
  24625. * uniqueness is computed. The order of result values is determined by the
  24626. * order they occur in the array. The iteratee is invoked with one argument:
  24627. * (value).
  24628. *
  24629. * @static
  24630. * @memberOf _
  24631. * @since 4.0.0
  24632. * @category Array
  24633. * @param {Array} array The array to inspect.
  24634. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24635. * @returns {Array} Returns the new duplicate free array.
  24636. * @example
  24637. *
  24638. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24639. * // => [2.1, 1.2]
  24640. *
  24641. * // The `_.property` iteratee shorthand.
  24642. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24643. * // => [{ 'x': 1 }, { 'x': 2 }]
  24644. */
  24645. function uniqBy(array, iteratee) {
  24646. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24647. }
  24648. /**
  24649. * This method is like `_.uniq` except that it accepts `comparator` which
  24650. * is invoked to compare elements of `array`. The order of result values is
  24651. * determined by the order they occur in the array.The comparator is invoked
  24652. * with two arguments: (arrVal, othVal).
  24653. *
  24654. * @static
  24655. * @memberOf _
  24656. * @since 4.0.0
  24657. * @category Array
  24658. * @param {Array} array The array to inspect.
  24659. * @param {Function} [comparator] The comparator invoked per element.
  24660. * @returns {Array} Returns the new duplicate free array.
  24661. * @example
  24662. *
  24663. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24664. *
  24665. * _.uniqWith(objects, _.isEqual);
  24666. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24667. */
  24668. function uniqWith(array, comparator) {
  24669. comparator = typeof comparator == 'function' ? comparator : undefined;
  24670. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24671. }
  24672. /**
  24673. * This method is like `_.zip` except that it accepts an array of grouped
  24674. * elements and creates an array regrouping the elements to their pre-zip
  24675. * configuration.
  24676. *
  24677. * @static
  24678. * @memberOf _
  24679. * @since 1.2.0
  24680. * @category Array
  24681. * @param {Array} array The array of grouped elements to process.
  24682. * @returns {Array} Returns the new array of regrouped elements.
  24683. * @example
  24684. *
  24685. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24686. * // => [['a', 1, true], ['b', 2, false]]
  24687. *
  24688. * _.unzip(zipped);
  24689. * // => [['a', 'b'], [1, 2], [true, false]]
  24690. */
  24691. function unzip(array) {
  24692. if (!(array && array.length)) {
  24693. return [];
  24694. }
  24695. var length = 0;
  24696. array = arrayFilter(array, function(group) {
  24697. if (isArrayLikeObject(group)) {
  24698. length = nativeMax(group.length, length);
  24699. return true;
  24700. }
  24701. });
  24702. return baseTimes(length, function(index) {
  24703. return arrayMap(array, baseProperty(index));
  24704. });
  24705. }
  24706. /**
  24707. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24708. * how regrouped values should be combined. The iteratee is invoked with the
  24709. * elements of each group: (...group).
  24710. *
  24711. * @static
  24712. * @memberOf _
  24713. * @since 3.8.0
  24714. * @category Array
  24715. * @param {Array} array The array of grouped elements to process.
  24716. * @param {Function} [iteratee=_.identity] The function to combine
  24717. * regrouped values.
  24718. * @returns {Array} Returns the new array of regrouped elements.
  24719. * @example
  24720. *
  24721. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24722. * // => [[1, 10, 100], [2, 20, 200]]
  24723. *
  24724. * _.unzipWith(zipped, _.add);
  24725. * // => [3, 30, 300]
  24726. */
  24727. function unzipWith(array, iteratee) {
  24728. if (!(array && array.length)) {
  24729. return [];
  24730. }
  24731. var result = unzip(array);
  24732. if (iteratee == null) {
  24733. return result;
  24734. }
  24735. return arrayMap(result, function(group) {
  24736. return apply(iteratee, undefined, group);
  24737. });
  24738. }
  24739. /**
  24740. * Creates an array excluding all given values using
  24741. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24742. * for equality comparisons.
  24743. *
  24744. * **Note:** Unlike `_.pull`, this method returns a new array.
  24745. *
  24746. * @static
  24747. * @memberOf _
  24748. * @since 0.1.0
  24749. * @category Array
  24750. * @param {Array} array The array to inspect.
  24751. * @param {...*} [values] The values to exclude.
  24752. * @returns {Array} Returns the new array of filtered values.
  24753. * @see _.difference, _.xor
  24754. * @example
  24755. *
  24756. * _.without([2, 1, 2, 3], 1, 2);
  24757. * // => [3]
  24758. */
  24759. var without = baseRest(function(array, values) {
  24760. return isArrayLikeObject(array)
  24761. ? baseDifference(array, values)
  24762. : [];
  24763. });
  24764. /**
  24765. * Creates an array of unique values that is the
  24766. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24767. * of the given arrays. The order of result values is determined by the order
  24768. * they occur in the arrays.
  24769. *
  24770. * @static
  24771. * @memberOf _
  24772. * @since 2.4.0
  24773. * @category Array
  24774. * @param {...Array} [arrays] The arrays to inspect.
  24775. * @returns {Array} Returns the new array of filtered values.
  24776. * @see _.difference, _.without
  24777. * @example
  24778. *
  24779. * _.xor([2, 1], [2, 3]);
  24780. * // => [1, 3]
  24781. */
  24782. var xor = baseRest(function(arrays) {
  24783. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24784. });
  24785. /**
  24786. * This method is like `_.xor` except that it accepts `iteratee` which is
  24787. * invoked for each element of each `arrays` to generate the criterion by
  24788. * which by which they're compared. The order of result values is determined
  24789. * by the order they occur in the arrays. The iteratee is invoked with one
  24790. * argument: (value).
  24791. *
  24792. * @static
  24793. * @memberOf _
  24794. * @since 4.0.0
  24795. * @category Array
  24796. * @param {...Array} [arrays] The arrays to inspect.
  24797. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24798. * @returns {Array} Returns the new array of filtered values.
  24799. * @example
  24800. *
  24801. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24802. * // => [1.2, 3.4]
  24803. *
  24804. * // The `_.property` iteratee shorthand.
  24805. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24806. * // => [{ 'x': 2 }]
  24807. */
  24808. var xorBy = baseRest(function(arrays) {
  24809. var iteratee = last(arrays);
  24810. if (isArrayLikeObject(iteratee)) {
  24811. iteratee = undefined;
  24812. }
  24813. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24814. });
  24815. /**
  24816. * This method is like `_.xor` except that it accepts `comparator` which is
  24817. * invoked to compare elements of `arrays`. The order of result values is
  24818. * determined by the order they occur in the arrays. The comparator is invoked
  24819. * with two arguments: (arrVal, othVal).
  24820. *
  24821. * @static
  24822. * @memberOf _
  24823. * @since 4.0.0
  24824. * @category Array
  24825. * @param {...Array} [arrays] The arrays to inspect.
  24826. * @param {Function} [comparator] The comparator invoked per element.
  24827. * @returns {Array} Returns the new array of filtered values.
  24828. * @example
  24829. *
  24830. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24831. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24832. *
  24833. * _.xorWith(objects, others, _.isEqual);
  24834. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24835. */
  24836. var xorWith = baseRest(function(arrays) {
  24837. var comparator = last(arrays);
  24838. comparator = typeof comparator == 'function' ? comparator : undefined;
  24839. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24840. });
  24841. /**
  24842. * Creates an array of grouped elements, the first of which contains the
  24843. * first elements of the given arrays, the second of which contains the
  24844. * second elements of the given arrays, and so on.
  24845. *
  24846. * @static
  24847. * @memberOf _
  24848. * @since 0.1.0
  24849. * @category Array
  24850. * @param {...Array} [arrays] The arrays to process.
  24851. * @returns {Array} Returns the new array of grouped elements.
  24852. * @example
  24853. *
  24854. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24855. * // => [['a', 1, true], ['b', 2, false]]
  24856. */
  24857. var zip = baseRest(unzip);
  24858. /**
  24859. * This method is like `_.fromPairs` except that it accepts two arrays,
  24860. * one of property identifiers and one of corresponding values.
  24861. *
  24862. * @static
  24863. * @memberOf _
  24864. * @since 0.4.0
  24865. * @category Array
  24866. * @param {Array} [props=[]] The property identifiers.
  24867. * @param {Array} [values=[]] The property values.
  24868. * @returns {Object} Returns the new object.
  24869. * @example
  24870. *
  24871. * _.zipObject(['a', 'b'], [1, 2]);
  24872. * // => { 'a': 1, 'b': 2 }
  24873. */
  24874. function zipObject(props, values) {
  24875. return baseZipObject(props || [], values || [], assignValue);
  24876. }
  24877. /**
  24878. * This method is like `_.zipObject` except that it supports property paths.
  24879. *
  24880. * @static
  24881. * @memberOf _
  24882. * @since 4.1.0
  24883. * @category Array
  24884. * @param {Array} [props=[]] The property identifiers.
  24885. * @param {Array} [values=[]] The property values.
  24886. * @returns {Object} Returns the new object.
  24887. * @example
  24888. *
  24889. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24890. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24891. */
  24892. function zipObjectDeep(props, values) {
  24893. return baseZipObject(props || [], values || [], baseSet);
  24894. }
  24895. /**
  24896. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24897. * how grouped values should be combined. The iteratee is invoked with the
  24898. * elements of each group: (...group).
  24899. *
  24900. * @static
  24901. * @memberOf _
  24902. * @since 3.8.0
  24903. * @category Array
  24904. * @param {...Array} [arrays] The arrays to process.
  24905. * @param {Function} [iteratee=_.identity] The function to combine
  24906. * grouped values.
  24907. * @returns {Array} Returns the new array of grouped elements.
  24908. * @example
  24909. *
  24910. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24911. * return a + b + c;
  24912. * });
  24913. * // => [111, 222]
  24914. */
  24915. var zipWith = baseRest(function(arrays) {
  24916. var length = arrays.length,
  24917. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24918. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24919. return unzipWith(arrays, iteratee);
  24920. });
  24921. /*------------------------------------------------------------------------*/
  24922. /**
  24923. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24924. * chain sequences enabled. The result of such sequences must be unwrapped
  24925. * with `_#value`.
  24926. *
  24927. * @static
  24928. * @memberOf _
  24929. * @since 1.3.0
  24930. * @category Seq
  24931. * @param {*} value The value to wrap.
  24932. * @returns {Object} Returns the new `lodash` wrapper instance.
  24933. * @example
  24934. *
  24935. * var users = [
  24936. * { 'user': 'barney', 'age': 36 },
  24937. * { 'user': 'fred', 'age': 40 },
  24938. * { 'user': 'pebbles', 'age': 1 }
  24939. * ];
  24940. *
  24941. * var youngest = _
  24942. * .chain(users)
  24943. * .sortBy('age')
  24944. * .map(function(o) {
  24945. * return o.user + ' is ' + o.age;
  24946. * })
  24947. * .head()
  24948. * .value();
  24949. * // => 'pebbles is 1'
  24950. */
  24951. function chain(value) {
  24952. var result = lodash(value);
  24953. result.__chain__ = true;
  24954. return result;
  24955. }
  24956. /**
  24957. * This method invokes `interceptor` and returns `value`. The interceptor
  24958. * is invoked with one argument; (value). The purpose of this method is to
  24959. * "tap into" a method chain sequence in order to modify intermediate results.
  24960. *
  24961. * @static
  24962. * @memberOf _
  24963. * @since 0.1.0
  24964. * @category Seq
  24965. * @param {*} value The value to provide to `interceptor`.
  24966. * @param {Function} interceptor The function to invoke.
  24967. * @returns {*} Returns `value`.
  24968. * @example
  24969. *
  24970. * _([1, 2, 3])
  24971. * .tap(function(array) {
  24972. * // Mutate input array.
  24973. * array.pop();
  24974. * })
  24975. * .reverse()
  24976. * .value();
  24977. * // => [2, 1]
  24978. */
  24979. function tap(value, interceptor) {
  24980. interceptor(value);
  24981. return value;
  24982. }
  24983. /**
  24984. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24985. * The purpose of this method is to "pass thru" values replacing intermediate
  24986. * results in a method chain sequence.
  24987. *
  24988. * @static
  24989. * @memberOf _
  24990. * @since 3.0.0
  24991. * @category Seq
  24992. * @param {*} value The value to provide to `interceptor`.
  24993. * @param {Function} interceptor The function to invoke.
  24994. * @returns {*} Returns the result of `interceptor`.
  24995. * @example
  24996. *
  24997. * _(' abc ')
  24998. * .chain()
  24999. * .trim()
  25000. * .thru(function(value) {
  25001. * return [value];
  25002. * })
  25003. * .value();
  25004. * // => ['abc']
  25005. */
  25006. function thru(value, interceptor) {
  25007. return interceptor(value);
  25008. }
  25009. /**
  25010. * This method is the wrapper version of `_.at`.
  25011. *
  25012. * @name at
  25013. * @memberOf _
  25014. * @since 1.0.0
  25015. * @category Seq
  25016. * @param {...(string|string[])} [paths] The property paths to pick.
  25017. * @returns {Object} Returns the new `lodash` wrapper instance.
  25018. * @example
  25019. *
  25020. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25021. *
  25022. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25023. * // => [3, 4]
  25024. */
  25025. var wrapperAt = flatRest(function(paths) {
  25026. var length = paths.length,
  25027. start = length ? paths[0] : 0,
  25028. value = this.__wrapped__,
  25029. interceptor = function(object) { return baseAt(object, paths); };
  25030. if (length > 1 || this.__actions__.length ||
  25031. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25032. return this.thru(interceptor);
  25033. }
  25034. value = value.slice(start, +start + (length ? 1 : 0));
  25035. value.__actions__.push({
  25036. 'func': thru,
  25037. 'args': [interceptor],
  25038. 'thisArg': undefined
  25039. });
  25040. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25041. if (length && !array.length) {
  25042. array.push(undefined);
  25043. }
  25044. return array;
  25045. });
  25046. });
  25047. /**
  25048. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25049. *
  25050. * @name chain
  25051. * @memberOf _
  25052. * @since 0.1.0
  25053. * @category Seq
  25054. * @returns {Object} Returns the new `lodash` wrapper instance.
  25055. * @example
  25056. *
  25057. * var users = [
  25058. * { 'user': 'barney', 'age': 36 },
  25059. * { 'user': 'fred', 'age': 40 }
  25060. * ];
  25061. *
  25062. * // A sequence without explicit chaining.
  25063. * _(users).head();
  25064. * // => { 'user': 'barney', 'age': 36 }
  25065. *
  25066. * // A sequence with explicit chaining.
  25067. * _(users)
  25068. * .chain()
  25069. * .head()
  25070. * .pick('user')
  25071. * .value();
  25072. * // => { 'user': 'barney' }
  25073. */
  25074. function wrapperChain() {
  25075. return chain(this);
  25076. }
  25077. /**
  25078. * Executes the chain sequence and returns the wrapped result.
  25079. *
  25080. * @name commit
  25081. * @memberOf _
  25082. * @since 3.2.0
  25083. * @category Seq
  25084. * @returns {Object} Returns the new `lodash` wrapper instance.
  25085. * @example
  25086. *
  25087. * var array = [1, 2];
  25088. * var wrapped = _(array).push(3);
  25089. *
  25090. * console.log(array);
  25091. * // => [1, 2]
  25092. *
  25093. * wrapped = wrapped.commit();
  25094. * console.log(array);
  25095. * // => [1, 2, 3]
  25096. *
  25097. * wrapped.last();
  25098. * // => 3
  25099. *
  25100. * console.log(array);
  25101. * // => [1, 2, 3]
  25102. */
  25103. function wrapperCommit() {
  25104. return new LodashWrapper(this.value(), this.__chain__);
  25105. }
  25106. /**
  25107. * Gets the next value on a wrapped object following the
  25108. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25109. *
  25110. * @name next
  25111. * @memberOf _
  25112. * @since 4.0.0
  25113. * @category Seq
  25114. * @returns {Object} Returns the next iterator value.
  25115. * @example
  25116. *
  25117. * var wrapped = _([1, 2]);
  25118. *
  25119. * wrapped.next();
  25120. * // => { 'done': false, 'value': 1 }
  25121. *
  25122. * wrapped.next();
  25123. * // => { 'done': false, 'value': 2 }
  25124. *
  25125. * wrapped.next();
  25126. * // => { 'done': true, 'value': undefined }
  25127. */
  25128. function wrapperNext() {
  25129. if (this.__values__ === undefined) {
  25130. this.__values__ = toArray(this.value());
  25131. }
  25132. var done = this.__index__ >= this.__values__.length,
  25133. value = done ? undefined : this.__values__[this.__index__++];
  25134. return { 'done': done, 'value': value };
  25135. }
  25136. /**
  25137. * Enables the wrapper to be iterable.
  25138. *
  25139. * @name Symbol.iterator
  25140. * @memberOf _
  25141. * @since 4.0.0
  25142. * @category Seq
  25143. * @returns {Object} Returns the wrapper object.
  25144. * @example
  25145. *
  25146. * var wrapped = _([1, 2]);
  25147. *
  25148. * wrapped[Symbol.iterator]() === wrapped;
  25149. * // => true
  25150. *
  25151. * Array.from(wrapped);
  25152. * // => [1, 2]
  25153. */
  25154. function wrapperToIterator() {
  25155. return this;
  25156. }
  25157. /**
  25158. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25159. *
  25160. * @name plant
  25161. * @memberOf _
  25162. * @since 3.2.0
  25163. * @category Seq
  25164. * @param {*} value The value to plant.
  25165. * @returns {Object} Returns the new `lodash` wrapper instance.
  25166. * @example
  25167. *
  25168. * function square(n) {
  25169. * return n * n;
  25170. * }
  25171. *
  25172. * var wrapped = _([1, 2]).map(square);
  25173. * var other = wrapped.plant([3, 4]);
  25174. *
  25175. * other.value();
  25176. * // => [9, 16]
  25177. *
  25178. * wrapped.value();
  25179. * // => [1, 4]
  25180. */
  25181. function wrapperPlant(value) {
  25182. var result,
  25183. parent = this;
  25184. while (parent instanceof baseLodash) {
  25185. var clone = wrapperClone(parent);
  25186. clone.__index__ = 0;
  25187. clone.__values__ = undefined;
  25188. if (result) {
  25189. previous.__wrapped__ = clone;
  25190. } else {
  25191. result = clone;
  25192. }
  25193. var previous = clone;
  25194. parent = parent.__wrapped__;
  25195. }
  25196. previous.__wrapped__ = value;
  25197. return result;
  25198. }
  25199. /**
  25200. * This method is the wrapper version of `_.reverse`.
  25201. *
  25202. * **Note:** This method mutates the wrapped array.
  25203. *
  25204. * @name reverse
  25205. * @memberOf _
  25206. * @since 0.1.0
  25207. * @category Seq
  25208. * @returns {Object} Returns the new `lodash` wrapper instance.
  25209. * @example
  25210. *
  25211. * var array = [1, 2, 3];
  25212. *
  25213. * _(array).reverse().value()
  25214. * // => [3, 2, 1]
  25215. *
  25216. * console.log(array);
  25217. * // => [3, 2, 1]
  25218. */
  25219. function wrapperReverse() {
  25220. var value = this.__wrapped__;
  25221. if (value instanceof LazyWrapper) {
  25222. var wrapped = value;
  25223. if (this.__actions__.length) {
  25224. wrapped = new LazyWrapper(this);
  25225. }
  25226. wrapped = wrapped.reverse();
  25227. wrapped.__actions__.push({
  25228. 'func': thru,
  25229. 'args': [reverse],
  25230. 'thisArg': undefined
  25231. });
  25232. return new LodashWrapper(wrapped, this.__chain__);
  25233. }
  25234. return this.thru(reverse);
  25235. }
  25236. /**
  25237. * Executes the chain sequence to resolve the unwrapped value.
  25238. *
  25239. * @name value
  25240. * @memberOf _
  25241. * @since 0.1.0
  25242. * @alias toJSON, valueOf
  25243. * @category Seq
  25244. * @returns {*} Returns the resolved unwrapped value.
  25245. * @example
  25246. *
  25247. * _([1, 2, 3]).value();
  25248. * // => [1, 2, 3]
  25249. */
  25250. function wrapperValue() {
  25251. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25252. }
  25253. /*------------------------------------------------------------------------*/
  25254. /**
  25255. * Creates an object composed of keys generated from the results of running
  25256. * each element of `collection` thru `iteratee`. The corresponding value of
  25257. * each key is the number of times the key was returned by `iteratee`. The
  25258. * iteratee is invoked with one argument: (value).
  25259. *
  25260. * @static
  25261. * @memberOf _
  25262. * @since 0.5.0
  25263. * @category Collection
  25264. * @param {Array|Object} collection The collection to iterate over.
  25265. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25266. * @returns {Object} Returns the composed aggregate object.
  25267. * @example
  25268. *
  25269. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25270. * // => { '4': 1, '6': 2 }
  25271. *
  25272. * // The `_.property` iteratee shorthand.
  25273. * _.countBy(['one', 'two', 'three'], 'length');
  25274. * // => { '3': 2, '5': 1 }
  25275. */
  25276. var countBy = createAggregator(function(result, value, key) {
  25277. if (hasOwnProperty.call(result, key)) {
  25278. ++result[key];
  25279. } else {
  25280. baseAssignValue(result, key, 1);
  25281. }
  25282. });
  25283. /**
  25284. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25285. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25286. * invoked with three arguments: (value, index|key, collection).
  25287. *
  25288. * **Note:** This method returns `true` for
  25289. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25290. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25291. * elements of empty collections.
  25292. *
  25293. * @static
  25294. * @memberOf _
  25295. * @since 0.1.0
  25296. * @category Collection
  25297. * @param {Array|Object} collection The collection to iterate over.
  25298. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25299. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25300. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25301. * else `false`.
  25302. * @example
  25303. *
  25304. * _.every([true, 1, null, 'yes'], Boolean);
  25305. * // => false
  25306. *
  25307. * var users = [
  25308. * { 'user': 'barney', 'age': 36, 'active': false },
  25309. * { 'user': 'fred', 'age': 40, 'active': false }
  25310. * ];
  25311. *
  25312. * // The `_.matches` iteratee shorthand.
  25313. * _.every(users, { 'user': 'barney', 'active': false });
  25314. * // => false
  25315. *
  25316. * // The `_.matchesProperty` iteratee shorthand.
  25317. * _.every(users, ['active', false]);
  25318. * // => true
  25319. *
  25320. * // The `_.property` iteratee shorthand.
  25321. * _.every(users, 'active');
  25322. * // => false
  25323. */
  25324. function every(collection, predicate, guard) {
  25325. var func = isArray(collection) ? arrayEvery : baseEvery;
  25326. if (guard && isIterateeCall(collection, predicate, guard)) {
  25327. predicate = undefined;
  25328. }
  25329. return func(collection, getIteratee(predicate, 3));
  25330. }
  25331. /**
  25332. * Iterates over elements of `collection`, returning an array of all elements
  25333. * `predicate` returns truthy for. The predicate is invoked with three
  25334. * arguments: (value, index|key, collection).
  25335. *
  25336. * **Note:** Unlike `_.remove`, this method returns a new array.
  25337. *
  25338. * @static
  25339. * @memberOf _
  25340. * @since 0.1.0
  25341. * @category Collection
  25342. * @param {Array|Object} collection The collection to iterate over.
  25343. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25344. * @returns {Array} Returns the new filtered array.
  25345. * @see _.reject
  25346. * @example
  25347. *
  25348. * var users = [
  25349. * { 'user': 'barney', 'age': 36, 'active': true },
  25350. * { 'user': 'fred', 'age': 40, 'active': false }
  25351. * ];
  25352. *
  25353. * _.filter(users, function(o) { return !o.active; });
  25354. * // => objects for ['fred']
  25355. *
  25356. * // The `_.matches` iteratee shorthand.
  25357. * _.filter(users, { 'age': 36, 'active': true });
  25358. * // => objects for ['barney']
  25359. *
  25360. * // The `_.matchesProperty` iteratee shorthand.
  25361. * _.filter(users, ['active', false]);
  25362. * // => objects for ['fred']
  25363. *
  25364. * // The `_.property` iteratee shorthand.
  25365. * _.filter(users, 'active');
  25366. * // => objects for ['barney']
  25367. */
  25368. function filter(collection, predicate) {
  25369. var func = isArray(collection) ? arrayFilter : baseFilter;
  25370. return func(collection, getIteratee(predicate, 3));
  25371. }
  25372. /**
  25373. * Iterates over elements of `collection`, returning the first element
  25374. * `predicate` returns truthy for. The predicate is invoked with three
  25375. * arguments: (value, index|key, collection).
  25376. *
  25377. * @static
  25378. * @memberOf _
  25379. * @since 0.1.0
  25380. * @category Collection
  25381. * @param {Array|Object} collection The collection to inspect.
  25382. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25383. * @param {number} [fromIndex=0] The index to search from.
  25384. * @returns {*} Returns the matched element, else `undefined`.
  25385. * @example
  25386. *
  25387. * var users = [
  25388. * { 'user': 'barney', 'age': 36, 'active': true },
  25389. * { 'user': 'fred', 'age': 40, 'active': false },
  25390. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25391. * ];
  25392. *
  25393. * _.find(users, function(o) { return o.age < 40; });
  25394. * // => object for 'barney'
  25395. *
  25396. * // The `_.matches` iteratee shorthand.
  25397. * _.find(users, { 'age': 1, 'active': true });
  25398. * // => object for 'pebbles'
  25399. *
  25400. * // The `_.matchesProperty` iteratee shorthand.
  25401. * _.find(users, ['active', false]);
  25402. * // => object for 'fred'
  25403. *
  25404. * // The `_.property` iteratee shorthand.
  25405. * _.find(users, 'active');
  25406. * // => object for 'barney'
  25407. */
  25408. var find = createFind(findIndex);
  25409. /**
  25410. * This method is like `_.find` except that it iterates over elements of
  25411. * `collection` from right to left.
  25412. *
  25413. * @static
  25414. * @memberOf _
  25415. * @since 2.0.0
  25416. * @category Collection
  25417. * @param {Array|Object} collection The collection to inspect.
  25418. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25419. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25420. * @returns {*} Returns the matched element, else `undefined`.
  25421. * @example
  25422. *
  25423. * _.findLast([1, 2, 3, 4], function(n) {
  25424. * return n % 2 == 1;
  25425. * });
  25426. * // => 3
  25427. */
  25428. var findLast = createFind(findLastIndex);
  25429. /**
  25430. * Creates a flattened array of values by running each element in `collection`
  25431. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25432. * with three arguments: (value, index|key, collection).
  25433. *
  25434. * @static
  25435. * @memberOf _
  25436. * @since 4.0.0
  25437. * @category Collection
  25438. * @param {Array|Object} collection The collection to iterate over.
  25439. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25440. * @returns {Array} Returns the new flattened array.
  25441. * @example
  25442. *
  25443. * function duplicate(n) {
  25444. * return [n, n];
  25445. * }
  25446. *
  25447. * _.flatMap([1, 2], duplicate);
  25448. * // => [1, 1, 2, 2]
  25449. */
  25450. function flatMap(collection, iteratee) {
  25451. return baseFlatten(map(collection, iteratee), 1);
  25452. }
  25453. /**
  25454. * This method is like `_.flatMap` except that it recursively flattens the
  25455. * mapped results.
  25456. *
  25457. * @static
  25458. * @memberOf _
  25459. * @since 4.7.0
  25460. * @category Collection
  25461. * @param {Array|Object} collection The collection to iterate over.
  25462. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25463. * @returns {Array} Returns the new flattened array.
  25464. * @example
  25465. *
  25466. * function duplicate(n) {
  25467. * return [[[n, n]]];
  25468. * }
  25469. *
  25470. * _.flatMapDeep([1, 2], duplicate);
  25471. * // => [1, 1, 2, 2]
  25472. */
  25473. function flatMapDeep(collection, iteratee) {
  25474. return baseFlatten(map(collection, iteratee), INFINITY);
  25475. }
  25476. /**
  25477. * This method is like `_.flatMap` except that it recursively flattens the
  25478. * mapped results up to `depth` times.
  25479. *
  25480. * @static
  25481. * @memberOf _
  25482. * @since 4.7.0
  25483. * @category Collection
  25484. * @param {Array|Object} collection The collection to iterate over.
  25485. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25486. * @param {number} [depth=1] The maximum recursion depth.
  25487. * @returns {Array} Returns the new flattened array.
  25488. * @example
  25489. *
  25490. * function duplicate(n) {
  25491. * return [[[n, n]]];
  25492. * }
  25493. *
  25494. * _.flatMapDepth([1, 2], duplicate, 2);
  25495. * // => [[1, 1], [2, 2]]
  25496. */
  25497. function flatMapDepth(collection, iteratee, depth) {
  25498. depth = depth === undefined ? 1 : toInteger(depth);
  25499. return baseFlatten(map(collection, iteratee), depth);
  25500. }
  25501. /**
  25502. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25503. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25504. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25505. *
  25506. * **Note:** As with other "Collections" methods, objects with a "length"
  25507. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25508. * or `_.forOwn` for object iteration.
  25509. *
  25510. * @static
  25511. * @memberOf _
  25512. * @since 0.1.0
  25513. * @alias each
  25514. * @category Collection
  25515. * @param {Array|Object} collection The collection to iterate over.
  25516. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25517. * @returns {Array|Object} Returns `collection`.
  25518. * @see _.forEachRight
  25519. * @example
  25520. *
  25521. * _.forEach([1, 2], function(value) {
  25522. * console.log(value);
  25523. * });
  25524. * // => Logs `1` then `2`.
  25525. *
  25526. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25527. * console.log(key);
  25528. * });
  25529. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25530. */
  25531. function forEach(collection, iteratee) {
  25532. var func = isArray(collection) ? arrayEach : baseEach;
  25533. return func(collection, getIteratee(iteratee, 3));
  25534. }
  25535. /**
  25536. * This method is like `_.forEach` except that it iterates over elements of
  25537. * `collection` from right to left.
  25538. *
  25539. * @static
  25540. * @memberOf _
  25541. * @since 2.0.0
  25542. * @alias eachRight
  25543. * @category Collection
  25544. * @param {Array|Object} collection The collection to iterate over.
  25545. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25546. * @returns {Array|Object} Returns `collection`.
  25547. * @see _.forEach
  25548. * @example
  25549. *
  25550. * _.forEachRight([1, 2], function(value) {
  25551. * console.log(value);
  25552. * });
  25553. * // => Logs `2` then `1`.
  25554. */
  25555. function forEachRight(collection, iteratee) {
  25556. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25557. return func(collection, getIteratee(iteratee, 3));
  25558. }
  25559. /**
  25560. * Creates an object composed of keys generated from the results of running
  25561. * each element of `collection` thru `iteratee`. The order of grouped values
  25562. * is determined by the order they occur in `collection`. The corresponding
  25563. * value of each key is an array of elements responsible for generating the
  25564. * key. The iteratee is invoked with one argument: (value).
  25565. *
  25566. * @static
  25567. * @memberOf _
  25568. * @since 0.1.0
  25569. * @category Collection
  25570. * @param {Array|Object} collection The collection to iterate over.
  25571. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25572. * @returns {Object} Returns the composed aggregate object.
  25573. * @example
  25574. *
  25575. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25576. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25577. *
  25578. * // The `_.property` iteratee shorthand.
  25579. * _.groupBy(['one', 'two', 'three'], 'length');
  25580. * // => { '3': ['one', 'two'], '5': ['three'] }
  25581. */
  25582. var groupBy = createAggregator(function(result, value, key) {
  25583. if (hasOwnProperty.call(result, key)) {
  25584. result[key].push(value);
  25585. } else {
  25586. baseAssignValue(result, key, [value]);
  25587. }
  25588. });
  25589. /**
  25590. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25591. * checked for a substring of `value`, otherwise
  25592. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25593. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25594. * the offset from the end of `collection`.
  25595. *
  25596. * @static
  25597. * @memberOf _
  25598. * @since 0.1.0
  25599. * @category Collection
  25600. * @param {Array|Object|string} collection The collection to inspect.
  25601. * @param {*} value The value to search for.
  25602. * @param {number} [fromIndex=0] The index to search from.
  25603. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25604. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25605. * @example
  25606. *
  25607. * _.includes([1, 2, 3], 1);
  25608. * // => true
  25609. *
  25610. * _.includes([1, 2, 3], 1, 2);
  25611. * // => false
  25612. *
  25613. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25614. * // => true
  25615. *
  25616. * _.includes('abcd', 'bc');
  25617. * // => true
  25618. */
  25619. function includes(collection, value, fromIndex, guard) {
  25620. collection = isArrayLike(collection) ? collection : values(collection);
  25621. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25622. var length = collection.length;
  25623. if (fromIndex < 0) {
  25624. fromIndex = nativeMax(length + fromIndex, 0);
  25625. }
  25626. return isString(collection)
  25627. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25628. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25629. }
  25630. /**
  25631. * Invokes the method at `path` of each element in `collection`, returning
  25632. * an array of the results of each invoked method. Any additional arguments
  25633. * are provided to each invoked method. If `path` is a function, it's invoked
  25634. * for, and `this` bound to, each element in `collection`.
  25635. *
  25636. * @static
  25637. * @memberOf _
  25638. * @since 4.0.0
  25639. * @category Collection
  25640. * @param {Array|Object} collection The collection to iterate over.
  25641. * @param {Array|Function|string} path The path of the method to invoke or
  25642. * the function invoked per iteration.
  25643. * @param {...*} [args] The arguments to invoke each method with.
  25644. * @returns {Array} Returns the array of results.
  25645. * @example
  25646. *
  25647. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25648. * // => [[1, 5, 7], [1, 2, 3]]
  25649. *
  25650. * _.invokeMap([123, 456], String.prototype.split, '');
  25651. * // => [['1', '2', '3'], ['4', '5', '6']]
  25652. */
  25653. var invokeMap = baseRest(function(collection, path, args) {
  25654. var index = -1,
  25655. isFunc = typeof path == 'function',
  25656. result = isArrayLike(collection) ? Array(collection.length) : [];
  25657. baseEach(collection, function(value) {
  25658. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25659. });
  25660. return result;
  25661. });
  25662. /**
  25663. * Creates an object composed of keys generated from the results of running
  25664. * each element of `collection` thru `iteratee`. The corresponding value of
  25665. * each key is the last element responsible for generating the key. The
  25666. * iteratee is invoked with one argument: (value).
  25667. *
  25668. * @static
  25669. * @memberOf _
  25670. * @since 4.0.0
  25671. * @category Collection
  25672. * @param {Array|Object} collection The collection to iterate over.
  25673. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25674. * @returns {Object} Returns the composed aggregate object.
  25675. * @example
  25676. *
  25677. * var array = [
  25678. * { 'dir': 'left', 'code': 97 },
  25679. * { 'dir': 'right', 'code': 100 }
  25680. * ];
  25681. *
  25682. * _.keyBy(array, function(o) {
  25683. * return String.fromCharCode(o.code);
  25684. * });
  25685. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25686. *
  25687. * _.keyBy(array, 'dir');
  25688. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25689. */
  25690. var keyBy = createAggregator(function(result, value, key) {
  25691. baseAssignValue(result, key, value);
  25692. });
  25693. /**
  25694. * Creates an array of values by running each element in `collection` thru
  25695. * `iteratee`. The iteratee is invoked with three arguments:
  25696. * (value, index|key, collection).
  25697. *
  25698. * Many lodash methods are guarded to work as iteratees for methods like
  25699. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25700. *
  25701. * The guarded methods are:
  25702. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25703. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25704. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25705. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25706. *
  25707. * @static
  25708. * @memberOf _
  25709. * @since 0.1.0
  25710. * @category Collection
  25711. * @param {Array|Object} collection The collection to iterate over.
  25712. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25713. * @returns {Array} Returns the new mapped array.
  25714. * @example
  25715. *
  25716. * function square(n) {
  25717. * return n * n;
  25718. * }
  25719. *
  25720. * _.map([4, 8], square);
  25721. * // => [16, 64]
  25722. *
  25723. * _.map({ 'a': 4, 'b': 8 }, square);
  25724. * // => [16, 64] (iteration order is not guaranteed)
  25725. *
  25726. * var users = [
  25727. * { 'user': 'barney' },
  25728. * { 'user': 'fred' }
  25729. * ];
  25730. *
  25731. * // The `_.property` iteratee shorthand.
  25732. * _.map(users, 'user');
  25733. * // => ['barney', 'fred']
  25734. */
  25735. function map(collection, iteratee) {
  25736. var func = isArray(collection) ? arrayMap : baseMap;
  25737. return func(collection, getIteratee(iteratee, 3));
  25738. }
  25739. /**
  25740. * This method is like `_.sortBy` except that it allows specifying the sort
  25741. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25742. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25743. * descending or "asc" for ascending sort order of corresponding values.
  25744. *
  25745. * @static
  25746. * @memberOf _
  25747. * @since 4.0.0
  25748. * @category Collection
  25749. * @param {Array|Object} collection The collection to iterate over.
  25750. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25751. * The iteratees to sort by.
  25752. * @param {string[]} [orders] The sort orders of `iteratees`.
  25753. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25754. * @returns {Array} Returns the new sorted array.
  25755. * @example
  25756. *
  25757. * var users = [
  25758. * { 'user': 'fred', 'age': 48 },
  25759. * { 'user': 'barney', 'age': 34 },
  25760. * { 'user': 'fred', 'age': 40 },
  25761. * { 'user': 'barney', 'age': 36 }
  25762. * ];
  25763. *
  25764. * // Sort by `user` in ascending order and by `age` in descending order.
  25765. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25766. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25767. */
  25768. function orderBy(collection, iteratees, orders, guard) {
  25769. if (collection == null) {
  25770. return [];
  25771. }
  25772. if (!isArray(iteratees)) {
  25773. iteratees = iteratees == null ? [] : [iteratees];
  25774. }
  25775. orders = guard ? undefined : orders;
  25776. if (!isArray(orders)) {
  25777. orders = orders == null ? [] : [orders];
  25778. }
  25779. return baseOrderBy(collection, iteratees, orders);
  25780. }
  25781. /**
  25782. * Creates an array of elements split into two groups, the first of which
  25783. * contains elements `predicate` returns truthy for, the second of which
  25784. * contains elements `predicate` returns falsey for. The predicate is
  25785. * invoked with one argument: (value).
  25786. *
  25787. * @static
  25788. * @memberOf _
  25789. * @since 3.0.0
  25790. * @category Collection
  25791. * @param {Array|Object} collection The collection to iterate over.
  25792. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25793. * @returns {Array} Returns the array of grouped elements.
  25794. * @example
  25795. *
  25796. * var users = [
  25797. * { 'user': 'barney', 'age': 36, 'active': false },
  25798. * { 'user': 'fred', 'age': 40, 'active': true },
  25799. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25800. * ];
  25801. *
  25802. * _.partition(users, function(o) { return o.active; });
  25803. * // => objects for [['fred'], ['barney', 'pebbles']]
  25804. *
  25805. * // The `_.matches` iteratee shorthand.
  25806. * _.partition(users, { 'age': 1, 'active': false });
  25807. * // => objects for [['pebbles'], ['barney', 'fred']]
  25808. *
  25809. * // The `_.matchesProperty` iteratee shorthand.
  25810. * _.partition(users, ['active', false]);
  25811. * // => objects for [['barney', 'pebbles'], ['fred']]
  25812. *
  25813. * // The `_.property` iteratee shorthand.
  25814. * _.partition(users, 'active');
  25815. * // => objects for [['fred'], ['barney', 'pebbles']]
  25816. */
  25817. var partition = createAggregator(function(result, value, key) {
  25818. result[key ? 0 : 1].push(value);
  25819. }, function() { return [[], []]; });
  25820. /**
  25821. * Reduces `collection` to a value which is the accumulated result of running
  25822. * each element in `collection` thru `iteratee`, where each successive
  25823. * invocation is supplied the return value of the previous. If `accumulator`
  25824. * is not given, the first element of `collection` is used as the initial
  25825. * value. The iteratee is invoked with four arguments:
  25826. * (accumulator, value, index|key, collection).
  25827. *
  25828. * Many lodash methods are guarded to work as iteratees for methods like
  25829. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25830. *
  25831. * The guarded methods are:
  25832. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25833. * and `sortBy`
  25834. *
  25835. * @static
  25836. * @memberOf _
  25837. * @since 0.1.0
  25838. * @category Collection
  25839. * @param {Array|Object} collection The collection to iterate over.
  25840. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25841. * @param {*} [accumulator] The initial value.
  25842. * @returns {*} Returns the accumulated value.
  25843. * @see _.reduceRight
  25844. * @example
  25845. *
  25846. * _.reduce([1, 2], function(sum, n) {
  25847. * return sum + n;
  25848. * }, 0);
  25849. * // => 3
  25850. *
  25851. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25852. * (result[value] || (result[value] = [])).push(key);
  25853. * return result;
  25854. * }, {});
  25855. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25856. */
  25857. function reduce(collection, iteratee, accumulator) {
  25858. var func = isArray(collection) ? arrayReduce : baseReduce,
  25859. initAccum = arguments.length < 3;
  25860. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25861. }
  25862. /**
  25863. * This method is like `_.reduce` except that it iterates over elements of
  25864. * `collection` from right to left.
  25865. *
  25866. * @static
  25867. * @memberOf _
  25868. * @since 0.1.0
  25869. * @category Collection
  25870. * @param {Array|Object} collection The collection to iterate over.
  25871. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25872. * @param {*} [accumulator] The initial value.
  25873. * @returns {*} Returns the accumulated value.
  25874. * @see _.reduce
  25875. * @example
  25876. *
  25877. * var array = [[0, 1], [2, 3], [4, 5]];
  25878. *
  25879. * _.reduceRight(array, function(flattened, other) {
  25880. * return flattened.concat(other);
  25881. * }, []);
  25882. * // => [4, 5, 2, 3, 0, 1]
  25883. */
  25884. function reduceRight(collection, iteratee, accumulator) {
  25885. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25886. initAccum = arguments.length < 3;
  25887. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25888. }
  25889. /**
  25890. * The opposite of `_.filter`; this method returns the elements of `collection`
  25891. * that `predicate` does **not** return truthy for.
  25892. *
  25893. * @static
  25894. * @memberOf _
  25895. * @since 0.1.0
  25896. * @category Collection
  25897. * @param {Array|Object} collection The collection to iterate over.
  25898. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25899. * @returns {Array} Returns the new filtered array.
  25900. * @see _.filter
  25901. * @example
  25902. *
  25903. * var users = [
  25904. * { 'user': 'barney', 'age': 36, 'active': false },
  25905. * { 'user': 'fred', 'age': 40, 'active': true }
  25906. * ];
  25907. *
  25908. * _.reject(users, function(o) { return !o.active; });
  25909. * // => objects for ['fred']
  25910. *
  25911. * // The `_.matches` iteratee shorthand.
  25912. * _.reject(users, { 'age': 40, 'active': true });
  25913. * // => objects for ['barney']
  25914. *
  25915. * // The `_.matchesProperty` iteratee shorthand.
  25916. * _.reject(users, ['active', false]);
  25917. * // => objects for ['fred']
  25918. *
  25919. * // The `_.property` iteratee shorthand.
  25920. * _.reject(users, 'active');
  25921. * // => objects for ['barney']
  25922. */
  25923. function reject(collection, predicate) {
  25924. var func = isArray(collection) ? arrayFilter : baseFilter;
  25925. return func(collection, negate(getIteratee(predicate, 3)));
  25926. }
  25927. /**
  25928. * Gets a random element from `collection`.
  25929. *
  25930. * @static
  25931. * @memberOf _
  25932. * @since 2.0.0
  25933. * @category Collection
  25934. * @param {Array|Object} collection The collection to sample.
  25935. * @returns {*} Returns the random element.
  25936. * @example
  25937. *
  25938. * _.sample([1, 2, 3, 4]);
  25939. * // => 2
  25940. */
  25941. function sample(collection) {
  25942. var func = isArray(collection) ? arraySample : baseSample;
  25943. return func(collection);
  25944. }
  25945. /**
  25946. * Gets `n` random elements at unique keys from `collection` up to the
  25947. * size of `collection`.
  25948. *
  25949. * @static
  25950. * @memberOf _
  25951. * @since 4.0.0
  25952. * @category Collection
  25953. * @param {Array|Object} collection The collection to sample.
  25954. * @param {number} [n=1] The number of elements to sample.
  25955. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25956. * @returns {Array} Returns the random elements.
  25957. * @example
  25958. *
  25959. * _.sampleSize([1, 2, 3], 2);
  25960. * // => [3, 1]
  25961. *
  25962. * _.sampleSize([1, 2, 3], 4);
  25963. * // => [2, 3, 1]
  25964. */
  25965. function sampleSize(collection, n, guard) {
  25966. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25967. n = 1;
  25968. } else {
  25969. n = toInteger(n);
  25970. }
  25971. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25972. return func(collection, n);
  25973. }
  25974. /**
  25975. * Creates an array of shuffled values, using a version of the
  25976. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25977. *
  25978. * @static
  25979. * @memberOf _
  25980. * @since 0.1.0
  25981. * @category Collection
  25982. * @param {Array|Object} collection The collection to shuffle.
  25983. * @returns {Array} Returns the new shuffled array.
  25984. * @example
  25985. *
  25986. * _.shuffle([1, 2, 3, 4]);
  25987. * // => [4, 1, 3, 2]
  25988. */
  25989. function shuffle(collection) {
  25990. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25991. return func(collection);
  25992. }
  25993. /**
  25994. * Gets the size of `collection` by returning its length for array-like
  25995. * values or the number of own enumerable string keyed properties for objects.
  25996. *
  25997. * @static
  25998. * @memberOf _
  25999. * @since 0.1.0
  26000. * @category Collection
  26001. * @param {Array|Object|string} collection The collection to inspect.
  26002. * @returns {number} Returns the collection size.
  26003. * @example
  26004. *
  26005. * _.size([1, 2, 3]);
  26006. * // => 3
  26007. *
  26008. * _.size({ 'a': 1, 'b': 2 });
  26009. * // => 2
  26010. *
  26011. * _.size('pebbles');
  26012. * // => 7
  26013. */
  26014. function size(collection) {
  26015. if (collection == null) {
  26016. return 0;
  26017. }
  26018. if (isArrayLike(collection)) {
  26019. return isString(collection) ? stringSize(collection) : collection.length;
  26020. }
  26021. var tag = getTag(collection);
  26022. if (tag == mapTag || tag == setTag) {
  26023. return collection.size;
  26024. }
  26025. return baseKeys(collection).length;
  26026. }
  26027. /**
  26028. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26029. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26030. * invoked with three arguments: (value, index|key, collection).
  26031. *
  26032. * @static
  26033. * @memberOf _
  26034. * @since 0.1.0
  26035. * @category Collection
  26036. * @param {Array|Object} collection The collection to iterate over.
  26037. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26038. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26039. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26040. * else `false`.
  26041. * @example
  26042. *
  26043. * _.some([null, 0, 'yes', false], Boolean);
  26044. * // => true
  26045. *
  26046. * var users = [
  26047. * { 'user': 'barney', 'active': true },
  26048. * { 'user': 'fred', 'active': false }
  26049. * ];
  26050. *
  26051. * // The `_.matches` iteratee shorthand.
  26052. * _.some(users, { 'user': 'barney', 'active': false });
  26053. * // => false
  26054. *
  26055. * // The `_.matchesProperty` iteratee shorthand.
  26056. * _.some(users, ['active', false]);
  26057. * // => true
  26058. *
  26059. * // The `_.property` iteratee shorthand.
  26060. * _.some(users, 'active');
  26061. * // => true
  26062. */
  26063. function some(collection, predicate, guard) {
  26064. var func = isArray(collection) ? arraySome : baseSome;
  26065. if (guard && isIterateeCall(collection, predicate, guard)) {
  26066. predicate = undefined;
  26067. }
  26068. return func(collection, getIteratee(predicate, 3));
  26069. }
  26070. /**
  26071. * Creates an array of elements, sorted in ascending order by the results of
  26072. * running each element in a collection thru each iteratee. This method
  26073. * performs a stable sort, that is, it preserves the original sort order of
  26074. * equal elements. The iteratees are invoked with one argument: (value).
  26075. *
  26076. * @static
  26077. * @memberOf _
  26078. * @since 0.1.0
  26079. * @category Collection
  26080. * @param {Array|Object} collection The collection to iterate over.
  26081. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26082. * The iteratees to sort by.
  26083. * @returns {Array} Returns the new sorted array.
  26084. * @example
  26085. *
  26086. * var users = [
  26087. * { 'user': 'fred', 'age': 48 },
  26088. * { 'user': 'barney', 'age': 36 },
  26089. * { 'user': 'fred', 'age': 40 },
  26090. * { 'user': 'barney', 'age': 34 }
  26091. * ];
  26092. *
  26093. * _.sortBy(users, [function(o) { return o.user; }]);
  26094. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26095. *
  26096. * _.sortBy(users, ['user', 'age']);
  26097. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26098. */
  26099. var sortBy = baseRest(function(collection, iteratees) {
  26100. if (collection == null) {
  26101. return [];
  26102. }
  26103. var length = iteratees.length;
  26104. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26105. iteratees = [];
  26106. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26107. iteratees = [iteratees[0]];
  26108. }
  26109. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26110. });
  26111. /*------------------------------------------------------------------------*/
  26112. /**
  26113. * Gets the timestamp of the number of milliseconds that have elapsed since
  26114. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26115. *
  26116. * @static
  26117. * @memberOf _
  26118. * @since 2.4.0
  26119. * @category Date
  26120. * @returns {number} Returns the timestamp.
  26121. * @example
  26122. *
  26123. * _.defer(function(stamp) {
  26124. * console.log(_.now() - stamp);
  26125. * }, _.now());
  26126. * // => Logs the number of milliseconds it took for the deferred invocation.
  26127. */
  26128. var now = ctxNow || function() {
  26129. return root.Date.now();
  26130. };
  26131. /*------------------------------------------------------------------------*/
  26132. /**
  26133. * The opposite of `_.before`; this method creates a function that invokes
  26134. * `func` once it's called `n` or more times.
  26135. *
  26136. * @static
  26137. * @memberOf _
  26138. * @since 0.1.0
  26139. * @category Function
  26140. * @param {number} n The number of calls before `func` is invoked.
  26141. * @param {Function} func The function to restrict.
  26142. * @returns {Function} Returns the new restricted function.
  26143. * @example
  26144. *
  26145. * var saves = ['profile', 'settings'];
  26146. *
  26147. * var done = _.after(saves.length, function() {
  26148. * console.log('done saving!');
  26149. * });
  26150. *
  26151. * _.forEach(saves, function(type) {
  26152. * asyncSave({ 'type': type, 'complete': done });
  26153. * });
  26154. * // => Logs 'done saving!' after the two async saves have completed.
  26155. */
  26156. function after(n, func) {
  26157. if (typeof func != 'function') {
  26158. throw new TypeError(FUNC_ERROR_TEXT);
  26159. }
  26160. n = toInteger(n);
  26161. return function() {
  26162. if (--n < 1) {
  26163. return func.apply(this, arguments);
  26164. }
  26165. };
  26166. }
  26167. /**
  26168. * Creates a function that invokes `func`, with up to `n` arguments,
  26169. * ignoring any additional arguments.
  26170. *
  26171. * @static
  26172. * @memberOf _
  26173. * @since 3.0.0
  26174. * @category Function
  26175. * @param {Function} func The function to cap arguments for.
  26176. * @param {number} [n=func.length] The arity cap.
  26177. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26178. * @returns {Function} Returns the new capped function.
  26179. * @example
  26180. *
  26181. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26182. * // => [6, 8, 10]
  26183. */
  26184. function ary(func, n, guard) {
  26185. n = guard ? undefined : n;
  26186. n = (func && n == null) ? func.length : n;
  26187. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26188. }
  26189. /**
  26190. * Creates a function that invokes `func`, with the `this` binding and arguments
  26191. * of the created function, while it's called less than `n` times. Subsequent
  26192. * calls to the created function return the result of the last `func` invocation.
  26193. *
  26194. * @static
  26195. * @memberOf _
  26196. * @since 3.0.0
  26197. * @category Function
  26198. * @param {number} n The number of calls at which `func` is no longer invoked.
  26199. * @param {Function} func The function to restrict.
  26200. * @returns {Function} Returns the new restricted function.
  26201. * @example
  26202. *
  26203. * jQuery(element).on('click', _.before(5, addContactToList));
  26204. * // => Allows adding up to 4 contacts to the list.
  26205. */
  26206. function before(n, func) {
  26207. var result;
  26208. if (typeof func != 'function') {
  26209. throw new TypeError(FUNC_ERROR_TEXT);
  26210. }
  26211. n = toInteger(n);
  26212. return function() {
  26213. if (--n > 0) {
  26214. result = func.apply(this, arguments);
  26215. }
  26216. if (n <= 1) {
  26217. func = undefined;
  26218. }
  26219. return result;
  26220. };
  26221. }
  26222. /**
  26223. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26224. * and `partials` prepended to the arguments it receives.
  26225. *
  26226. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26227. * may be used as a placeholder for partially applied arguments.
  26228. *
  26229. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26230. * property of bound functions.
  26231. *
  26232. * @static
  26233. * @memberOf _
  26234. * @since 0.1.0
  26235. * @category Function
  26236. * @param {Function} func The function to bind.
  26237. * @param {*} thisArg The `this` binding of `func`.
  26238. * @param {...*} [partials] The arguments to be partially applied.
  26239. * @returns {Function} Returns the new bound function.
  26240. * @example
  26241. *
  26242. * function greet(greeting, punctuation) {
  26243. * return greeting + ' ' + this.user + punctuation;
  26244. * }
  26245. *
  26246. * var object = { 'user': 'fred' };
  26247. *
  26248. * var bound = _.bind(greet, object, 'hi');
  26249. * bound('!');
  26250. * // => 'hi fred!'
  26251. *
  26252. * // Bound with placeholders.
  26253. * var bound = _.bind(greet, object, _, '!');
  26254. * bound('hi');
  26255. * // => 'hi fred!'
  26256. */
  26257. var bind = baseRest(function(func, thisArg, partials) {
  26258. var bitmask = WRAP_BIND_FLAG;
  26259. if (partials.length) {
  26260. var holders = replaceHolders(partials, getHolder(bind));
  26261. bitmask |= WRAP_PARTIAL_FLAG;
  26262. }
  26263. return createWrap(func, bitmask, thisArg, partials, holders);
  26264. });
  26265. /**
  26266. * Creates a function that invokes the method at `object[key]` with `partials`
  26267. * prepended to the arguments it receives.
  26268. *
  26269. * This method differs from `_.bind` by allowing bound functions to reference
  26270. * methods that may be redefined or don't yet exist. See
  26271. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26272. * for more details.
  26273. *
  26274. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26275. * builds, may be used as a placeholder for partially applied arguments.
  26276. *
  26277. * @static
  26278. * @memberOf _
  26279. * @since 0.10.0
  26280. * @category Function
  26281. * @param {Object} object The object to invoke the method on.
  26282. * @param {string} key The key of the method.
  26283. * @param {...*} [partials] The arguments to be partially applied.
  26284. * @returns {Function} Returns the new bound function.
  26285. * @example
  26286. *
  26287. * var object = {
  26288. * 'user': 'fred',
  26289. * 'greet': function(greeting, punctuation) {
  26290. * return greeting + ' ' + this.user + punctuation;
  26291. * }
  26292. * };
  26293. *
  26294. * var bound = _.bindKey(object, 'greet', 'hi');
  26295. * bound('!');
  26296. * // => 'hi fred!'
  26297. *
  26298. * object.greet = function(greeting, punctuation) {
  26299. * return greeting + 'ya ' + this.user + punctuation;
  26300. * };
  26301. *
  26302. * bound('!');
  26303. * // => 'hiya fred!'
  26304. *
  26305. * // Bound with placeholders.
  26306. * var bound = _.bindKey(object, 'greet', _, '!');
  26307. * bound('hi');
  26308. * // => 'hiya fred!'
  26309. */
  26310. var bindKey = baseRest(function(object, key, partials) {
  26311. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26312. if (partials.length) {
  26313. var holders = replaceHolders(partials, getHolder(bindKey));
  26314. bitmask |= WRAP_PARTIAL_FLAG;
  26315. }
  26316. return createWrap(key, bitmask, object, partials, holders);
  26317. });
  26318. /**
  26319. * Creates a function that accepts arguments of `func` and either invokes
  26320. * `func` returning its result, if at least `arity` number of arguments have
  26321. * been provided, or returns a function that accepts the remaining `func`
  26322. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26323. * is not sufficient.
  26324. *
  26325. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26326. * may be used as a placeholder for provided arguments.
  26327. *
  26328. * **Note:** This method doesn't set the "length" property of curried functions.
  26329. *
  26330. * @static
  26331. * @memberOf _
  26332. * @since 2.0.0
  26333. * @category Function
  26334. * @param {Function} func The function to curry.
  26335. * @param {number} [arity=func.length] The arity of `func`.
  26336. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26337. * @returns {Function} Returns the new curried function.
  26338. * @example
  26339. *
  26340. * var abc = function(a, b, c) {
  26341. * return [a, b, c];
  26342. * };
  26343. *
  26344. * var curried = _.curry(abc);
  26345. *
  26346. * curried(1)(2)(3);
  26347. * // => [1, 2, 3]
  26348. *
  26349. * curried(1, 2)(3);
  26350. * // => [1, 2, 3]
  26351. *
  26352. * curried(1, 2, 3);
  26353. * // => [1, 2, 3]
  26354. *
  26355. * // Curried with placeholders.
  26356. * curried(1)(_, 3)(2);
  26357. * // => [1, 2, 3]
  26358. */
  26359. function curry(func, arity, guard) {
  26360. arity = guard ? undefined : arity;
  26361. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26362. result.placeholder = curry.placeholder;
  26363. return result;
  26364. }
  26365. /**
  26366. * This method is like `_.curry` except that arguments are applied to `func`
  26367. * in the manner of `_.partialRight` instead of `_.partial`.
  26368. *
  26369. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26370. * builds, may be used as a placeholder for provided arguments.
  26371. *
  26372. * **Note:** This method doesn't set the "length" property of curried functions.
  26373. *
  26374. * @static
  26375. * @memberOf _
  26376. * @since 3.0.0
  26377. * @category Function
  26378. * @param {Function} func The function to curry.
  26379. * @param {number} [arity=func.length] The arity of `func`.
  26380. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26381. * @returns {Function} Returns the new curried function.
  26382. * @example
  26383. *
  26384. * var abc = function(a, b, c) {
  26385. * return [a, b, c];
  26386. * };
  26387. *
  26388. * var curried = _.curryRight(abc);
  26389. *
  26390. * curried(3)(2)(1);
  26391. * // => [1, 2, 3]
  26392. *
  26393. * curried(2, 3)(1);
  26394. * // => [1, 2, 3]
  26395. *
  26396. * curried(1, 2, 3);
  26397. * // => [1, 2, 3]
  26398. *
  26399. * // Curried with placeholders.
  26400. * curried(3)(1, _)(2);
  26401. * // => [1, 2, 3]
  26402. */
  26403. function curryRight(func, arity, guard) {
  26404. arity = guard ? undefined : arity;
  26405. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26406. result.placeholder = curryRight.placeholder;
  26407. return result;
  26408. }
  26409. /**
  26410. * Creates a debounced function that delays invoking `func` until after `wait`
  26411. * milliseconds have elapsed since the last time the debounced function was
  26412. * invoked. The debounced function comes with a `cancel` method to cancel
  26413. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26414. * Provide `options` to indicate whether `func` should be invoked on the
  26415. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26416. * with the last arguments provided to the debounced function. Subsequent
  26417. * calls to the debounced function return the result of the last `func`
  26418. * invocation.
  26419. *
  26420. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26421. * invoked on the trailing edge of the timeout only if the debounced function
  26422. * is invoked more than once during the `wait` timeout.
  26423. *
  26424. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26425. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26426. *
  26427. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26428. * for details over the differences between `_.debounce` and `_.throttle`.
  26429. *
  26430. * @static
  26431. * @memberOf _
  26432. * @since 0.1.0
  26433. * @category Function
  26434. * @param {Function} func The function to debounce.
  26435. * @param {number} [wait=0] The number of milliseconds to delay.
  26436. * @param {Object} [options={}] The options object.
  26437. * @param {boolean} [options.leading=false]
  26438. * Specify invoking on the leading edge of the timeout.
  26439. * @param {number} [options.maxWait]
  26440. * The maximum time `func` is allowed to be delayed before it's invoked.
  26441. * @param {boolean} [options.trailing=true]
  26442. * Specify invoking on the trailing edge of the timeout.
  26443. * @returns {Function} Returns the new debounced function.
  26444. * @example
  26445. *
  26446. * // Avoid costly calculations while the window size is in flux.
  26447. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26448. *
  26449. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26450. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26451. * 'leading': true,
  26452. * 'trailing': false
  26453. * }));
  26454. *
  26455. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26456. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26457. * var source = new EventSource('/stream');
  26458. * jQuery(source).on('message', debounced);
  26459. *
  26460. * // Cancel the trailing debounced invocation.
  26461. * jQuery(window).on('popstate', debounced.cancel);
  26462. */
  26463. function debounce(func, wait, options) {
  26464. var lastArgs,
  26465. lastThis,
  26466. maxWait,
  26467. result,
  26468. timerId,
  26469. lastCallTime,
  26470. lastInvokeTime = 0,
  26471. leading = false,
  26472. maxing = false,
  26473. trailing = true;
  26474. if (typeof func != 'function') {
  26475. throw new TypeError(FUNC_ERROR_TEXT);
  26476. }
  26477. wait = toNumber(wait) || 0;
  26478. if (isObject(options)) {
  26479. leading = !!options.leading;
  26480. maxing = 'maxWait' in options;
  26481. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26482. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26483. }
  26484. function invokeFunc(time) {
  26485. var args = lastArgs,
  26486. thisArg = lastThis;
  26487. lastArgs = lastThis = undefined;
  26488. lastInvokeTime = time;
  26489. result = func.apply(thisArg, args);
  26490. return result;
  26491. }
  26492. function leadingEdge(time) {
  26493. // Reset any `maxWait` timer.
  26494. lastInvokeTime = time;
  26495. // Start the timer for the trailing edge.
  26496. timerId = setTimeout(timerExpired, wait);
  26497. // Invoke the leading edge.
  26498. return leading ? invokeFunc(time) : result;
  26499. }
  26500. function remainingWait(time) {
  26501. var timeSinceLastCall = time - lastCallTime,
  26502. timeSinceLastInvoke = time - lastInvokeTime,
  26503. timeWaiting = wait - timeSinceLastCall;
  26504. return maxing
  26505. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26506. : timeWaiting;
  26507. }
  26508. function shouldInvoke(time) {
  26509. var timeSinceLastCall = time - lastCallTime,
  26510. timeSinceLastInvoke = time - lastInvokeTime;
  26511. // Either this is the first call, activity has stopped and we're at the
  26512. // trailing edge, the system time has gone backwards and we're treating
  26513. // it as the trailing edge, or we've hit the `maxWait` limit.
  26514. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26515. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26516. }
  26517. function timerExpired() {
  26518. var time = now();
  26519. if (shouldInvoke(time)) {
  26520. return trailingEdge(time);
  26521. }
  26522. // Restart the timer.
  26523. timerId = setTimeout(timerExpired, remainingWait(time));
  26524. }
  26525. function trailingEdge(time) {
  26526. timerId = undefined;
  26527. // Only invoke if we have `lastArgs` which means `func` has been
  26528. // debounced at least once.
  26529. if (trailing && lastArgs) {
  26530. return invokeFunc(time);
  26531. }
  26532. lastArgs = lastThis = undefined;
  26533. return result;
  26534. }
  26535. function cancel() {
  26536. if (timerId !== undefined) {
  26537. clearTimeout(timerId);
  26538. }
  26539. lastInvokeTime = 0;
  26540. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26541. }
  26542. function flush() {
  26543. return timerId === undefined ? result : trailingEdge(now());
  26544. }
  26545. function debounced() {
  26546. var time = now(),
  26547. isInvoking = shouldInvoke(time);
  26548. lastArgs = arguments;
  26549. lastThis = this;
  26550. lastCallTime = time;
  26551. if (isInvoking) {
  26552. if (timerId === undefined) {
  26553. return leadingEdge(lastCallTime);
  26554. }
  26555. if (maxing) {
  26556. // Handle invocations in a tight loop.
  26557. clearTimeout(timerId);
  26558. timerId = setTimeout(timerExpired, wait);
  26559. return invokeFunc(lastCallTime);
  26560. }
  26561. }
  26562. if (timerId === undefined) {
  26563. timerId = setTimeout(timerExpired, wait);
  26564. }
  26565. return result;
  26566. }
  26567. debounced.cancel = cancel;
  26568. debounced.flush = flush;
  26569. return debounced;
  26570. }
  26571. /**
  26572. * Defers invoking the `func` until the current call stack has cleared. Any
  26573. * additional arguments are provided to `func` when it's invoked.
  26574. *
  26575. * @static
  26576. * @memberOf _
  26577. * @since 0.1.0
  26578. * @category Function
  26579. * @param {Function} func The function to defer.
  26580. * @param {...*} [args] The arguments to invoke `func` with.
  26581. * @returns {number} Returns the timer id.
  26582. * @example
  26583. *
  26584. * _.defer(function(text) {
  26585. * console.log(text);
  26586. * }, 'deferred');
  26587. * // => Logs 'deferred' after one millisecond.
  26588. */
  26589. var defer = baseRest(function(func, args) {
  26590. return baseDelay(func, 1, args);
  26591. });
  26592. /**
  26593. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26594. * provided to `func` when it's invoked.
  26595. *
  26596. * @static
  26597. * @memberOf _
  26598. * @since 0.1.0
  26599. * @category Function
  26600. * @param {Function} func The function to delay.
  26601. * @param {number} wait The number of milliseconds to delay invocation.
  26602. * @param {...*} [args] The arguments to invoke `func` with.
  26603. * @returns {number} Returns the timer id.
  26604. * @example
  26605. *
  26606. * _.delay(function(text) {
  26607. * console.log(text);
  26608. * }, 1000, 'later');
  26609. * // => Logs 'later' after one second.
  26610. */
  26611. var delay = baseRest(function(func, wait, args) {
  26612. return baseDelay(func, toNumber(wait) || 0, args);
  26613. });
  26614. /**
  26615. * Creates a function that invokes `func` with arguments reversed.
  26616. *
  26617. * @static
  26618. * @memberOf _
  26619. * @since 4.0.0
  26620. * @category Function
  26621. * @param {Function} func The function to flip arguments for.
  26622. * @returns {Function} Returns the new flipped function.
  26623. * @example
  26624. *
  26625. * var flipped = _.flip(function() {
  26626. * return _.toArray(arguments);
  26627. * });
  26628. *
  26629. * flipped('a', 'b', 'c', 'd');
  26630. * // => ['d', 'c', 'b', 'a']
  26631. */
  26632. function flip(func) {
  26633. return createWrap(func, WRAP_FLIP_FLAG);
  26634. }
  26635. /**
  26636. * Creates a function that memoizes the result of `func`. If `resolver` is
  26637. * provided, it determines the cache key for storing the result based on the
  26638. * arguments provided to the memoized function. By default, the first argument
  26639. * provided to the memoized function is used as the map cache key. The `func`
  26640. * is invoked with the `this` binding of the memoized function.
  26641. *
  26642. * **Note:** The cache is exposed as the `cache` property on the memoized
  26643. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26644. * constructor with one whose instances implement the
  26645. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26646. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26647. *
  26648. * @static
  26649. * @memberOf _
  26650. * @since 0.1.0
  26651. * @category Function
  26652. * @param {Function} func The function to have its output memoized.
  26653. * @param {Function} [resolver] The function to resolve the cache key.
  26654. * @returns {Function} Returns the new memoized function.
  26655. * @example
  26656. *
  26657. * var object = { 'a': 1, 'b': 2 };
  26658. * var other = { 'c': 3, 'd': 4 };
  26659. *
  26660. * var values = _.memoize(_.values);
  26661. * values(object);
  26662. * // => [1, 2]
  26663. *
  26664. * values(other);
  26665. * // => [3, 4]
  26666. *
  26667. * object.a = 2;
  26668. * values(object);
  26669. * // => [1, 2]
  26670. *
  26671. * // Modify the result cache.
  26672. * values.cache.set(object, ['a', 'b']);
  26673. * values(object);
  26674. * // => ['a', 'b']
  26675. *
  26676. * // Replace `_.memoize.Cache`.
  26677. * _.memoize.Cache = WeakMap;
  26678. */
  26679. function memoize(func, resolver) {
  26680. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26681. throw new TypeError(FUNC_ERROR_TEXT);
  26682. }
  26683. var memoized = function() {
  26684. var args = arguments,
  26685. key = resolver ? resolver.apply(this, args) : args[0],
  26686. cache = memoized.cache;
  26687. if (cache.has(key)) {
  26688. return cache.get(key);
  26689. }
  26690. var result = func.apply(this, args);
  26691. memoized.cache = cache.set(key, result) || cache;
  26692. return result;
  26693. };
  26694. memoized.cache = new (memoize.Cache || MapCache);
  26695. return memoized;
  26696. }
  26697. // Expose `MapCache`.
  26698. memoize.Cache = MapCache;
  26699. /**
  26700. * Creates a function that negates the result of the predicate `func`. The
  26701. * `func` predicate is invoked with the `this` binding and arguments of the
  26702. * created function.
  26703. *
  26704. * @static
  26705. * @memberOf _
  26706. * @since 3.0.0
  26707. * @category Function
  26708. * @param {Function} predicate The predicate to negate.
  26709. * @returns {Function} Returns the new negated function.
  26710. * @example
  26711. *
  26712. * function isEven(n) {
  26713. * return n % 2 == 0;
  26714. * }
  26715. *
  26716. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26717. * // => [1, 3, 5]
  26718. */
  26719. function negate(predicate) {
  26720. if (typeof predicate != 'function') {
  26721. throw new TypeError(FUNC_ERROR_TEXT);
  26722. }
  26723. return function() {
  26724. var args = arguments;
  26725. switch (args.length) {
  26726. case 0: return !predicate.call(this);
  26727. case 1: return !predicate.call(this, args[0]);
  26728. case 2: return !predicate.call(this, args[0], args[1]);
  26729. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26730. }
  26731. return !predicate.apply(this, args);
  26732. };
  26733. }
  26734. /**
  26735. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26736. * to the function return the value of the first invocation. The `func` is
  26737. * invoked with the `this` binding and arguments of the created function.
  26738. *
  26739. * @static
  26740. * @memberOf _
  26741. * @since 0.1.0
  26742. * @category Function
  26743. * @param {Function} func The function to restrict.
  26744. * @returns {Function} Returns the new restricted function.
  26745. * @example
  26746. *
  26747. * var initialize = _.once(createApplication);
  26748. * initialize();
  26749. * initialize();
  26750. * // => `createApplication` is invoked once
  26751. */
  26752. function once(func) {
  26753. return before(2, func);
  26754. }
  26755. /**
  26756. * Creates a function that invokes `func` with its arguments transformed.
  26757. *
  26758. * @static
  26759. * @since 4.0.0
  26760. * @memberOf _
  26761. * @category Function
  26762. * @param {Function} func The function to wrap.
  26763. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26764. * The argument transforms.
  26765. * @returns {Function} Returns the new function.
  26766. * @example
  26767. *
  26768. * function doubled(n) {
  26769. * return n * 2;
  26770. * }
  26771. *
  26772. * function square(n) {
  26773. * return n * n;
  26774. * }
  26775. *
  26776. * var func = _.overArgs(function(x, y) {
  26777. * return [x, y];
  26778. * }, [square, doubled]);
  26779. *
  26780. * func(9, 3);
  26781. * // => [81, 6]
  26782. *
  26783. * func(10, 5);
  26784. * // => [100, 10]
  26785. */
  26786. var overArgs = castRest(function(func, transforms) {
  26787. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26788. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26789. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26790. var funcsLength = transforms.length;
  26791. return baseRest(function(args) {
  26792. var index = -1,
  26793. length = nativeMin(args.length, funcsLength);
  26794. while (++index < length) {
  26795. args[index] = transforms[index].call(this, args[index]);
  26796. }
  26797. return apply(func, this, args);
  26798. });
  26799. });
  26800. /**
  26801. * Creates a function that invokes `func` with `partials` prepended to the
  26802. * arguments it receives. This method is like `_.bind` except it does **not**
  26803. * alter the `this` binding.
  26804. *
  26805. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26806. * builds, may be used as a placeholder for partially applied arguments.
  26807. *
  26808. * **Note:** This method doesn't set the "length" property of partially
  26809. * applied functions.
  26810. *
  26811. * @static
  26812. * @memberOf _
  26813. * @since 0.2.0
  26814. * @category Function
  26815. * @param {Function} func The function to partially apply arguments to.
  26816. * @param {...*} [partials] The arguments to be partially applied.
  26817. * @returns {Function} Returns the new partially applied function.
  26818. * @example
  26819. *
  26820. * function greet(greeting, name) {
  26821. * return greeting + ' ' + name;
  26822. * }
  26823. *
  26824. * var sayHelloTo = _.partial(greet, 'hello');
  26825. * sayHelloTo('fred');
  26826. * // => 'hello fred'
  26827. *
  26828. * // Partially applied with placeholders.
  26829. * var greetFred = _.partial(greet, _, 'fred');
  26830. * greetFred('hi');
  26831. * // => 'hi fred'
  26832. */
  26833. var partial = baseRest(function(func, partials) {
  26834. var holders = replaceHolders(partials, getHolder(partial));
  26835. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26836. });
  26837. /**
  26838. * This method is like `_.partial` except that partially applied arguments
  26839. * are appended to the arguments it receives.
  26840. *
  26841. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26842. * builds, may be used as a placeholder for partially applied arguments.
  26843. *
  26844. * **Note:** This method doesn't set the "length" property of partially
  26845. * applied functions.
  26846. *
  26847. * @static
  26848. * @memberOf _
  26849. * @since 1.0.0
  26850. * @category Function
  26851. * @param {Function} func The function to partially apply arguments to.
  26852. * @param {...*} [partials] The arguments to be partially applied.
  26853. * @returns {Function} Returns the new partially applied function.
  26854. * @example
  26855. *
  26856. * function greet(greeting, name) {
  26857. * return greeting + ' ' + name;
  26858. * }
  26859. *
  26860. * var greetFred = _.partialRight(greet, 'fred');
  26861. * greetFred('hi');
  26862. * // => 'hi fred'
  26863. *
  26864. * // Partially applied with placeholders.
  26865. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26866. * sayHelloTo('fred');
  26867. * // => 'hello fred'
  26868. */
  26869. var partialRight = baseRest(function(func, partials) {
  26870. var holders = replaceHolders(partials, getHolder(partialRight));
  26871. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26872. });
  26873. /**
  26874. * Creates a function that invokes `func` with arguments arranged according
  26875. * to the specified `indexes` where the argument value at the first index is
  26876. * provided as the first argument, the argument value at the second index is
  26877. * provided as the second argument, and so on.
  26878. *
  26879. * @static
  26880. * @memberOf _
  26881. * @since 3.0.0
  26882. * @category Function
  26883. * @param {Function} func The function to rearrange arguments for.
  26884. * @param {...(number|number[])} indexes The arranged argument indexes.
  26885. * @returns {Function} Returns the new function.
  26886. * @example
  26887. *
  26888. * var rearged = _.rearg(function(a, b, c) {
  26889. * return [a, b, c];
  26890. * }, [2, 0, 1]);
  26891. *
  26892. * rearged('b', 'c', 'a')
  26893. * // => ['a', 'b', 'c']
  26894. */
  26895. var rearg = flatRest(function(func, indexes) {
  26896. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26897. });
  26898. /**
  26899. * Creates a function that invokes `func` with the `this` binding of the
  26900. * created function and arguments from `start` and beyond provided as
  26901. * an array.
  26902. *
  26903. * **Note:** This method is based on the
  26904. * [rest parameter](https://mdn.io/rest_parameters).
  26905. *
  26906. * @static
  26907. * @memberOf _
  26908. * @since 4.0.0
  26909. * @category Function
  26910. * @param {Function} func The function to apply a rest parameter to.
  26911. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26912. * @returns {Function} Returns the new function.
  26913. * @example
  26914. *
  26915. * var say = _.rest(function(what, names) {
  26916. * return what + ' ' + _.initial(names).join(', ') +
  26917. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26918. * });
  26919. *
  26920. * say('hello', 'fred', 'barney', 'pebbles');
  26921. * // => 'hello fred, barney, & pebbles'
  26922. */
  26923. function rest(func, start) {
  26924. if (typeof func != 'function') {
  26925. throw new TypeError(FUNC_ERROR_TEXT);
  26926. }
  26927. start = start === undefined ? start : toInteger(start);
  26928. return baseRest(func, start);
  26929. }
  26930. /**
  26931. * Creates a function that invokes `func` with the `this` binding of the
  26932. * create function and an array of arguments much like
  26933. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26934. *
  26935. * **Note:** This method is based on the
  26936. * [spread operator](https://mdn.io/spread_operator).
  26937. *
  26938. * @static
  26939. * @memberOf _
  26940. * @since 3.2.0
  26941. * @category Function
  26942. * @param {Function} func The function to spread arguments over.
  26943. * @param {number} [start=0] The start position of the spread.
  26944. * @returns {Function} Returns the new function.
  26945. * @example
  26946. *
  26947. * var say = _.spread(function(who, what) {
  26948. * return who + ' says ' + what;
  26949. * });
  26950. *
  26951. * say(['fred', 'hello']);
  26952. * // => 'fred says hello'
  26953. *
  26954. * var numbers = Promise.all([
  26955. * Promise.resolve(40),
  26956. * Promise.resolve(36)
  26957. * ]);
  26958. *
  26959. * numbers.then(_.spread(function(x, y) {
  26960. * return x + y;
  26961. * }));
  26962. * // => a Promise of 76
  26963. */
  26964. function spread(func, start) {
  26965. if (typeof func != 'function') {
  26966. throw new TypeError(FUNC_ERROR_TEXT);
  26967. }
  26968. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26969. return baseRest(function(args) {
  26970. var array = args[start],
  26971. otherArgs = castSlice(args, 0, start);
  26972. if (array) {
  26973. arrayPush(otherArgs, array);
  26974. }
  26975. return apply(func, this, otherArgs);
  26976. });
  26977. }
  26978. /**
  26979. * Creates a throttled function that only invokes `func` at most once per
  26980. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26981. * method to cancel delayed `func` invocations and a `flush` method to
  26982. * immediately invoke them. Provide `options` to indicate whether `func`
  26983. * should be invoked on the leading and/or trailing edge of the `wait`
  26984. * timeout. The `func` is invoked with the last arguments provided to the
  26985. * throttled function. Subsequent calls to the throttled function return the
  26986. * result of the last `func` invocation.
  26987. *
  26988. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26989. * invoked on the trailing edge of the timeout only if the throttled function
  26990. * is invoked more than once during the `wait` timeout.
  26991. *
  26992. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26993. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26994. *
  26995. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26996. * for details over the differences between `_.throttle` and `_.debounce`.
  26997. *
  26998. * @static
  26999. * @memberOf _
  27000. * @since 0.1.0
  27001. * @category Function
  27002. * @param {Function} func The function to throttle.
  27003. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27004. * @param {Object} [options={}] The options object.
  27005. * @param {boolean} [options.leading=true]
  27006. * Specify invoking on the leading edge of the timeout.
  27007. * @param {boolean} [options.trailing=true]
  27008. * Specify invoking on the trailing edge of the timeout.
  27009. * @returns {Function} Returns the new throttled function.
  27010. * @example
  27011. *
  27012. * // Avoid excessively updating the position while scrolling.
  27013. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27014. *
  27015. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27016. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27017. * jQuery(element).on('click', throttled);
  27018. *
  27019. * // Cancel the trailing throttled invocation.
  27020. * jQuery(window).on('popstate', throttled.cancel);
  27021. */
  27022. function throttle(func, wait, options) {
  27023. var leading = true,
  27024. trailing = true;
  27025. if (typeof func != 'function') {
  27026. throw new TypeError(FUNC_ERROR_TEXT);
  27027. }
  27028. if (isObject(options)) {
  27029. leading = 'leading' in options ? !!options.leading : leading;
  27030. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27031. }
  27032. return debounce(func, wait, {
  27033. 'leading': leading,
  27034. 'maxWait': wait,
  27035. 'trailing': trailing
  27036. });
  27037. }
  27038. /**
  27039. * Creates a function that accepts up to one argument, ignoring any
  27040. * additional arguments.
  27041. *
  27042. * @static
  27043. * @memberOf _
  27044. * @since 4.0.0
  27045. * @category Function
  27046. * @param {Function} func The function to cap arguments for.
  27047. * @returns {Function} Returns the new capped function.
  27048. * @example
  27049. *
  27050. * _.map(['6', '8', '10'], _.unary(parseInt));
  27051. * // => [6, 8, 10]
  27052. */
  27053. function unary(func) {
  27054. return ary(func, 1);
  27055. }
  27056. /**
  27057. * Creates a function that provides `value` to `wrapper` as its first
  27058. * argument. Any additional arguments provided to the function are appended
  27059. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27060. * binding of the created function.
  27061. *
  27062. * @static
  27063. * @memberOf _
  27064. * @since 0.1.0
  27065. * @category Function
  27066. * @param {*} value The value to wrap.
  27067. * @param {Function} [wrapper=identity] The wrapper function.
  27068. * @returns {Function} Returns the new function.
  27069. * @example
  27070. *
  27071. * var p = _.wrap(_.escape, function(func, text) {
  27072. * return '<p>' + func(text) + '</p>';
  27073. * });
  27074. *
  27075. * p('fred, barney, & pebbles');
  27076. * // => '<p>fred, barney, &amp; pebbles</p>'
  27077. */
  27078. function wrap(value, wrapper) {
  27079. return partial(castFunction(wrapper), value);
  27080. }
  27081. /*------------------------------------------------------------------------*/
  27082. /**
  27083. * Casts `value` as an array if it's not one.
  27084. *
  27085. * @static
  27086. * @memberOf _
  27087. * @since 4.4.0
  27088. * @category Lang
  27089. * @param {*} value The value to inspect.
  27090. * @returns {Array} Returns the cast array.
  27091. * @example
  27092. *
  27093. * _.castArray(1);
  27094. * // => [1]
  27095. *
  27096. * _.castArray({ 'a': 1 });
  27097. * // => [{ 'a': 1 }]
  27098. *
  27099. * _.castArray('abc');
  27100. * // => ['abc']
  27101. *
  27102. * _.castArray(null);
  27103. * // => [null]
  27104. *
  27105. * _.castArray(undefined);
  27106. * // => [undefined]
  27107. *
  27108. * _.castArray();
  27109. * // => []
  27110. *
  27111. * var array = [1, 2, 3];
  27112. * console.log(_.castArray(array) === array);
  27113. * // => true
  27114. */
  27115. function castArray() {
  27116. if (!arguments.length) {
  27117. return [];
  27118. }
  27119. var value = arguments[0];
  27120. return isArray(value) ? value : [value];
  27121. }
  27122. /**
  27123. * Creates a shallow clone of `value`.
  27124. *
  27125. * **Note:** This method is loosely based on the
  27126. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27127. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27128. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27129. * arrays. The own enumerable properties of `arguments` objects are cloned
  27130. * as plain objects. An empty object is returned for uncloneable values such
  27131. * as error objects, functions, DOM nodes, and WeakMaps.
  27132. *
  27133. * @static
  27134. * @memberOf _
  27135. * @since 0.1.0
  27136. * @category Lang
  27137. * @param {*} value The value to clone.
  27138. * @returns {*} Returns the cloned value.
  27139. * @see _.cloneDeep
  27140. * @example
  27141. *
  27142. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27143. *
  27144. * var shallow = _.clone(objects);
  27145. * console.log(shallow[0] === objects[0]);
  27146. * // => true
  27147. */
  27148. function clone(value) {
  27149. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27150. }
  27151. /**
  27152. * This method is like `_.clone` except that it accepts `customizer` which
  27153. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27154. * cloning is handled by the method instead. The `customizer` is invoked with
  27155. * up to four arguments; (value [, index|key, object, stack]).
  27156. *
  27157. * @static
  27158. * @memberOf _
  27159. * @since 4.0.0
  27160. * @category Lang
  27161. * @param {*} value The value to clone.
  27162. * @param {Function} [customizer] The function to customize cloning.
  27163. * @returns {*} Returns the cloned value.
  27164. * @see _.cloneDeepWith
  27165. * @example
  27166. *
  27167. * function customizer(value) {
  27168. * if (_.isElement(value)) {
  27169. * return value.cloneNode(false);
  27170. * }
  27171. * }
  27172. *
  27173. * var el = _.cloneWith(document.body, customizer);
  27174. *
  27175. * console.log(el === document.body);
  27176. * // => false
  27177. * console.log(el.nodeName);
  27178. * // => 'BODY'
  27179. * console.log(el.childNodes.length);
  27180. * // => 0
  27181. */
  27182. function cloneWith(value, customizer) {
  27183. customizer = typeof customizer == 'function' ? customizer : undefined;
  27184. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27185. }
  27186. /**
  27187. * This method is like `_.clone` except that it recursively clones `value`.
  27188. *
  27189. * @static
  27190. * @memberOf _
  27191. * @since 1.0.0
  27192. * @category Lang
  27193. * @param {*} value The value to recursively clone.
  27194. * @returns {*} Returns the deep cloned value.
  27195. * @see _.clone
  27196. * @example
  27197. *
  27198. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27199. *
  27200. * var deep = _.cloneDeep(objects);
  27201. * console.log(deep[0] === objects[0]);
  27202. * // => false
  27203. */
  27204. function cloneDeep(value) {
  27205. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27206. }
  27207. /**
  27208. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27209. *
  27210. * @static
  27211. * @memberOf _
  27212. * @since 4.0.0
  27213. * @category Lang
  27214. * @param {*} value The value to recursively clone.
  27215. * @param {Function} [customizer] The function to customize cloning.
  27216. * @returns {*} Returns the deep cloned value.
  27217. * @see _.cloneWith
  27218. * @example
  27219. *
  27220. * function customizer(value) {
  27221. * if (_.isElement(value)) {
  27222. * return value.cloneNode(true);
  27223. * }
  27224. * }
  27225. *
  27226. * var el = _.cloneDeepWith(document.body, customizer);
  27227. *
  27228. * console.log(el === document.body);
  27229. * // => false
  27230. * console.log(el.nodeName);
  27231. * // => 'BODY'
  27232. * console.log(el.childNodes.length);
  27233. * // => 20
  27234. */
  27235. function cloneDeepWith(value, customizer) {
  27236. customizer = typeof customizer == 'function' ? customizer : undefined;
  27237. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27238. }
  27239. /**
  27240. * Checks if `object` conforms to `source` by invoking the predicate
  27241. * properties of `source` with the corresponding property values of `object`.
  27242. *
  27243. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27244. * partially applied.
  27245. *
  27246. * @static
  27247. * @memberOf _
  27248. * @since 4.14.0
  27249. * @category Lang
  27250. * @param {Object} object The object to inspect.
  27251. * @param {Object} source The object of property predicates to conform to.
  27252. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27253. * @example
  27254. *
  27255. * var object = { 'a': 1, 'b': 2 };
  27256. *
  27257. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27258. * // => true
  27259. *
  27260. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27261. * // => false
  27262. */
  27263. function conformsTo(object, source) {
  27264. return source == null || baseConformsTo(object, source, keys(source));
  27265. }
  27266. /**
  27267. * Performs a
  27268. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27269. * comparison between two values to determine if they are equivalent.
  27270. *
  27271. * @static
  27272. * @memberOf _
  27273. * @since 4.0.0
  27274. * @category Lang
  27275. * @param {*} value The value to compare.
  27276. * @param {*} other The other value to compare.
  27277. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27278. * @example
  27279. *
  27280. * var object = { 'a': 1 };
  27281. * var other = { 'a': 1 };
  27282. *
  27283. * _.eq(object, object);
  27284. * // => true
  27285. *
  27286. * _.eq(object, other);
  27287. * // => false
  27288. *
  27289. * _.eq('a', 'a');
  27290. * // => true
  27291. *
  27292. * _.eq('a', Object('a'));
  27293. * // => false
  27294. *
  27295. * _.eq(NaN, NaN);
  27296. * // => true
  27297. */
  27298. function eq(value, other) {
  27299. return value === other || (value !== value && other !== other);
  27300. }
  27301. /**
  27302. * Checks if `value` is greater than `other`.
  27303. *
  27304. * @static
  27305. * @memberOf _
  27306. * @since 3.9.0
  27307. * @category Lang
  27308. * @param {*} value The value to compare.
  27309. * @param {*} other The other value to compare.
  27310. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27311. * else `false`.
  27312. * @see _.lt
  27313. * @example
  27314. *
  27315. * _.gt(3, 1);
  27316. * // => true
  27317. *
  27318. * _.gt(3, 3);
  27319. * // => false
  27320. *
  27321. * _.gt(1, 3);
  27322. * // => false
  27323. */
  27324. var gt = createRelationalOperation(baseGt);
  27325. /**
  27326. * Checks if `value` is greater than or equal to `other`.
  27327. *
  27328. * @static
  27329. * @memberOf _
  27330. * @since 3.9.0
  27331. * @category Lang
  27332. * @param {*} value The value to compare.
  27333. * @param {*} other The other value to compare.
  27334. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27335. * `other`, else `false`.
  27336. * @see _.lte
  27337. * @example
  27338. *
  27339. * _.gte(3, 1);
  27340. * // => true
  27341. *
  27342. * _.gte(3, 3);
  27343. * // => true
  27344. *
  27345. * _.gte(1, 3);
  27346. * // => false
  27347. */
  27348. var gte = createRelationalOperation(function(value, other) {
  27349. return value >= other;
  27350. });
  27351. /**
  27352. * Checks if `value` is likely an `arguments` object.
  27353. *
  27354. * @static
  27355. * @memberOf _
  27356. * @since 0.1.0
  27357. * @category Lang
  27358. * @param {*} value The value to check.
  27359. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27360. * else `false`.
  27361. * @example
  27362. *
  27363. * _.isArguments(function() { return arguments; }());
  27364. * // => true
  27365. *
  27366. * _.isArguments([1, 2, 3]);
  27367. * // => false
  27368. */
  27369. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27370. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27371. !propertyIsEnumerable.call(value, 'callee');
  27372. };
  27373. /**
  27374. * Checks if `value` is classified as an `Array` object.
  27375. *
  27376. * @static
  27377. * @memberOf _
  27378. * @since 0.1.0
  27379. * @category Lang
  27380. * @param {*} value The value to check.
  27381. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27382. * @example
  27383. *
  27384. * _.isArray([1, 2, 3]);
  27385. * // => true
  27386. *
  27387. * _.isArray(document.body.children);
  27388. * // => false
  27389. *
  27390. * _.isArray('abc');
  27391. * // => false
  27392. *
  27393. * _.isArray(_.noop);
  27394. * // => false
  27395. */
  27396. var isArray = Array.isArray;
  27397. /**
  27398. * Checks if `value` is classified as an `ArrayBuffer` object.
  27399. *
  27400. * @static
  27401. * @memberOf _
  27402. * @since 4.3.0
  27403. * @category Lang
  27404. * @param {*} value The value to check.
  27405. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27406. * @example
  27407. *
  27408. * _.isArrayBuffer(new ArrayBuffer(2));
  27409. * // => true
  27410. *
  27411. * _.isArrayBuffer(new Array(2));
  27412. * // => false
  27413. */
  27414. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27415. /**
  27416. * Checks if `value` is array-like. A value is considered array-like if it's
  27417. * not a function and has a `value.length` that's an integer greater than or
  27418. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27419. *
  27420. * @static
  27421. * @memberOf _
  27422. * @since 4.0.0
  27423. * @category Lang
  27424. * @param {*} value The value to check.
  27425. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27426. * @example
  27427. *
  27428. * _.isArrayLike([1, 2, 3]);
  27429. * // => true
  27430. *
  27431. * _.isArrayLike(document.body.children);
  27432. * // => true
  27433. *
  27434. * _.isArrayLike('abc');
  27435. * // => true
  27436. *
  27437. * _.isArrayLike(_.noop);
  27438. * // => false
  27439. */
  27440. function isArrayLike(value) {
  27441. return value != null && isLength(value.length) && !isFunction(value);
  27442. }
  27443. /**
  27444. * This method is like `_.isArrayLike` except that it also checks if `value`
  27445. * is an object.
  27446. *
  27447. * @static
  27448. * @memberOf _
  27449. * @since 4.0.0
  27450. * @category Lang
  27451. * @param {*} value The value to check.
  27452. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27453. * else `false`.
  27454. * @example
  27455. *
  27456. * _.isArrayLikeObject([1, 2, 3]);
  27457. * // => true
  27458. *
  27459. * _.isArrayLikeObject(document.body.children);
  27460. * // => true
  27461. *
  27462. * _.isArrayLikeObject('abc');
  27463. * // => false
  27464. *
  27465. * _.isArrayLikeObject(_.noop);
  27466. * // => false
  27467. */
  27468. function isArrayLikeObject(value) {
  27469. return isObjectLike(value) && isArrayLike(value);
  27470. }
  27471. /**
  27472. * Checks if `value` is classified as a boolean primitive or object.
  27473. *
  27474. * @static
  27475. * @memberOf _
  27476. * @since 0.1.0
  27477. * @category Lang
  27478. * @param {*} value The value to check.
  27479. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27480. * @example
  27481. *
  27482. * _.isBoolean(false);
  27483. * // => true
  27484. *
  27485. * _.isBoolean(null);
  27486. * // => false
  27487. */
  27488. function isBoolean(value) {
  27489. return value === true || value === false ||
  27490. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27491. }
  27492. /**
  27493. * Checks if `value` is a buffer.
  27494. *
  27495. * @static
  27496. * @memberOf _
  27497. * @since 4.3.0
  27498. * @category Lang
  27499. * @param {*} value The value to check.
  27500. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27501. * @example
  27502. *
  27503. * _.isBuffer(new Buffer(2));
  27504. * // => true
  27505. *
  27506. * _.isBuffer(new Uint8Array(2));
  27507. * // => false
  27508. */
  27509. var isBuffer = nativeIsBuffer || stubFalse;
  27510. /**
  27511. * Checks if `value` is classified as a `Date` object.
  27512. *
  27513. * @static
  27514. * @memberOf _
  27515. * @since 0.1.0
  27516. * @category Lang
  27517. * @param {*} value The value to check.
  27518. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27519. * @example
  27520. *
  27521. * _.isDate(new Date);
  27522. * // => true
  27523. *
  27524. * _.isDate('Mon April 23 2012');
  27525. * // => false
  27526. */
  27527. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27528. /**
  27529. * Checks if `value` is likely a DOM element.
  27530. *
  27531. * @static
  27532. * @memberOf _
  27533. * @since 0.1.0
  27534. * @category Lang
  27535. * @param {*} value The value to check.
  27536. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27537. * @example
  27538. *
  27539. * _.isElement(document.body);
  27540. * // => true
  27541. *
  27542. * _.isElement('<body>');
  27543. * // => false
  27544. */
  27545. function isElement(value) {
  27546. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27547. }
  27548. /**
  27549. * Checks if `value` is an empty object, collection, map, or set.
  27550. *
  27551. * Objects are considered empty if they have no own enumerable string keyed
  27552. * properties.
  27553. *
  27554. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27555. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27556. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27557. *
  27558. * @static
  27559. * @memberOf _
  27560. * @since 0.1.0
  27561. * @category Lang
  27562. * @param {*} value The value to check.
  27563. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27564. * @example
  27565. *
  27566. * _.isEmpty(null);
  27567. * // => true
  27568. *
  27569. * _.isEmpty(true);
  27570. * // => true
  27571. *
  27572. * _.isEmpty(1);
  27573. * // => true
  27574. *
  27575. * _.isEmpty([1, 2, 3]);
  27576. * // => false
  27577. *
  27578. * _.isEmpty({ 'a': 1 });
  27579. * // => false
  27580. */
  27581. function isEmpty(value) {
  27582. if (value == null) {
  27583. return true;
  27584. }
  27585. if (isArrayLike(value) &&
  27586. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27587. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27588. return !value.length;
  27589. }
  27590. var tag = getTag(value);
  27591. if (tag == mapTag || tag == setTag) {
  27592. return !value.size;
  27593. }
  27594. if (isPrototype(value)) {
  27595. return !baseKeys(value).length;
  27596. }
  27597. for (var key in value) {
  27598. if (hasOwnProperty.call(value, key)) {
  27599. return false;
  27600. }
  27601. }
  27602. return true;
  27603. }
  27604. /**
  27605. * Performs a deep comparison between two values to determine if they are
  27606. * equivalent.
  27607. *
  27608. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27609. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27610. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27611. * by their own, not inherited, enumerable properties. Functions and DOM
  27612. * nodes are compared by strict equality, i.e. `===`.
  27613. *
  27614. * @static
  27615. * @memberOf _
  27616. * @since 0.1.0
  27617. * @category Lang
  27618. * @param {*} value The value to compare.
  27619. * @param {*} other The other value to compare.
  27620. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27621. * @example
  27622. *
  27623. * var object = { 'a': 1 };
  27624. * var other = { 'a': 1 };
  27625. *
  27626. * _.isEqual(object, other);
  27627. * // => true
  27628. *
  27629. * object === other;
  27630. * // => false
  27631. */
  27632. function isEqual(value, other) {
  27633. return baseIsEqual(value, other);
  27634. }
  27635. /**
  27636. * This method is like `_.isEqual` except that it accepts `customizer` which
  27637. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27638. * are handled by the method instead. The `customizer` is invoked with up to
  27639. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27640. *
  27641. * @static
  27642. * @memberOf _
  27643. * @since 4.0.0
  27644. * @category Lang
  27645. * @param {*} value The value to compare.
  27646. * @param {*} other The other value to compare.
  27647. * @param {Function} [customizer] The function to customize comparisons.
  27648. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27649. * @example
  27650. *
  27651. * function isGreeting(value) {
  27652. * return /^h(?:i|ello)$/.test(value);
  27653. * }
  27654. *
  27655. * function customizer(objValue, othValue) {
  27656. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27657. * return true;
  27658. * }
  27659. * }
  27660. *
  27661. * var array = ['hello', 'goodbye'];
  27662. * var other = ['hi', 'goodbye'];
  27663. *
  27664. * _.isEqualWith(array, other, customizer);
  27665. * // => true
  27666. */
  27667. function isEqualWith(value, other, customizer) {
  27668. customizer = typeof customizer == 'function' ? customizer : undefined;
  27669. var result = customizer ? customizer(value, other) : undefined;
  27670. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27671. }
  27672. /**
  27673. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27674. * `SyntaxError`, `TypeError`, or `URIError` object.
  27675. *
  27676. * @static
  27677. * @memberOf _
  27678. * @since 3.0.0
  27679. * @category Lang
  27680. * @param {*} value The value to check.
  27681. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27682. * @example
  27683. *
  27684. * _.isError(new Error);
  27685. * // => true
  27686. *
  27687. * _.isError(Error);
  27688. * // => false
  27689. */
  27690. function isError(value) {
  27691. if (!isObjectLike(value)) {
  27692. return false;
  27693. }
  27694. var tag = baseGetTag(value);
  27695. return tag == errorTag || tag == domExcTag ||
  27696. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27697. }
  27698. /**
  27699. * Checks if `value` is a finite primitive number.
  27700. *
  27701. * **Note:** This method is based on
  27702. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27703. *
  27704. * @static
  27705. * @memberOf _
  27706. * @since 0.1.0
  27707. * @category Lang
  27708. * @param {*} value The value to check.
  27709. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27710. * @example
  27711. *
  27712. * _.isFinite(3);
  27713. * // => true
  27714. *
  27715. * _.isFinite(Number.MIN_VALUE);
  27716. * // => true
  27717. *
  27718. * _.isFinite(Infinity);
  27719. * // => false
  27720. *
  27721. * _.isFinite('3');
  27722. * // => false
  27723. */
  27724. function isFinite(value) {
  27725. return typeof value == 'number' && nativeIsFinite(value);
  27726. }
  27727. /**
  27728. * Checks if `value` is classified as a `Function` object.
  27729. *
  27730. * @static
  27731. * @memberOf _
  27732. * @since 0.1.0
  27733. * @category Lang
  27734. * @param {*} value The value to check.
  27735. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27736. * @example
  27737. *
  27738. * _.isFunction(_);
  27739. * // => true
  27740. *
  27741. * _.isFunction(/abc/);
  27742. * // => false
  27743. */
  27744. function isFunction(value) {
  27745. if (!isObject(value)) {
  27746. return false;
  27747. }
  27748. // The use of `Object#toString` avoids issues with the `typeof` operator
  27749. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27750. var tag = baseGetTag(value);
  27751. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27752. }
  27753. /**
  27754. * Checks if `value` is an integer.
  27755. *
  27756. * **Note:** This method is based on
  27757. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27758. *
  27759. * @static
  27760. * @memberOf _
  27761. * @since 4.0.0
  27762. * @category Lang
  27763. * @param {*} value The value to check.
  27764. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27765. * @example
  27766. *
  27767. * _.isInteger(3);
  27768. * // => true
  27769. *
  27770. * _.isInteger(Number.MIN_VALUE);
  27771. * // => false
  27772. *
  27773. * _.isInteger(Infinity);
  27774. * // => false
  27775. *
  27776. * _.isInteger('3');
  27777. * // => false
  27778. */
  27779. function isInteger(value) {
  27780. return typeof value == 'number' && value == toInteger(value);
  27781. }
  27782. /**
  27783. * Checks if `value` is a valid array-like length.
  27784. *
  27785. * **Note:** This method is loosely based on
  27786. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27787. *
  27788. * @static
  27789. * @memberOf _
  27790. * @since 4.0.0
  27791. * @category Lang
  27792. * @param {*} value The value to check.
  27793. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27794. * @example
  27795. *
  27796. * _.isLength(3);
  27797. * // => true
  27798. *
  27799. * _.isLength(Number.MIN_VALUE);
  27800. * // => false
  27801. *
  27802. * _.isLength(Infinity);
  27803. * // => false
  27804. *
  27805. * _.isLength('3');
  27806. * // => false
  27807. */
  27808. function isLength(value) {
  27809. return typeof value == 'number' &&
  27810. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27811. }
  27812. /**
  27813. * Checks if `value` is the
  27814. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27815. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27816. *
  27817. * @static
  27818. * @memberOf _
  27819. * @since 0.1.0
  27820. * @category Lang
  27821. * @param {*} value The value to check.
  27822. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27823. * @example
  27824. *
  27825. * _.isObject({});
  27826. * // => true
  27827. *
  27828. * _.isObject([1, 2, 3]);
  27829. * // => true
  27830. *
  27831. * _.isObject(_.noop);
  27832. * // => true
  27833. *
  27834. * _.isObject(null);
  27835. * // => false
  27836. */
  27837. function isObject(value) {
  27838. var type = typeof value;
  27839. return value != null && (type == 'object' || type == 'function');
  27840. }
  27841. /**
  27842. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27843. * and has a `typeof` result of "object".
  27844. *
  27845. * @static
  27846. * @memberOf _
  27847. * @since 4.0.0
  27848. * @category Lang
  27849. * @param {*} value The value to check.
  27850. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27851. * @example
  27852. *
  27853. * _.isObjectLike({});
  27854. * // => true
  27855. *
  27856. * _.isObjectLike([1, 2, 3]);
  27857. * // => true
  27858. *
  27859. * _.isObjectLike(_.noop);
  27860. * // => false
  27861. *
  27862. * _.isObjectLike(null);
  27863. * // => false
  27864. */
  27865. function isObjectLike(value) {
  27866. return value != null && typeof value == 'object';
  27867. }
  27868. /**
  27869. * Checks if `value` is classified as a `Map` object.
  27870. *
  27871. * @static
  27872. * @memberOf _
  27873. * @since 4.3.0
  27874. * @category Lang
  27875. * @param {*} value The value to check.
  27876. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27877. * @example
  27878. *
  27879. * _.isMap(new Map);
  27880. * // => true
  27881. *
  27882. * _.isMap(new WeakMap);
  27883. * // => false
  27884. */
  27885. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27886. /**
  27887. * Performs a partial deep comparison between `object` and `source` to
  27888. * determine if `object` contains equivalent property values.
  27889. *
  27890. * **Note:** This method is equivalent to `_.matches` when `source` is
  27891. * partially applied.
  27892. *
  27893. * Partial comparisons will match empty array and empty object `source`
  27894. * values against any array or object value, respectively. See `_.isEqual`
  27895. * for a list of supported value comparisons.
  27896. *
  27897. * @static
  27898. * @memberOf _
  27899. * @since 3.0.0
  27900. * @category Lang
  27901. * @param {Object} object The object to inspect.
  27902. * @param {Object} source The object of property values to match.
  27903. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27904. * @example
  27905. *
  27906. * var object = { 'a': 1, 'b': 2 };
  27907. *
  27908. * _.isMatch(object, { 'b': 2 });
  27909. * // => true
  27910. *
  27911. * _.isMatch(object, { 'b': 1 });
  27912. * // => false
  27913. */
  27914. function isMatch(object, source) {
  27915. return object === source || baseIsMatch(object, source, getMatchData(source));
  27916. }
  27917. /**
  27918. * This method is like `_.isMatch` except that it accepts `customizer` which
  27919. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27920. * are handled by the method instead. The `customizer` is invoked with five
  27921. * arguments: (objValue, srcValue, index|key, object, source).
  27922. *
  27923. * @static
  27924. * @memberOf _
  27925. * @since 4.0.0
  27926. * @category Lang
  27927. * @param {Object} object The object to inspect.
  27928. * @param {Object} source The object of property values to match.
  27929. * @param {Function} [customizer] The function to customize comparisons.
  27930. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27931. * @example
  27932. *
  27933. * function isGreeting(value) {
  27934. * return /^h(?:i|ello)$/.test(value);
  27935. * }
  27936. *
  27937. * function customizer(objValue, srcValue) {
  27938. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27939. * return true;
  27940. * }
  27941. * }
  27942. *
  27943. * var object = { 'greeting': 'hello' };
  27944. * var source = { 'greeting': 'hi' };
  27945. *
  27946. * _.isMatchWith(object, source, customizer);
  27947. * // => true
  27948. */
  27949. function isMatchWith(object, source, customizer) {
  27950. customizer = typeof customizer == 'function' ? customizer : undefined;
  27951. return baseIsMatch(object, source, getMatchData(source), customizer);
  27952. }
  27953. /**
  27954. * Checks if `value` is `NaN`.
  27955. *
  27956. * **Note:** This method is based on
  27957. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27958. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27959. * `undefined` and other non-number values.
  27960. *
  27961. * @static
  27962. * @memberOf _
  27963. * @since 0.1.0
  27964. * @category Lang
  27965. * @param {*} value The value to check.
  27966. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27967. * @example
  27968. *
  27969. * _.isNaN(NaN);
  27970. * // => true
  27971. *
  27972. * _.isNaN(new Number(NaN));
  27973. * // => true
  27974. *
  27975. * isNaN(undefined);
  27976. * // => true
  27977. *
  27978. * _.isNaN(undefined);
  27979. * // => false
  27980. */
  27981. function isNaN(value) {
  27982. // An `NaN` primitive is the only value that is not equal to itself.
  27983. // Perform the `toStringTag` check first to avoid errors with some
  27984. // ActiveX objects in IE.
  27985. return isNumber(value) && value != +value;
  27986. }
  27987. /**
  27988. * Checks if `value` is a pristine native function.
  27989. *
  27990. * **Note:** This method can't reliably detect native functions in the presence
  27991. * of the core-js package because core-js circumvents this kind of detection.
  27992. * Despite multiple requests, the core-js maintainer has made it clear: any
  27993. * attempt to fix the detection will be obstructed. As a result, we're left
  27994. * with little choice but to throw an error. Unfortunately, this also affects
  27995. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27996. * which rely on core-js.
  27997. *
  27998. * @static
  27999. * @memberOf _
  28000. * @since 3.0.0
  28001. * @category Lang
  28002. * @param {*} value The value to check.
  28003. * @returns {boolean} Returns `true` if `value` is a native function,
  28004. * else `false`.
  28005. * @example
  28006. *
  28007. * _.isNative(Array.prototype.push);
  28008. * // => true
  28009. *
  28010. * _.isNative(_);
  28011. * // => false
  28012. */
  28013. function isNative(value) {
  28014. if (isMaskable(value)) {
  28015. throw new Error(CORE_ERROR_TEXT);
  28016. }
  28017. return baseIsNative(value);
  28018. }
  28019. /**
  28020. * Checks if `value` is `null`.
  28021. *
  28022. * @static
  28023. * @memberOf _
  28024. * @since 0.1.0
  28025. * @category Lang
  28026. * @param {*} value The value to check.
  28027. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28028. * @example
  28029. *
  28030. * _.isNull(null);
  28031. * // => true
  28032. *
  28033. * _.isNull(void 0);
  28034. * // => false
  28035. */
  28036. function isNull(value) {
  28037. return value === null;
  28038. }
  28039. /**
  28040. * Checks if `value` is `null` or `undefined`.
  28041. *
  28042. * @static
  28043. * @memberOf _
  28044. * @since 4.0.0
  28045. * @category Lang
  28046. * @param {*} value The value to check.
  28047. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28048. * @example
  28049. *
  28050. * _.isNil(null);
  28051. * // => true
  28052. *
  28053. * _.isNil(void 0);
  28054. * // => true
  28055. *
  28056. * _.isNil(NaN);
  28057. * // => false
  28058. */
  28059. function isNil(value) {
  28060. return value == null;
  28061. }
  28062. /**
  28063. * Checks if `value` is classified as a `Number` primitive or object.
  28064. *
  28065. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28066. * classified as numbers, use the `_.isFinite` method.
  28067. *
  28068. * @static
  28069. * @memberOf _
  28070. * @since 0.1.0
  28071. * @category Lang
  28072. * @param {*} value The value to check.
  28073. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28074. * @example
  28075. *
  28076. * _.isNumber(3);
  28077. * // => true
  28078. *
  28079. * _.isNumber(Number.MIN_VALUE);
  28080. * // => true
  28081. *
  28082. * _.isNumber(Infinity);
  28083. * // => true
  28084. *
  28085. * _.isNumber('3');
  28086. * // => false
  28087. */
  28088. function isNumber(value) {
  28089. return typeof value == 'number' ||
  28090. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28091. }
  28092. /**
  28093. * Checks if `value` is a plain object, that is, an object created by the
  28094. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28095. *
  28096. * @static
  28097. * @memberOf _
  28098. * @since 0.8.0
  28099. * @category Lang
  28100. * @param {*} value The value to check.
  28101. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28102. * @example
  28103. *
  28104. * function Foo() {
  28105. * this.a = 1;
  28106. * }
  28107. *
  28108. * _.isPlainObject(new Foo);
  28109. * // => false
  28110. *
  28111. * _.isPlainObject([1, 2, 3]);
  28112. * // => false
  28113. *
  28114. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28115. * // => true
  28116. *
  28117. * _.isPlainObject(Object.create(null));
  28118. * // => true
  28119. */
  28120. function isPlainObject(value) {
  28121. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28122. return false;
  28123. }
  28124. var proto = getPrototype(value);
  28125. if (proto === null) {
  28126. return true;
  28127. }
  28128. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28129. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28130. funcToString.call(Ctor) == objectCtorString;
  28131. }
  28132. /**
  28133. * Checks if `value` is classified as a `RegExp` object.
  28134. *
  28135. * @static
  28136. * @memberOf _
  28137. * @since 0.1.0
  28138. * @category Lang
  28139. * @param {*} value The value to check.
  28140. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28141. * @example
  28142. *
  28143. * _.isRegExp(/abc/);
  28144. * // => true
  28145. *
  28146. * _.isRegExp('/abc/');
  28147. * // => false
  28148. */
  28149. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28150. /**
  28151. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28152. * double precision number which isn't the result of a rounded unsafe integer.
  28153. *
  28154. * **Note:** This method is based on
  28155. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28156. *
  28157. * @static
  28158. * @memberOf _
  28159. * @since 4.0.0
  28160. * @category Lang
  28161. * @param {*} value The value to check.
  28162. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28163. * @example
  28164. *
  28165. * _.isSafeInteger(3);
  28166. * // => true
  28167. *
  28168. * _.isSafeInteger(Number.MIN_VALUE);
  28169. * // => false
  28170. *
  28171. * _.isSafeInteger(Infinity);
  28172. * // => false
  28173. *
  28174. * _.isSafeInteger('3');
  28175. * // => false
  28176. */
  28177. function isSafeInteger(value) {
  28178. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28179. }
  28180. /**
  28181. * Checks if `value` is classified as a `Set` object.
  28182. *
  28183. * @static
  28184. * @memberOf _
  28185. * @since 4.3.0
  28186. * @category Lang
  28187. * @param {*} value The value to check.
  28188. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28189. * @example
  28190. *
  28191. * _.isSet(new Set);
  28192. * // => true
  28193. *
  28194. * _.isSet(new WeakSet);
  28195. * // => false
  28196. */
  28197. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28198. /**
  28199. * Checks if `value` is classified as a `String` primitive or object.
  28200. *
  28201. * @static
  28202. * @since 0.1.0
  28203. * @memberOf _
  28204. * @category Lang
  28205. * @param {*} value The value to check.
  28206. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28207. * @example
  28208. *
  28209. * _.isString('abc');
  28210. * // => true
  28211. *
  28212. * _.isString(1);
  28213. * // => false
  28214. */
  28215. function isString(value) {
  28216. return typeof value == 'string' ||
  28217. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28218. }
  28219. /**
  28220. * Checks if `value` is classified as a `Symbol` primitive or object.
  28221. *
  28222. * @static
  28223. * @memberOf _
  28224. * @since 4.0.0
  28225. * @category Lang
  28226. * @param {*} value The value to check.
  28227. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28228. * @example
  28229. *
  28230. * _.isSymbol(Symbol.iterator);
  28231. * // => true
  28232. *
  28233. * _.isSymbol('abc');
  28234. * // => false
  28235. */
  28236. function isSymbol(value) {
  28237. return typeof value == 'symbol' ||
  28238. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28239. }
  28240. /**
  28241. * Checks if `value` is classified as a typed array.
  28242. *
  28243. * @static
  28244. * @memberOf _
  28245. * @since 3.0.0
  28246. * @category Lang
  28247. * @param {*} value The value to check.
  28248. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28249. * @example
  28250. *
  28251. * _.isTypedArray(new Uint8Array);
  28252. * // => true
  28253. *
  28254. * _.isTypedArray([]);
  28255. * // => false
  28256. */
  28257. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28258. /**
  28259. * Checks if `value` is `undefined`.
  28260. *
  28261. * @static
  28262. * @since 0.1.0
  28263. * @memberOf _
  28264. * @category Lang
  28265. * @param {*} value The value to check.
  28266. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28267. * @example
  28268. *
  28269. * _.isUndefined(void 0);
  28270. * // => true
  28271. *
  28272. * _.isUndefined(null);
  28273. * // => false
  28274. */
  28275. function isUndefined(value) {
  28276. return value === undefined;
  28277. }
  28278. /**
  28279. * Checks if `value` is classified as a `WeakMap` object.
  28280. *
  28281. * @static
  28282. * @memberOf _
  28283. * @since 4.3.0
  28284. * @category Lang
  28285. * @param {*} value The value to check.
  28286. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28287. * @example
  28288. *
  28289. * _.isWeakMap(new WeakMap);
  28290. * // => true
  28291. *
  28292. * _.isWeakMap(new Map);
  28293. * // => false
  28294. */
  28295. function isWeakMap(value) {
  28296. return isObjectLike(value) && getTag(value) == weakMapTag;
  28297. }
  28298. /**
  28299. * Checks if `value` is classified as a `WeakSet` object.
  28300. *
  28301. * @static
  28302. * @memberOf _
  28303. * @since 4.3.0
  28304. * @category Lang
  28305. * @param {*} value The value to check.
  28306. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28307. * @example
  28308. *
  28309. * _.isWeakSet(new WeakSet);
  28310. * // => true
  28311. *
  28312. * _.isWeakSet(new Set);
  28313. * // => false
  28314. */
  28315. function isWeakSet(value) {
  28316. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28317. }
  28318. /**
  28319. * Checks if `value` is less than `other`.
  28320. *
  28321. * @static
  28322. * @memberOf _
  28323. * @since 3.9.0
  28324. * @category Lang
  28325. * @param {*} value The value to compare.
  28326. * @param {*} other The other value to compare.
  28327. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28328. * else `false`.
  28329. * @see _.gt
  28330. * @example
  28331. *
  28332. * _.lt(1, 3);
  28333. * // => true
  28334. *
  28335. * _.lt(3, 3);
  28336. * // => false
  28337. *
  28338. * _.lt(3, 1);
  28339. * // => false
  28340. */
  28341. var lt = createRelationalOperation(baseLt);
  28342. /**
  28343. * Checks if `value` is less than or equal to `other`.
  28344. *
  28345. * @static
  28346. * @memberOf _
  28347. * @since 3.9.0
  28348. * @category Lang
  28349. * @param {*} value The value to compare.
  28350. * @param {*} other The other value to compare.
  28351. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28352. * `other`, else `false`.
  28353. * @see _.gte
  28354. * @example
  28355. *
  28356. * _.lte(1, 3);
  28357. * // => true
  28358. *
  28359. * _.lte(3, 3);
  28360. * // => true
  28361. *
  28362. * _.lte(3, 1);
  28363. * // => false
  28364. */
  28365. var lte = createRelationalOperation(function(value, other) {
  28366. return value <= other;
  28367. });
  28368. /**
  28369. * Converts `value` to an array.
  28370. *
  28371. * @static
  28372. * @since 0.1.0
  28373. * @memberOf _
  28374. * @category Lang
  28375. * @param {*} value The value to convert.
  28376. * @returns {Array} Returns the converted array.
  28377. * @example
  28378. *
  28379. * _.toArray({ 'a': 1, 'b': 2 });
  28380. * // => [1, 2]
  28381. *
  28382. * _.toArray('abc');
  28383. * // => ['a', 'b', 'c']
  28384. *
  28385. * _.toArray(1);
  28386. * // => []
  28387. *
  28388. * _.toArray(null);
  28389. * // => []
  28390. */
  28391. function toArray(value) {
  28392. if (!value) {
  28393. return [];
  28394. }
  28395. if (isArrayLike(value)) {
  28396. return isString(value) ? stringToArray(value) : copyArray(value);
  28397. }
  28398. if (symIterator && value[symIterator]) {
  28399. return iteratorToArray(value[symIterator]());
  28400. }
  28401. var tag = getTag(value),
  28402. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28403. return func(value);
  28404. }
  28405. /**
  28406. * Converts `value` to a finite number.
  28407. *
  28408. * @static
  28409. * @memberOf _
  28410. * @since 4.12.0
  28411. * @category Lang
  28412. * @param {*} value The value to convert.
  28413. * @returns {number} Returns the converted number.
  28414. * @example
  28415. *
  28416. * _.toFinite(3.2);
  28417. * // => 3.2
  28418. *
  28419. * _.toFinite(Number.MIN_VALUE);
  28420. * // => 5e-324
  28421. *
  28422. * _.toFinite(Infinity);
  28423. * // => 1.7976931348623157e+308
  28424. *
  28425. * _.toFinite('3.2');
  28426. * // => 3.2
  28427. */
  28428. function toFinite(value) {
  28429. if (!value) {
  28430. return value === 0 ? value : 0;
  28431. }
  28432. value = toNumber(value);
  28433. if (value === INFINITY || value === -INFINITY) {
  28434. var sign = (value < 0 ? -1 : 1);
  28435. return sign * MAX_INTEGER;
  28436. }
  28437. return value === value ? value : 0;
  28438. }
  28439. /**
  28440. * Converts `value` to an integer.
  28441. *
  28442. * **Note:** This method is loosely based on
  28443. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28444. *
  28445. * @static
  28446. * @memberOf _
  28447. * @since 4.0.0
  28448. * @category Lang
  28449. * @param {*} value The value to convert.
  28450. * @returns {number} Returns the converted integer.
  28451. * @example
  28452. *
  28453. * _.toInteger(3.2);
  28454. * // => 3
  28455. *
  28456. * _.toInteger(Number.MIN_VALUE);
  28457. * // => 0
  28458. *
  28459. * _.toInteger(Infinity);
  28460. * // => 1.7976931348623157e+308
  28461. *
  28462. * _.toInteger('3.2');
  28463. * // => 3
  28464. */
  28465. function toInteger(value) {
  28466. var result = toFinite(value),
  28467. remainder = result % 1;
  28468. return result === result ? (remainder ? result - remainder : result) : 0;
  28469. }
  28470. /**
  28471. * Converts `value` to an integer suitable for use as the length of an
  28472. * array-like object.
  28473. *
  28474. * **Note:** This method is based on
  28475. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28476. *
  28477. * @static
  28478. * @memberOf _
  28479. * @since 4.0.0
  28480. * @category Lang
  28481. * @param {*} value The value to convert.
  28482. * @returns {number} Returns the converted integer.
  28483. * @example
  28484. *
  28485. * _.toLength(3.2);
  28486. * // => 3
  28487. *
  28488. * _.toLength(Number.MIN_VALUE);
  28489. * // => 0
  28490. *
  28491. * _.toLength(Infinity);
  28492. * // => 4294967295
  28493. *
  28494. * _.toLength('3.2');
  28495. * // => 3
  28496. */
  28497. function toLength(value) {
  28498. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28499. }
  28500. /**
  28501. * Converts `value` to a number.
  28502. *
  28503. * @static
  28504. * @memberOf _
  28505. * @since 4.0.0
  28506. * @category Lang
  28507. * @param {*} value The value to process.
  28508. * @returns {number} Returns the number.
  28509. * @example
  28510. *
  28511. * _.toNumber(3.2);
  28512. * // => 3.2
  28513. *
  28514. * _.toNumber(Number.MIN_VALUE);
  28515. * // => 5e-324
  28516. *
  28517. * _.toNumber(Infinity);
  28518. * // => Infinity
  28519. *
  28520. * _.toNumber('3.2');
  28521. * // => 3.2
  28522. */
  28523. function toNumber(value) {
  28524. if (typeof value == 'number') {
  28525. return value;
  28526. }
  28527. if (isSymbol(value)) {
  28528. return NAN;
  28529. }
  28530. if (isObject(value)) {
  28531. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28532. value = isObject(other) ? (other + '') : other;
  28533. }
  28534. if (typeof value != 'string') {
  28535. return value === 0 ? value : +value;
  28536. }
  28537. value = value.replace(reTrim, '');
  28538. var isBinary = reIsBinary.test(value);
  28539. return (isBinary || reIsOctal.test(value))
  28540. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28541. : (reIsBadHex.test(value) ? NAN : +value);
  28542. }
  28543. /**
  28544. * Converts `value` to a plain object flattening inherited enumerable string
  28545. * keyed properties of `value` to own properties of the plain object.
  28546. *
  28547. * @static
  28548. * @memberOf _
  28549. * @since 3.0.0
  28550. * @category Lang
  28551. * @param {*} value The value to convert.
  28552. * @returns {Object} Returns the converted plain object.
  28553. * @example
  28554. *
  28555. * function Foo() {
  28556. * this.b = 2;
  28557. * }
  28558. *
  28559. * Foo.prototype.c = 3;
  28560. *
  28561. * _.assign({ 'a': 1 }, new Foo);
  28562. * // => { 'a': 1, 'b': 2 }
  28563. *
  28564. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28565. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28566. */
  28567. function toPlainObject(value) {
  28568. return copyObject(value, keysIn(value));
  28569. }
  28570. /**
  28571. * Converts `value` to a safe integer. A safe integer can be compared and
  28572. * represented correctly.
  28573. *
  28574. * @static
  28575. * @memberOf _
  28576. * @since 4.0.0
  28577. * @category Lang
  28578. * @param {*} value The value to convert.
  28579. * @returns {number} Returns the converted integer.
  28580. * @example
  28581. *
  28582. * _.toSafeInteger(3.2);
  28583. * // => 3
  28584. *
  28585. * _.toSafeInteger(Number.MIN_VALUE);
  28586. * // => 0
  28587. *
  28588. * _.toSafeInteger(Infinity);
  28589. * // => 9007199254740991
  28590. *
  28591. * _.toSafeInteger('3.2');
  28592. * // => 3
  28593. */
  28594. function toSafeInteger(value) {
  28595. return value
  28596. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28597. : (value === 0 ? value : 0);
  28598. }
  28599. /**
  28600. * Converts `value` to a string. An empty string is returned for `null`
  28601. * and `undefined` values. The sign of `-0` is preserved.
  28602. *
  28603. * @static
  28604. * @memberOf _
  28605. * @since 4.0.0
  28606. * @category Lang
  28607. * @param {*} value The value to convert.
  28608. * @returns {string} Returns the converted string.
  28609. * @example
  28610. *
  28611. * _.toString(null);
  28612. * // => ''
  28613. *
  28614. * _.toString(-0);
  28615. * // => '-0'
  28616. *
  28617. * _.toString([1, 2, 3]);
  28618. * // => '1,2,3'
  28619. */
  28620. function toString(value) {
  28621. return value == null ? '' : baseToString(value);
  28622. }
  28623. /*------------------------------------------------------------------------*/
  28624. /**
  28625. * Assigns own enumerable string keyed properties of source objects to the
  28626. * destination object. Source objects are applied from left to right.
  28627. * Subsequent sources overwrite property assignments of previous sources.
  28628. *
  28629. * **Note:** This method mutates `object` and is loosely based on
  28630. * [`Object.assign`](https://mdn.io/Object/assign).
  28631. *
  28632. * @static
  28633. * @memberOf _
  28634. * @since 0.10.0
  28635. * @category Object
  28636. * @param {Object} object The destination object.
  28637. * @param {...Object} [sources] The source objects.
  28638. * @returns {Object} Returns `object`.
  28639. * @see _.assignIn
  28640. * @example
  28641. *
  28642. * function Foo() {
  28643. * this.a = 1;
  28644. * }
  28645. *
  28646. * function Bar() {
  28647. * this.c = 3;
  28648. * }
  28649. *
  28650. * Foo.prototype.b = 2;
  28651. * Bar.prototype.d = 4;
  28652. *
  28653. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28654. * // => { 'a': 1, 'c': 3 }
  28655. */
  28656. var assign = createAssigner(function(object, source) {
  28657. if (isPrototype(source) || isArrayLike(source)) {
  28658. copyObject(source, keys(source), object);
  28659. return;
  28660. }
  28661. for (var key in source) {
  28662. if (hasOwnProperty.call(source, key)) {
  28663. assignValue(object, key, source[key]);
  28664. }
  28665. }
  28666. });
  28667. /**
  28668. * This method is like `_.assign` except that it iterates over own and
  28669. * inherited source properties.
  28670. *
  28671. * **Note:** This method mutates `object`.
  28672. *
  28673. * @static
  28674. * @memberOf _
  28675. * @since 4.0.0
  28676. * @alias extend
  28677. * @category Object
  28678. * @param {Object} object The destination object.
  28679. * @param {...Object} [sources] The source objects.
  28680. * @returns {Object} Returns `object`.
  28681. * @see _.assign
  28682. * @example
  28683. *
  28684. * function Foo() {
  28685. * this.a = 1;
  28686. * }
  28687. *
  28688. * function Bar() {
  28689. * this.c = 3;
  28690. * }
  28691. *
  28692. * Foo.prototype.b = 2;
  28693. * Bar.prototype.d = 4;
  28694. *
  28695. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28696. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28697. */
  28698. var assignIn = createAssigner(function(object, source) {
  28699. copyObject(source, keysIn(source), object);
  28700. });
  28701. /**
  28702. * This method is like `_.assignIn` except that it accepts `customizer`
  28703. * which is invoked to produce the assigned values. If `customizer` returns
  28704. * `undefined`, assignment is handled by the method instead. The `customizer`
  28705. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28706. *
  28707. * **Note:** This method mutates `object`.
  28708. *
  28709. * @static
  28710. * @memberOf _
  28711. * @since 4.0.0
  28712. * @alias extendWith
  28713. * @category Object
  28714. * @param {Object} object The destination object.
  28715. * @param {...Object} sources The source objects.
  28716. * @param {Function} [customizer] The function to customize assigned values.
  28717. * @returns {Object} Returns `object`.
  28718. * @see _.assignWith
  28719. * @example
  28720. *
  28721. * function customizer(objValue, srcValue) {
  28722. * return _.isUndefined(objValue) ? srcValue : objValue;
  28723. * }
  28724. *
  28725. * var defaults = _.partialRight(_.assignInWith, customizer);
  28726. *
  28727. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28728. * // => { 'a': 1, 'b': 2 }
  28729. */
  28730. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28731. copyObject(source, keysIn(source), object, customizer);
  28732. });
  28733. /**
  28734. * This method is like `_.assign` except that it accepts `customizer`
  28735. * which is invoked to produce the assigned values. If `customizer` returns
  28736. * `undefined`, assignment is handled by the method instead. The `customizer`
  28737. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28738. *
  28739. * **Note:** This method mutates `object`.
  28740. *
  28741. * @static
  28742. * @memberOf _
  28743. * @since 4.0.0
  28744. * @category Object
  28745. * @param {Object} object The destination object.
  28746. * @param {...Object} sources The source objects.
  28747. * @param {Function} [customizer] The function to customize assigned values.
  28748. * @returns {Object} Returns `object`.
  28749. * @see _.assignInWith
  28750. * @example
  28751. *
  28752. * function customizer(objValue, srcValue) {
  28753. * return _.isUndefined(objValue) ? srcValue : objValue;
  28754. * }
  28755. *
  28756. * var defaults = _.partialRight(_.assignWith, customizer);
  28757. *
  28758. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28759. * // => { 'a': 1, 'b': 2 }
  28760. */
  28761. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28762. copyObject(source, keys(source), object, customizer);
  28763. });
  28764. /**
  28765. * Creates an array of values corresponding to `paths` of `object`.
  28766. *
  28767. * @static
  28768. * @memberOf _
  28769. * @since 1.0.0
  28770. * @category Object
  28771. * @param {Object} object The object to iterate over.
  28772. * @param {...(string|string[])} [paths] The property paths to pick.
  28773. * @returns {Array} Returns the picked values.
  28774. * @example
  28775. *
  28776. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28777. *
  28778. * _.at(object, ['a[0].b.c', 'a[1]']);
  28779. * // => [3, 4]
  28780. */
  28781. var at = flatRest(baseAt);
  28782. /**
  28783. * Creates an object that inherits from the `prototype` object. If a
  28784. * `properties` object is given, its own enumerable string keyed properties
  28785. * are assigned to the created object.
  28786. *
  28787. * @static
  28788. * @memberOf _
  28789. * @since 2.3.0
  28790. * @category Object
  28791. * @param {Object} prototype The object to inherit from.
  28792. * @param {Object} [properties] The properties to assign to the object.
  28793. * @returns {Object} Returns the new object.
  28794. * @example
  28795. *
  28796. * function Shape() {
  28797. * this.x = 0;
  28798. * this.y = 0;
  28799. * }
  28800. *
  28801. * function Circle() {
  28802. * Shape.call(this);
  28803. * }
  28804. *
  28805. * Circle.prototype = _.create(Shape.prototype, {
  28806. * 'constructor': Circle
  28807. * });
  28808. *
  28809. * var circle = new Circle;
  28810. * circle instanceof Circle;
  28811. * // => true
  28812. *
  28813. * circle instanceof Shape;
  28814. * // => true
  28815. */
  28816. function create(prototype, properties) {
  28817. var result = baseCreate(prototype);
  28818. return properties == null ? result : baseAssign(result, properties);
  28819. }
  28820. /**
  28821. * Assigns own and inherited enumerable string keyed properties of source
  28822. * objects to the destination object for all destination properties that
  28823. * resolve to `undefined`. Source objects are applied from left to right.
  28824. * Once a property is set, additional values of the same property are ignored.
  28825. *
  28826. * **Note:** This method mutates `object`.
  28827. *
  28828. * @static
  28829. * @since 0.1.0
  28830. * @memberOf _
  28831. * @category Object
  28832. * @param {Object} object The destination object.
  28833. * @param {...Object} [sources] The source objects.
  28834. * @returns {Object} Returns `object`.
  28835. * @see _.defaultsDeep
  28836. * @example
  28837. *
  28838. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28839. * // => { 'a': 1, 'b': 2 }
  28840. */
  28841. var defaults = baseRest(function(object, sources) {
  28842. object = Object(object);
  28843. var index = -1;
  28844. var length = sources.length;
  28845. var guard = length > 2 ? sources[2] : undefined;
  28846. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28847. length = 1;
  28848. }
  28849. while (++index < length) {
  28850. var source = sources[index];
  28851. var props = keysIn(source);
  28852. var propsIndex = -1;
  28853. var propsLength = props.length;
  28854. while (++propsIndex < propsLength) {
  28855. var key = props[propsIndex];
  28856. var value = object[key];
  28857. if (value === undefined ||
  28858. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28859. object[key] = source[key];
  28860. }
  28861. }
  28862. }
  28863. return object;
  28864. });
  28865. /**
  28866. * This method is like `_.defaults` except that it recursively assigns
  28867. * default properties.
  28868. *
  28869. * **Note:** This method mutates `object`.
  28870. *
  28871. * @static
  28872. * @memberOf _
  28873. * @since 3.10.0
  28874. * @category Object
  28875. * @param {Object} object The destination object.
  28876. * @param {...Object} [sources] The source objects.
  28877. * @returns {Object} Returns `object`.
  28878. * @see _.defaults
  28879. * @example
  28880. *
  28881. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28882. * // => { 'a': { 'b': 2, 'c': 3 } }
  28883. */
  28884. var defaultsDeep = baseRest(function(args) {
  28885. args.push(undefined, customDefaultsMerge);
  28886. return apply(mergeWith, undefined, args);
  28887. });
  28888. /**
  28889. * This method is like `_.find` except that it returns the key of the first
  28890. * element `predicate` returns truthy for instead of the element itself.
  28891. *
  28892. * @static
  28893. * @memberOf _
  28894. * @since 1.1.0
  28895. * @category Object
  28896. * @param {Object} object The object to inspect.
  28897. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28898. * @returns {string|undefined} Returns the key of the matched element,
  28899. * else `undefined`.
  28900. * @example
  28901. *
  28902. * var users = {
  28903. * 'barney': { 'age': 36, 'active': true },
  28904. * 'fred': { 'age': 40, 'active': false },
  28905. * 'pebbles': { 'age': 1, 'active': true }
  28906. * };
  28907. *
  28908. * _.findKey(users, function(o) { return o.age < 40; });
  28909. * // => 'barney' (iteration order is not guaranteed)
  28910. *
  28911. * // The `_.matches` iteratee shorthand.
  28912. * _.findKey(users, { 'age': 1, 'active': true });
  28913. * // => 'pebbles'
  28914. *
  28915. * // The `_.matchesProperty` iteratee shorthand.
  28916. * _.findKey(users, ['active', false]);
  28917. * // => 'fred'
  28918. *
  28919. * // The `_.property` iteratee shorthand.
  28920. * _.findKey(users, 'active');
  28921. * // => 'barney'
  28922. */
  28923. function findKey(object, predicate) {
  28924. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28925. }
  28926. /**
  28927. * This method is like `_.findKey` except that it iterates over elements of
  28928. * a collection in the opposite order.
  28929. *
  28930. * @static
  28931. * @memberOf _
  28932. * @since 2.0.0
  28933. * @category Object
  28934. * @param {Object} object The object to inspect.
  28935. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28936. * @returns {string|undefined} Returns the key of the matched element,
  28937. * else `undefined`.
  28938. * @example
  28939. *
  28940. * var users = {
  28941. * 'barney': { 'age': 36, 'active': true },
  28942. * 'fred': { 'age': 40, 'active': false },
  28943. * 'pebbles': { 'age': 1, 'active': true }
  28944. * };
  28945. *
  28946. * _.findLastKey(users, function(o) { return o.age < 40; });
  28947. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28948. *
  28949. * // The `_.matches` iteratee shorthand.
  28950. * _.findLastKey(users, { 'age': 36, 'active': true });
  28951. * // => 'barney'
  28952. *
  28953. * // The `_.matchesProperty` iteratee shorthand.
  28954. * _.findLastKey(users, ['active', false]);
  28955. * // => 'fred'
  28956. *
  28957. * // The `_.property` iteratee shorthand.
  28958. * _.findLastKey(users, 'active');
  28959. * // => 'pebbles'
  28960. */
  28961. function findLastKey(object, predicate) {
  28962. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28963. }
  28964. /**
  28965. * Iterates over own and inherited enumerable string keyed properties of an
  28966. * object and invokes `iteratee` for each property. The iteratee is invoked
  28967. * with three arguments: (value, key, object). Iteratee functions may exit
  28968. * iteration early by explicitly returning `false`.
  28969. *
  28970. * @static
  28971. * @memberOf _
  28972. * @since 0.3.0
  28973. * @category Object
  28974. * @param {Object} object The object to iterate over.
  28975. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28976. * @returns {Object} Returns `object`.
  28977. * @see _.forInRight
  28978. * @example
  28979. *
  28980. * function Foo() {
  28981. * this.a = 1;
  28982. * this.b = 2;
  28983. * }
  28984. *
  28985. * Foo.prototype.c = 3;
  28986. *
  28987. * _.forIn(new Foo, function(value, key) {
  28988. * console.log(key);
  28989. * });
  28990. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28991. */
  28992. function forIn(object, iteratee) {
  28993. return object == null
  28994. ? object
  28995. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28996. }
  28997. /**
  28998. * This method is like `_.forIn` except that it iterates over properties of
  28999. * `object` in the opposite order.
  29000. *
  29001. * @static
  29002. * @memberOf _
  29003. * @since 2.0.0
  29004. * @category Object
  29005. * @param {Object} object The object to iterate over.
  29006. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29007. * @returns {Object} Returns `object`.
  29008. * @see _.forIn
  29009. * @example
  29010. *
  29011. * function Foo() {
  29012. * this.a = 1;
  29013. * this.b = 2;
  29014. * }
  29015. *
  29016. * Foo.prototype.c = 3;
  29017. *
  29018. * _.forInRight(new Foo, function(value, key) {
  29019. * console.log(key);
  29020. * });
  29021. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29022. */
  29023. function forInRight(object, iteratee) {
  29024. return object == null
  29025. ? object
  29026. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29027. }
  29028. /**
  29029. * Iterates over own enumerable string keyed properties of an object and
  29030. * invokes `iteratee` for each property. The iteratee is invoked with three
  29031. * arguments: (value, key, object). Iteratee functions may exit iteration
  29032. * early by explicitly returning `false`.
  29033. *
  29034. * @static
  29035. * @memberOf _
  29036. * @since 0.3.0
  29037. * @category Object
  29038. * @param {Object} object The object to iterate over.
  29039. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29040. * @returns {Object} Returns `object`.
  29041. * @see _.forOwnRight
  29042. * @example
  29043. *
  29044. * function Foo() {
  29045. * this.a = 1;
  29046. * this.b = 2;
  29047. * }
  29048. *
  29049. * Foo.prototype.c = 3;
  29050. *
  29051. * _.forOwn(new Foo, function(value, key) {
  29052. * console.log(key);
  29053. * });
  29054. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29055. */
  29056. function forOwn(object, iteratee) {
  29057. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29058. }
  29059. /**
  29060. * This method is like `_.forOwn` except that it iterates over properties of
  29061. * `object` in the opposite order.
  29062. *
  29063. * @static
  29064. * @memberOf _
  29065. * @since 2.0.0
  29066. * @category Object
  29067. * @param {Object} object The object to iterate over.
  29068. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29069. * @returns {Object} Returns `object`.
  29070. * @see _.forOwn
  29071. * @example
  29072. *
  29073. * function Foo() {
  29074. * this.a = 1;
  29075. * this.b = 2;
  29076. * }
  29077. *
  29078. * Foo.prototype.c = 3;
  29079. *
  29080. * _.forOwnRight(new Foo, function(value, key) {
  29081. * console.log(key);
  29082. * });
  29083. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29084. */
  29085. function forOwnRight(object, iteratee) {
  29086. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29087. }
  29088. /**
  29089. * Creates an array of function property names from own enumerable properties
  29090. * of `object`.
  29091. *
  29092. * @static
  29093. * @since 0.1.0
  29094. * @memberOf _
  29095. * @category Object
  29096. * @param {Object} object The object to inspect.
  29097. * @returns {Array} Returns the function names.
  29098. * @see _.functionsIn
  29099. * @example
  29100. *
  29101. * function Foo() {
  29102. * this.a = _.constant('a');
  29103. * this.b = _.constant('b');
  29104. * }
  29105. *
  29106. * Foo.prototype.c = _.constant('c');
  29107. *
  29108. * _.functions(new Foo);
  29109. * // => ['a', 'b']
  29110. */
  29111. function functions(object) {
  29112. return object == null ? [] : baseFunctions(object, keys(object));
  29113. }
  29114. /**
  29115. * Creates an array of function property names from own and inherited
  29116. * enumerable properties of `object`.
  29117. *
  29118. * @static
  29119. * @memberOf _
  29120. * @since 4.0.0
  29121. * @category Object
  29122. * @param {Object} object The object to inspect.
  29123. * @returns {Array} Returns the function names.
  29124. * @see _.functions
  29125. * @example
  29126. *
  29127. * function Foo() {
  29128. * this.a = _.constant('a');
  29129. * this.b = _.constant('b');
  29130. * }
  29131. *
  29132. * Foo.prototype.c = _.constant('c');
  29133. *
  29134. * _.functionsIn(new Foo);
  29135. * // => ['a', 'b', 'c']
  29136. */
  29137. function functionsIn(object) {
  29138. return object == null ? [] : baseFunctions(object, keysIn(object));
  29139. }
  29140. /**
  29141. * Gets the value at `path` of `object`. If the resolved value is
  29142. * `undefined`, the `defaultValue` is returned in its place.
  29143. *
  29144. * @static
  29145. * @memberOf _
  29146. * @since 3.7.0
  29147. * @category Object
  29148. * @param {Object} object The object to query.
  29149. * @param {Array|string} path The path of the property to get.
  29150. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29151. * @returns {*} Returns the resolved value.
  29152. * @example
  29153. *
  29154. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29155. *
  29156. * _.get(object, 'a[0].b.c');
  29157. * // => 3
  29158. *
  29159. * _.get(object, ['a', '0', 'b', 'c']);
  29160. * // => 3
  29161. *
  29162. * _.get(object, 'a.b.c', 'default');
  29163. * // => 'default'
  29164. */
  29165. function get(object, path, defaultValue) {
  29166. var result = object == null ? undefined : baseGet(object, path);
  29167. return result === undefined ? defaultValue : result;
  29168. }
  29169. /**
  29170. * Checks if `path` is a direct property of `object`.
  29171. *
  29172. * @static
  29173. * @since 0.1.0
  29174. * @memberOf _
  29175. * @category Object
  29176. * @param {Object} object The object to query.
  29177. * @param {Array|string} path The path to check.
  29178. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29179. * @example
  29180. *
  29181. * var object = { 'a': { 'b': 2 } };
  29182. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29183. *
  29184. * _.has(object, 'a');
  29185. * // => true
  29186. *
  29187. * _.has(object, 'a.b');
  29188. * // => true
  29189. *
  29190. * _.has(object, ['a', 'b']);
  29191. * // => true
  29192. *
  29193. * _.has(other, 'a');
  29194. * // => false
  29195. */
  29196. function has(object, path) {
  29197. return object != null && hasPath(object, path, baseHas);
  29198. }
  29199. /**
  29200. * Checks if `path` is a direct or inherited property of `object`.
  29201. *
  29202. * @static
  29203. * @memberOf _
  29204. * @since 4.0.0
  29205. * @category Object
  29206. * @param {Object} object The object to query.
  29207. * @param {Array|string} path The path to check.
  29208. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29209. * @example
  29210. *
  29211. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29212. *
  29213. * _.hasIn(object, 'a');
  29214. * // => true
  29215. *
  29216. * _.hasIn(object, 'a.b');
  29217. * // => true
  29218. *
  29219. * _.hasIn(object, ['a', 'b']);
  29220. * // => true
  29221. *
  29222. * _.hasIn(object, 'b');
  29223. * // => false
  29224. */
  29225. function hasIn(object, path) {
  29226. return object != null && hasPath(object, path, baseHasIn);
  29227. }
  29228. /**
  29229. * Creates an object composed of the inverted keys and values of `object`.
  29230. * If `object` contains duplicate values, subsequent values overwrite
  29231. * property assignments of previous values.
  29232. *
  29233. * @static
  29234. * @memberOf _
  29235. * @since 0.7.0
  29236. * @category Object
  29237. * @param {Object} object The object to invert.
  29238. * @returns {Object} Returns the new inverted object.
  29239. * @example
  29240. *
  29241. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29242. *
  29243. * _.invert(object);
  29244. * // => { '1': 'c', '2': 'b' }
  29245. */
  29246. var invert = createInverter(function(result, value, key) {
  29247. if (value != null &&
  29248. typeof value.toString != 'function') {
  29249. value = nativeObjectToString.call(value);
  29250. }
  29251. result[value] = key;
  29252. }, constant(identity));
  29253. /**
  29254. * This method is like `_.invert` except that the inverted object is generated
  29255. * from the results of running each element of `object` thru `iteratee`. The
  29256. * corresponding inverted value of each inverted key is an array of keys
  29257. * responsible for generating the inverted value. The iteratee is invoked
  29258. * with one argument: (value).
  29259. *
  29260. * @static
  29261. * @memberOf _
  29262. * @since 4.1.0
  29263. * @category Object
  29264. * @param {Object} object The object to invert.
  29265. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29266. * @returns {Object} Returns the new inverted object.
  29267. * @example
  29268. *
  29269. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29270. *
  29271. * _.invertBy(object);
  29272. * // => { '1': ['a', 'c'], '2': ['b'] }
  29273. *
  29274. * _.invertBy(object, function(value) {
  29275. * return 'group' + value;
  29276. * });
  29277. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29278. */
  29279. var invertBy = createInverter(function(result, value, key) {
  29280. if (value != null &&
  29281. typeof value.toString != 'function') {
  29282. value = nativeObjectToString.call(value);
  29283. }
  29284. if (hasOwnProperty.call(result, value)) {
  29285. result[value].push(key);
  29286. } else {
  29287. result[value] = [key];
  29288. }
  29289. }, getIteratee);
  29290. /**
  29291. * Invokes the method at `path` of `object`.
  29292. *
  29293. * @static
  29294. * @memberOf _
  29295. * @since 4.0.0
  29296. * @category Object
  29297. * @param {Object} object The object to query.
  29298. * @param {Array|string} path The path of the method to invoke.
  29299. * @param {...*} [args] The arguments to invoke the method with.
  29300. * @returns {*} Returns the result of the invoked method.
  29301. * @example
  29302. *
  29303. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29304. *
  29305. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29306. * // => [2, 3]
  29307. */
  29308. var invoke = baseRest(baseInvoke);
  29309. /**
  29310. * Creates an array of the own enumerable property names of `object`.
  29311. *
  29312. * **Note:** Non-object values are coerced to objects. See the
  29313. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29314. * for more details.
  29315. *
  29316. * @static
  29317. * @since 0.1.0
  29318. * @memberOf _
  29319. * @category Object
  29320. * @param {Object} object The object to query.
  29321. * @returns {Array} Returns the array of property names.
  29322. * @example
  29323. *
  29324. * function Foo() {
  29325. * this.a = 1;
  29326. * this.b = 2;
  29327. * }
  29328. *
  29329. * Foo.prototype.c = 3;
  29330. *
  29331. * _.keys(new Foo);
  29332. * // => ['a', 'b'] (iteration order is not guaranteed)
  29333. *
  29334. * _.keys('hi');
  29335. * // => ['0', '1']
  29336. */
  29337. function keys(object) {
  29338. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29339. }
  29340. /**
  29341. * Creates an array of the own and inherited enumerable property names of `object`.
  29342. *
  29343. * **Note:** Non-object values are coerced to objects.
  29344. *
  29345. * @static
  29346. * @memberOf _
  29347. * @since 3.0.0
  29348. * @category Object
  29349. * @param {Object} object The object to query.
  29350. * @returns {Array} Returns the array of property names.
  29351. * @example
  29352. *
  29353. * function Foo() {
  29354. * this.a = 1;
  29355. * this.b = 2;
  29356. * }
  29357. *
  29358. * Foo.prototype.c = 3;
  29359. *
  29360. * _.keysIn(new Foo);
  29361. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29362. */
  29363. function keysIn(object) {
  29364. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29365. }
  29366. /**
  29367. * The opposite of `_.mapValues`; this method creates an object with the
  29368. * same values as `object` and keys generated by running each own enumerable
  29369. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29370. * with three arguments: (value, key, object).
  29371. *
  29372. * @static
  29373. * @memberOf _
  29374. * @since 3.8.0
  29375. * @category Object
  29376. * @param {Object} object The object to iterate over.
  29377. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29378. * @returns {Object} Returns the new mapped object.
  29379. * @see _.mapValues
  29380. * @example
  29381. *
  29382. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29383. * return key + value;
  29384. * });
  29385. * // => { 'a1': 1, 'b2': 2 }
  29386. */
  29387. function mapKeys(object, iteratee) {
  29388. var result = {};
  29389. iteratee = getIteratee(iteratee, 3);
  29390. baseForOwn(object, function(value, key, object) {
  29391. baseAssignValue(result, iteratee(value, key, object), value);
  29392. });
  29393. return result;
  29394. }
  29395. /**
  29396. * Creates an object with the same keys as `object` and values generated
  29397. * by running each own enumerable string keyed property of `object` thru
  29398. * `iteratee`. The iteratee is invoked with three arguments:
  29399. * (value, key, object).
  29400. *
  29401. * @static
  29402. * @memberOf _
  29403. * @since 2.4.0
  29404. * @category Object
  29405. * @param {Object} object The object to iterate over.
  29406. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29407. * @returns {Object} Returns the new mapped object.
  29408. * @see _.mapKeys
  29409. * @example
  29410. *
  29411. * var users = {
  29412. * 'fred': { 'user': 'fred', 'age': 40 },
  29413. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29414. * };
  29415. *
  29416. * _.mapValues(users, function(o) { return o.age; });
  29417. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29418. *
  29419. * // The `_.property` iteratee shorthand.
  29420. * _.mapValues(users, 'age');
  29421. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29422. */
  29423. function mapValues(object, iteratee) {
  29424. var result = {};
  29425. iteratee = getIteratee(iteratee, 3);
  29426. baseForOwn(object, function(value, key, object) {
  29427. baseAssignValue(result, key, iteratee(value, key, object));
  29428. });
  29429. return result;
  29430. }
  29431. /**
  29432. * This method is like `_.assign` except that it recursively merges own and
  29433. * inherited enumerable string keyed properties of source objects into the
  29434. * destination object. Source properties that resolve to `undefined` are
  29435. * skipped if a destination value exists. Array and plain object properties
  29436. * are merged recursively. Other objects and value types are overridden by
  29437. * assignment. Source objects are applied from left to right. Subsequent
  29438. * sources overwrite property assignments of previous sources.
  29439. *
  29440. * **Note:** This method mutates `object`.
  29441. *
  29442. * @static
  29443. * @memberOf _
  29444. * @since 0.5.0
  29445. * @category Object
  29446. * @param {Object} object The destination object.
  29447. * @param {...Object} [sources] The source objects.
  29448. * @returns {Object} Returns `object`.
  29449. * @example
  29450. *
  29451. * var object = {
  29452. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29453. * };
  29454. *
  29455. * var other = {
  29456. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29457. * };
  29458. *
  29459. * _.merge(object, other);
  29460. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29461. */
  29462. var merge = createAssigner(function(object, source, srcIndex) {
  29463. baseMerge(object, source, srcIndex);
  29464. });
  29465. /**
  29466. * This method is like `_.merge` except that it accepts `customizer` which
  29467. * is invoked to produce the merged values of the destination and source
  29468. * properties. If `customizer` returns `undefined`, merging is handled by the
  29469. * method instead. The `customizer` is invoked with six arguments:
  29470. * (objValue, srcValue, key, object, source, stack).
  29471. *
  29472. * **Note:** This method mutates `object`.
  29473. *
  29474. * @static
  29475. * @memberOf _
  29476. * @since 4.0.0
  29477. * @category Object
  29478. * @param {Object} object The destination object.
  29479. * @param {...Object} sources The source objects.
  29480. * @param {Function} customizer The function to customize assigned values.
  29481. * @returns {Object} Returns `object`.
  29482. * @example
  29483. *
  29484. * function customizer(objValue, srcValue) {
  29485. * if (_.isArray(objValue)) {
  29486. * return objValue.concat(srcValue);
  29487. * }
  29488. * }
  29489. *
  29490. * var object = { 'a': [1], 'b': [2] };
  29491. * var other = { 'a': [3], 'b': [4] };
  29492. *
  29493. * _.mergeWith(object, other, customizer);
  29494. * // => { 'a': [1, 3], 'b': [2, 4] }
  29495. */
  29496. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29497. baseMerge(object, source, srcIndex, customizer);
  29498. });
  29499. /**
  29500. * The opposite of `_.pick`; this method creates an object composed of the
  29501. * own and inherited enumerable property paths of `object` that are not omitted.
  29502. *
  29503. * **Note:** This method is considerably slower than `_.pick`.
  29504. *
  29505. * @static
  29506. * @since 0.1.0
  29507. * @memberOf _
  29508. * @category Object
  29509. * @param {Object} object The source object.
  29510. * @param {...(string|string[])} [paths] The property paths to omit.
  29511. * @returns {Object} Returns the new object.
  29512. * @example
  29513. *
  29514. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29515. *
  29516. * _.omit(object, ['a', 'c']);
  29517. * // => { 'b': '2' }
  29518. */
  29519. var omit = flatRest(function(object, paths) {
  29520. var result = {};
  29521. if (object == null) {
  29522. return result;
  29523. }
  29524. var isDeep = false;
  29525. paths = arrayMap(paths, function(path) {
  29526. path = castPath(path, object);
  29527. isDeep || (isDeep = path.length > 1);
  29528. return path;
  29529. });
  29530. copyObject(object, getAllKeysIn(object), result);
  29531. if (isDeep) {
  29532. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29533. }
  29534. var length = paths.length;
  29535. while (length--) {
  29536. baseUnset(result, paths[length]);
  29537. }
  29538. return result;
  29539. });
  29540. /**
  29541. * The opposite of `_.pickBy`; this method creates an object composed of
  29542. * the own and inherited enumerable string keyed properties of `object` that
  29543. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29544. * arguments: (value, key).
  29545. *
  29546. * @static
  29547. * @memberOf _
  29548. * @since 4.0.0
  29549. * @category Object
  29550. * @param {Object} object The source object.
  29551. * @param {Function} [predicate=_.identity] The function invoked per property.
  29552. * @returns {Object} Returns the new object.
  29553. * @example
  29554. *
  29555. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29556. *
  29557. * _.omitBy(object, _.isNumber);
  29558. * // => { 'b': '2' }
  29559. */
  29560. function omitBy(object, predicate) {
  29561. return pickBy(object, negate(getIteratee(predicate)));
  29562. }
  29563. /**
  29564. * Creates an object composed of the picked `object` properties.
  29565. *
  29566. * @static
  29567. * @since 0.1.0
  29568. * @memberOf _
  29569. * @category Object
  29570. * @param {Object} object The source object.
  29571. * @param {...(string|string[])} [paths] The property paths to pick.
  29572. * @returns {Object} Returns the new object.
  29573. * @example
  29574. *
  29575. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29576. *
  29577. * _.pick(object, ['a', 'c']);
  29578. * // => { 'a': 1, 'c': 3 }
  29579. */
  29580. var pick = flatRest(function(object, paths) {
  29581. return object == null ? {} : basePick(object, paths);
  29582. });
  29583. /**
  29584. * Creates an object composed of the `object` properties `predicate` returns
  29585. * truthy for. The predicate is invoked with two arguments: (value, key).
  29586. *
  29587. * @static
  29588. * @memberOf _
  29589. * @since 4.0.0
  29590. * @category Object
  29591. * @param {Object} object The source object.
  29592. * @param {Function} [predicate=_.identity] The function invoked per property.
  29593. * @returns {Object} Returns the new object.
  29594. * @example
  29595. *
  29596. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29597. *
  29598. * _.pickBy(object, _.isNumber);
  29599. * // => { 'a': 1, 'c': 3 }
  29600. */
  29601. function pickBy(object, predicate) {
  29602. if (object == null) {
  29603. return {};
  29604. }
  29605. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29606. return [prop];
  29607. });
  29608. predicate = getIteratee(predicate);
  29609. return basePickBy(object, props, function(value, path) {
  29610. return predicate(value, path[0]);
  29611. });
  29612. }
  29613. /**
  29614. * This method is like `_.get` except that if the resolved value is a
  29615. * function it's invoked with the `this` binding of its parent object and
  29616. * its result is returned.
  29617. *
  29618. * @static
  29619. * @since 0.1.0
  29620. * @memberOf _
  29621. * @category Object
  29622. * @param {Object} object The object to query.
  29623. * @param {Array|string} path The path of the property to resolve.
  29624. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29625. * @returns {*} Returns the resolved value.
  29626. * @example
  29627. *
  29628. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29629. *
  29630. * _.result(object, 'a[0].b.c1');
  29631. * // => 3
  29632. *
  29633. * _.result(object, 'a[0].b.c2');
  29634. * // => 4
  29635. *
  29636. * _.result(object, 'a[0].b.c3', 'default');
  29637. * // => 'default'
  29638. *
  29639. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29640. * // => 'default'
  29641. */
  29642. function result(object, path, defaultValue) {
  29643. path = castPath(path, object);
  29644. var index = -1,
  29645. length = path.length;
  29646. // Ensure the loop is entered when path is empty.
  29647. if (!length) {
  29648. length = 1;
  29649. object = undefined;
  29650. }
  29651. while (++index < length) {
  29652. var value = object == null ? undefined : object[toKey(path[index])];
  29653. if (value === undefined) {
  29654. index = length;
  29655. value = defaultValue;
  29656. }
  29657. object = isFunction(value) ? value.call(object) : value;
  29658. }
  29659. return object;
  29660. }
  29661. /**
  29662. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29663. * it's created. Arrays are created for missing index properties while objects
  29664. * are created for all other missing properties. Use `_.setWith` to customize
  29665. * `path` creation.
  29666. *
  29667. * **Note:** This method mutates `object`.
  29668. *
  29669. * @static
  29670. * @memberOf _
  29671. * @since 3.7.0
  29672. * @category Object
  29673. * @param {Object} object The object to modify.
  29674. * @param {Array|string} path The path of the property to set.
  29675. * @param {*} value The value to set.
  29676. * @returns {Object} Returns `object`.
  29677. * @example
  29678. *
  29679. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29680. *
  29681. * _.set(object, 'a[0].b.c', 4);
  29682. * console.log(object.a[0].b.c);
  29683. * // => 4
  29684. *
  29685. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29686. * console.log(object.x[0].y.z);
  29687. * // => 5
  29688. */
  29689. function set(object, path, value) {
  29690. return object == null ? object : baseSet(object, path, value);
  29691. }
  29692. /**
  29693. * This method is like `_.set` except that it accepts `customizer` which is
  29694. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29695. * path creation is handled by the method instead. The `customizer` is invoked
  29696. * with three arguments: (nsValue, key, nsObject).
  29697. *
  29698. * **Note:** This method mutates `object`.
  29699. *
  29700. * @static
  29701. * @memberOf _
  29702. * @since 4.0.0
  29703. * @category Object
  29704. * @param {Object} object The object to modify.
  29705. * @param {Array|string} path The path of the property to set.
  29706. * @param {*} value The value to set.
  29707. * @param {Function} [customizer] The function to customize assigned values.
  29708. * @returns {Object} Returns `object`.
  29709. * @example
  29710. *
  29711. * var object = {};
  29712. *
  29713. * _.setWith(object, '[0][1]', 'a', Object);
  29714. * // => { '0': { '1': 'a' } }
  29715. */
  29716. function setWith(object, path, value, customizer) {
  29717. customizer = typeof customizer == 'function' ? customizer : undefined;
  29718. return object == null ? object : baseSet(object, path, value, customizer);
  29719. }
  29720. /**
  29721. * Creates an array of own enumerable string keyed-value pairs for `object`
  29722. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29723. * entries are returned.
  29724. *
  29725. * @static
  29726. * @memberOf _
  29727. * @since 4.0.0
  29728. * @alias entries
  29729. * @category Object
  29730. * @param {Object} object The object to query.
  29731. * @returns {Array} Returns the key-value pairs.
  29732. * @example
  29733. *
  29734. * function Foo() {
  29735. * this.a = 1;
  29736. * this.b = 2;
  29737. * }
  29738. *
  29739. * Foo.prototype.c = 3;
  29740. *
  29741. * _.toPairs(new Foo);
  29742. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29743. */
  29744. var toPairs = createToPairs(keys);
  29745. /**
  29746. * Creates an array of own and inherited enumerable string keyed-value pairs
  29747. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29748. * or set, its entries are returned.
  29749. *
  29750. * @static
  29751. * @memberOf _
  29752. * @since 4.0.0
  29753. * @alias entriesIn
  29754. * @category Object
  29755. * @param {Object} object The object to query.
  29756. * @returns {Array} Returns the key-value pairs.
  29757. * @example
  29758. *
  29759. * function Foo() {
  29760. * this.a = 1;
  29761. * this.b = 2;
  29762. * }
  29763. *
  29764. * Foo.prototype.c = 3;
  29765. *
  29766. * _.toPairsIn(new Foo);
  29767. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29768. */
  29769. var toPairsIn = createToPairs(keysIn);
  29770. /**
  29771. * An alternative to `_.reduce`; this method transforms `object` to a new
  29772. * `accumulator` object which is the result of running each of its own
  29773. * enumerable string keyed properties thru `iteratee`, with each invocation
  29774. * potentially mutating the `accumulator` object. If `accumulator` is not
  29775. * provided, a new object with the same `[[Prototype]]` will be used. The
  29776. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29777. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29778. *
  29779. * @static
  29780. * @memberOf _
  29781. * @since 1.3.0
  29782. * @category Object
  29783. * @param {Object} object The object to iterate over.
  29784. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29785. * @param {*} [accumulator] The custom accumulator value.
  29786. * @returns {*} Returns the accumulated value.
  29787. * @example
  29788. *
  29789. * _.transform([2, 3, 4], function(result, n) {
  29790. * result.push(n *= n);
  29791. * return n % 2 == 0;
  29792. * }, []);
  29793. * // => [4, 9]
  29794. *
  29795. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29796. * (result[value] || (result[value] = [])).push(key);
  29797. * }, {});
  29798. * // => { '1': ['a', 'c'], '2': ['b'] }
  29799. */
  29800. function transform(object, iteratee, accumulator) {
  29801. var isArr = isArray(object),
  29802. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29803. iteratee = getIteratee(iteratee, 4);
  29804. if (accumulator == null) {
  29805. var Ctor = object && object.constructor;
  29806. if (isArrLike) {
  29807. accumulator = isArr ? new Ctor : [];
  29808. }
  29809. else if (isObject(object)) {
  29810. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29811. }
  29812. else {
  29813. accumulator = {};
  29814. }
  29815. }
  29816. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29817. return iteratee(accumulator, value, index, object);
  29818. });
  29819. return accumulator;
  29820. }
  29821. /**
  29822. * Removes the property at `path` of `object`.
  29823. *
  29824. * **Note:** This method mutates `object`.
  29825. *
  29826. * @static
  29827. * @memberOf _
  29828. * @since 4.0.0
  29829. * @category Object
  29830. * @param {Object} object The object to modify.
  29831. * @param {Array|string} path The path of the property to unset.
  29832. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29833. * @example
  29834. *
  29835. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29836. * _.unset(object, 'a[0].b.c');
  29837. * // => true
  29838. *
  29839. * console.log(object);
  29840. * // => { 'a': [{ 'b': {} }] };
  29841. *
  29842. * _.unset(object, ['a', '0', 'b', 'c']);
  29843. * // => true
  29844. *
  29845. * console.log(object);
  29846. * // => { 'a': [{ 'b': {} }] };
  29847. */
  29848. function unset(object, path) {
  29849. return object == null ? true : baseUnset(object, path);
  29850. }
  29851. /**
  29852. * This method is like `_.set` except that accepts `updater` to produce the
  29853. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29854. * is invoked with one argument: (value).
  29855. *
  29856. * **Note:** This method mutates `object`.
  29857. *
  29858. * @static
  29859. * @memberOf _
  29860. * @since 4.6.0
  29861. * @category Object
  29862. * @param {Object} object The object to modify.
  29863. * @param {Array|string} path The path of the property to set.
  29864. * @param {Function} updater The function to produce the updated value.
  29865. * @returns {Object} Returns `object`.
  29866. * @example
  29867. *
  29868. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29869. *
  29870. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29871. * console.log(object.a[0].b.c);
  29872. * // => 9
  29873. *
  29874. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29875. * console.log(object.x[0].y.z);
  29876. * // => 0
  29877. */
  29878. function update(object, path, updater) {
  29879. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29880. }
  29881. /**
  29882. * This method is like `_.update` except that it accepts `customizer` which is
  29883. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29884. * path creation is handled by the method instead. The `customizer` is invoked
  29885. * with three arguments: (nsValue, key, nsObject).
  29886. *
  29887. * **Note:** This method mutates `object`.
  29888. *
  29889. * @static
  29890. * @memberOf _
  29891. * @since 4.6.0
  29892. * @category Object
  29893. * @param {Object} object The object to modify.
  29894. * @param {Array|string} path The path of the property to set.
  29895. * @param {Function} updater The function to produce the updated value.
  29896. * @param {Function} [customizer] The function to customize assigned values.
  29897. * @returns {Object} Returns `object`.
  29898. * @example
  29899. *
  29900. * var object = {};
  29901. *
  29902. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29903. * // => { '0': { '1': 'a' } }
  29904. */
  29905. function updateWith(object, path, updater, customizer) {
  29906. customizer = typeof customizer == 'function' ? customizer : undefined;
  29907. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29908. }
  29909. /**
  29910. * Creates an array of the own enumerable string keyed property values of `object`.
  29911. *
  29912. * **Note:** Non-object values are coerced to objects.
  29913. *
  29914. * @static
  29915. * @since 0.1.0
  29916. * @memberOf _
  29917. * @category Object
  29918. * @param {Object} object The object to query.
  29919. * @returns {Array} Returns the array of property values.
  29920. * @example
  29921. *
  29922. * function Foo() {
  29923. * this.a = 1;
  29924. * this.b = 2;
  29925. * }
  29926. *
  29927. * Foo.prototype.c = 3;
  29928. *
  29929. * _.values(new Foo);
  29930. * // => [1, 2] (iteration order is not guaranteed)
  29931. *
  29932. * _.values('hi');
  29933. * // => ['h', 'i']
  29934. */
  29935. function values(object) {
  29936. return object == null ? [] : baseValues(object, keys(object));
  29937. }
  29938. /**
  29939. * Creates an array of the own and inherited enumerable string keyed property
  29940. * values of `object`.
  29941. *
  29942. * **Note:** Non-object values are coerced to objects.
  29943. *
  29944. * @static
  29945. * @memberOf _
  29946. * @since 3.0.0
  29947. * @category Object
  29948. * @param {Object} object The object to query.
  29949. * @returns {Array} Returns the array of property values.
  29950. * @example
  29951. *
  29952. * function Foo() {
  29953. * this.a = 1;
  29954. * this.b = 2;
  29955. * }
  29956. *
  29957. * Foo.prototype.c = 3;
  29958. *
  29959. * _.valuesIn(new Foo);
  29960. * // => [1, 2, 3] (iteration order is not guaranteed)
  29961. */
  29962. function valuesIn(object) {
  29963. return object == null ? [] : baseValues(object, keysIn(object));
  29964. }
  29965. /*------------------------------------------------------------------------*/
  29966. /**
  29967. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29968. *
  29969. * @static
  29970. * @memberOf _
  29971. * @since 4.0.0
  29972. * @category Number
  29973. * @param {number} number The number to clamp.
  29974. * @param {number} [lower] The lower bound.
  29975. * @param {number} upper The upper bound.
  29976. * @returns {number} Returns the clamped number.
  29977. * @example
  29978. *
  29979. * _.clamp(-10, -5, 5);
  29980. * // => -5
  29981. *
  29982. * _.clamp(10, -5, 5);
  29983. * // => 5
  29984. */
  29985. function clamp(number, lower, upper) {
  29986. if (upper === undefined) {
  29987. upper = lower;
  29988. lower = undefined;
  29989. }
  29990. if (upper !== undefined) {
  29991. upper = toNumber(upper);
  29992. upper = upper === upper ? upper : 0;
  29993. }
  29994. if (lower !== undefined) {
  29995. lower = toNumber(lower);
  29996. lower = lower === lower ? lower : 0;
  29997. }
  29998. return baseClamp(toNumber(number), lower, upper);
  29999. }
  30000. /**
  30001. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30002. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30003. * If `start` is greater than `end` the params are swapped to support
  30004. * negative ranges.
  30005. *
  30006. * @static
  30007. * @memberOf _
  30008. * @since 3.3.0
  30009. * @category Number
  30010. * @param {number} number The number to check.
  30011. * @param {number} [start=0] The start of the range.
  30012. * @param {number} end The end of the range.
  30013. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30014. * @see _.range, _.rangeRight
  30015. * @example
  30016. *
  30017. * _.inRange(3, 2, 4);
  30018. * // => true
  30019. *
  30020. * _.inRange(4, 8);
  30021. * // => true
  30022. *
  30023. * _.inRange(4, 2);
  30024. * // => false
  30025. *
  30026. * _.inRange(2, 2);
  30027. * // => false
  30028. *
  30029. * _.inRange(1.2, 2);
  30030. * // => true
  30031. *
  30032. * _.inRange(5.2, 4);
  30033. * // => false
  30034. *
  30035. * _.inRange(-3, -2, -6);
  30036. * // => true
  30037. */
  30038. function inRange(number, start, end) {
  30039. start = toFinite(start);
  30040. if (end === undefined) {
  30041. end = start;
  30042. start = 0;
  30043. } else {
  30044. end = toFinite(end);
  30045. }
  30046. number = toNumber(number);
  30047. return baseInRange(number, start, end);
  30048. }
  30049. /**
  30050. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30051. * If only one argument is provided a number between `0` and the given number
  30052. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30053. * floats, a floating-point number is returned instead of an integer.
  30054. *
  30055. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30056. * floating-point values which can produce unexpected results.
  30057. *
  30058. * @static
  30059. * @memberOf _
  30060. * @since 0.7.0
  30061. * @category Number
  30062. * @param {number} [lower=0] The lower bound.
  30063. * @param {number} [upper=1] The upper bound.
  30064. * @param {boolean} [floating] Specify returning a floating-point number.
  30065. * @returns {number} Returns the random number.
  30066. * @example
  30067. *
  30068. * _.random(0, 5);
  30069. * // => an integer between 0 and 5
  30070. *
  30071. * _.random(5);
  30072. * // => also an integer between 0 and 5
  30073. *
  30074. * _.random(5, true);
  30075. * // => a floating-point number between 0 and 5
  30076. *
  30077. * _.random(1.2, 5.2);
  30078. * // => a floating-point number between 1.2 and 5.2
  30079. */
  30080. function random(lower, upper, floating) {
  30081. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30082. upper = floating = undefined;
  30083. }
  30084. if (floating === undefined) {
  30085. if (typeof upper == 'boolean') {
  30086. floating = upper;
  30087. upper = undefined;
  30088. }
  30089. else if (typeof lower == 'boolean') {
  30090. floating = lower;
  30091. lower = undefined;
  30092. }
  30093. }
  30094. if (lower === undefined && upper === undefined) {
  30095. lower = 0;
  30096. upper = 1;
  30097. }
  30098. else {
  30099. lower = toFinite(lower);
  30100. if (upper === undefined) {
  30101. upper = lower;
  30102. lower = 0;
  30103. } else {
  30104. upper = toFinite(upper);
  30105. }
  30106. }
  30107. if (lower > upper) {
  30108. var temp = lower;
  30109. lower = upper;
  30110. upper = temp;
  30111. }
  30112. if (floating || lower % 1 || upper % 1) {
  30113. var rand = nativeRandom();
  30114. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30115. }
  30116. return baseRandom(lower, upper);
  30117. }
  30118. /*------------------------------------------------------------------------*/
  30119. /**
  30120. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30121. *
  30122. * @static
  30123. * @memberOf _
  30124. * @since 3.0.0
  30125. * @category String
  30126. * @param {string} [string=''] The string to convert.
  30127. * @returns {string} Returns the camel cased string.
  30128. * @example
  30129. *
  30130. * _.camelCase('Foo Bar');
  30131. * // => 'fooBar'
  30132. *
  30133. * _.camelCase('--foo-bar--');
  30134. * // => 'fooBar'
  30135. *
  30136. * _.camelCase('__FOO_BAR__');
  30137. * // => 'fooBar'
  30138. */
  30139. var camelCase = createCompounder(function(result, word, index) {
  30140. word = word.toLowerCase();
  30141. return result + (index ? capitalize(word) : word);
  30142. });
  30143. /**
  30144. * Converts the first character of `string` to upper case and the remaining
  30145. * to lower case.
  30146. *
  30147. * @static
  30148. * @memberOf _
  30149. * @since 3.0.0
  30150. * @category String
  30151. * @param {string} [string=''] The string to capitalize.
  30152. * @returns {string} Returns the capitalized string.
  30153. * @example
  30154. *
  30155. * _.capitalize('FRED');
  30156. * // => 'Fred'
  30157. */
  30158. function capitalize(string) {
  30159. return upperFirst(toString(string).toLowerCase());
  30160. }
  30161. /**
  30162. * Deburrs `string` by converting
  30163. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30164. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30165. * letters to basic Latin letters and removing
  30166. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30167. *
  30168. * @static
  30169. * @memberOf _
  30170. * @since 3.0.0
  30171. * @category String
  30172. * @param {string} [string=''] The string to deburr.
  30173. * @returns {string} Returns the deburred string.
  30174. * @example
  30175. *
  30176. * _.deburr('déjà vu');
  30177. * // => 'deja vu'
  30178. */
  30179. function deburr(string) {
  30180. string = toString(string);
  30181. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30182. }
  30183. /**
  30184. * Checks if `string` ends with the given target string.
  30185. *
  30186. * @static
  30187. * @memberOf _
  30188. * @since 3.0.0
  30189. * @category String
  30190. * @param {string} [string=''] The string to inspect.
  30191. * @param {string} [target] The string to search for.
  30192. * @param {number} [position=string.length] The position to search up to.
  30193. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30194. * else `false`.
  30195. * @example
  30196. *
  30197. * _.endsWith('abc', 'c');
  30198. * // => true
  30199. *
  30200. * _.endsWith('abc', 'b');
  30201. * // => false
  30202. *
  30203. * _.endsWith('abc', 'b', 2);
  30204. * // => true
  30205. */
  30206. function endsWith(string, target, position) {
  30207. string = toString(string);
  30208. target = baseToString(target);
  30209. var length = string.length;
  30210. position = position === undefined
  30211. ? length
  30212. : baseClamp(toInteger(position), 0, length);
  30213. var end = position;
  30214. position -= target.length;
  30215. return position >= 0 && string.slice(position, end) == target;
  30216. }
  30217. /**
  30218. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30219. * corresponding HTML entities.
  30220. *
  30221. * **Note:** No other characters are escaped. To escape additional
  30222. * characters use a third-party library like [_he_](https://mths.be/he).
  30223. *
  30224. * Though the ">" character is escaped for symmetry, characters like
  30225. * ">" and "/" don't need escaping in HTML and have no special meaning
  30226. * unless they're part of a tag or unquoted attribute value. See
  30227. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30228. * (under "semi-related fun fact") for more details.
  30229. *
  30230. * When working with HTML you should always
  30231. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30232. * XSS vectors.
  30233. *
  30234. * @static
  30235. * @since 0.1.0
  30236. * @memberOf _
  30237. * @category String
  30238. * @param {string} [string=''] The string to escape.
  30239. * @returns {string} Returns the escaped string.
  30240. * @example
  30241. *
  30242. * _.escape('fred, barney, & pebbles');
  30243. * // => 'fred, barney, &amp; pebbles'
  30244. */
  30245. function escape(string) {
  30246. string = toString(string);
  30247. return (string && reHasUnescapedHtml.test(string))
  30248. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30249. : string;
  30250. }
  30251. /**
  30252. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30253. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30254. *
  30255. * @static
  30256. * @memberOf _
  30257. * @since 3.0.0
  30258. * @category String
  30259. * @param {string} [string=''] The string to escape.
  30260. * @returns {string} Returns the escaped string.
  30261. * @example
  30262. *
  30263. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30264. * // => '\[lodash\]\(https://lodash\.com/\)'
  30265. */
  30266. function escapeRegExp(string) {
  30267. string = toString(string);
  30268. return (string && reHasRegExpChar.test(string))
  30269. ? string.replace(reRegExpChar, '\\$&')
  30270. : string;
  30271. }
  30272. /**
  30273. * Converts `string` to
  30274. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30275. *
  30276. * @static
  30277. * @memberOf _
  30278. * @since 3.0.0
  30279. * @category String
  30280. * @param {string} [string=''] The string to convert.
  30281. * @returns {string} Returns the kebab cased string.
  30282. * @example
  30283. *
  30284. * _.kebabCase('Foo Bar');
  30285. * // => 'foo-bar'
  30286. *
  30287. * _.kebabCase('fooBar');
  30288. * // => 'foo-bar'
  30289. *
  30290. * _.kebabCase('__FOO_BAR__');
  30291. * // => 'foo-bar'
  30292. */
  30293. var kebabCase = createCompounder(function(result, word, index) {
  30294. return result + (index ? '-' : '') + word.toLowerCase();
  30295. });
  30296. /**
  30297. * Converts `string`, as space separated words, to lower case.
  30298. *
  30299. * @static
  30300. * @memberOf _
  30301. * @since 4.0.0
  30302. * @category String
  30303. * @param {string} [string=''] The string to convert.
  30304. * @returns {string} Returns the lower cased string.
  30305. * @example
  30306. *
  30307. * _.lowerCase('--Foo-Bar--');
  30308. * // => 'foo bar'
  30309. *
  30310. * _.lowerCase('fooBar');
  30311. * // => 'foo bar'
  30312. *
  30313. * _.lowerCase('__FOO_BAR__');
  30314. * // => 'foo bar'
  30315. */
  30316. var lowerCase = createCompounder(function(result, word, index) {
  30317. return result + (index ? ' ' : '') + word.toLowerCase();
  30318. });
  30319. /**
  30320. * Converts the first character of `string` to lower case.
  30321. *
  30322. * @static
  30323. * @memberOf _
  30324. * @since 4.0.0
  30325. * @category String
  30326. * @param {string} [string=''] The string to convert.
  30327. * @returns {string} Returns the converted string.
  30328. * @example
  30329. *
  30330. * _.lowerFirst('Fred');
  30331. * // => 'fred'
  30332. *
  30333. * _.lowerFirst('FRED');
  30334. * // => 'fRED'
  30335. */
  30336. var lowerFirst = createCaseFirst('toLowerCase');
  30337. /**
  30338. * Pads `string` on the left and right sides if it's shorter than `length`.
  30339. * Padding characters are truncated if they can't be evenly divided by `length`.
  30340. *
  30341. * @static
  30342. * @memberOf _
  30343. * @since 3.0.0
  30344. * @category String
  30345. * @param {string} [string=''] The string to pad.
  30346. * @param {number} [length=0] The padding length.
  30347. * @param {string} [chars=' '] The string used as padding.
  30348. * @returns {string} Returns the padded string.
  30349. * @example
  30350. *
  30351. * _.pad('abc', 8);
  30352. * // => ' abc '
  30353. *
  30354. * _.pad('abc', 8, '_-');
  30355. * // => '_-abc_-_'
  30356. *
  30357. * _.pad('abc', 3);
  30358. * // => 'abc'
  30359. */
  30360. function pad(string, length, chars) {
  30361. string = toString(string);
  30362. length = toInteger(length);
  30363. var strLength = length ? stringSize(string) : 0;
  30364. if (!length || strLength >= length) {
  30365. return string;
  30366. }
  30367. var mid = (length - strLength) / 2;
  30368. return (
  30369. createPadding(nativeFloor(mid), chars) +
  30370. string +
  30371. createPadding(nativeCeil(mid), chars)
  30372. );
  30373. }
  30374. /**
  30375. * Pads `string` on the right side if it's shorter than `length`. Padding
  30376. * characters are truncated if they exceed `length`.
  30377. *
  30378. * @static
  30379. * @memberOf _
  30380. * @since 4.0.0
  30381. * @category String
  30382. * @param {string} [string=''] The string to pad.
  30383. * @param {number} [length=0] The padding length.
  30384. * @param {string} [chars=' '] The string used as padding.
  30385. * @returns {string} Returns the padded string.
  30386. * @example
  30387. *
  30388. * _.padEnd('abc', 6);
  30389. * // => 'abc '
  30390. *
  30391. * _.padEnd('abc', 6, '_-');
  30392. * // => 'abc_-_'
  30393. *
  30394. * _.padEnd('abc', 3);
  30395. * // => 'abc'
  30396. */
  30397. function padEnd(string, length, chars) {
  30398. string = toString(string);
  30399. length = toInteger(length);
  30400. var strLength = length ? stringSize(string) : 0;
  30401. return (length && strLength < length)
  30402. ? (string + createPadding(length - strLength, chars))
  30403. : string;
  30404. }
  30405. /**
  30406. * Pads `string` on the left side if it's shorter than `length`. Padding
  30407. * characters are truncated if they exceed `length`.
  30408. *
  30409. * @static
  30410. * @memberOf _
  30411. * @since 4.0.0
  30412. * @category String
  30413. * @param {string} [string=''] The string to pad.
  30414. * @param {number} [length=0] The padding length.
  30415. * @param {string} [chars=' '] The string used as padding.
  30416. * @returns {string} Returns the padded string.
  30417. * @example
  30418. *
  30419. * _.padStart('abc', 6);
  30420. * // => ' abc'
  30421. *
  30422. * _.padStart('abc', 6, '_-');
  30423. * // => '_-_abc'
  30424. *
  30425. * _.padStart('abc', 3);
  30426. * // => 'abc'
  30427. */
  30428. function padStart(string, length, chars) {
  30429. string = toString(string);
  30430. length = toInteger(length);
  30431. var strLength = length ? stringSize(string) : 0;
  30432. return (length && strLength < length)
  30433. ? (createPadding(length - strLength, chars) + string)
  30434. : string;
  30435. }
  30436. /**
  30437. * Converts `string` to an integer of the specified radix. If `radix` is
  30438. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30439. * hexadecimal, in which case a `radix` of `16` is used.
  30440. *
  30441. * **Note:** This method aligns with the
  30442. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30443. *
  30444. * @static
  30445. * @memberOf _
  30446. * @since 1.1.0
  30447. * @category String
  30448. * @param {string} string The string to convert.
  30449. * @param {number} [radix=10] The radix to interpret `value` by.
  30450. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30451. * @returns {number} Returns the converted integer.
  30452. * @example
  30453. *
  30454. * _.parseInt('08');
  30455. * // => 8
  30456. *
  30457. * _.map(['6', '08', '10'], _.parseInt);
  30458. * // => [6, 8, 10]
  30459. */
  30460. function parseInt(string, radix, guard) {
  30461. if (guard || radix == null) {
  30462. radix = 0;
  30463. } else if (radix) {
  30464. radix = +radix;
  30465. }
  30466. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30467. }
  30468. /**
  30469. * Repeats the given string `n` times.
  30470. *
  30471. * @static
  30472. * @memberOf _
  30473. * @since 3.0.0
  30474. * @category String
  30475. * @param {string} [string=''] The string to repeat.
  30476. * @param {number} [n=1] The number of times to repeat the string.
  30477. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30478. * @returns {string} Returns the repeated string.
  30479. * @example
  30480. *
  30481. * _.repeat('*', 3);
  30482. * // => '***'
  30483. *
  30484. * _.repeat('abc', 2);
  30485. * // => 'abcabc'
  30486. *
  30487. * _.repeat('abc', 0);
  30488. * // => ''
  30489. */
  30490. function repeat(string, n, guard) {
  30491. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30492. n = 1;
  30493. } else {
  30494. n = toInteger(n);
  30495. }
  30496. return baseRepeat(toString(string), n);
  30497. }
  30498. /**
  30499. * Replaces matches for `pattern` in `string` with `replacement`.
  30500. *
  30501. * **Note:** This method is based on
  30502. * [`String#replace`](https://mdn.io/String/replace).
  30503. *
  30504. * @static
  30505. * @memberOf _
  30506. * @since 4.0.0
  30507. * @category String
  30508. * @param {string} [string=''] The string to modify.
  30509. * @param {RegExp|string} pattern The pattern to replace.
  30510. * @param {Function|string} replacement The match replacement.
  30511. * @returns {string} Returns the modified string.
  30512. * @example
  30513. *
  30514. * _.replace('Hi Fred', 'Fred', 'Barney');
  30515. * // => 'Hi Barney'
  30516. */
  30517. function replace() {
  30518. var args = arguments,
  30519. string = toString(args[0]);
  30520. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30521. }
  30522. /**
  30523. * Converts `string` to
  30524. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30525. *
  30526. * @static
  30527. * @memberOf _
  30528. * @since 3.0.0
  30529. * @category String
  30530. * @param {string} [string=''] The string to convert.
  30531. * @returns {string} Returns the snake cased string.
  30532. * @example
  30533. *
  30534. * _.snakeCase('Foo Bar');
  30535. * // => 'foo_bar'
  30536. *
  30537. * _.snakeCase('fooBar');
  30538. * // => 'foo_bar'
  30539. *
  30540. * _.snakeCase('--FOO-BAR--');
  30541. * // => 'foo_bar'
  30542. */
  30543. var snakeCase = createCompounder(function(result, word, index) {
  30544. return result + (index ? '_' : '') + word.toLowerCase();
  30545. });
  30546. /**
  30547. * Splits `string` by `separator`.
  30548. *
  30549. * **Note:** This method is based on
  30550. * [`String#split`](https://mdn.io/String/split).
  30551. *
  30552. * @static
  30553. * @memberOf _
  30554. * @since 4.0.0
  30555. * @category String
  30556. * @param {string} [string=''] The string to split.
  30557. * @param {RegExp|string} separator The separator pattern to split by.
  30558. * @param {number} [limit] The length to truncate results to.
  30559. * @returns {Array} Returns the string segments.
  30560. * @example
  30561. *
  30562. * _.split('a-b-c', '-', 2);
  30563. * // => ['a', 'b']
  30564. */
  30565. function split(string, separator, limit) {
  30566. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30567. separator = limit = undefined;
  30568. }
  30569. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30570. if (!limit) {
  30571. return [];
  30572. }
  30573. string = toString(string);
  30574. if (string && (
  30575. typeof separator == 'string' ||
  30576. (separator != null && !isRegExp(separator))
  30577. )) {
  30578. separator = baseToString(separator);
  30579. if (!separator && hasUnicode(string)) {
  30580. return castSlice(stringToArray(string), 0, limit);
  30581. }
  30582. }
  30583. return string.split(separator, limit);
  30584. }
  30585. /**
  30586. * Converts `string` to
  30587. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30588. *
  30589. * @static
  30590. * @memberOf _
  30591. * @since 3.1.0
  30592. * @category String
  30593. * @param {string} [string=''] The string to convert.
  30594. * @returns {string} Returns the start cased string.
  30595. * @example
  30596. *
  30597. * _.startCase('--foo-bar--');
  30598. * // => 'Foo Bar'
  30599. *
  30600. * _.startCase('fooBar');
  30601. * // => 'Foo Bar'
  30602. *
  30603. * _.startCase('__FOO_BAR__');
  30604. * // => 'FOO BAR'
  30605. */
  30606. var startCase = createCompounder(function(result, word, index) {
  30607. return result + (index ? ' ' : '') + upperFirst(word);
  30608. });
  30609. /**
  30610. * Checks if `string` starts with the given target string.
  30611. *
  30612. * @static
  30613. * @memberOf _
  30614. * @since 3.0.0
  30615. * @category String
  30616. * @param {string} [string=''] The string to inspect.
  30617. * @param {string} [target] The string to search for.
  30618. * @param {number} [position=0] The position to search from.
  30619. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30620. * else `false`.
  30621. * @example
  30622. *
  30623. * _.startsWith('abc', 'a');
  30624. * // => true
  30625. *
  30626. * _.startsWith('abc', 'b');
  30627. * // => false
  30628. *
  30629. * _.startsWith('abc', 'b', 1);
  30630. * // => true
  30631. */
  30632. function startsWith(string, target, position) {
  30633. string = toString(string);
  30634. position = position == null
  30635. ? 0
  30636. : baseClamp(toInteger(position), 0, string.length);
  30637. target = baseToString(target);
  30638. return string.slice(position, position + target.length) == target;
  30639. }
  30640. /**
  30641. * Creates a compiled template function that can interpolate data properties
  30642. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30643. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30644. * properties may be accessed as free variables in the template. If a setting
  30645. * object is given, it takes precedence over `_.templateSettings` values.
  30646. *
  30647. * **Note:** In the development build `_.template` utilizes
  30648. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30649. * for easier debugging.
  30650. *
  30651. * For more information on precompiling templates see
  30652. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30653. *
  30654. * For more information on Chrome extension sandboxes see
  30655. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30656. *
  30657. * @static
  30658. * @since 0.1.0
  30659. * @memberOf _
  30660. * @category String
  30661. * @param {string} [string=''] The template string.
  30662. * @param {Object} [options={}] The options object.
  30663. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30664. * The HTML "escape" delimiter.
  30665. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30666. * The "evaluate" delimiter.
  30667. * @param {Object} [options.imports=_.templateSettings.imports]
  30668. * An object to import into the template as free variables.
  30669. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30670. * The "interpolate" delimiter.
  30671. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30672. * The sourceURL of the compiled template.
  30673. * @param {string} [options.variable='obj']
  30674. * The data object variable name.
  30675. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30676. * @returns {Function} Returns the compiled template function.
  30677. * @example
  30678. *
  30679. * // Use the "interpolate" delimiter to create a compiled template.
  30680. * var compiled = _.template('hello <%= user %>!');
  30681. * compiled({ 'user': 'fred' });
  30682. * // => 'hello fred!'
  30683. *
  30684. * // Use the HTML "escape" delimiter to escape data property values.
  30685. * var compiled = _.template('<b><%- value %></b>');
  30686. * compiled({ 'value': '<script>' });
  30687. * // => '<b>&lt;script&gt;</b>'
  30688. *
  30689. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30690. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30691. * compiled({ 'users': ['fred', 'barney'] });
  30692. * // => '<li>fred</li><li>barney</li>'
  30693. *
  30694. * // Use the internal `print` function in "evaluate" delimiters.
  30695. * var compiled = _.template('<% print("hello " + user); %>!');
  30696. * compiled({ 'user': 'barney' });
  30697. * // => 'hello barney!'
  30698. *
  30699. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30700. * // Disable support by replacing the "interpolate" delimiter.
  30701. * var compiled = _.template('hello ${ user }!');
  30702. * compiled({ 'user': 'pebbles' });
  30703. * // => 'hello pebbles!'
  30704. *
  30705. * // Use backslashes to treat delimiters as plain text.
  30706. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30707. * compiled({ 'value': 'ignored' });
  30708. * // => '<%- value %>'
  30709. *
  30710. * // Use the `imports` option to import `jQuery` as `jq`.
  30711. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30712. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30713. * compiled({ 'users': ['fred', 'barney'] });
  30714. * // => '<li>fred</li><li>barney</li>'
  30715. *
  30716. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30717. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30718. * compiled(data);
  30719. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30720. *
  30721. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30722. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30723. * compiled.source;
  30724. * // => function(data) {
  30725. * // var __t, __p = '';
  30726. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30727. * // return __p;
  30728. * // }
  30729. *
  30730. * // Use custom template delimiters.
  30731. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30732. * var compiled = _.template('hello {{ user }}!');
  30733. * compiled({ 'user': 'mustache' });
  30734. * // => 'hello mustache!'
  30735. *
  30736. * // Use the `source` property to inline compiled templates for meaningful
  30737. * // line numbers in error messages and stack traces.
  30738. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30739. * var JST = {\
  30740. * "main": ' + _.template(mainText).source + '\
  30741. * };\
  30742. * ');
  30743. */
  30744. function template(string, options, guard) {
  30745. // Based on John Resig's `tmpl` implementation
  30746. // (http://ejohn.org/blog/javascript-micro-templating/)
  30747. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30748. var settings = lodash.templateSettings;
  30749. if (guard && isIterateeCall(string, options, guard)) {
  30750. options = undefined;
  30751. }
  30752. string = toString(string);
  30753. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30754. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30755. importsKeys = keys(imports),
  30756. importsValues = baseValues(imports, importsKeys);
  30757. var isEscaping,
  30758. isEvaluating,
  30759. index = 0,
  30760. interpolate = options.interpolate || reNoMatch,
  30761. source = "__p += '";
  30762. // Compile the regexp to match each delimiter.
  30763. var reDelimiters = RegExp(
  30764. (options.escape || reNoMatch).source + '|' +
  30765. interpolate.source + '|' +
  30766. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30767. (options.evaluate || reNoMatch).source + '|$'
  30768. , 'g');
  30769. // Use a sourceURL for easier debugging.
  30770. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30771. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30772. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30773. var sourceURL = '//# sourceURL=' +
  30774. (hasOwnProperty.call(options, 'sourceURL')
  30775. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30776. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30777. ) + '\n';
  30778. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30779. interpolateValue || (interpolateValue = esTemplateValue);
  30780. // Escape characters that can't be included in string literals.
  30781. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30782. // Replace delimiters with snippets.
  30783. if (escapeValue) {
  30784. isEscaping = true;
  30785. source += "' +\n__e(" + escapeValue + ") +\n'";
  30786. }
  30787. if (evaluateValue) {
  30788. isEvaluating = true;
  30789. source += "';\n" + evaluateValue + ";\n__p += '";
  30790. }
  30791. if (interpolateValue) {
  30792. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30793. }
  30794. index = offset + match.length;
  30795. // The JS engine embedded in Adobe products needs `match` returned in
  30796. // order to produce the correct `offset` value.
  30797. return match;
  30798. });
  30799. source += "';\n";
  30800. // If `variable` is not specified wrap a with-statement around the generated
  30801. // code to add the data object to the top of the scope chain.
  30802. // Like with sourceURL, we take care to not check the option's prototype,
  30803. // as this configuration is a code injection vector.
  30804. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30805. if (!variable) {
  30806. source = 'with (obj) {\n' + source + '\n}\n';
  30807. }
  30808. // Cleanup code by stripping empty strings.
  30809. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30810. .replace(reEmptyStringMiddle, '$1')
  30811. .replace(reEmptyStringTrailing, '$1;');
  30812. // Frame code as the function body.
  30813. source = 'function(' + (variable || 'obj') + ') {\n' +
  30814. (variable
  30815. ? ''
  30816. : 'obj || (obj = {});\n'
  30817. ) +
  30818. "var __t, __p = ''" +
  30819. (isEscaping
  30820. ? ', __e = _.escape'
  30821. : ''
  30822. ) +
  30823. (isEvaluating
  30824. ? ', __j = Array.prototype.join;\n' +
  30825. "function print() { __p += __j.call(arguments, '') }\n"
  30826. : ';\n'
  30827. ) +
  30828. source +
  30829. 'return __p\n}';
  30830. var result = attempt(function() {
  30831. return Function(importsKeys, sourceURL + 'return ' + source)
  30832. .apply(undefined, importsValues);
  30833. });
  30834. // Provide the compiled function's source by its `toString` method or
  30835. // the `source` property as a convenience for inlining compiled templates.
  30836. result.source = source;
  30837. if (isError(result)) {
  30838. throw result;
  30839. }
  30840. return result;
  30841. }
  30842. /**
  30843. * Converts `string`, as a whole, to lower case just like
  30844. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30845. *
  30846. * @static
  30847. * @memberOf _
  30848. * @since 4.0.0
  30849. * @category String
  30850. * @param {string} [string=''] The string to convert.
  30851. * @returns {string} Returns the lower cased string.
  30852. * @example
  30853. *
  30854. * _.toLower('--Foo-Bar--');
  30855. * // => '--foo-bar--'
  30856. *
  30857. * _.toLower('fooBar');
  30858. * // => 'foobar'
  30859. *
  30860. * _.toLower('__FOO_BAR__');
  30861. * // => '__foo_bar__'
  30862. */
  30863. function toLower(value) {
  30864. return toString(value).toLowerCase();
  30865. }
  30866. /**
  30867. * Converts `string`, as a whole, to upper case just like
  30868. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30869. *
  30870. * @static
  30871. * @memberOf _
  30872. * @since 4.0.0
  30873. * @category String
  30874. * @param {string} [string=''] The string to convert.
  30875. * @returns {string} Returns the upper cased string.
  30876. * @example
  30877. *
  30878. * _.toUpper('--foo-bar--');
  30879. * // => '--FOO-BAR--'
  30880. *
  30881. * _.toUpper('fooBar');
  30882. * // => 'FOOBAR'
  30883. *
  30884. * _.toUpper('__foo_bar__');
  30885. * // => '__FOO_BAR__'
  30886. */
  30887. function toUpper(value) {
  30888. return toString(value).toUpperCase();
  30889. }
  30890. /**
  30891. * Removes leading and trailing whitespace or specified characters from `string`.
  30892. *
  30893. * @static
  30894. * @memberOf _
  30895. * @since 3.0.0
  30896. * @category String
  30897. * @param {string} [string=''] The string to trim.
  30898. * @param {string} [chars=whitespace] The characters to trim.
  30899. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30900. * @returns {string} Returns the trimmed string.
  30901. * @example
  30902. *
  30903. * _.trim(' abc ');
  30904. * // => 'abc'
  30905. *
  30906. * _.trim('-_-abc-_-', '_-');
  30907. * // => 'abc'
  30908. *
  30909. * _.map([' foo ', ' bar '], _.trim);
  30910. * // => ['foo', 'bar']
  30911. */
  30912. function trim(string, chars, guard) {
  30913. string = toString(string);
  30914. if (string && (guard || chars === undefined)) {
  30915. return string.replace(reTrim, '');
  30916. }
  30917. if (!string || !(chars = baseToString(chars))) {
  30918. return string;
  30919. }
  30920. var strSymbols = stringToArray(string),
  30921. chrSymbols = stringToArray(chars),
  30922. start = charsStartIndex(strSymbols, chrSymbols),
  30923. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30924. return castSlice(strSymbols, start, end).join('');
  30925. }
  30926. /**
  30927. * Removes trailing whitespace or specified characters from `string`.
  30928. *
  30929. * @static
  30930. * @memberOf _
  30931. * @since 4.0.0
  30932. * @category String
  30933. * @param {string} [string=''] The string to trim.
  30934. * @param {string} [chars=whitespace] The characters to trim.
  30935. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30936. * @returns {string} Returns the trimmed string.
  30937. * @example
  30938. *
  30939. * _.trimEnd(' abc ');
  30940. * // => ' abc'
  30941. *
  30942. * _.trimEnd('-_-abc-_-', '_-');
  30943. * // => '-_-abc'
  30944. */
  30945. function trimEnd(string, chars, guard) {
  30946. string = toString(string);
  30947. if (string && (guard || chars === undefined)) {
  30948. return string.replace(reTrimEnd, '');
  30949. }
  30950. if (!string || !(chars = baseToString(chars))) {
  30951. return string;
  30952. }
  30953. var strSymbols = stringToArray(string),
  30954. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30955. return castSlice(strSymbols, 0, end).join('');
  30956. }
  30957. /**
  30958. * Removes leading whitespace or specified characters from `string`.
  30959. *
  30960. * @static
  30961. * @memberOf _
  30962. * @since 4.0.0
  30963. * @category String
  30964. * @param {string} [string=''] The string to trim.
  30965. * @param {string} [chars=whitespace] The characters to trim.
  30966. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30967. * @returns {string} Returns the trimmed string.
  30968. * @example
  30969. *
  30970. * _.trimStart(' abc ');
  30971. * // => 'abc '
  30972. *
  30973. * _.trimStart('-_-abc-_-', '_-');
  30974. * // => 'abc-_-'
  30975. */
  30976. function trimStart(string, chars, guard) {
  30977. string = toString(string);
  30978. if (string && (guard || chars === undefined)) {
  30979. return string.replace(reTrimStart, '');
  30980. }
  30981. if (!string || !(chars = baseToString(chars))) {
  30982. return string;
  30983. }
  30984. var strSymbols = stringToArray(string),
  30985. start = charsStartIndex(strSymbols, stringToArray(chars));
  30986. return castSlice(strSymbols, start).join('');
  30987. }
  30988. /**
  30989. * Truncates `string` if it's longer than the given maximum string length.
  30990. * The last characters of the truncated string are replaced with the omission
  30991. * string which defaults to "...".
  30992. *
  30993. * @static
  30994. * @memberOf _
  30995. * @since 4.0.0
  30996. * @category String
  30997. * @param {string} [string=''] The string to truncate.
  30998. * @param {Object} [options={}] The options object.
  30999. * @param {number} [options.length=30] The maximum string length.
  31000. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31001. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31002. * @returns {string} Returns the truncated string.
  31003. * @example
  31004. *
  31005. * _.truncate('hi-diddly-ho there, neighborino');
  31006. * // => 'hi-diddly-ho there, neighbo...'
  31007. *
  31008. * _.truncate('hi-diddly-ho there, neighborino', {
  31009. * 'length': 24,
  31010. * 'separator': ' '
  31011. * });
  31012. * // => 'hi-diddly-ho there,...'
  31013. *
  31014. * _.truncate('hi-diddly-ho there, neighborino', {
  31015. * 'length': 24,
  31016. * 'separator': /,? +/
  31017. * });
  31018. * // => 'hi-diddly-ho there...'
  31019. *
  31020. * _.truncate('hi-diddly-ho there, neighborino', {
  31021. * 'omission': ' [...]'
  31022. * });
  31023. * // => 'hi-diddly-ho there, neig [...]'
  31024. */
  31025. function truncate(string, options) {
  31026. var length = DEFAULT_TRUNC_LENGTH,
  31027. omission = DEFAULT_TRUNC_OMISSION;
  31028. if (isObject(options)) {
  31029. var separator = 'separator' in options ? options.separator : separator;
  31030. length = 'length' in options ? toInteger(options.length) : length;
  31031. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31032. }
  31033. string = toString(string);
  31034. var strLength = string.length;
  31035. if (hasUnicode(string)) {
  31036. var strSymbols = stringToArray(string);
  31037. strLength = strSymbols.length;
  31038. }
  31039. if (length >= strLength) {
  31040. return string;
  31041. }
  31042. var end = length - stringSize(omission);
  31043. if (end < 1) {
  31044. return omission;
  31045. }
  31046. var result = strSymbols
  31047. ? castSlice(strSymbols, 0, end).join('')
  31048. : string.slice(0, end);
  31049. if (separator === undefined) {
  31050. return result + omission;
  31051. }
  31052. if (strSymbols) {
  31053. end += (result.length - end);
  31054. }
  31055. if (isRegExp(separator)) {
  31056. if (string.slice(end).search(separator)) {
  31057. var match,
  31058. substring = result;
  31059. if (!separator.global) {
  31060. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31061. }
  31062. separator.lastIndex = 0;
  31063. while ((match = separator.exec(substring))) {
  31064. var newEnd = match.index;
  31065. }
  31066. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31067. }
  31068. } else if (string.indexOf(baseToString(separator), end) != end) {
  31069. var index = result.lastIndexOf(separator);
  31070. if (index > -1) {
  31071. result = result.slice(0, index);
  31072. }
  31073. }
  31074. return result + omission;
  31075. }
  31076. /**
  31077. * The inverse of `_.escape`; this method converts the HTML entities
  31078. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31079. * their corresponding characters.
  31080. *
  31081. * **Note:** No other HTML entities are unescaped. To unescape additional
  31082. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31083. *
  31084. * @static
  31085. * @memberOf _
  31086. * @since 0.6.0
  31087. * @category String
  31088. * @param {string} [string=''] The string to unescape.
  31089. * @returns {string} Returns the unescaped string.
  31090. * @example
  31091. *
  31092. * _.unescape('fred, barney, &amp; pebbles');
  31093. * // => 'fred, barney, & pebbles'
  31094. */
  31095. function unescape(string) {
  31096. string = toString(string);
  31097. return (string && reHasEscapedHtml.test(string))
  31098. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31099. : string;
  31100. }
  31101. /**
  31102. * Converts `string`, as space separated words, to upper case.
  31103. *
  31104. * @static
  31105. * @memberOf _
  31106. * @since 4.0.0
  31107. * @category String
  31108. * @param {string} [string=''] The string to convert.
  31109. * @returns {string} Returns the upper cased string.
  31110. * @example
  31111. *
  31112. * _.upperCase('--foo-bar');
  31113. * // => 'FOO BAR'
  31114. *
  31115. * _.upperCase('fooBar');
  31116. * // => 'FOO BAR'
  31117. *
  31118. * _.upperCase('__foo_bar__');
  31119. * // => 'FOO BAR'
  31120. */
  31121. var upperCase = createCompounder(function(result, word, index) {
  31122. return result + (index ? ' ' : '') + word.toUpperCase();
  31123. });
  31124. /**
  31125. * Converts the first character of `string` to upper case.
  31126. *
  31127. * @static
  31128. * @memberOf _
  31129. * @since 4.0.0
  31130. * @category String
  31131. * @param {string} [string=''] The string to convert.
  31132. * @returns {string} Returns the converted string.
  31133. * @example
  31134. *
  31135. * _.upperFirst('fred');
  31136. * // => 'Fred'
  31137. *
  31138. * _.upperFirst('FRED');
  31139. * // => 'FRED'
  31140. */
  31141. var upperFirst = createCaseFirst('toUpperCase');
  31142. /**
  31143. * Splits `string` into an array of its words.
  31144. *
  31145. * @static
  31146. * @memberOf _
  31147. * @since 3.0.0
  31148. * @category String
  31149. * @param {string} [string=''] The string to inspect.
  31150. * @param {RegExp|string} [pattern] The pattern to match words.
  31151. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31152. * @returns {Array} Returns the words of `string`.
  31153. * @example
  31154. *
  31155. * _.words('fred, barney, & pebbles');
  31156. * // => ['fred', 'barney', 'pebbles']
  31157. *
  31158. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31159. * // => ['fred', 'barney', '&', 'pebbles']
  31160. */
  31161. function words(string, pattern, guard) {
  31162. string = toString(string);
  31163. pattern = guard ? undefined : pattern;
  31164. if (pattern === undefined) {
  31165. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31166. }
  31167. return string.match(pattern) || [];
  31168. }
  31169. /*------------------------------------------------------------------------*/
  31170. /**
  31171. * Attempts to invoke `func`, returning either the result or the caught error
  31172. * object. Any additional arguments are provided to `func` when it's invoked.
  31173. *
  31174. * @static
  31175. * @memberOf _
  31176. * @since 3.0.0
  31177. * @category Util
  31178. * @param {Function} func The function to attempt.
  31179. * @param {...*} [args] The arguments to invoke `func` with.
  31180. * @returns {*} Returns the `func` result or error object.
  31181. * @example
  31182. *
  31183. * // Avoid throwing errors for invalid selectors.
  31184. * var elements = _.attempt(function(selector) {
  31185. * return document.querySelectorAll(selector);
  31186. * }, '>_>');
  31187. *
  31188. * if (_.isError(elements)) {
  31189. * elements = [];
  31190. * }
  31191. */
  31192. var attempt = baseRest(function(func, args) {
  31193. try {
  31194. return apply(func, undefined, args);
  31195. } catch (e) {
  31196. return isError(e) ? e : new Error(e);
  31197. }
  31198. });
  31199. /**
  31200. * Binds methods of an object to the object itself, overwriting the existing
  31201. * method.
  31202. *
  31203. * **Note:** This method doesn't set the "length" property of bound functions.
  31204. *
  31205. * @static
  31206. * @since 0.1.0
  31207. * @memberOf _
  31208. * @category Util
  31209. * @param {Object} object The object to bind and assign the bound methods to.
  31210. * @param {...(string|string[])} methodNames The object method names to bind.
  31211. * @returns {Object} Returns `object`.
  31212. * @example
  31213. *
  31214. * var view = {
  31215. * 'label': 'docs',
  31216. * 'click': function() {
  31217. * console.log('clicked ' + this.label);
  31218. * }
  31219. * };
  31220. *
  31221. * _.bindAll(view, ['click']);
  31222. * jQuery(element).on('click', view.click);
  31223. * // => Logs 'clicked docs' when clicked.
  31224. */
  31225. var bindAll = flatRest(function(object, methodNames) {
  31226. arrayEach(methodNames, function(key) {
  31227. key = toKey(key);
  31228. baseAssignValue(object, key, bind(object[key], object));
  31229. });
  31230. return object;
  31231. });
  31232. /**
  31233. * Creates a function that iterates over `pairs` and invokes the corresponding
  31234. * function of the first predicate to return truthy. The predicate-function
  31235. * pairs are invoked with the `this` binding and arguments of the created
  31236. * function.
  31237. *
  31238. * @static
  31239. * @memberOf _
  31240. * @since 4.0.0
  31241. * @category Util
  31242. * @param {Array} pairs The predicate-function pairs.
  31243. * @returns {Function} Returns the new composite function.
  31244. * @example
  31245. *
  31246. * var func = _.cond([
  31247. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31248. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31249. * [_.stubTrue, _.constant('no match')]
  31250. * ]);
  31251. *
  31252. * func({ 'a': 1, 'b': 2 });
  31253. * // => 'matches A'
  31254. *
  31255. * func({ 'a': 0, 'b': 1 });
  31256. * // => 'matches B'
  31257. *
  31258. * func({ 'a': '1', 'b': '2' });
  31259. * // => 'no match'
  31260. */
  31261. function cond(pairs) {
  31262. var length = pairs == null ? 0 : pairs.length,
  31263. toIteratee = getIteratee();
  31264. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31265. if (typeof pair[1] != 'function') {
  31266. throw new TypeError(FUNC_ERROR_TEXT);
  31267. }
  31268. return [toIteratee(pair[0]), pair[1]];
  31269. });
  31270. return baseRest(function(args) {
  31271. var index = -1;
  31272. while (++index < length) {
  31273. var pair = pairs[index];
  31274. if (apply(pair[0], this, args)) {
  31275. return apply(pair[1], this, args);
  31276. }
  31277. }
  31278. });
  31279. }
  31280. /**
  31281. * Creates a function that invokes the predicate properties of `source` with
  31282. * the corresponding property values of a given object, returning `true` if
  31283. * all predicates return truthy, else `false`.
  31284. *
  31285. * **Note:** The created function is equivalent to `_.conformsTo` with
  31286. * `source` partially applied.
  31287. *
  31288. * @static
  31289. * @memberOf _
  31290. * @since 4.0.0
  31291. * @category Util
  31292. * @param {Object} source The object of property predicates to conform to.
  31293. * @returns {Function} Returns the new spec function.
  31294. * @example
  31295. *
  31296. * var objects = [
  31297. * { 'a': 2, 'b': 1 },
  31298. * { 'a': 1, 'b': 2 }
  31299. * ];
  31300. *
  31301. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31302. * // => [{ 'a': 1, 'b': 2 }]
  31303. */
  31304. function conforms(source) {
  31305. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31306. }
  31307. /**
  31308. * Creates a function that returns `value`.
  31309. *
  31310. * @static
  31311. * @memberOf _
  31312. * @since 2.4.0
  31313. * @category Util
  31314. * @param {*} value The value to return from the new function.
  31315. * @returns {Function} Returns the new constant function.
  31316. * @example
  31317. *
  31318. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31319. *
  31320. * console.log(objects);
  31321. * // => [{ 'a': 1 }, { 'a': 1 }]
  31322. *
  31323. * console.log(objects[0] === objects[1]);
  31324. * // => true
  31325. */
  31326. function constant(value) {
  31327. return function() {
  31328. return value;
  31329. };
  31330. }
  31331. /**
  31332. * Checks `value` to determine whether a default value should be returned in
  31333. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31334. * or `undefined`.
  31335. *
  31336. * @static
  31337. * @memberOf _
  31338. * @since 4.14.0
  31339. * @category Util
  31340. * @param {*} value The value to check.
  31341. * @param {*} defaultValue The default value.
  31342. * @returns {*} Returns the resolved value.
  31343. * @example
  31344. *
  31345. * _.defaultTo(1, 10);
  31346. * // => 1
  31347. *
  31348. * _.defaultTo(undefined, 10);
  31349. * // => 10
  31350. */
  31351. function defaultTo(value, defaultValue) {
  31352. return (value == null || value !== value) ? defaultValue : value;
  31353. }
  31354. /**
  31355. * Creates a function that returns the result of invoking the given functions
  31356. * with the `this` binding of the created function, where each successive
  31357. * invocation is supplied the return value of the previous.
  31358. *
  31359. * @static
  31360. * @memberOf _
  31361. * @since 3.0.0
  31362. * @category Util
  31363. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31364. * @returns {Function} Returns the new composite function.
  31365. * @see _.flowRight
  31366. * @example
  31367. *
  31368. * function square(n) {
  31369. * return n * n;
  31370. * }
  31371. *
  31372. * var addSquare = _.flow([_.add, square]);
  31373. * addSquare(1, 2);
  31374. * // => 9
  31375. */
  31376. var flow = createFlow();
  31377. /**
  31378. * This method is like `_.flow` except that it creates a function that
  31379. * invokes the given functions from right to left.
  31380. *
  31381. * @static
  31382. * @since 3.0.0
  31383. * @memberOf _
  31384. * @category Util
  31385. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31386. * @returns {Function} Returns the new composite function.
  31387. * @see _.flow
  31388. * @example
  31389. *
  31390. * function square(n) {
  31391. * return n * n;
  31392. * }
  31393. *
  31394. * var addSquare = _.flowRight([square, _.add]);
  31395. * addSquare(1, 2);
  31396. * // => 9
  31397. */
  31398. var flowRight = createFlow(true);
  31399. /**
  31400. * This method returns the first argument it receives.
  31401. *
  31402. * @static
  31403. * @since 0.1.0
  31404. * @memberOf _
  31405. * @category Util
  31406. * @param {*} value Any value.
  31407. * @returns {*} Returns `value`.
  31408. * @example
  31409. *
  31410. * var object = { 'a': 1 };
  31411. *
  31412. * console.log(_.identity(object) === object);
  31413. * // => true
  31414. */
  31415. function identity(value) {
  31416. return value;
  31417. }
  31418. /**
  31419. * Creates a function that invokes `func` with the arguments of the created
  31420. * function. If `func` is a property name, the created function returns the
  31421. * property value for a given element. If `func` is an array or object, the
  31422. * created function returns `true` for elements that contain the equivalent
  31423. * source properties, otherwise it returns `false`.
  31424. *
  31425. * @static
  31426. * @since 4.0.0
  31427. * @memberOf _
  31428. * @category Util
  31429. * @param {*} [func=_.identity] The value to convert to a callback.
  31430. * @returns {Function} Returns the callback.
  31431. * @example
  31432. *
  31433. * var users = [
  31434. * { 'user': 'barney', 'age': 36, 'active': true },
  31435. * { 'user': 'fred', 'age': 40, 'active': false }
  31436. * ];
  31437. *
  31438. * // The `_.matches` iteratee shorthand.
  31439. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31440. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31441. *
  31442. * // The `_.matchesProperty` iteratee shorthand.
  31443. * _.filter(users, _.iteratee(['user', 'fred']));
  31444. * // => [{ 'user': 'fred', 'age': 40 }]
  31445. *
  31446. * // The `_.property` iteratee shorthand.
  31447. * _.map(users, _.iteratee('user'));
  31448. * // => ['barney', 'fred']
  31449. *
  31450. * // Create custom iteratee shorthands.
  31451. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31452. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31453. * return func.test(string);
  31454. * };
  31455. * });
  31456. *
  31457. * _.filter(['abc', 'def'], /ef/);
  31458. * // => ['def']
  31459. */
  31460. function iteratee(func) {
  31461. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31462. }
  31463. /**
  31464. * Creates a function that performs a partial deep comparison between a given
  31465. * object and `source`, returning `true` if the given object has equivalent
  31466. * property values, else `false`.
  31467. *
  31468. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31469. * partially applied.
  31470. *
  31471. * Partial comparisons will match empty array and empty object `source`
  31472. * values against any array or object value, respectively. See `_.isEqual`
  31473. * for a list of supported value comparisons.
  31474. *
  31475. * @static
  31476. * @memberOf _
  31477. * @since 3.0.0
  31478. * @category Util
  31479. * @param {Object} source The object of property values to match.
  31480. * @returns {Function} Returns the new spec function.
  31481. * @example
  31482. *
  31483. * var objects = [
  31484. * { 'a': 1, 'b': 2, 'c': 3 },
  31485. * { 'a': 4, 'b': 5, 'c': 6 }
  31486. * ];
  31487. *
  31488. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31489. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31490. */
  31491. function matches(source) {
  31492. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31493. }
  31494. /**
  31495. * Creates a function that performs a partial deep comparison between the
  31496. * value at `path` of a given object to `srcValue`, returning `true` if the
  31497. * object value is equivalent, else `false`.
  31498. *
  31499. * **Note:** Partial comparisons will match empty array and empty object
  31500. * `srcValue` values against any array or object value, respectively. See
  31501. * `_.isEqual` for a list of supported value comparisons.
  31502. *
  31503. * @static
  31504. * @memberOf _
  31505. * @since 3.2.0
  31506. * @category Util
  31507. * @param {Array|string} path The path of the property to get.
  31508. * @param {*} srcValue The value to match.
  31509. * @returns {Function} Returns the new spec function.
  31510. * @example
  31511. *
  31512. * var objects = [
  31513. * { 'a': 1, 'b': 2, 'c': 3 },
  31514. * { 'a': 4, 'b': 5, 'c': 6 }
  31515. * ];
  31516. *
  31517. * _.find(objects, _.matchesProperty('a', 4));
  31518. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31519. */
  31520. function matchesProperty(path, srcValue) {
  31521. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31522. }
  31523. /**
  31524. * Creates a function that invokes the method at `path` of a given object.
  31525. * Any additional arguments are provided to the invoked method.
  31526. *
  31527. * @static
  31528. * @memberOf _
  31529. * @since 3.7.0
  31530. * @category Util
  31531. * @param {Array|string} path The path of the method to invoke.
  31532. * @param {...*} [args] The arguments to invoke the method with.
  31533. * @returns {Function} Returns the new invoker function.
  31534. * @example
  31535. *
  31536. * var objects = [
  31537. * { 'a': { 'b': _.constant(2) } },
  31538. * { 'a': { 'b': _.constant(1) } }
  31539. * ];
  31540. *
  31541. * _.map(objects, _.method('a.b'));
  31542. * // => [2, 1]
  31543. *
  31544. * _.map(objects, _.method(['a', 'b']));
  31545. * // => [2, 1]
  31546. */
  31547. var method = baseRest(function(path, args) {
  31548. return function(object) {
  31549. return baseInvoke(object, path, args);
  31550. };
  31551. });
  31552. /**
  31553. * The opposite of `_.method`; this method creates a function that invokes
  31554. * the method at a given path of `object`. Any additional arguments are
  31555. * provided to the invoked method.
  31556. *
  31557. * @static
  31558. * @memberOf _
  31559. * @since 3.7.0
  31560. * @category Util
  31561. * @param {Object} object The object to query.
  31562. * @param {...*} [args] The arguments to invoke the method with.
  31563. * @returns {Function} Returns the new invoker function.
  31564. * @example
  31565. *
  31566. * var array = _.times(3, _.constant),
  31567. * object = { 'a': array, 'b': array, 'c': array };
  31568. *
  31569. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31570. * // => [2, 0]
  31571. *
  31572. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31573. * // => [2, 0]
  31574. */
  31575. var methodOf = baseRest(function(object, args) {
  31576. return function(path) {
  31577. return baseInvoke(object, path, args);
  31578. };
  31579. });
  31580. /**
  31581. * Adds all own enumerable string keyed function properties of a source
  31582. * object to the destination object. If `object` is a function, then methods
  31583. * are added to its prototype as well.
  31584. *
  31585. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31586. * avoid conflicts caused by modifying the original.
  31587. *
  31588. * @static
  31589. * @since 0.1.0
  31590. * @memberOf _
  31591. * @category Util
  31592. * @param {Function|Object} [object=lodash] The destination object.
  31593. * @param {Object} source The object of functions to add.
  31594. * @param {Object} [options={}] The options object.
  31595. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31596. * @returns {Function|Object} Returns `object`.
  31597. * @example
  31598. *
  31599. * function vowels(string) {
  31600. * return _.filter(string, function(v) {
  31601. * return /[aeiou]/i.test(v);
  31602. * });
  31603. * }
  31604. *
  31605. * _.mixin({ 'vowels': vowels });
  31606. * _.vowels('fred');
  31607. * // => ['e']
  31608. *
  31609. * _('fred').vowels().value();
  31610. * // => ['e']
  31611. *
  31612. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31613. * _('fred').vowels();
  31614. * // => ['e']
  31615. */
  31616. function mixin(object, source, options) {
  31617. var props = keys(source),
  31618. methodNames = baseFunctions(source, props);
  31619. if (options == null &&
  31620. !(isObject(source) && (methodNames.length || !props.length))) {
  31621. options = source;
  31622. source = object;
  31623. object = this;
  31624. methodNames = baseFunctions(source, keys(source));
  31625. }
  31626. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31627. isFunc = isFunction(object);
  31628. arrayEach(methodNames, function(methodName) {
  31629. var func = source[methodName];
  31630. object[methodName] = func;
  31631. if (isFunc) {
  31632. object.prototype[methodName] = function() {
  31633. var chainAll = this.__chain__;
  31634. if (chain || chainAll) {
  31635. var result = object(this.__wrapped__),
  31636. actions = result.__actions__ = copyArray(this.__actions__);
  31637. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31638. result.__chain__ = chainAll;
  31639. return result;
  31640. }
  31641. return func.apply(object, arrayPush([this.value()], arguments));
  31642. };
  31643. }
  31644. });
  31645. return object;
  31646. }
  31647. /**
  31648. * Reverts the `_` variable to its previous value and returns a reference to
  31649. * the `lodash` function.
  31650. *
  31651. * @static
  31652. * @since 0.1.0
  31653. * @memberOf _
  31654. * @category Util
  31655. * @returns {Function} Returns the `lodash` function.
  31656. * @example
  31657. *
  31658. * var lodash = _.noConflict();
  31659. */
  31660. function noConflict() {
  31661. if (root._ === this) {
  31662. root._ = oldDash;
  31663. }
  31664. return this;
  31665. }
  31666. /**
  31667. * This method returns `undefined`.
  31668. *
  31669. * @static
  31670. * @memberOf _
  31671. * @since 2.3.0
  31672. * @category Util
  31673. * @example
  31674. *
  31675. * _.times(2, _.noop);
  31676. * // => [undefined, undefined]
  31677. */
  31678. function noop() {
  31679. // No operation performed.
  31680. }
  31681. /**
  31682. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31683. * the nth argument from the end is returned.
  31684. *
  31685. * @static
  31686. * @memberOf _
  31687. * @since 4.0.0
  31688. * @category Util
  31689. * @param {number} [n=0] The index of the argument to return.
  31690. * @returns {Function} Returns the new pass-thru function.
  31691. * @example
  31692. *
  31693. * var func = _.nthArg(1);
  31694. * func('a', 'b', 'c', 'd');
  31695. * // => 'b'
  31696. *
  31697. * var func = _.nthArg(-2);
  31698. * func('a', 'b', 'c', 'd');
  31699. * // => 'c'
  31700. */
  31701. function nthArg(n) {
  31702. n = toInteger(n);
  31703. return baseRest(function(args) {
  31704. return baseNth(args, n);
  31705. });
  31706. }
  31707. /**
  31708. * Creates a function that invokes `iteratees` with the arguments it receives
  31709. * and returns their results.
  31710. *
  31711. * @static
  31712. * @memberOf _
  31713. * @since 4.0.0
  31714. * @category Util
  31715. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31716. * The iteratees to invoke.
  31717. * @returns {Function} Returns the new function.
  31718. * @example
  31719. *
  31720. * var func = _.over([Math.max, Math.min]);
  31721. *
  31722. * func(1, 2, 3, 4);
  31723. * // => [4, 1]
  31724. */
  31725. var over = createOver(arrayMap);
  31726. /**
  31727. * Creates a function that checks if **all** of the `predicates` return
  31728. * truthy when invoked with the arguments it receives.
  31729. *
  31730. * @static
  31731. * @memberOf _
  31732. * @since 4.0.0
  31733. * @category Util
  31734. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31735. * The predicates to check.
  31736. * @returns {Function} Returns the new function.
  31737. * @example
  31738. *
  31739. * var func = _.overEvery([Boolean, isFinite]);
  31740. *
  31741. * func('1');
  31742. * // => true
  31743. *
  31744. * func(null);
  31745. * // => false
  31746. *
  31747. * func(NaN);
  31748. * // => false
  31749. */
  31750. var overEvery = createOver(arrayEvery);
  31751. /**
  31752. * Creates a function that checks if **any** of the `predicates` return
  31753. * truthy when invoked with the arguments it receives.
  31754. *
  31755. * @static
  31756. * @memberOf _
  31757. * @since 4.0.0
  31758. * @category Util
  31759. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31760. * The predicates to check.
  31761. * @returns {Function} Returns the new function.
  31762. * @example
  31763. *
  31764. * var func = _.overSome([Boolean, isFinite]);
  31765. *
  31766. * func('1');
  31767. * // => true
  31768. *
  31769. * func(null);
  31770. * // => true
  31771. *
  31772. * func(NaN);
  31773. * // => false
  31774. */
  31775. var overSome = createOver(arraySome);
  31776. /**
  31777. * Creates a function that returns the value at `path` of a given object.
  31778. *
  31779. * @static
  31780. * @memberOf _
  31781. * @since 2.4.0
  31782. * @category Util
  31783. * @param {Array|string} path The path of the property to get.
  31784. * @returns {Function} Returns the new accessor function.
  31785. * @example
  31786. *
  31787. * var objects = [
  31788. * { 'a': { 'b': 2 } },
  31789. * { 'a': { 'b': 1 } }
  31790. * ];
  31791. *
  31792. * _.map(objects, _.property('a.b'));
  31793. * // => [2, 1]
  31794. *
  31795. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31796. * // => [1, 2]
  31797. */
  31798. function property(path) {
  31799. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31800. }
  31801. /**
  31802. * The opposite of `_.property`; this method creates a function that returns
  31803. * the value at a given path of `object`.
  31804. *
  31805. * @static
  31806. * @memberOf _
  31807. * @since 3.0.0
  31808. * @category Util
  31809. * @param {Object} object The object to query.
  31810. * @returns {Function} Returns the new accessor function.
  31811. * @example
  31812. *
  31813. * var array = [0, 1, 2],
  31814. * object = { 'a': array, 'b': array, 'c': array };
  31815. *
  31816. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31817. * // => [2, 0]
  31818. *
  31819. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31820. * // => [2, 0]
  31821. */
  31822. function propertyOf(object) {
  31823. return function(path) {
  31824. return object == null ? undefined : baseGet(object, path);
  31825. };
  31826. }
  31827. /**
  31828. * Creates an array of numbers (positive and/or negative) progressing from
  31829. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31830. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31831. * it's set to `start` with `start` then set to `0`.
  31832. *
  31833. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31834. * floating-point values which can produce unexpected results.
  31835. *
  31836. * @static
  31837. * @since 0.1.0
  31838. * @memberOf _
  31839. * @category Util
  31840. * @param {number} [start=0] The start of the range.
  31841. * @param {number} end The end of the range.
  31842. * @param {number} [step=1] The value to increment or decrement by.
  31843. * @returns {Array} Returns the range of numbers.
  31844. * @see _.inRange, _.rangeRight
  31845. * @example
  31846. *
  31847. * _.range(4);
  31848. * // => [0, 1, 2, 3]
  31849. *
  31850. * _.range(-4);
  31851. * // => [0, -1, -2, -3]
  31852. *
  31853. * _.range(1, 5);
  31854. * // => [1, 2, 3, 4]
  31855. *
  31856. * _.range(0, 20, 5);
  31857. * // => [0, 5, 10, 15]
  31858. *
  31859. * _.range(0, -4, -1);
  31860. * // => [0, -1, -2, -3]
  31861. *
  31862. * _.range(1, 4, 0);
  31863. * // => [1, 1, 1]
  31864. *
  31865. * _.range(0);
  31866. * // => []
  31867. */
  31868. var range = createRange();
  31869. /**
  31870. * This method is like `_.range` except that it populates values in
  31871. * descending order.
  31872. *
  31873. * @static
  31874. * @memberOf _
  31875. * @since 4.0.0
  31876. * @category Util
  31877. * @param {number} [start=0] The start of the range.
  31878. * @param {number} end The end of the range.
  31879. * @param {number} [step=1] The value to increment or decrement by.
  31880. * @returns {Array} Returns the range of numbers.
  31881. * @see _.inRange, _.range
  31882. * @example
  31883. *
  31884. * _.rangeRight(4);
  31885. * // => [3, 2, 1, 0]
  31886. *
  31887. * _.rangeRight(-4);
  31888. * // => [-3, -2, -1, 0]
  31889. *
  31890. * _.rangeRight(1, 5);
  31891. * // => [4, 3, 2, 1]
  31892. *
  31893. * _.rangeRight(0, 20, 5);
  31894. * // => [15, 10, 5, 0]
  31895. *
  31896. * _.rangeRight(0, -4, -1);
  31897. * // => [-3, -2, -1, 0]
  31898. *
  31899. * _.rangeRight(1, 4, 0);
  31900. * // => [1, 1, 1]
  31901. *
  31902. * _.rangeRight(0);
  31903. * // => []
  31904. */
  31905. var rangeRight = createRange(true);
  31906. /**
  31907. * This method returns a new empty array.
  31908. *
  31909. * @static
  31910. * @memberOf _
  31911. * @since 4.13.0
  31912. * @category Util
  31913. * @returns {Array} Returns the new empty array.
  31914. * @example
  31915. *
  31916. * var arrays = _.times(2, _.stubArray);
  31917. *
  31918. * console.log(arrays);
  31919. * // => [[], []]
  31920. *
  31921. * console.log(arrays[0] === arrays[1]);
  31922. * // => false
  31923. */
  31924. function stubArray() {
  31925. return [];
  31926. }
  31927. /**
  31928. * This method returns `false`.
  31929. *
  31930. * @static
  31931. * @memberOf _
  31932. * @since 4.13.0
  31933. * @category Util
  31934. * @returns {boolean} Returns `false`.
  31935. * @example
  31936. *
  31937. * _.times(2, _.stubFalse);
  31938. * // => [false, false]
  31939. */
  31940. function stubFalse() {
  31941. return false;
  31942. }
  31943. /**
  31944. * This method returns a new empty object.
  31945. *
  31946. * @static
  31947. * @memberOf _
  31948. * @since 4.13.0
  31949. * @category Util
  31950. * @returns {Object} Returns the new empty object.
  31951. * @example
  31952. *
  31953. * var objects = _.times(2, _.stubObject);
  31954. *
  31955. * console.log(objects);
  31956. * // => [{}, {}]
  31957. *
  31958. * console.log(objects[0] === objects[1]);
  31959. * // => false
  31960. */
  31961. function stubObject() {
  31962. return {};
  31963. }
  31964. /**
  31965. * This method returns an empty string.
  31966. *
  31967. * @static
  31968. * @memberOf _
  31969. * @since 4.13.0
  31970. * @category Util
  31971. * @returns {string} Returns the empty string.
  31972. * @example
  31973. *
  31974. * _.times(2, _.stubString);
  31975. * // => ['', '']
  31976. */
  31977. function stubString() {
  31978. return '';
  31979. }
  31980. /**
  31981. * This method returns `true`.
  31982. *
  31983. * @static
  31984. * @memberOf _
  31985. * @since 4.13.0
  31986. * @category Util
  31987. * @returns {boolean} Returns `true`.
  31988. * @example
  31989. *
  31990. * _.times(2, _.stubTrue);
  31991. * // => [true, true]
  31992. */
  31993. function stubTrue() {
  31994. return true;
  31995. }
  31996. /**
  31997. * Invokes the iteratee `n` times, returning an array of the results of
  31998. * each invocation. The iteratee is invoked with one argument; (index).
  31999. *
  32000. * @static
  32001. * @since 0.1.0
  32002. * @memberOf _
  32003. * @category Util
  32004. * @param {number} n The number of times to invoke `iteratee`.
  32005. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32006. * @returns {Array} Returns the array of results.
  32007. * @example
  32008. *
  32009. * _.times(3, String);
  32010. * // => ['0', '1', '2']
  32011. *
  32012. * _.times(4, _.constant(0));
  32013. * // => [0, 0, 0, 0]
  32014. */
  32015. function times(n, iteratee) {
  32016. n = toInteger(n);
  32017. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32018. return [];
  32019. }
  32020. var index = MAX_ARRAY_LENGTH,
  32021. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32022. iteratee = getIteratee(iteratee);
  32023. n -= MAX_ARRAY_LENGTH;
  32024. var result = baseTimes(length, iteratee);
  32025. while (++index < n) {
  32026. iteratee(index);
  32027. }
  32028. return result;
  32029. }
  32030. /**
  32031. * Converts `value` to a property path array.
  32032. *
  32033. * @static
  32034. * @memberOf _
  32035. * @since 4.0.0
  32036. * @category Util
  32037. * @param {*} value The value to convert.
  32038. * @returns {Array} Returns the new property path array.
  32039. * @example
  32040. *
  32041. * _.toPath('a.b.c');
  32042. * // => ['a', 'b', 'c']
  32043. *
  32044. * _.toPath('a[0].b.c');
  32045. * // => ['a', '0', 'b', 'c']
  32046. */
  32047. function toPath(value) {
  32048. if (isArray(value)) {
  32049. return arrayMap(value, toKey);
  32050. }
  32051. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32052. }
  32053. /**
  32054. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32055. *
  32056. * @static
  32057. * @since 0.1.0
  32058. * @memberOf _
  32059. * @category Util
  32060. * @param {string} [prefix=''] The value to prefix the ID with.
  32061. * @returns {string} Returns the unique ID.
  32062. * @example
  32063. *
  32064. * _.uniqueId('contact_');
  32065. * // => 'contact_104'
  32066. *
  32067. * _.uniqueId();
  32068. * // => '105'
  32069. */
  32070. function uniqueId(prefix) {
  32071. var id = ++idCounter;
  32072. return toString(prefix) + id;
  32073. }
  32074. /*------------------------------------------------------------------------*/
  32075. /**
  32076. * Adds two numbers.
  32077. *
  32078. * @static
  32079. * @memberOf _
  32080. * @since 3.4.0
  32081. * @category Math
  32082. * @param {number} augend The first number in an addition.
  32083. * @param {number} addend The second number in an addition.
  32084. * @returns {number} Returns the total.
  32085. * @example
  32086. *
  32087. * _.add(6, 4);
  32088. * // => 10
  32089. */
  32090. var add = createMathOperation(function(augend, addend) {
  32091. return augend + addend;
  32092. }, 0);
  32093. /**
  32094. * Computes `number` rounded up to `precision`.
  32095. *
  32096. * @static
  32097. * @memberOf _
  32098. * @since 3.10.0
  32099. * @category Math
  32100. * @param {number} number The number to round up.
  32101. * @param {number} [precision=0] The precision to round up to.
  32102. * @returns {number} Returns the rounded up number.
  32103. * @example
  32104. *
  32105. * _.ceil(4.006);
  32106. * // => 5
  32107. *
  32108. * _.ceil(6.004, 2);
  32109. * // => 6.01
  32110. *
  32111. * _.ceil(6040, -2);
  32112. * // => 6100
  32113. */
  32114. var ceil = createRound('ceil');
  32115. /**
  32116. * Divide two numbers.
  32117. *
  32118. * @static
  32119. * @memberOf _
  32120. * @since 4.7.0
  32121. * @category Math
  32122. * @param {number} dividend The first number in a division.
  32123. * @param {number} divisor The second number in a division.
  32124. * @returns {number} Returns the quotient.
  32125. * @example
  32126. *
  32127. * _.divide(6, 4);
  32128. * // => 1.5
  32129. */
  32130. var divide = createMathOperation(function(dividend, divisor) {
  32131. return dividend / divisor;
  32132. }, 1);
  32133. /**
  32134. * Computes `number` rounded down to `precision`.
  32135. *
  32136. * @static
  32137. * @memberOf _
  32138. * @since 3.10.0
  32139. * @category Math
  32140. * @param {number} number The number to round down.
  32141. * @param {number} [precision=0] The precision to round down to.
  32142. * @returns {number} Returns the rounded down number.
  32143. * @example
  32144. *
  32145. * _.floor(4.006);
  32146. * // => 4
  32147. *
  32148. * _.floor(0.046, 2);
  32149. * // => 0.04
  32150. *
  32151. * _.floor(4060, -2);
  32152. * // => 4000
  32153. */
  32154. var floor = createRound('floor');
  32155. /**
  32156. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32157. * `undefined` is returned.
  32158. *
  32159. * @static
  32160. * @since 0.1.0
  32161. * @memberOf _
  32162. * @category Math
  32163. * @param {Array} array The array to iterate over.
  32164. * @returns {*} Returns the maximum value.
  32165. * @example
  32166. *
  32167. * _.max([4, 2, 8, 6]);
  32168. * // => 8
  32169. *
  32170. * _.max([]);
  32171. * // => undefined
  32172. */
  32173. function max(array) {
  32174. return (array && array.length)
  32175. ? baseExtremum(array, identity, baseGt)
  32176. : undefined;
  32177. }
  32178. /**
  32179. * This method is like `_.max` except that it accepts `iteratee` which is
  32180. * invoked for each element in `array` to generate the criterion by which
  32181. * the value is ranked. The iteratee is invoked with one argument: (value).
  32182. *
  32183. * @static
  32184. * @memberOf _
  32185. * @since 4.0.0
  32186. * @category Math
  32187. * @param {Array} array The array to iterate over.
  32188. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32189. * @returns {*} Returns the maximum value.
  32190. * @example
  32191. *
  32192. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32193. *
  32194. * _.maxBy(objects, function(o) { return o.n; });
  32195. * // => { 'n': 2 }
  32196. *
  32197. * // The `_.property` iteratee shorthand.
  32198. * _.maxBy(objects, 'n');
  32199. * // => { 'n': 2 }
  32200. */
  32201. function maxBy(array, iteratee) {
  32202. return (array && array.length)
  32203. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32204. : undefined;
  32205. }
  32206. /**
  32207. * Computes the mean of the values in `array`.
  32208. *
  32209. * @static
  32210. * @memberOf _
  32211. * @since 4.0.0
  32212. * @category Math
  32213. * @param {Array} array The array to iterate over.
  32214. * @returns {number} Returns the mean.
  32215. * @example
  32216. *
  32217. * _.mean([4, 2, 8, 6]);
  32218. * // => 5
  32219. */
  32220. function mean(array) {
  32221. return baseMean(array, identity);
  32222. }
  32223. /**
  32224. * This method is like `_.mean` except that it accepts `iteratee` which is
  32225. * invoked for each element in `array` to generate the value to be averaged.
  32226. * The iteratee is invoked with one argument: (value).
  32227. *
  32228. * @static
  32229. * @memberOf _
  32230. * @since 4.7.0
  32231. * @category Math
  32232. * @param {Array} array The array to iterate over.
  32233. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32234. * @returns {number} Returns the mean.
  32235. * @example
  32236. *
  32237. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32238. *
  32239. * _.meanBy(objects, function(o) { return o.n; });
  32240. * // => 5
  32241. *
  32242. * // The `_.property` iteratee shorthand.
  32243. * _.meanBy(objects, 'n');
  32244. * // => 5
  32245. */
  32246. function meanBy(array, iteratee) {
  32247. return baseMean(array, getIteratee(iteratee, 2));
  32248. }
  32249. /**
  32250. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32251. * `undefined` is returned.
  32252. *
  32253. * @static
  32254. * @since 0.1.0
  32255. * @memberOf _
  32256. * @category Math
  32257. * @param {Array} array The array to iterate over.
  32258. * @returns {*} Returns the minimum value.
  32259. * @example
  32260. *
  32261. * _.min([4, 2, 8, 6]);
  32262. * // => 2
  32263. *
  32264. * _.min([]);
  32265. * // => undefined
  32266. */
  32267. function min(array) {
  32268. return (array && array.length)
  32269. ? baseExtremum(array, identity, baseLt)
  32270. : undefined;
  32271. }
  32272. /**
  32273. * This method is like `_.min` except that it accepts `iteratee` which is
  32274. * invoked for each element in `array` to generate the criterion by which
  32275. * the value is ranked. The iteratee is invoked with one argument: (value).
  32276. *
  32277. * @static
  32278. * @memberOf _
  32279. * @since 4.0.0
  32280. * @category Math
  32281. * @param {Array} array The array to iterate over.
  32282. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32283. * @returns {*} Returns the minimum value.
  32284. * @example
  32285. *
  32286. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32287. *
  32288. * _.minBy(objects, function(o) { return o.n; });
  32289. * // => { 'n': 1 }
  32290. *
  32291. * // The `_.property` iteratee shorthand.
  32292. * _.minBy(objects, 'n');
  32293. * // => { 'n': 1 }
  32294. */
  32295. function minBy(array, iteratee) {
  32296. return (array && array.length)
  32297. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32298. : undefined;
  32299. }
  32300. /**
  32301. * Multiply two numbers.
  32302. *
  32303. * @static
  32304. * @memberOf _
  32305. * @since 4.7.0
  32306. * @category Math
  32307. * @param {number} multiplier The first number in a multiplication.
  32308. * @param {number} multiplicand The second number in a multiplication.
  32309. * @returns {number} Returns the product.
  32310. * @example
  32311. *
  32312. * _.multiply(6, 4);
  32313. * // => 24
  32314. */
  32315. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32316. return multiplier * multiplicand;
  32317. }, 1);
  32318. /**
  32319. * Computes `number` rounded to `precision`.
  32320. *
  32321. * @static
  32322. * @memberOf _
  32323. * @since 3.10.0
  32324. * @category Math
  32325. * @param {number} number The number to round.
  32326. * @param {number} [precision=0] The precision to round to.
  32327. * @returns {number} Returns the rounded number.
  32328. * @example
  32329. *
  32330. * _.round(4.006);
  32331. * // => 4
  32332. *
  32333. * _.round(4.006, 2);
  32334. * // => 4.01
  32335. *
  32336. * _.round(4060, -2);
  32337. * // => 4100
  32338. */
  32339. var round = createRound('round');
  32340. /**
  32341. * Subtract two numbers.
  32342. *
  32343. * @static
  32344. * @memberOf _
  32345. * @since 4.0.0
  32346. * @category Math
  32347. * @param {number} minuend The first number in a subtraction.
  32348. * @param {number} subtrahend The second number in a subtraction.
  32349. * @returns {number} Returns the difference.
  32350. * @example
  32351. *
  32352. * _.subtract(6, 4);
  32353. * // => 2
  32354. */
  32355. var subtract = createMathOperation(function(minuend, subtrahend) {
  32356. return minuend - subtrahend;
  32357. }, 0);
  32358. /**
  32359. * Computes the sum of the values in `array`.
  32360. *
  32361. * @static
  32362. * @memberOf _
  32363. * @since 3.4.0
  32364. * @category Math
  32365. * @param {Array} array The array to iterate over.
  32366. * @returns {number} Returns the sum.
  32367. * @example
  32368. *
  32369. * _.sum([4, 2, 8, 6]);
  32370. * // => 20
  32371. */
  32372. function sum(array) {
  32373. return (array && array.length)
  32374. ? baseSum(array, identity)
  32375. : 0;
  32376. }
  32377. /**
  32378. * This method is like `_.sum` except that it accepts `iteratee` which is
  32379. * invoked for each element in `array` to generate the value to be summed.
  32380. * The iteratee is invoked with one argument: (value).
  32381. *
  32382. * @static
  32383. * @memberOf _
  32384. * @since 4.0.0
  32385. * @category Math
  32386. * @param {Array} array The array to iterate over.
  32387. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32388. * @returns {number} Returns the sum.
  32389. * @example
  32390. *
  32391. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32392. *
  32393. * _.sumBy(objects, function(o) { return o.n; });
  32394. * // => 20
  32395. *
  32396. * // The `_.property` iteratee shorthand.
  32397. * _.sumBy(objects, 'n');
  32398. * // => 20
  32399. */
  32400. function sumBy(array, iteratee) {
  32401. return (array && array.length)
  32402. ? baseSum(array, getIteratee(iteratee, 2))
  32403. : 0;
  32404. }
  32405. /*------------------------------------------------------------------------*/
  32406. // Add methods that return wrapped values in chain sequences.
  32407. lodash.after = after;
  32408. lodash.ary = ary;
  32409. lodash.assign = assign;
  32410. lodash.assignIn = assignIn;
  32411. lodash.assignInWith = assignInWith;
  32412. lodash.assignWith = assignWith;
  32413. lodash.at = at;
  32414. lodash.before = before;
  32415. lodash.bind = bind;
  32416. lodash.bindAll = bindAll;
  32417. lodash.bindKey = bindKey;
  32418. lodash.castArray = castArray;
  32419. lodash.chain = chain;
  32420. lodash.chunk = chunk;
  32421. lodash.compact = compact;
  32422. lodash.concat = concat;
  32423. lodash.cond = cond;
  32424. lodash.conforms = conforms;
  32425. lodash.constant = constant;
  32426. lodash.countBy = countBy;
  32427. lodash.create = create;
  32428. lodash.curry = curry;
  32429. lodash.curryRight = curryRight;
  32430. lodash.debounce = debounce;
  32431. lodash.defaults = defaults;
  32432. lodash.defaultsDeep = defaultsDeep;
  32433. lodash.defer = defer;
  32434. lodash.delay = delay;
  32435. lodash.difference = difference;
  32436. lodash.differenceBy = differenceBy;
  32437. lodash.differenceWith = differenceWith;
  32438. lodash.drop = drop;
  32439. lodash.dropRight = dropRight;
  32440. lodash.dropRightWhile = dropRightWhile;
  32441. lodash.dropWhile = dropWhile;
  32442. lodash.fill = fill;
  32443. lodash.filter = filter;
  32444. lodash.flatMap = flatMap;
  32445. lodash.flatMapDeep = flatMapDeep;
  32446. lodash.flatMapDepth = flatMapDepth;
  32447. lodash.flatten = flatten;
  32448. lodash.flattenDeep = flattenDeep;
  32449. lodash.flattenDepth = flattenDepth;
  32450. lodash.flip = flip;
  32451. lodash.flow = flow;
  32452. lodash.flowRight = flowRight;
  32453. lodash.fromPairs = fromPairs;
  32454. lodash.functions = functions;
  32455. lodash.functionsIn = functionsIn;
  32456. lodash.groupBy = groupBy;
  32457. lodash.initial = initial;
  32458. lodash.intersection = intersection;
  32459. lodash.intersectionBy = intersectionBy;
  32460. lodash.intersectionWith = intersectionWith;
  32461. lodash.invert = invert;
  32462. lodash.invertBy = invertBy;
  32463. lodash.invokeMap = invokeMap;
  32464. lodash.iteratee = iteratee;
  32465. lodash.keyBy = keyBy;
  32466. lodash.keys = keys;
  32467. lodash.keysIn = keysIn;
  32468. lodash.map = map;
  32469. lodash.mapKeys = mapKeys;
  32470. lodash.mapValues = mapValues;
  32471. lodash.matches = matches;
  32472. lodash.matchesProperty = matchesProperty;
  32473. lodash.memoize = memoize;
  32474. lodash.merge = merge;
  32475. lodash.mergeWith = mergeWith;
  32476. lodash.method = method;
  32477. lodash.methodOf = methodOf;
  32478. lodash.mixin = mixin;
  32479. lodash.negate = negate;
  32480. lodash.nthArg = nthArg;
  32481. lodash.omit = omit;
  32482. lodash.omitBy = omitBy;
  32483. lodash.once = once;
  32484. lodash.orderBy = orderBy;
  32485. lodash.over = over;
  32486. lodash.overArgs = overArgs;
  32487. lodash.overEvery = overEvery;
  32488. lodash.overSome = overSome;
  32489. lodash.partial = partial;
  32490. lodash.partialRight = partialRight;
  32491. lodash.partition = partition;
  32492. lodash.pick = pick;
  32493. lodash.pickBy = pickBy;
  32494. lodash.property = property;
  32495. lodash.propertyOf = propertyOf;
  32496. lodash.pull = pull;
  32497. lodash.pullAll = pullAll;
  32498. lodash.pullAllBy = pullAllBy;
  32499. lodash.pullAllWith = pullAllWith;
  32500. lodash.pullAt = pullAt;
  32501. lodash.range = range;
  32502. lodash.rangeRight = rangeRight;
  32503. lodash.rearg = rearg;
  32504. lodash.reject = reject;
  32505. lodash.remove = remove;
  32506. lodash.rest = rest;
  32507. lodash.reverse = reverse;
  32508. lodash.sampleSize = sampleSize;
  32509. lodash.set = set;
  32510. lodash.setWith = setWith;
  32511. lodash.shuffle = shuffle;
  32512. lodash.slice = slice;
  32513. lodash.sortBy = sortBy;
  32514. lodash.sortedUniq = sortedUniq;
  32515. lodash.sortedUniqBy = sortedUniqBy;
  32516. lodash.split = split;
  32517. lodash.spread = spread;
  32518. lodash.tail = tail;
  32519. lodash.take = take;
  32520. lodash.takeRight = takeRight;
  32521. lodash.takeRightWhile = takeRightWhile;
  32522. lodash.takeWhile = takeWhile;
  32523. lodash.tap = tap;
  32524. lodash.throttle = throttle;
  32525. lodash.thru = thru;
  32526. lodash.toArray = toArray;
  32527. lodash.toPairs = toPairs;
  32528. lodash.toPairsIn = toPairsIn;
  32529. lodash.toPath = toPath;
  32530. lodash.toPlainObject = toPlainObject;
  32531. lodash.transform = transform;
  32532. lodash.unary = unary;
  32533. lodash.union = union;
  32534. lodash.unionBy = unionBy;
  32535. lodash.unionWith = unionWith;
  32536. lodash.uniq = uniq;
  32537. lodash.uniqBy = uniqBy;
  32538. lodash.uniqWith = uniqWith;
  32539. lodash.unset = unset;
  32540. lodash.unzip = unzip;
  32541. lodash.unzipWith = unzipWith;
  32542. lodash.update = update;
  32543. lodash.updateWith = updateWith;
  32544. lodash.values = values;
  32545. lodash.valuesIn = valuesIn;
  32546. lodash.without = without;
  32547. lodash.words = words;
  32548. lodash.wrap = wrap;
  32549. lodash.xor = xor;
  32550. lodash.xorBy = xorBy;
  32551. lodash.xorWith = xorWith;
  32552. lodash.zip = zip;
  32553. lodash.zipObject = zipObject;
  32554. lodash.zipObjectDeep = zipObjectDeep;
  32555. lodash.zipWith = zipWith;
  32556. // Add aliases.
  32557. lodash.entries = toPairs;
  32558. lodash.entriesIn = toPairsIn;
  32559. lodash.extend = assignIn;
  32560. lodash.extendWith = assignInWith;
  32561. // Add methods to `lodash.prototype`.
  32562. mixin(lodash, lodash);
  32563. /*------------------------------------------------------------------------*/
  32564. // Add methods that return unwrapped values in chain sequences.
  32565. lodash.add = add;
  32566. lodash.attempt = attempt;
  32567. lodash.camelCase = camelCase;
  32568. lodash.capitalize = capitalize;
  32569. lodash.ceil = ceil;
  32570. lodash.clamp = clamp;
  32571. lodash.clone = clone;
  32572. lodash.cloneDeep = cloneDeep;
  32573. lodash.cloneDeepWith = cloneDeepWith;
  32574. lodash.cloneWith = cloneWith;
  32575. lodash.conformsTo = conformsTo;
  32576. lodash.deburr = deburr;
  32577. lodash.defaultTo = defaultTo;
  32578. lodash.divide = divide;
  32579. lodash.endsWith = endsWith;
  32580. lodash.eq = eq;
  32581. lodash.escape = escape;
  32582. lodash.escapeRegExp = escapeRegExp;
  32583. lodash.every = every;
  32584. lodash.find = find;
  32585. lodash.findIndex = findIndex;
  32586. lodash.findKey = findKey;
  32587. lodash.findLast = findLast;
  32588. lodash.findLastIndex = findLastIndex;
  32589. lodash.findLastKey = findLastKey;
  32590. lodash.floor = floor;
  32591. lodash.forEach = forEach;
  32592. lodash.forEachRight = forEachRight;
  32593. lodash.forIn = forIn;
  32594. lodash.forInRight = forInRight;
  32595. lodash.forOwn = forOwn;
  32596. lodash.forOwnRight = forOwnRight;
  32597. lodash.get = get;
  32598. lodash.gt = gt;
  32599. lodash.gte = gte;
  32600. lodash.has = has;
  32601. lodash.hasIn = hasIn;
  32602. lodash.head = head;
  32603. lodash.identity = identity;
  32604. lodash.includes = includes;
  32605. lodash.indexOf = indexOf;
  32606. lodash.inRange = inRange;
  32607. lodash.invoke = invoke;
  32608. lodash.isArguments = isArguments;
  32609. lodash.isArray = isArray;
  32610. lodash.isArrayBuffer = isArrayBuffer;
  32611. lodash.isArrayLike = isArrayLike;
  32612. lodash.isArrayLikeObject = isArrayLikeObject;
  32613. lodash.isBoolean = isBoolean;
  32614. lodash.isBuffer = isBuffer;
  32615. lodash.isDate = isDate;
  32616. lodash.isElement = isElement;
  32617. lodash.isEmpty = isEmpty;
  32618. lodash.isEqual = isEqual;
  32619. lodash.isEqualWith = isEqualWith;
  32620. lodash.isError = isError;
  32621. lodash.isFinite = isFinite;
  32622. lodash.isFunction = isFunction;
  32623. lodash.isInteger = isInteger;
  32624. lodash.isLength = isLength;
  32625. lodash.isMap = isMap;
  32626. lodash.isMatch = isMatch;
  32627. lodash.isMatchWith = isMatchWith;
  32628. lodash.isNaN = isNaN;
  32629. lodash.isNative = isNative;
  32630. lodash.isNil = isNil;
  32631. lodash.isNull = isNull;
  32632. lodash.isNumber = isNumber;
  32633. lodash.isObject = isObject;
  32634. lodash.isObjectLike = isObjectLike;
  32635. lodash.isPlainObject = isPlainObject;
  32636. lodash.isRegExp = isRegExp;
  32637. lodash.isSafeInteger = isSafeInteger;
  32638. lodash.isSet = isSet;
  32639. lodash.isString = isString;
  32640. lodash.isSymbol = isSymbol;
  32641. lodash.isTypedArray = isTypedArray;
  32642. lodash.isUndefined = isUndefined;
  32643. lodash.isWeakMap = isWeakMap;
  32644. lodash.isWeakSet = isWeakSet;
  32645. lodash.join = join;
  32646. lodash.kebabCase = kebabCase;
  32647. lodash.last = last;
  32648. lodash.lastIndexOf = lastIndexOf;
  32649. lodash.lowerCase = lowerCase;
  32650. lodash.lowerFirst = lowerFirst;
  32651. lodash.lt = lt;
  32652. lodash.lte = lte;
  32653. lodash.max = max;
  32654. lodash.maxBy = maxBy;
  32655. lodash.mean = mean;
  32656. lodash.meanBy = meanBy;
  32657. lodash.min = min;
  32658. lodash.minBy = minBy;
  32659. lodash.stubArray = stubArray;
  32660. lodash.stubFalse = stubFalse;
  32661. lodash.stubObject = stubObject;
  32662. lodash.stubString = stubString;
  32663. lodash.stubTrue = stubTrue;
  32664. lodash.multiply = multiply;
  32665. lodash.nth = nth;
  32666. lodash.noConflict = noConflict;
  32667. lodash.noop = noop;
  32668. lodash.now = now;
  32669. lodash.pad = pad;
  32670. lodash.padEnd = padEnd;
  32671. lodash.padStart = padStart;
  32672. lodash.parseInt = parseInt;
  32673. lodash.random = random;
  32674. lodash.reduce = reduce;
  32675. lodash.reduceRight = reduceRight;
  32676. lodash.repeat = repeat;
  32677. lodash.replace = replace;
  32678. lodash.result = result;
  32679. lodash.round = round;
  32680. lodash.runInContext = runInContext;
  32681. lodash.sample = sample;
  32682. lodash.size = size;
  32683. lodash.snakeCase = snakeCase;
  32684. lodash.some = some;
  32685. lodash.sortedIndex = sortedIndex;
  32686. lodash.sortedIndexBy = sortedIndexBy;
  32687. lodash.sortedIndexOf = sortedIndexOf;
  32688. lodash.sortedLastIndex = sortedLastIndex;
  32689. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32690. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32691. lodash.startCase = startCase;
  32692. lodash.startsWith = startsWith;
  32693. lodash.subtract = subtract;
  32694. lodash.sum = sum;
  32695. lodash.sumBy = sumBy;
  32696. lodash.template = template;
  32697. lodash.times = times;
  32698. lodash.toFinite = toFinite;
  32699. lodash.toInteger = toInteger;
  32700. lodash.toLength = toLength;
  32701. lodash.toLower = toLower;
  32702. lodash.toNumber = toNumber;
  32703. lodash.toSafeInteger = toSafeInteger;
  32704. lodash.toString = toString;
  32705. lodash.toUpper = toUpper;
  32706. lodash.trim = trim;
  32707. lodash.trimEnd = trimEnd;
  32708. lodash.trimStart = trimStart;
  32709. lodash.truncate = truncate;
  32710. lodash.unescape = unescape;
  32711. lodash.uniqueId = uniqueId;
  32712. lodash.upperCase = upperCase;
  32713. lodash.upperFirst = upperFirst;
  32714. // Add aliases.
  32715. lodash.each = forEach;
  32716. lodash.eachRight = forEachRight;
  32717. lodash.first = head;
  32718. mixin(lodash, (function() {
  32719. var source = {};
  32720. baseForOwn(lodash, function(func, methodName) {
  32721. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32722. source[methodName] = func;
  32723. }
  32724. });
  32725. return source;
  32726. }()), { 'chain': false });
  32727. /*------------------------------------------------------------------------*/
  32728. /**
  32729. * The semantic version number.
  32730. *
  32731. * @static
  32732. * @memberOf _
  32733. * @type {string}
  32734. */
  32735. lodash.VERSION = VERSION;
  32736. // Assign default placeholders.
  32737. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32738. lodash[methodName].placeholder = lodash;
  32739. });
  32740. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32741. arrayEach(['drop', 'take'], function(methodName, index) {
  32742. LazyWrapper.prototype[methodName] = function(n) {
  32743. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32744. var result = (this.__filtered__ && !index)
  32745. ? new LazyWrapper(this)
  32746. : this.clone();
  32747. if (result.__filtered__) {
  32748. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32749. } else {
  32750. result.__views__.push({
  32751. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32752. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32753. });
  32754. }
  32755. return result;
  32756. };
  32757. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32758. return this.reverse()[methodName](n).reverse();
  32759. };
  32760. });
  32761. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32762. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32763. var type = index + 1,
  32764. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32765. LazyWrapper.prototype[methodName] = function(iteratee) {
  32766. var result = this.clone();
  32767. result.__iteratees__.push({
  32768. 'iteratee': getIteratee(iteratee, 3),
  32769. 'type': type
  32770. });
  32771. result.__filtered__ = result.__filtered__ || isFilter;
  32772. return result;
  32773. };
  32774. });
  32775. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32776. arrayEach(['head', 'last'], function(methodName, index) {
  32777. var takeName = 'take' + (index ? 'Right' : '');
  32778. LazyWrapper.prototype[methodName] = function() {
  32779. return this[takeName](1).value()[0];
  32780. };
  32781. });
  32782. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32783. arrayEach(['initial', 'tail'], function(methodName, index) {
  32784. var dropName = 'drop' + (index ? '' : 'Right');
  32785. LazyWrapper.prototype[methodName] = function() {
  32786. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32787. };
  32788. });
  32789. LazyWrapper.prototype.compact = function() {
  32790. return this.filter(identity);
  32791. };
  32792. LazyWrapper.prototype.find = function(predicate) {
  32793. return this.filter(predicate).head();
  32794. };
  32795. LazyWrapper.prototype.findLast = function(predicate) {
  32796. return this.reverse().find(predicate);
  32797. };
  32798. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32799. if (typeof path == 'function') {
  32800. return new LazyWrapper(this);
  32801. }
  32802. return this.map(function(value) {
  32803. return baseInvoke(value, path, args);
  32804. });
  32805. });
  32806. LazyWrapper.prototype.reject = function(predicate) {
  32807. return this.filter(negate(getIteratee(predicate)));
  32808. };
  32809. LazyWrapper.prototype.slice = function(start, end) {
  32810. start = toInteger(start);
  32811. var result = this;
  32812. if (result.__filtered__ && (start > 0 || end < 0)) {
  32813. return new LazyWrapper(result);
  32814. }
  32815. if (start < 0) {
  32816. result = result.takeRight(-start);
  32817. } else if (start) {
  32818. result = result.drop(start);
  32819. }
  32820. if (end !== undefined) {
  32821. end = toInteger(end);
  32822. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32823. }
  32824. return result;
  32825. };
  32826. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32827. return this.reverse().takeWhile(predicate).reverse();
  32828. };
  32829. LazyWrapper.prototype.toArray = function() {
  32830. return this.take(MAX_ARRAY_LENGTH);
  32831. };
  32832. // Add `LazyWrapper` methods to `lodash.prototype`.
  32833. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32834. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32835. isTaker = /^(?:head|last)$/.test(methodName),
  32836. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32837. retUnwrapped = isTaker || /^find/.test(methodName);
  32838. if (!lodashFunc) {
  32839. return;
  32840. }
  32841. lodash.prototype[methodName] = function() {
  32842. var value = this.__wrapped__,
  32843. args = isTaker ? [1] : arguments,
  32844. isLazy = value instanceof LazyWrapper,
  32845. iteratee = args[0],
  32846. useLazy = isLazy || isArray(value);
  32847. var interceptor = function(value) {
  32848. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32849. return (isTaker && chainAll) ? result[0] : result;
  32850. };
  32851. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32852. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32853. isLazy = useLazy = false;
  32854. }
  32855. var chainAll = this.__chain__,
  32856. isHybrid = !!this.__actions__.length,
  32857. isUnwrapped = retUnwrapped && !chainAll,
  32858. onlyLazy = isLazy && !isHybrid;
  32859. if (!retUnwrapped && useLazy) {
  32860. value = onlyLazy ? value : new LazyWrapper(this);
  32861. var result = func.apply(value, args);
  32862. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32863. return new LodashWrapper(result, chainAll);
  32864. }
  32865. if (isUnwrapped && onlyLazy) {
  32866. return func.apply(this, args);
  32867. }
  32868. result = this.thru(interceptor);
  32869. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32870. };
  32871. });
  32872. // Add `Array` methods to `lodash.prototype`.
  32873. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32874. var func = arrayProto[methodName],
  32875. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32876. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32877. lodash.prototype[methodName] = function() {
  32878. var args = arguments;
  32879. if (retUnwrapped && !this.__chain__) {
  32880. var value = this.value();
  32881. return func.apply(isArray(value) ? value : [], args);
  32882. }
  32883. return this[chainName](function(value) {
  32884. return func.apply(isArray(value) ? value : [], args);
  32885. });
  32886. };
  32887. });
  32888. // Map minified method names to their real names.
  32889. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32890. var lodashFunc = lodash[methodName];
  32891. if (lodashFunc) {
  32892. var key = lodashFunc.name + '';
  32893. if (!hasOwnProperty.call(realNames, key)) {
  32894. realNames[key] = [];
  32895. }
  32896. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32897. }
  32898. });
  32899. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32900. 'name': 'wrapper',
  32901. 'func': undefined
  32902. }];
  32903. // Add methods to `LazyWrapper`.
  32904. LazyWrapper.prototype.clone = lazyClone;
  32905. LazyWrapper.prototype.reverse = lazyReverse;
  32906. LazyWrapper.prototype.value = lazyValue;
  32907. // Add chain sequence methods to the `lodash` wrapper.
  32908. lodash.prototype.at = wrapperAt;
  32909. lodash.prototype.chain = wrapperChain;
  32910. lodash.prototype.commit = wrapperCommit;
  32911. lodash.prototype.next = wrapperNext;
  32912. lodash.prototype.plant = wrapperPlant;
  32913. lodash.prototype.reverse = wrapperReverse;
  32914. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32915. // Add lazy aliases.
  32916. lodash.prototype.first = lodash.prototype.head;
  32917. if (symIterator) {
  32918. lodash.prototype[symIterator] = wrapperToIterator;
  32919. }
  32920. return lodash;
  32921. });
  32922. /*--------------------------------------------------------------------------*/
  32923. // Export lodash.
  32924. var _ = runInContext();
  32925. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32926. if (true) {
  32927. // Expose Lodash on the global object to prevent errors when Lodash is
  32928. // loaded by a script tag in the presence of an AMD loader.
  32929. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32930. // Use `_.noConflict` to remove Lodash from the global object.
  32931. root._ = _;
  32932. // Define as an anonymous module so, through path mapping, it can be
  32933. // referenced as the "underscore" module.
  32934. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32935. return _;
  32936. }).call(exports, __webpack_require__, exports, module),
  32937. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32938. }
  32939. // Check for `exports` after `define` in case a build optimizer adds it.
  32940. else {}
  32941. }.call(this));
  32942. /* 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)))
  32943. /***/ }),
  32944. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32945. /*!***************************************************!*\
  32946. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32947. \***************************************************/
  32948. /*! exports provided: default */
  32949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32950. "use strict";
  32951. __webpack_require__.r(__webpack_exports__);
  32952. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32953. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32954. * @version 1.16.1
  32955. * @license
  32956. * Copyright (c) 2016 Federico Zivolo and contributors
  32957. *
  32958. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32959. * of this software and associated documentation files (the "Software"), to deal
  32960. * in the Software without restriction, including without limitation the rights
  32961. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32962. * copies of the Software, and to permit persons to whom the Software is
  32963. * furnished to do so, subject to the following conditions:
  32964. *
  32965. * The above copyright notice and this permission notice shall be included in all
  32966. * copies or substantial portions of the Software.
  32967. *
  32968. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32969. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32970. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32971. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32972. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32973. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32974. * SOFTWARE.
  32975. */
  32976. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32977. var timeoutDuration = function () {
  32978. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32979. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32980. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32981. return 1;
  32982. }
  32983. }
  32984. return 0;
  32985. }();
  32986. function microtaskDebounce(fn) {
  32987. var called = false;
  32988. return function () {
  32989. if (called) {
  32990. return;
  32991. }
  32992. called = true;
  32993. window.Promise.resolve().then(function () {
  32994. called = false;
  32995. fn();
  32996. });
  32997. };
  32998. }
  32999. function taskDebounce(fn) {
  33000. var scheduled = false;
  33001. return function () {
  33002. if (!scheduled) {
  33003. scheduled = true;
  33004. setTimeout(function () {
  33005. scheduled = false;
  33006. fn();
  33007. }, timeoutDuration);
  33008. }
  33009. };
  33010. }
  33011. var supportsMicroTasks = isBrowser && window.Promise;
  33012. /**
  33013. * Create a debounced version of a method, that's asynchronously deferred
  33014. * but called in the minimum time possible.
  33015. *
  33016. * @method
  33017. * @memberof Popper.Utils
  33018. * @argument {Function} fn
  33019. * @returns {Function}
  33020. */
  33021. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33022. /**
  33023. * Check if the given variable is a function
  33024. * @method
  33025. * @memberof Popper.Utils
  33026. * @argument {Any} functionToCheck - variable to check
  33027. * @returns {Boolean} answer to: is a function?
  33028. */
  33029. function isFunction(functionToCheck) {
  33030. var getType = {};
  33031. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33032. }
  33033. /**
  33034. * Get CSS computed property of the given element
  33035. * @method
  33036. * @memberof Popper.Utils
  33037. * @argument {Eement} element
  33038. * @argument {String} property
  33039. */
  33040. function getStyleComputedProperty(element, property) {
  33041. if (element.nodeType !== 1) {
  33042. return [];
  33043. }
  33044. // NOTE: 1 DOM access here
  33045. var window = element.ownerDocument.defaultView;
  33046. var css = window.getComputedStyle(element, null);
  33047. return property ? css[property] : css;
  33048. }
  33049. /**
  33050. * Returns the parentNode or the host of the element
  33051. * @method
  33052. * @memberof Popper.Utils
  33053. * @argument {Element} element
  33054. * @returns {Element} parent
  33055. */
  33056. function getParentNode(element) {
  33057. if (element.nodeName === 'HTML') {
  33058. return element;
  33059. }
  33060. return element.parentNode || element.host;
  33061. }
  33062. /**
  33063. * Returns the scrolling parent of the given element
  33064. * @method
  33065. * @memberof Popper.Utils
  33066. * @argument {Element} element
  33067. * @returns {Element} scroll parent
  33068. */
  33069. function getScrollParent(element) {
  33070. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33071. if (!element) {
  33072. return document.body;
  33073. }
  33074. switch (element.nodeName) {
  33075. case 'HTML':
  33076. case 'BODY':
  33077. return element.ownerDocument.body;
  33078. case '#document':
  33079. return element.body;
  33080. }
  33081. // Firefox want us to check `-x` and `-y` variations as well
  33082. var _getStyleComputedProp = getStyleComputedProperty(element),
  33083. overflow = _getStyleComputedProp.overflow,
  33084. overflowX = _getStyleComputedProp.overflowX,
  33085. overflowY = _getStyleComputedProp.overflowY;
  33086. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33087. return element;
  33088. }
  33089. return getScrollParent(getParentNode(element));
  33090. }
  33091. /**
  33092. * Returns the reference node of the reference object, or the reference object itself.
  33093. * @method
  33094. * @memberof Popper.Utils
  33095. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33096. * @returns {Element} parent
  33097. */
  33098. function getReferenceNode(reference) {
  33099. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33100. }
  33101. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33102. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33103. /**
  33104. * Determines if the browser is Internet Explorer
  33105. * @method
  33106. * @memberof Popper.Utils
  33107. * @param {Number} version to check
  33108. * @returns {Boolean} isIE
  33109. */
  33110. function isIE(version) {
  33111. if (version === 11) {
  33112. return isIE11;
  33113. }
  33114. if (version === 10) {
  33115. return isIE10;
  33116. }
  33117. return isIE11 || isIE10;
  33118. }
  33119. /**
  33120. * Returns the offset parent of the given element
  33121. * @method
  33122. * @memberof Popper.Utils
  33123. * @argument {Element} element
  33124. * @returns {Element} offset parent
  33125. */
  33126. function getOffsetParent(element) {
  33127. if (!element) {
  33128. return document.documentElement;
  33129. }
  33130. var noOffsetParent = isIE(10) ? document.body : null;
  33131. // NOTE: 1 DOM access here
  33132. var offsetParent = element.offsetParent || null;
  33133. // Skip hidden elements which don't have an offsetParent
  33134. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33135. offsetParent = (element = element.nextElementSibling).offsetParent;
  33136. }
  33137. var nodeName = offsetParent && offsetParent.nodeName;
  33138. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33139. return element ? element.ownerDocument.documentElement : document.documentElement;
  33140. }
  33141. // .offsetParent will return the closest TH, TD or TABLE in case
  33142. // no offsetParent is present, I hate this job...
  33143. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33144. return getOffsetParent(offsetParent);
  33145. }
  33146. return offsetParent;
  33147. }
  33148. function isOffsetContainer(element) {
  33149. var nodeName = element.nodeName;
  33150. if (nodeName === 'BODY') {
  33151. return false;
  33152. }
  33153. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33154. }
  33155. /**
  33156. * Finds the root node (document, shadowDOM root) of the given element
  33157. * @method
  33158. * @memberof Popper.Utils
  33159. * @argument {Element} node
  33160. * @returns {Element} root node
  33161. */
  33162. function getRoot(node) {
  33163. if (node.parentNode !== null) {
  33164. return getRoot(node.parentNode);
  33165. }
  33166. return node;
  33167. }
  33168. /**
  33169. * Finds the offset parent common to the two provided nodes
  33170. * @method
  33171. * @memberof Popper.Utils
  33172. * @argument {Element} element1
  33173. * @argument {Element} element2
  33174. * @returns {Element} common offset parent
  33175. */
  33176. function findCommonOffsetParent(element1, element2) {
  33177. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33178. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33179. return document.documentElement;
  33180. }
  33181. // Here we make sure to give as "start" the element that comes first in the DOM
  33182. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33183. var start = order ? element1 : element2;
  33184. var end = order ? element2 : element1;
  33185. // Get common ancestor container
  33186. var range = document.createRange();
  33187. range.setStart(start, 0);
  33188. range.setEnd(end, 0);
  33189. var commonAncestorContainer = range.commonAncestorContainer;
  33190. // Both nodes are inside #document
  33191. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33192. if (isOffsetContainer(commonAncestorContainer)) {
  33193. return commonAncestorContainer;
  33194. }
  33195. return getOffsetParent(commonAncestorContainer);
  33196. }
  33197. // one of the nodes is inside shadowDOM, find which one
  33198. var element1root = getRoot(element1);
  33199. if (element1root.host) {
  33200. return findCommonOffsetParent(element1root.host, element2);
  33201. } else {
  33202. return findCommonOffsetParent(element1, getRoot(element2).host);
  33203. }
  33204. }
  33205. /**
  33206. * Gets the scroll value of the given element in the given side (top and left)
  33207. * @method
  33208. * @memberof Popper.Utils
  33209. * @argument {Element} element
  33210. * @argument {String} side `top` or `left`
  33211. * @returns {number} amount of scrolled pixels
  33212. */
  33213. function getScroll(element) {
  33214. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33215. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33216. var nodeName = element.nodeName;
  33217. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33218. var html = element.ownerDocument.documentElement;
  33219. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33220. return scrollingElement[upperSide];
  33221. }
  33222. return element[upperSide];
  33223. }
  33224. /*
  33225. * Sum or subtract the element scroll values (left and top) from a given rect object
  33226. * @method
  33227. * @memberof Popper.Utils
  33228. * @param {Object} rect - Rect object you want to change
  33229. * @param {HTMLElement} element - The element from the function reads the scroll values
  33230. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33231. * @return {Object} rect - The modifier rect object
  33232. */
  33233. function includeScroll(rect, element) {
  33234. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33235. var scrollTop = getScroll(element, 'top');
  33236. var scrollLeft = getScroll(element, 'left');
  33237. var modifier = subtract ? -1 : 1;
  33238. rect.top += scrollTop * modifier;
  33239. rect.bottom += scrollTop * modifier;
  33240. rect.left += scrollLeft * modifier;
  33241. rect.right += scrollLeft * modifier;
  33242. return rect;
  33243. }
  33244. /*
  33245. * Helper to detect borders of a given element
  33246. * @method
  33247. * @memberof Popper.Utils
  33248. * @param {CSSStyleDeclaration} styles
  33249. * Result of `getStyleComputedProperty` on the given element
  33250. * @param {String} axis - `x` or `y`
  33251. * @return {number} borders - The borders size of the given axis
  33252. */
  33253. function getBordersSize(styles, axis) {
  33254. var sideA = axis === 'x' ? 'Left' : 'Top';
  33255. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33256. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33257. }
  33258. function getSize(axis, body, html, computedStyle) {
  33259. 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);
  33260. }
  33261. function getWindowSizes(document) {
  33262. var body = document.body;
  33263. var html = document.documentElement;
  33264. var computedStyle = isIE(10) && getComputedStyle(html);
  33265. return {
  33266. height: getSize('Height', body, html, computedStyle),
  33267. width: getSize('Width', body, html, computedStyle)
  33268. };
  33269. }
  33270. var classCallCheck = function (instance, Constructor) {
  33271. if (!(instance instanceof Constructor)) {
  33272. throw new TypeError("Cannot call a class as a function");
  33273. }
  33274. };
  33275. var createClass = function () {
  33276. function defineProperties(target, props) {
  33277. for (var i = 0; i < props.length; i++) {
  33278. var descriptor = props[i];
  33279. descriptor.enumerable = descriptor.enumerable || false;
  33280. descriptor.configurable = true;
  33281. if ("value" in descriptor) descriptor.writable = true;
  33282. Object.defineProperty(target, descriptor.key, descriptor);
  33283. }
  33284. }
  33285. return function (Constructor, protoProps, staticProps) {
  33286. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33287. if (staticProps) defineProperties(Constructor, staticProps);
  33288. return Constructor;
  33289. };
  33290. }();
  33291. var defineProperty = function (obj, key, value) {
  33292. if (key in obj) {
  33293. Object.defineProperty(obj, key, {
  33294. value: value,
  33295. enumerable: true,
  33296. configurable: true,
  33297. writable: true
  33298. });
  33299. } else {
  33300. obj[key] = value;
  33301. }
  33302. return obj;
  33303. };
  33304. var _extends = Object.assign || function (target) {
  33305. for (var i = 1; i < arguments.length; i++) {
  33306. var source = arguments[i];
  33307. for (var key in source) {
  33308. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33309. target[key] = source[key];
  33310. }
  33311. }
  33312. }
  33313. return target;
  33314. };
  33315. /**
  33316. * Given element offsets, generate an output similar to getBoundingClientRect
  33317. * @method
  33318. * @memberof Popper.Utils
  33319. * @argument {Object} offsets
  33320. * @returns {Object} ClientRect like output
  33321. */
  33322. function getClientRect(offsets) {
  33323. return _extends({}, offsets, {
  33324. right: offsets.left + offsets.width,
  33325. bottom: offsets.top + offsets.height
  33326. });
  33327. }
  33328. /**
  33329. * Get bounding client rect of given element
  33330. * @method
  33331. * @memberof Popper.Utils
  33332. * @param {HTMLElement} element
  33333. * @return {Object} client rect
  33334. */
  33335. function getBoundingClientRect(element) {
  33336. var rect = {};
  33337. // IE10 10 FIX: Please, don't ask, the element isn't
  33338. // considered in DOM in some circumstances...
  33339. // This isn't reproducible in IE10 compatibility mode of IE11
  33340. try {
  33341. if (isIE(10)) {
  33342. rect = element.getBoundingClientRect();
  33343. var scrollTop = getScroll(element, 'top');
  33344. var scrollLeft = getScroll(element, 'left');
  33345. rect.top += scrollTop;
  33346. rect.left += scrollLeft;
  33347. rect.bottom += scrollTop;
  33348. rect.right += scrollLeft;
  33349. } else {
  33350. rect = element.getBoundingClientRect();
  33351. }
  33352. } catch (e) {}
  33353. var result = {
  33354. left: rect.left,
  33355. top: rect.top,
  33356. width: rect.right - rect.left,
  33357. height: rect.bottom - rect.top
  33358. };
  33359. // subtract scrollbar size from sizes
  33360. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33361. var width = sizes.width || element.clientWidth || result.width;
  33362. var height = sizes.height || element.clientHeight || result.height;
  33363. var horizScrollbar = element.offsetWidth - width;
  33364. var vertScrollbar = element.offsetHeight - height;
  33365. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33366. // we make this check conditional for performance reasons
  33367. if (horizScrollbar || vertScrollbar) {
  33368. var styles = getStyleComputedProperty(element);
  33369. horizScrollbar -= getBordersSize(styles, 'x');
  33370. vertScrollbar -= getBordersSize(styles, 'y');
  33371. result.width -= horizScrollbar;
  33372. result.height -= vertScrollbar;
  33373. }
  33374. return getClientRect(result);
  33375. }
  33376. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33377. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33378. var isIE10 = isIE(10);
  33379. var isHTML = parent.nodeName === 'HTML';
  33380. var childrenRect = getBoundingClientRect(children);
  33381. var parentRect = getBoundingClientRect(parent);
  33382. var scrollParent = getScrollParent(children);
  33383. var styles = getStyleComputedProperty(parent);
  33384. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33385. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33386. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33387. if (fixedPosition && isHTML) {
  33388. parentRect.top = Math.max(parentRect.top, 0);
  33389. parentRect.left = Math.max(parentRect.left, 0);
  33390. }
  33391. var offsets = getClientRect({
  33392. top: childrenRect.top - parentRect.top - borderTopWidth,
  33393. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33394. width: childrenRect.width,
  33395. height: childrenRect.height
  33396. });
  33397. offsets.marginTop = 0;
  33398. offsets.marginLeft = 0;
  33399. // Subtract margins of documentElement in case it's being used as parent
  33400. // we do this only on HTML because it's the only element that behaves
  33401. // differently when margins are applied to it. The margins are included in
  33402. // the box of the documentElement, in the other cases not.
  33403. if (!isIE10 && isHTML) {
  33404. var marginTop = parseFloat(styles.marginTop);
  33405. var marginLeft = parseFloat(styles.marginLeft);
  33406. offsets.top -= borderTopWidth - marginTop;
  33407. offsets.bottom -= borderTopWidth - marginTop;
  33408. offsets.left -= borderLeftWidth - marginLeft;
  33409. offsets.right -= borderLeftWidth - marginLeft;
  33410. // Attach marginTop and marginLeft because in some circumstances we may need them
  33411. offsets.marginTop = marginTop;
  33412. offsets.marginLeft = marginLeft;
  33413. }
  33414. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33415. offsets = includeScroll(offsets, parent);
  33416. }
  33417. return offsets;
  33418. }
  33419. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33420. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33421. var html = element.ownerDocument.documentElement;
  33422. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33423. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33424. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33425. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33426. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33427. var offset = {
  33428. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33429. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33430. width: width,
  33431. height: height
  33432. };
  33433. return getClientRect(offset);
  33434. }
  33435. /**
  33436. * Check if the given element is fixed or is inside a fixed parent
  33437. * @method
  33438. * @memberof Popper.Utils
  33439. * @argument {Element} element
  33440. * @argument {Element} customContainer
  33441. * @returns {Boolean} answer to "isFixed?"
  33442. */
  33443. function isFixed(element) {
  33444. var nodeName = element.nodeName;
  33445. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33446. return false;
  33447. }
  33448. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33449. return true;
  33450. }
  33451. var parentNode = getParentNode(element);
  33452. if (!parentNode) {
  33453. return false;
  33454. }
  33455. return isFixed(parentNode);
  33456. }
  33457. /**
  33458. * Finds the first parent of an element that has a transformed property defined
  33459. * @method
  33460. * @memberof Popper.Utils
  33461. * @argument {Element} element
  33462. * @returns {Element} first transformed parent or documentElement
  33463. */
  33464. function getFixedPositionOffsetParent(element) {
  33465. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33466. if (!element || !element.parentElement || isIE()) {
  33467. return document.documentElement;
  33468. }
  33469. var el = element.parentElement;
  33470. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33471. el = el.parentElement;
  33472. }
  33473. return el || document.documentElement;
  33474. }
  33475. /**
  33476. * Computed the boundaries limits and return them
  33477. * @method
  33478. * @memberof Popper.Utils
  33479. * @param {HTMLElement} popper
  33480. * @param {HTMLElement} reference
  33481. * @param {number} padding
  33482. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33483. * @param {Boolean} fixedPosition - Is in fixed position mode
  33484. * @returns {Object} Coordinates of the boundaries
  33485. */
  33486. function getBoundaries(popper, reference, padding, boundariesElement) {
  33487. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33488. // NOTE: 1 DOM access here
  33489. var boundaries = { top: 0, left: 0 };
  33490. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33491. // Handle viewport case
  33492. if (boundariesElement === 'viewport') {
  33493. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33494. } else {
  33495. // Handle other cases based on DOM element used as boundaries
  33496. var boundariesNode = void 0;
  33497. if (boundariesElement === 'scrollParent') {
  33498. boundariesNode = getScrollParent(getParentNode(reference));
  33499. if (boundariesNode.nodeName === 'BODY') {
  33500. boundariesNode = popper.ownerDocument.documentElement;
  33501. }
  33502. } else if (boundariesElement === 'window') {
  33503. boundariesNode = popper.ownerDocument.documentElement;
  33504. } else {
  33505. boundariesNode = boundariesElement;
  33506. }
  33507. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33508. // In case of HTML, we need a different computation
  33509. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33510. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33511. height = _getWindowSizes.height,
  33512. width = _getWindowSizes.width;
  33513. boundaries.top += offsets.top - offsets.marginTop;
  33514. boundaries.bottom = height + offsets.top;
  33515. boundaries.left += offsets.left - offsets.marginLeft;
  33516. boundaries.right = width + offsets.left;
  33517. } else {
  33518. // for all the other DOM elements, this one is good
  33519. boundaries = offsets;
  33520. }
  33521. }
  33522. // Add paddings
  33523. padding = padding || 0;
  33524. var isPaddingNumber = typeof padding === 'number';
  33525. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33526. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33527. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33528. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33529. return boundaries;
  33530. }
  33531. function getArea(_ref) {
  33532. var width = _ref.width,
  33533. height = _ref.height;
  33534. return width * height;
  33535. }
  33536. /**
  33537. * Utility used to transform the `auto` placement to the placement with more
  33538. * available space.
  33539. * @method
  33540. * @memberof Popper.Utils
  33541. * @argument {Object} data - The data object generated by update method
  33542. * @argument {Object} options - Modifiers configuration and options
  33543. * @returns {Object} The data object, properly modified
  33544. */
  33545. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33546. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33547. if (placement.indexOf('auto') === -1) {
  33548. return placement;
  33549. }
  33550. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33551. var rects = {
  33552. top: {
  33553. width: boundaries.width,
  33554. height: refRect.top - boundaries.top
  33555. },
  33556. right: {
  33557. width: boundaries.right - refRect.right,
  33558. height: boundaries.height
  33559. },
  33560. bottom: {
  33561. width: boundaries.width,
  33562. height: boundaries.bottom - refRect.bottom
  33563. },
  33564. left: {
  33565. width: refRect.left - boundaries.left,
  33566. height: boundaries.height
  33567. }
  33568. };
  33569. var sortedAreas = Object.keys(rects).map(function (key) {
  33570. return _extends({
  33571. key: key
  33572. }, rects[key], {
  33573. area: getArea(rects[key])
  33574. });
  33575. }).sort(function (a, b) {
  33576. return b.area - a.area;
  33577. });
  33578. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33579. var width = _ref2.width,
  33580. height = _ref2.height;
  33581. return width >= popper.clientWidth && height >= popper.clientHeight;
  33582. });
  33583. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33584. var variation = placement.split('-')[1];
  33585. return computedPlacement + (variation ? '-' + variation : '');
  33586. }
  33587. /**
  33588. * Get offsets to the reference element
  33589. * @method
  33590. * @memberof Popper.Utils
  33591. * @param {Object} state
  33592. * @param {Element} popper - the popper element
  33593. * @param {Element} reference - the reference element (the popper will be relative to this)
  33594. * @param {Element} fixedPosition - is in fixed position mode
  33595. * @returns {Object} An object containing the offsets which will be applied to the popper
  33596. */
  33597. function getReferenceOffsets(state, popper, reference) {
  33598. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33599. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33600. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33601. }
  33602. /**
  33603. * Get the outer sizes of the given element (offset size + margins)
  33604. * @method
  33605. * @memberof Popper.Utils
  33606. * @argument {Element} element
  33607. * @returns {Object} object containing width and height properties
  33608. */
  33609. function getOuterSizes(element) {
  33610. var window = element.ownerDocument.defaultView;
  33611. var styles = window.getComputedStyle(element);
  33612. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33613. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33614. var result = {
  33615. width: element.offsetWidth + y,
  33616. height: element.offsetHeight + x
  33617. };
  33618. return result;
  33619. }
  33620. /**
  33621. * Get the opposite placement of the given one
  33622. * @method
  33623. * @memberof Popper.Utils
  33624. * @argument {String} placement
  33625. * @returns {String} flipped placement
  33626. */
  33627. function getOppositePlacement(placement) {
  33628. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33629. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33630. return hash[matched];
  33631. });
  33632. }
  33633. /**
  33634. * Get offsets to the popper
  33635. * @method
  33636. * @memberof Popper.Utils
  33637. * @param {Object} position - CSS position the Popper will get applied
  33638. * @param {HTMLElement} popper - the popper element
  33639. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33640. * @param {String} placement - one of the valid placement options
  33641. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33642. */
  33643. function getPopperOffsets(popper, referenceOffsets, placement) {
  33644. placement = placement.split('-')[0];
  33645. // Get popper node sizes
  33646. var popperRect = getOuterSizes(popper);
  33647. // Add position, width and height to our offsets object
  33648. var popperOffsets = {
  33649. width: popperRect.width,
  33650. height: popperRect.height
  33651. };
  33652. // depending by the popper placement we have to compute its offsets slightly differently
  33653. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33654. var mainSide = isHoriz ? 'top' : 'left';
  33655. var secondarySide = isHoriz ? 'left' : 'top';
  33656. var measurement = isHoriz ? 'height' : 'width';
  33657. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33658. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33659. if (placement === secondarySide) {
  33660. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33661. } else {
  33662. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33663. }
  33664. return popperOffsets;
  33665. }
  33666. /**
  33667. * Mimics the `find` method of Array
  33668. * @method
  33669. * @memberof Popper.Utils
  33670. * @argument {Array} arr
  33671. * @argument prop
  33672. * @argument value
  33673. * @returns index or -1
  33674. */
  33675. function find(arr, check) {
  33676. // use native find if supported
  33677. if (Array.prototype.find) {
  33678. return arr.find(check);
  33679. }
  33680. // use `filter` to obtain the same behavior of `find`
  33681. return arr.filter(check)[0];
  33682. }
  33683. /**
  33684. * Return the index of the matching object
  33685. * @method
  33686. * @memberof Popper.Utils
  33687. * @argument {Array} arr
  33688. * @argument prop
  33689. * @argument value
  33690. * @returns index or -1
  33691. */
  33692. function findIndex(arr, prop, value) {
  33693. // use native findIndex if supported
  33694. if (Array.prototype.findIndex) {
  33695. return arr.findIndex(function (cur) {
  33696. return cur[prop] === value;
  33697. });
  33698. }
  33699. // use `find` + `indexOf` if `findIndex` isn't supported
  33700. var match = find(arr, function (obj) {
  33701. return obj[prop] === value;
  33702. });
  33703. return arr.indexOf(match);
  33704. }
  33705. /**
  33706. * Loop trough the list of modifiers and run them in order,
  33707. * each of them will then edit the data object.
  33708. * @method
  33709. * @memberof Popper.Utils
  33710. * @param {dataObject} data
  33711. * @param {Array} modifiers
  33712. * @param {String} ends - Optional modifier name used as stopper
  33713. * @returns {dataObject}
  33714. */
  33715. function runModifiers(modifiers, data, ends) {
  33716. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33717. modifiersToRun.forEach(function (modifier) {
  33718. if (modifier['function']) {
  33719. // eslint-disable-line dot-notation
  33720. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33721. }
  33722. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33723. if (modifier.enabled && isFunction(fn)) {
  33724. // Add properties to offsets to make them a complete clientRect object
  33725. // we do this before each modifier to make sure the previous one doesn't
  33726. // mess with these values
  33727. data.offsets.popper = getClientRect(data.offsets.popper);
  33728. data.offsets.reference = getClientRect(data.offsets.reference);
  33729. data = fn(data, modifier);
  33730. }
  33731. });
  33732. return data;
  33733. }
  33734. /**
  33735. * Updates the position of the popper, computing the new offsets and applying
  33736. * the new style.<br />
  33737. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33738. * @method
  33739. * @memberof Popper
  33740. */
  33741. function update() {
  33742. // if popper is destroyed, don't perform any further update
  33743. if (this.state.isDestroyed) {
  33744. return;
  33745. }
  33746. var data = {
  33747. instance: this,
  33748. styles: {},
  33749. arrowStyles: {},
  33750. attributes: {},
  33751. flipped: false,
  33752. offsets: {}
  33753. };
  33754. // compute reference element offsets
  33755. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33756. // compute auto placement, store placement inside the data object,
  33757. // modifiers will be able to edit `placement` if needed
  33758. // and refer to originalPlacement to know the original value
  33759. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33760. // store the computed placement inside `originalPlacement`
  33761. data.originalPlacement = data.placement;
  33762. data.positionFixed = this.options.positionFixed;
  33763. // compute the popper offsets
  33764. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33765. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33766. // run the modifiers
  33767. data = runModifiers(this.modifiers, data);
  33768. // the first `update` will call `onCreate` callback
  33769. // the other ones will call `onUpdate` callback
  33770. if (!this.state.isCreated) {
  33771. this.state.isCreated = true;
  33772. this.options.onCreate(data);
  33773. } else {
  33774. this.options.onUpdate(data);
  33775. }
  33776. }
  33777. /**
  33778. * Helper used to know if the given modifier is enabled.
  33779. * @method
  33780. * @memberof Popper.Utils
  33781. * @returns {Boolean}
  33782. */
  33783. function isModifierEnabled(modifiers, modifierName) {
  33784. return modifiers.some(function (_ref) {
  33785. var name = _ref.name,
  33786. enabled = _ref.enabled;
  33787. return enabled && name === modifierName;
  33788. });
  33789. }
  33790. /**
  33791. * Get the prefixed supported property name
  33792. * @method
  33793. * @memberof Popper.Utils
  33794. * @argument {String} property (camelCase)
  33795. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33796. */
  33797. function getSupportedPropertyName(property) {
  33798. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33799. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33800. for (var i = 0; i < prefixes.length; i++) {
  33801. var prefix = prefixes[i];
  33802. var toCheck = prefix ? '' + prefix + upperProp : property;
  33803. if (typeof document.body.style[toCheck] !== 'undefined') {
  33804. return toCheck;
  33805. }
  33806. }
  33807. return null;
  33808. }
  33809. /**
  33810. * Destroys the popper.
  33811. * @method
  33812. * @memberof Popper
  33813. */
  33814. function destroy() {
  33815. this.state.isDestroyed = true;
  33816. // touch DOM only if `applyStyle` modifier is enabled
  33817. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33818. this.popper.removeAttribute('x-placement');
  33819. this.popper.style.position = '';
  33820. this.popper.style.top = '';
  33821. this.popper.style.left = '';
  33822. this.popper.style.right = '';
  33823. this.popper.style.bottom = '';
  33824. this.popper.style.willChange = '';
  33825. this.popper.style[getSupportedPropertyName('transform')] = '';
  33826. }
  33827. this.disableEventListeners();
  33828. // remove the popper if user explicitly asked for the deletion on destroy
  33829. // do not use `remove` because IE11 doesn't support it
  33830. if (this.options.removeOnDestroy) {
  33831. this.popper.parentNode.removeChild(this.popper);
  33832. }
  33833. return this;
  33834. }
  33835. /**
  33836. * Get the window associated with the element
  33837. * @argument {Element} element
  33838. * @returns {Window}
  33839. */
  33840. function getWindow(element) {
  33841. var ownerDocument = element.ownerDocument;
  33842. return ownerDocument ? ownerDocument.defaultView : window;
  33843. }
  33844. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33845. var isBody = scrollParent.nodeName === 'BODY';
  33846. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33847. target.addEventListener(event, callback, { passive: true });
  33848. if (!isBody) {
  33849. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33850. }
  33851. scrollParents.push(target);
  33852. }
  33853. /**
  33854. * Setup needed event listeners used to update the popper position
  33855. * @method
  33856. * @memberof Popper.Utils
  33857. * @private
  33858. */
  33859. function setupEventListeners(reference, options, state, updateBound) {
  33860. // Resize event listener on window
  33861. state.updateBound = updateBound;
  33862. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33863. // Scroll event listener on scroll parents
  33864. var scrollElement = getScrollParent(reference);
  33865. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33866. state.scrollElement = scrollElement;
  33867. state.eventsEnabled = true;
  33868. return state;
  33869. }
  33870. /**
  33871. * It will add resize/scroll events and start recalculating
  33872. * position of the popper element when they are triggered.
  33873. * @method
  33874. * @memberof Popper
  33875. */
  33876. function enableEventListeners() {
  33877. if (!this.state.eventsEnabled) {
  33878. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33879. }
  33880. }
  33881. /**
  33882. * Remove event listeners used to update the popper position
  33883. * @method
  33884. * @memberof Popper.Utils
  33885. * @private
  33886. */
  33887. function removeEventListeners(reference, state) {
  33888. // Remove resize event listener on window
  33889. getWindow(reference).removeEventListener('resize', state.updateBound);
  33890. // Remove scroll event listener on scroll parents
  33891. state.scrollParents.forEach(function (target) {
  33892. target.removeEventListener('scroll', state.updateBound);
  33893. });
  33894. // Reset state
  33895. state.updateBound = null;
  33896. state.scrollParents = [];
  33897. state.scrollElement = null;
  33898. state.eventsEnabled = false;
  33899. return state;
  33900. }
  33901. /**
  33902. * It will remove resize/scroll events and won't recalculate popper position
  33903. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33904. * unless you call `update` method manually.
  33905. * @method
  33906. * @memberof Popper
  33907. */
  33908. function disableEventListeners() {
  33909. if (this.state.eventsEnabled) {
  33910. cancelAnimationFrame(this.scheduleUpdate);
  33911. this.state = removeEventListeners(this.reference, this.state);
  33912. }
  33913. }
  33914. /**
  33915. * Tells if a given input is a number
  33916. * @method
  33917. * @memberof Popper.Utils
  33918. * @param {*} input to check
  33919. * @return {Boolean}
  33920. */
  33921. function isNumeric(n) {
  33922. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33923. }
  33924. /**
  33925. * Set the style to the given popper
  33926. * @method
  33927. * @memberof Popper.Utils
  33928. * @argument {Element} element - Element to apply the style to
  33929. * @argument {Object} styles
  33930. * Object with a list of properties and values which will be applied to the element
  33931. */
  33932. function setStyles(element, styles) {
  33933. Object.keys(styles).forEach(function (prop) {
  33934. var unit = '';
  33935. // add unit if the value is numeric and is one of the following
  33936. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33937. unit = 'px';
  33938. }
  33939. element.style[prop] = styles[prop] + unit;
  33940. });
  33941. }
  33942. /**
  33943. * Set the attributes to the given popper
  33944. * @method
  33945. * @memberof Popper.Utils
  33946. * @argument {Element} element - Element to apply the attributes to
  33947. * @argument {Object} styles
  33948. * Object with a list of properties and values which will be applied to the element
  33949. */
  33950. function setAttributes(element, attributes) {
  33951. Object.keys(attributes).forEach(function (prop) {
  33952. var value = attributes[prop];
  33953. if (value !== false) {
  33954. element.setAttribute(prop, attributes[prop]);
  33955. } else {
  33956. element.removeAttribute(prop);
  33957. }
  33958. });
  33959. }
  33960. /**
  33961. * @function
  33962. * @memberof Modifiers
  33963. * @argument {Object} data - The data object generated by `update` method
  33964. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33965. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33966. * @argument {Object} options - Modifiers configuration and options
  33967. * @returns {Object} The same data object
  33968. */
  33969. function applyStyle(data) {
  33970. // any property present in `data.styles` will be applied to the popper,
  33971. // in this way we can make the 3rd party modifiers add custom styles to it
  33972. // Be aware, modifiers could override the properties defined in the previous
  33973. // lines of this modifier!
  33974. setStyles(data.instance.popper, data.styles);
  33975. // any property present in `data.attributes` will be applied to the popper,
  33976. // they will be set as HTML attributes of the element
  33977. setAttributes(data.instance.popper, data.attributes);
  33978. // if arrowElement is defined and arrowStyles has some properties
  33979. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33980. setStyles(data.arrowElement, data.arrowStyles);
  33981. }
  33982. return data;
  33983. }
  33984. /**
  33985. * Set the x-placement attribute before everything else because it could be used
  33986. * to add margins to the popper margins needs to be calculated to get the
  33987. * correct popper offsets.
  33988. * @method
  33989. * @memberof Popper.modifiers
  33990. * @param {HTMLElement} reference - The reference element used to position the popper
  33991. * @param {HTMLElement} popper - The HTML element used as popper
  33992. * @param {Object} options - Popper.js options
  33993. */
  33994. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33995. // compute reference element offsets
  33996. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33997. // compute auto placement, store placement inside the data object,
  33998. // modifiers will be able to edit `placement` if needed
  33999. // and refer to originalPlacement to know the original value
  34000. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34001. popper.setAttribute('x-placement', placement);
  34002. // Apply `position` to popper before anything else because
  34003. // without the position applied we can't guarantee correct computations
  34004. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34005. return options;
  34006. }
  34007. /**
  34008. * @function
  34009. * @memberof Popper.Utils
  34010. * @argument {Object} data - The data object generated by `update` method
  34011. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34012. * @returns {Object} The popper's position offsets rounded
  34013. *
  34014. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34015. * good as it can be within reason.
  34016. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34017. *
  34018. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34019. * as well on High DPI screens).
  34020. *
  34021. * Firefox prefers no rounding for positioning and does not have blurriness on
  34022. * high DPI screens.
  34023. *
  34024. * Only horizontal placement and left/right values need to be considered.
  34025. */
  34026. function getRoundedOffsets(data, shouldRound) {
  34027. var _data$offsets = data.offsets,
  34028. popper = _data$offsets.popper,
  34029. reference = _data$offsets.reference;
  34030. var round = Math.round,
  34031. floor = Math.floor;
  34032. var noRound = function noRound(v) {
  34033. return v;
  34034. };
  34035. var referenceWidth = round(reference.width);
  34036. var popperWidth = round(popper.width);
  34037. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34038. var isVariation = data.placement.indexOf('-') !== -1;
  34039. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34040. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34041. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34042. var verticalToInteger = !shouldRound ? noRound : round;
  34043. return {
  34044. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34045. top: verticalToInteger(popper.top),
  34046. bottom: verticalToInteger(popper.bottom),
  34047. right: horizontalToInteger(popper.right)
  34048. };
  34049. }
  34050. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34051. /**
  34052. * @function
  34053. * @memberof Modifiers
  34054. * @argument {Object} data - The data object generated by `update` method
  34055. * @argument {Object} options - Modifiers configuration and options
  34056. * @returns {Object} The data object, properly modified
  34057. */
  34058. function computeStyle(data, options) {
  34059. var x = options.x,
  34060. y = options.y;
  34061. var popper = data.offsets.popper;
  34062. // Remove this legacy support in Popper.js v2
  34063. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34064. return modifier.name === 'applyStyle';
  34065. }).gpuAcceleration;
  34066. if (legacyGpuAccelerationOption !== undefined) {
  34067. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34068. }
  34069. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34070. var offsetParent = getOffsetParent(data.instance.popper);
  34071. var offsetParentRect = getBoundingClientRect(offsetParent);
  34072. // Styles
  34073. var styles = {
  34074. position: popper.position
  34075. };
  34076. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34077. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34078. var sideB = y === 'right' ? 'left' : 'right';
  34079. // if gpuAcceleration is set to `true` and transform is supported,
  34080. // we use `translate3d` to apply the position to the popper we
  34081. // automatically use the supported prefixed version if needed
  34082. var prefixedProperty = getSupportedPropertyName('transform');
  34083. // now, let's make a step back and look at this code closely (wtf?)
  34084. // If the content of the popper grows once it's been positioned, it
  34085. // may happen that the popper gets misplaced because of the new content
  34086. // overflowing its reference element
  34087. // To avoid this problem, we provide two options (x and y), which allow
  34088. // the consumer to define the offset origin.
  34089. // If we position a popper on top of a reference element, we can set
  34090. // `x` to `top` to make the popper grow towards its top instead of
  34091. // its bottom.
  34092. var left = void 0,
  34093. top = void 0;
  34094. if (sideA === 'bottom') {
  34095. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34096. // and not the bottom of the html element
  34097. if (offsetParent.nodeName === 'HTML') {
  34098. top = -offsetParent.clientHeight + offsets.bottom;
  34099. } else {
  34100. top = -offsetParentRect.height + offsets.bottom;
  34101. }
  34102. } else {
  34103. top = offsets.top;
  34104. }
  34105. if (sideB === 'right') {
  34106. if (offsetParent.nodeName === 'HTML') {
  34107. left = -offsetParent.clientWidth + offsets.right;
  34108. } else {
  34109. left = -offsetParentRect.width + offsets.right;
  34110. }
  34111. } else {
  34112. left = offsets.left;
  34113. }
  34114. if (gpuAcceleration && prefixedProperty) {
  34115. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34116. styles[sideA] = 0;
  34117. styles[sideB] = 0;
  34118. styles.willChange = 'transform';
  34119. } else {
  34120. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34121. var invertTop = sideA === 'bottom' ? -1 : 1;
  34122. var invertLeft = sideB === 'right' ? -1 : 1;
  34123. styles[sideA] = top * invertTop;
  34124. styles[sideB] = left * invertLeft;
  34125. styles.willChange = sideA + ', ' + sideB;
  34126. }
  34127. // Attributes
  34128. var attributes = {
  34129. 'x-placement': data.placement
  34130. };
  34131. // Update `data` attributes, styles and arrowStyles
  34132. data.attributes = _extends({}, attributes, data.attributes);
  34133. data.styles = _extends({}, styles, data.styles);
  34134. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34135. return data;
  34136. }
  34137. /**
  34138. * Helper used to know if the given modifier depends from another one.<br />
  34139. * It checks if the needed modifier is listed and enabled.
  34140. * @method
  34141. * @memberof Popper.Utils
  34142. * @param {Array} modifiers - list of modifiers
  34143. * @param {String} requestingName - name of requesting modifier
  34144. * @param {String} requestedName - name of requested modifier
  34145. * @returns {Boolean}
  34146. */
  34147. function isModifierRequired(modifiers, requestingName, requestedName) {
  34148. var requesting = find(modifiers, function (_ref) {
  34149. var name = _ref.name;
  34150. return name === requestingName;
  34151. });
  34152. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34153. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34154. });
  34155. if (!isRequired) {
  34156. var _requesting = '`' + requestingName + '`';
  34157. var requested = '`' + requestedName + '`';
  34158. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34159. }
  34160. return isRequired;
  34161. }
  34162. /**
  34163. * @function
  34164. * @memberof Modifiers
  34165. * @argument {Object} data - The data object generated by update method
  34166. * @argument {Object} options - Modifiers configuration and options
  34167. * @returns {Object} The data object, properly modified
  34168. */
  34169. function arrow(data, options) {
  34170. var _data$offsets$arrow;
  34171. // arrow depends on keepTogether in order to work
  34172. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34173. return data;
  34174. }
  34175. var arrowElement = options.element;
  34176. // if arrowElement is a string, suppose it's a CSS selector
  34177. if (typeof arrowElement === 'string') {
  34178. arrowElement = data.instance.popper.querySelector(arrowElement);
  34179. // if arrowElement is not found, don't run the modifier
  34180. if (!arrowElement) {
  34181. return data;
  34182. }
  34183. } else {
  34184. // if the arrowElement isn't a query selector we must check that the
  34185. // provided DOM node is child of its popper node
  34186. if (!data.instance.popper.contains(arrowElement)) {
  34187. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34188. return data;
  34189. }
  34190. }
  34191. var placement = data.placement.split('-')[0];
  34192. var _data$offsets = data.offsets,
  34193. popper = _data$offsets.popper,
  34194. reference = _data$offsets.reference;
  34195. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34196. var len = isVertical ? 'height' : 'width';
  34197. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34198. var side = sideCapitalized.toLowerCase();
  34199. var altSide = isVertical ? 'left' : 'top';
  34200. var opSide = isVertical ? 'bottom' : 'right';
  34201. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34202. //
  34203. // extends keepTogether behavior making sure the popper and its
  34204. // reference have enough pixels in conjunction
  34205. //
  34206. // top/left side
  34207. if (reference[opSide] - arrowElementSize < popper[side]) {
  34208. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34209. }
  34210. // bottom/right side
  34211. if (reference[side] + arrowElementSize > popper[opSide]) {
  34212. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34213. }
  34214. data.offsets.popper = getClientRect(data.offsets.popper);
  34215. // compute center of the popper
  34216. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34217. // Compute the sideValue using the updated popper offsets
  34218. // take popper margin in account because we don't have this info available
  34219. var css = getStyleComputedProperty(data.instance.popper);
  34220. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34221. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34222. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34223. // prevent arrowElement from being placed not contiguously to its popper
  34224. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34225. data.arrowElement = arrowElement;
  34226. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34227. return data;
  34228. }
  34229. /**
  34230. * Get the opposite placement variation of the given one
  34231. * @method
  34232. * @memberof Popper.Utils
  34233. * @argument {String} placement variation
  34234. * @returns {String} flipped placement variation
  34235. */
  34236. function getOppositeVariation(variation) {
  34237. if (variation === 'end') {
  34238. return 'start';
  34239. } else if (variation === 'start') {
  34240. return 'end';
  34241. }
  34242. return variation;
  34243. }
  34244. /**
  34245. * List of accepted placements to use as values of the `placement` option.<br />
  34246. * Valid placements are:
  34247. * - `auto`
  34248. * - `top`
  34249. * - `right`
  34250. * - `bottom`
  34251. * - `left`
  34252. *
  34253. * Each placement can have a variation from this list:
  34254. * - `-start`
  34255. * - `-end`
  34256. *
  34257. * Variations are interpreted easily if you think of them as the left to right
  34258. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34259. * is right.<br />
  34260. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34261. *
  34262. * Some valid examples are:
  34263. * - `top-end` (on top of reference, right aligned)
  34264. * - `right-start` (on right of reference, top aligned)
  34265. * - `bottom` (on bottom, centered)
  34266. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34267. *
  34268. * @static
  34269. * @type {Array}
  34270. * @enum {String}
  34271. * @readonly
  34272. * @method placements
  34273. * @memberof Popper
  34274. */
  34275. 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'];
  34276. // Get rid of `auto` `auto-start` and `auto-end`
  34277. var validPlacements = placements.slice(3);
  34278. /**
  34279. * Given an initial placement, returns all the subsequent placements
  34280. * clockwise (or counter-clockwise).
  34281. *
  34282. * @method
  34283. * @memberof Popper.Utils
  34284. * @argument {String} placement - A valid placement (it accepts variations)
  34285. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34286. * @returns {Array} placements including their variations
  34287. */
  34288. function clockwise(placement) {
  34289. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34290. var index = validPlacements.indexOf(placement);
  34291. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34292. return counter ? arr.reverse() : arr;
  34293. }
  34294. var BEHAVIORS = {
  34295. FLIP: 'flip',
  34296. CLOCKWISE: 'clockwise',
  34297. COUNTERCLOCKWISE: 'counterclockwise'
  34298. };
  34299. /**
  34300. * @function
  34301. * @memberof Modifiers
  34302. * @argument {Object} data - The data object generated by update method
  34303. * @argument {Object} options - Modifiers configuration and options
  34304. * @returns {Object} The data object, properly modified
  34305. */
  34306. function flip(data, options) {
  34307. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34308. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34309. return data;
  34310. }
  34311. if (data.flipped && data.placement === data.originalPlacement) {
  34312. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34313. return data;
  34314. }
  34315. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34316. var placement = data.placement.split('-')[0];
  34317. var placementOpposite = getOppositePlacement(placement);
  34318. var variation = data.placement.split('-')[1] || '';
  34319. var flipOrder = [];
  34320. switch (options.behavior) {
  34321. case BEHAVIORS.FLIP:
  34322. flipOrder = [placement, placementOpposite];
  34323. break;
  34324. case BEHAVIORS.CLOCKWISE:
  34325. flipOrder = clockwise(placement);
  34326. break;
  34327. case BEHAVIORS.COUNTERCLOCKWISE:
  34328. flipOrder = clockwise(placement, true);
  34329. break;
  34330. default:
  34331. flipOrder = options.behavior;
  34332. }
  34333. flipOrder.forEach(function (step, index) {
  34334. if (placement !== step || flipOrder.length === index + 1) {
  34335. return data;
  34336. }
  34337. placement = data.placement.split('-')[0];
  34338. placementOpposite = getOppositePlacement(placement);
  34339. var popperOffsets = data.offsets.popper;
  34340. var refOffsets = data.offsets.reference;
  34341. // using floor because the reference offsets may contain decimals we are not going to consider here
  34342. var floor = Math.floor;
  34343. 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);
  34344. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34345. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34346. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34347. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34348. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34349. // flip the variation if required
  34350. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34351. // flips variation if reference element overflows boundaries
  34352. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34353. // flips variation if popper content overflows boundaries
  34354. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34355. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34356. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34357. // this boolean to detect any flip loop
  34358. data.flipped = true;
  34359. if (overlapsRef || overflowsBoundaries) {
  34360. placement = flipOrder[index + 1];
  34361. }
  34362. if (flippedVariation) {
  34363. variation = getOppositeVariation(variation);
  34364. }
  34365. data.placement = placement + (variation ? '-' + variation : '');
  34366. // this object contains `position`, we want to preserve it along with
  34367. // any additional property we may add in the future
  34368. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34369. data = runModifiers(data.instance.modifiers, data, 'flip');
  34370. }
  34371. });
  34372. return data;
  34373. }
  34374. /**
  34375. * @function
  34376. * @memberof Modifiers
  34377. * @argument {Object} data - The data object generated by update method
  34378. * @argument {Object} options - Modifiers configuration and options
  34379. * @returns {Object} The data object, properly modified
  34380. */
  34381. function keepTogether(data) {
  34382. var _data$offsets = data.offsets,
  34383. popper = _data$offsets.popper,
  34384. reference = _data$offsets.reference;
  34385. var placement = data.placement.split('-')[0];
  34386. var floor = Math.floor;
  34387. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34388. var side = isVertical ? 'right' : 'bottom';
  34389. var opSide = isVertical ? 'left' : 'top';
  34390. var measurement = isVertical ? 'width' : 'height';
  34391. if (popper[side] < floor(reference[opSide])) {
  34392. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34393. }
  34394. if (popper[opSide] > floor(reference[side])) {
  34395. data.offsets.popper[opSide] = floor(reference[side]);
  34396. }
  34397. return data;
  34398. }
  34399. /**
  34400. * Converts a string containing value + unit into a px value number
  34401. * @function
  34402. * @memberof {modifiers~offset}
  34403. * @private
  34404. * @argument {String} str - Value + unit string
  34405. * @argument {String} measurement - `height` or `width`
  34406. * @argument {Object} popperOffsets
  34407. * @argument {Object} referenceOffsets
  34408. * @returns {Number|String}
  34409. * Value in pixels, or original string if no values were extracted
  34410. */
  34411. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34412. // separate value from unit
  34413. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34414. var value = +split[1];
  34415. var unit = split[2];
  34416. // If it's not a number it's an operator, I guess
  34417. if (!value) {
  34418. return str;
  34419. }
  34420. if (unit.indexOf('%') === 0) {
  34421. var element = void 0;
  34422. switch (unit) {
  34423. case '%p':
  34424. element = popperOffsets;
  34425. break;
  34426. case '%':
  34427. case '%r':
  34428. default:
  34429. element = referenceOffsets;
  34430. }
  34431. var rect = getClientRect(element);
  34432. return rect[measurement] / 100 * value;
  34433. } else if (unit === 'vh' || unit === 'vw') {
  34434. // if is a vh or vw, we calculate the size based on the viewport
  34435. var size = void 0;
  34436. if (unit === 'vh') {
  34437. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34438. } else {
  34439. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34440. }
  34441. return size / 100 * value;
  34442. } else {
  34443. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34444. // if is an implicit unit, it's px, and we return just the value
  34445. return value;
  34446. }
  34447. }
  34448. /**
  34449. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34450. * @function
  34451. * @memberof {modifiers~offset}
  34452. * @private
  34453. * @argument {String} offset
  34454. * @argument {Object} popperOffsets
  34455. * @argument {Object} referenceOffsets
  34456. * @argument {String} basePlacement
  34457. * @returns {Array} a two cells array with x and y offsets in numbers
  34458. */
  34459. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34460. var offsets = [0, 0];
  34461. // Use height if placement is left or right and index is 0 otherwise use width
  34462. // in this way the first offset will use an axis and the second one
  34463. // will use the other one
  34464. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34465. // Split the offset string to obtain a list of values and operands
  34466. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34467. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34468. return frag.trim();
  34469. });
  34470. // Detect if the offset string contains a pair of values or a single one
  34471. // they could be separated by comma or space
  34472. var divider = fragments.indexOf(find(fragments, function (frag) {
  34473. return frag.search(/,|\s/) !== -1;
  34474. }));
  34475. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34476. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34477. }
  34478. // If divider is found, we divide the list of values and operands to divide
  34479. // them by ofset X and Y.
  34480. var splitRegex = /\s*,\s*|\s+/;
  34481. 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];
  34482. // Convert the values with units to absolute pixels to allow our computations
  34483. ops = ops.map(function (op, index) {
  34484. // Most of the units rely on the orientation of the popper
  34485. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34486. var mergeWithPrevious = false;
  34487. return op
  34488. // This aggregates any `+` or `-` sign that aren't considered operators
  34489. // e.g.: 10 + +5 => [10, +, +5]
  34490. .reduce(function (a, b) {
  34491. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34492. a[a.length - 1] = b;
  34493. mergeWithPrevious = true;
  34494. return a;
  34495. } else if (mergeWithPrevious) {
  34496. a[a.length - 1] += b;
  34497. mergeWithPrevious = false;
  34498. return a;
  34499. } else {
  34500. return a.concat(b);
  34501. }
  34502. }, [])
  34503. // Here we convert the string values into number values (in px)
  34504. .map(function (str) {
  34505. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34506. });
  34507. });
  34508. // Loop trough the offsets arrays and execute the operations
  34509. ops.forEach(function (op, index) {
  34510. op.forEach(function (frag, index2) {
  34511. if (isNumeric(frag)) {
  34512. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34513. }
  34514. });
  34515. });
  34516. return offsets;
  34517. }
  34518. /**
  34519. * @function
  34520. * @memberof Modifiers
  34521. * @argument {Object} data - The data object generated by update method
  34522. * @argument {Object} options - Modifiers configuration and options
  34523. * @argument {Number|String} options.offset=0
  34524. * The offset value as described in the modifier description
  34525. * @returns {Object} The data object, properly modified
  34526. */
  34527. function offset(data, _ref) {
  34528. var offset = _ref.offset;
  34529. var placement = data.placement,
  34530. _data$offsets = data.offsets,
  34531. popper = _data$offsets.popper,
  34532. reference = _data$offsets.reference;
  34533. var basePlacement = placement.split('-')[0];
  34534. var offsets = void 0;
  34535. if (isNumeric(+offset)) {
  34536. offsets = [+offset, 0];
  34537. } else {
  34538. offsets = parseOffset(offset, popper, reference, basePlacement);
  34539. }
  34540. if (basePlacement === 'left') {
  34541. popper.top += offsets[0];
  34542. popper.left -= offsets[1];
  34543. } else if (basePlacement === 'right') {
  34544. popper.top += offsets[0];
  34545. popper.left += offsets[1];
  34546. } else if (basePlacement === 'top') {
  34547. popper.left += offsets[0];
  34548. popper.top -= offsets[1];
  34549. } else if (basePlacement === 'bottom') {
  34550. popper.left += offsets[0];
  34551. popper.top += offsets[1];
  34552. }
  34553. data.popper = popper;
  34554. return data;
  34555. }
  34556. /**
  34557. * @function
  34558. * @memberof Modifiers
  34559. * @argument {Object} data - The data object generated by `update` method
  34560. * @argument {Object} options - Modifiers configuration and options
  34561. * @returns {Object} The data object, properly modified
  34562. */
  34563. function preventOverflow(data, options) {
  34564. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34565. // If offsetParent is the reference element, we really want to
  34566. // go one step up and use the next offsetParent as reference to
  34567. // avoid to make this modifier completely useless and look like broken
  34568. if (data.instance.reference === boundariesElement) {
  34569. boundariesElement = getOffsetParent(boundariesElement);
  34570. }
  34571. // NOTE: DOM access here
  34572. // resets the popper's position so that the document size can be calculated excluding
  34573. // the size of the popper element itself
  34574. var transformProp = getSupportedPropertyName('transform');
  34575. var popperStyles = data.instance.popper.style; // assignment to help minification
  34576. var top = popperStyles.top,
  34577. left = popperStyles.left,
  34578. transform = popperStyles[transformProp];
  34579. popperStyles.top = '';
  34580. popperStyles.left = '';
  34581. popperStyles[transformProp] = '';
  34582. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34583. // NOTE: DOM access here
  34584. // restores the original style properties after the offsets have been computed
  34585. popperStyles.top = top;
  34586. popperStyles.left = left;
  34587. popperStyles[transformProp] = transform;
  34588. options.boundaries = boundaries;
  34589. var order = options.priority;
  34590. var popper = data.offsets.popper;
  34591. var check = {
  34592. primary: function primary(placement) {
  34593. var value = popper[placement];
  34594. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34595. value = Math.max(popper[placement], boundaries[placement]);
  34596. }
  34597. return defineProperty({}, placement, value);
  34598. },
  34599. secondary: function secondary(placement) {
  34600. var mainSide = placement === 'right' ? 'left' : 'top';
  34601. var value = popper[mainSide];
  34602. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34603. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34604. }
  34605. return defineProperty({}, mainSide, value);
  34606. }
  34607. };
  34608. order.forEach(function (placement) {
  34609. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34610. popper = _extends({}, popper, check[side](placement));
  34611. });
  34612. data.offsets.popper = popper;
  34613. return data;
  34614. }
  34615. /**
  34616. * @function
  34617. * @memberof Modifiers
  34618. * @argument {Object} data - The data object generated by `update` method
  34619. * @argument {Object} options - Modifiers configuration and options
  34620. * @returns {Object} The data object, properly modified
  34621. */
  34622. function shift(data) {
  34623. var placement = data.placement;
  34624. var basePlacement = placement.split('-')[0];
  34625. var shiftvariation = placement.split('-')[1];
  34626. // if shift shiftvariation is specified, run the modifier
  34627. if (shiftvariation) {
  34628. var _data$offsets = data.offsets,
  34629. reference = _data$offsets.reference,
  34630. popper = _data$offsets.popper;
  34631. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34632. var side = isVertical ? 'left' : 'top';
  34633. var measurement = isVertical ? 'width' : 'height';
  34634. var shiftOffsets = {
  34635. start: defineProperty({}, side, reference[side]),
  34636. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34637. };
  34638. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34639. }
  34640. return data;
  34641. }
  34642. /**
  34643. * @function
  34644. * @memberof Modifiers
  34645. * @argument {Object} data - The data object generated by update method
  34646. * @argument {Object} options - Modifiers configuration and options
  34647. * @returns {Object} The data object, properly modified
  34648. */
  34649. function hide(data) {
  34650. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34651. return data;
  34652. }
  34653. var refRect = data.offsets.reference;
  34654. var bound = find(data.instance.modifiers, function (modifier) {
  34655. return modifier.name === 'preventOverflow';
  34656. }).boundaries;
  34657. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34658. // Avoid unnecessary DOM access if visibility hasn't changed
  34659. if (data.hide === true) {
  34660. return data;
  34661. }
  34662. data.hide = true;
  34663. data.attributes['x-out-of-boundaries'] = '';
  34664. } else {
  34665. // Avoid unnecessary DOM access if visibility hasn't changed
  34666. if (data.hide === false) {
  34667. return data;
  34668. }
  34669. data.hide = false;
  34670. data.attributes['x-out-of-boundaries'] = false;
  34671. }
  34672. return data;
  34673. }
  34674. /**
  34675. * @function
  34676. * @memberof Modifiers
  34677. * @argument {Object} data - The data object generated by `update` method
  34678. * @argument {Object} options - Modifiers configuration and options
  34679. * @returns {Object} The data object, properly modified
  34680. */
  34681. function inner(data) {
  34682. var placement = data.placement;
  34683. var basePlacement = placement.split('-')[0];
  34684. var _data$offsets = data.offsets,
  34685. popper = _data$offsets.popper,
  34686. reference = _data$offsets.reference;
  34687. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34688. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34689. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34690. data.placement = getOppositePlacement(placement);
  34691. data.offsets.popper = getClientRect(popper);
  34692. return data;
  34693. }
  34694. /**
  34695. * Modifier function, each modifier can have a function of this type assigned
  34696. * to its `fn` property.<br />
  34697. * These functions will be called on each update, this means that you must
  34698. * make sure they are performant enough to avoid performance bottlenecks.
  34699. *
  34700. * @function ModifierFn
  34701. * @argument {dataObject} data - The data object generated by `update` method
  34702. * @argument {Object} options - Modifiers configuration and options
  34703. * @returns {dataObject} The data object, properly modified
  34704. */
  34705. /**
  34706. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34707. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34708. * needed by the library.
  34709. *
  34710. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34711. * All the other properties are configurations that could be tweaked.
  34712. * @namespace modifiers
  34713. */
  34714. var modifiers = {
  34715. /**
  34716. * Modifier used to shift the popper on the start or end of its reference
  34717. * element.<br />
  34718. * It will read the variation of the `placement` property.<br />
  34719. * It can be one either `-end` or `-start`.
  34720. * @memberof modifiers
  34721. * @inner
  34722. */
  34723. shift: {
  34724. /** @prop {number} order=100 - Index used to define the order of execution */
  34725. order: 100,
  34726. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34727. enabled: true,
  34728. /** @prop {ModifierFn} */
  34729. fn: shift
  34730. },
  34731. /**
  34732. * The `offset` modifier can shift your popper on both its axis.
  34733. *
  34734. * It accepts the following units:
  34735. * - `px` or unit-less, interpreted as pixels
  34736. * - `%` or `%r`, percentage relative to the length of the reference element
  34737. * - `%p`, percentage relative to the length of the popper element
  34738. * - `vw`, CSS viewport width unit
  34739. * - `vh`, CSS viewport height unit
  34740. *
  34741. * For length is intended the main axis relative to the placement of the popper.<br />
  34742. * This means that if the placement is `top` or `bottom`, the length will be the
  34743. * `width`. In case of `left` or `right`, it will be the `height`.
  34744. *
  34745. * You can provide a single value (as `Number` or `String`), or a pair of values
  34746. * as `String` divided by a comma or one (or more) white spaces.<br />
  34747. * The latter is a deprecated method because it leads to confusion and will be
  34748. * removed in v2.<br />
  34749. * Additionally, it accepts additions and subtractions between different units.
  34750. * Note that multiplications and divisions aren't supported.
  34751. *
  34752. * Valid examples are:
  34753. * ```
  34754. * 10
  34755. * '10%'
  34756. * '10, 10'
  34757. * '10%, 10'
  34758. * '10 + 10%'
  34759. * '10 - 5vh + 3%'
  34760. * '-10px + 5vh, 5px - 6%'
  34761. * ```
  34762. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34763. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34764. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34765. *
  34766. * @memberof modifiers
  34767. * @inner
  34768. */
  34769. offset: {
  34770. /** @prop {number} order=200 - Index used to define the order of execution */
  34771. order: 200,
  34772. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34773. enabled: true,
  34774. /** @prop {ModifierFn} */
  34775. fn: offset,
  34776. /** @prop {Number|String} offset=0
  34777. * The offset value as described in the modifier description
  34778. */
  34779. offset: 0
  34780. },
  34781. /**
  34782. * Modifier used to prevent the popper from being positioned outside the boundary.
  34783. *
  34784. * A scenario exists where the reference itself is not within the boundaries.<br />
  34785. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34786. * In this case we need to decide whether the popper should either:
  34787. *
  34788. * - detach from the reference and remain "trapped" in the boundaries, or
  34789. * - if it should ignore the boundary and "escape with its reference"
  34790. *
  34791. * When `escapeWithReference` is set to`true` and reference is completely
  34792. * outside its boundaries, the popper will overflow (or completely leave)
  34793. * the boundaries in order to remain attached to the edge of the reference.
  34794. *
  34795. * @memberof modifiers
  34796. * @inner
  34797. */
  34798. preventOverflow: {
  34799. /** @prop {number} order=300 - Index used to define the order of execution */
  34800. order: 300,
  34801. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34802. enabled: true,
  34803. /** @prop {ModifierFn} */
  34804. fn: preventOverflow,
  34805. /**
  34806. * @prop {Array} [priority=['left','right','top','bottom']]
  34807. * Popper will try to prevent overflow following these priorities by default,
  34808. * then, it could overflow on the left and on top of the `boundariesElement`
  34809. */
  34810. priority: ['left', 'right', 'top', 'bottom'],
  34811. /**
  34812. * @prop {number} padding=5
  34813. * Amount of pixel used to define a minimum distance between the boundaries
  34814. * and the popper. This makes sure the popper always has a little padding
  34815. * between the edges of its container
  34816. */
  34817. padding: 5,
  34818. /**
  34819. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34820. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34821. * `viewport` or any DOM element.
  34822. */
  34823. boundariesElement: 'scrollParent'
  34824. },
  34825. /**
  34826. * Modifier used to make sure the reference and its popper stay near each other
  34827. * without leaving any gap between the two. Especially useful when the arrow is
  34828. * enabled and you want to ensure that it points to its reference element.
  34829. * It cares only about the first axis. You can still have poppers with margin
  34830. * between the popper and its reference element.
  34831. * @memberof modifiers
  34832. * @inner
  34833. */
  34834. keepTogether: {
  34835. /** @prop {number} order=400 - Index used to define the order of execution */
  34836. order: 400,
  34837. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34838. enabled: true,
  34839. /** @prop {ModifierFn} */
  34840. fn: keepTogether
  34841. },
  34842. /**
  34843. * This modifier is used to move the `arrowElement` of the popper to make
  34844. * sure it is positioned between the reference element and its popper element.
  34845. * It will read the outer size of the `arrowElement` node to detect how many
  34846. * pixels of conjunction are needed.
  34847. *
  34848. * It has no effect if no `arrowElement` is provided.
  34849. * @memberof modifiers
  34850. * @inner
  34851. */
  34852. arrow: {
  34853. /** @prop {number} order=500 - Index used to define the order of execution */
  34854. order: 500,
  34855. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34856. enabled: true,
  34857. /** @prop {ModifierFn} */
  34858. fn: arrow,
  34859. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34860. element: '[x-arrow]'
  34861. },
  34862. /**
  34863. * Modifier used to flip the popper's placement when it starts to overlap its
  34864. * reference element.
  34865. *
  34866. * Requires the `preventOverflow` modifier before it in order to work.
  34867. *
  34868. * **NOTE:** this modifier will interrupt the current update cycle and will
  34869. * restart it if it detects the need to flip the placement.
  34870. * @memberof modifiers
  34871. * @inner
  34872. */
  34873. flip: {
  34874. /** @prop {number} order=600 - Index used to define the order of execution */
  34875. order: 600,
  34876. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34877. enabled: true,
  34878. /** @prop {ModifierFn} */
  34879. fn: flip,
  34880. /**
  34881. * @prop {String|Array} behavior='flip'
  34882. * The behavior used to change the popper's placement. It can be one of
  34883. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34884. * placements (with optional variations)
  34885. */
  34886. behavior: 'flip',
  34887. /**
  34888. * @prop {number} padding=5
  34889. * The popper will flip if it hits the edges of the `boundariesElement`
  34890. */
  34891. padding: 5,
  34892. /**
  34893. * @prop {String|HTMLElement} boundariesElement='viewport'
  34894. * The element which will define the boundaries of the popper position.
  34895. * The popper will never be placed outside of the defined boundaries
  34896. * (except if `keepTogether` is enabled)
  34897. */
  34898. boundariesElement: 'viewport',
  34899. /**
  34900. * @prop {Boolean} flipVariations=false
  34901. * The popper will switch placement variation between `-start` and `-end` when
  34902. * the reference element overlaps its boundaries.
  34903. *
  34904. * The original placement should have a set variation.
  34905. */
  34906. flipVariations: false,
  34907. /**
  34908. * @prop {Boolean} flipVariationsByContent=false
  34909. * The popper will switch placement variation between `-start` and `-end` when
  34910. * the popper element overlaps its reference boundaries.
  34911. *
  34912. * The original placement should have a set variation.
  34913. */
  34914. flipVariationsByContent: false
  34915. },
  34916. /**
  34917. * Modifier used to make the popper flow toward the inner of the reference element.
  34918. * By default, when this modifier is disabled, the popper will be placed outside
  34919. * the reference element.
  34920. * @memberof modifiers
  34921. * @inner
  34922. */
  34923. inner: {
  34924. /** @prop {number} order=700 - Index used to define the order of execution */
  34925. order: 700,
  34926. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34927. enabled: false,
  34928. /** @prop {ModifierFn} */
  34929. fn: inner
  34930. },
  34931. /**
  34932. * Modifier used to hide the popper when its reference element is outside of the
  34933. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34934. * be used to hide with a CSS selector the popper when its reference is
  34935. * out of boundaries.
  34936. *
  34937. * Requires the `preventOverflow` modifier before it in order to work.
  34938. * @memberof modifiers
  34939. * @inner
  34940. */
  34941. hide: {
  34942. /** @prop {number} order=800 - Index used to define the order of execution */
  34943. order: 800,
  34944. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34945. enabled: true,
  34946. /** @prop {ModifierFn} */
  34947. fn: hide
  34948. },
  34949. /**
  34950. * Computes the style that will be applied to the popper element to gets
  34951. * properly positioned.
  34952. *
  34953. * Note that this modifier will not touch the DOM, it just prepares the styles
  34954. * so that `applyStyle` modifier can apply it. This separation is useful
  34955. * in case you need to replace `applyStyle` with a custom implementation.
  34956. *
  34957. * This modifier has `850` as `order` value to maintain backward compatibility
  34958. * with previous versions of Popper.js. Expect the modifiers ordering method
  34959. * to change in future major versions of the library.
  34960. *
  34961. * @memberof modifiers
  34962. * @inner
  34963. */
  34964. computeStyle: {
  34965. /** @prop {number} order=850 - Index used to define the order of execution */
  34966. order: 850,
  34967. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34968. enabled: true,
  34969. /** @prop {ModifierFn} */
  34970. fn: computeStyle,
  34971. /**
  34972. * @prop {Boolean} gpuAcceleration=true
  34973. * If true, it uses the CSS 3D transformation to position the popper.
  34974. * Otherwise, it will use the `top` and `left` properties
  34975. */
  34976. gpuAcceleration: true,
  34977. /**
  34978. * @prop {string} [x='bottom']
  34979. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34980. * Change this if your popper should grow in a direction different from `bottom`
  34981. */
  34982. x: 'bottom',
  34983. /**
  34984. * @prop {string} [x='left']
  34985. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34986. * Change this if your popper should grow in a direction different from `right`
  34987. */
  34988. y: 'right'
  34989. },
  34990. /**
  34991. * Applies the computed styles to the popper element.
  34992. *
  34993. * All the DOM manipulations are limited to this modifier. This is useful in case
  34994. * you want to integrate Popper.js inside a framework or view library and you
  34995. * want to delegate all the DOM manipulations to it.
  34996. *
  34997. * Note that if you disable this modifier, you must make sure the popper element
  34998. * has its position set to `absolute` before Popper.js can do its work!
  34999. *
  35000. * Just disable this modifier and define your own to achieve the desired effect.
  35001. *
  35002. * @memberof modifiers
  35003. * @inner
  35004. */
  35005. applyStyle: {
  35006. /** @prop {number} order=900 - Index used to define the order of execution */
  35007. order: 900,
  35008. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35009. enabled: true,
  35010. /** @prop {ModifierFn} */
  35011. fn: applyStyle,
  35012. /** @prop {Function} */
  35013. onLoad: applyStyleOnLoad,
  35014. /**
  35015. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35016. * @prop {Boolean} gpuAcceleration=true
  35017. * If true, it uses the CSS 3D transformation to position the popper.
  35018. * Otherwise, it will use the `top` and `left` properties
  35019. */
  35020. gpuAcceleration: undefined
  35021. }
  35022. };
  35023. /**
  35024. * The `dataObject` is an object containing all the information used by Popper.js.
  35025. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35026. * @name dataObject
  35027. * @property {Object} data.instance The Popper.js instance
  35028. * @property {String} data.placement Placement applied to popper
  35029. * @property {String} data.originalPlacement Placement originally defined on init
  35030. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35031. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35032. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35033. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35034. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35035. * @property {Object} data.boundaries Offsets of the popper boundaries
  35036. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35037. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35038. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35039. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35040. */
  35041. /**
  35042. * Default options provided to Popper.js constructor.<br />
  35043. * These can be overridden using the `options` argument of Popper.js.<br />
  35044. * To override an option, simply pass an object with the same
  35045. * structure of the `options` object, as the 3rd argument. For example:
  35046. * ```
  35047. * new Popper(ref, pop, {
  35048. * modifiers: {
  35049. * preventOverflow: { enabled: false }
  35050. * }
  35051. * })
  35052. * ```
  35053. * @type {Object}
  35054. * @static
  35055. * @memberof Popper
  35056. */
  35057. var Defaults = {
  35058. /**
  35059. * Popper's placement.
  35060. * @prop {Popper.placements} placement='bottom'
  35061. */
  35062. placement: 'bottom',
  35063. /**
  35064. * Set this to true if you want popper to position it self in 'fixed' mode
  35065. * @prop {Boolean} positionFixed=false
  35066. */
  35067. positionFixed: false,
  35068. /**
  35069. * Whether events (resize, scroll) are initially enabled.
  35070. * @prop {Boolean} eventsEnabled=true
  35071. */
  35072. eventsEnabled: true,
  35073. /**
  35074. * Set to true if you want to automatically remove the popper when
  35075. * you call the `destroy` method.
  35076. * @prop {Boolean} removeOnDestroy=false
  35077. */
  35078. removeOnDestroy: false,
  35079. /**
  35080. * Callback called when the popper is created.<br />
  35081. * By default, it is set to no-op.<br />
  35082. * Access Popper.js instance with `data.instance`.
  35083. * @prop {onCreate}
  35084. */
  35085. onCreate: function onCreate() {},
  35086. /**
  35087. * Callback called when the popper is updated. This callback is not called
  35088. * on the initialization/creation of the popper, but only on subsequent
  35089. * updates.<br />
  35090. * By default, it is set to no-op.<br />
  35091. * Access Popper.js instance with `data.instance`.
  35092. * @prop {onUpdate}
  35093. */
  35094. onUpdate: function onUpdate() {},
  35095. /**
  35096. * List of modifiers used to modify the offsets before they are applied to the popper.
  35097. * They provide most of the functionalities of Popper.js.
  35098. * @prop {modifiers}
  35099. */
  35100. modifiers: modifiers
  35101. };
  35102. /**
  35103. * @callback onCreate
  35104. * @param {dataObject} data
  35105. */
  35106. /**
  35107. * @callback onUpdate
  35108. * @param {dataObject} data
  35109. */
  35110. // Utils
  35111. // Methods
  35112. var Popper = function () {
  35113. /**
  35114. * Creates a new Popper.js instance.
  35115. * @class Popper
  35116. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35117. * @param {Element} popper - The HTML / XML element used as the popper
  35118. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35119. * @return {Object} instance - The generated Popper.js instance
  35120. */
  35121. function Popper(reference, popper) {
  35122. var _this = this;
  35123. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35124. classCallCheck(this, Popper);
  35125. this.scheduleUpdate = function () {
  35126. return requestAnimationFrame(_this.update);
  35127. };
  35128. // make update() debounced, so that it only runs at most once-per-tick
  35129. this.update = debounce(this.update.bind(this));
  35130. // with {} we create a new object with the options inside it
  35131. this.options = _extends({}, Popper.Defaults, options);
  35132. // init state
  35133. this.state = {
  35134. isDestroyed: false,
  35135. isCreated: false,
  35136. scrollParents: []
  35137. };
  35138. // get reference and popper elements (allow jQuery wrappers)
  35139. this.reference = reference && reference.jquery ? reference[0] : reference;
  35140. this.popper = popper && popper.jquery ? popper[0] : popper;
  35141. // Deep merge modifiers options
  35142. this.options.modifiers = {};
  35143. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35144. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35145. });
  35146. // Refactoring modifiers' list (Object => Array)
  35147. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35148. return _extends({
  35149. name: name
  35150. }, _this.options.modifiers[name]);
  35151. })
  35152. // sort the modifiers by order
  35153. .sort(function (a, b) {
  35154. return a.order - b.order;
  35155. });
  35156. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35157. // such code is executed in the same order of its modifier
  35158. // they could add new properties to their options configuration
  35159. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35160. this.modifiers.forEach(function (modifierOptions) {
  35161. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35162. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35163. }
  35164. });
  35165. // fire the first update to position the popper in the right place
  35166. this.update();
  35167. var eventsEnabled = this.options.eventsEnabled;
  35168. if (eventsEnabled) {
  35169. // setup event listeners, they will take care of update the position in specific situations
  35170. this.enableEventListeners();
  35171. }
  35172. this.state.eventsEnabled = eventsEnabled;
  35173. }
  35174. // We can't use class properties because they don't get listed in the
  35175. // class prototype and break stuff like Sinon stubs
  35176. createClass(Popper, [{
  35177. key: 'update',
  35178. value: function update$$1() {
  35179. return update.call(this);
  35180. }
  35181. }, {
  35182. key: 'destroy',
  35183. value: function destroy$$1() {
  35184. return destroy.call(this);
  35185. }
  35186. }, {
  35187. key: 'enableEventListeners',
  35188. value: function enableEventListeners$$1() {
  35189. return enableEventListeners.call(this);
  35190. }
  35191. }, {
  35192. key: 'disableEventListeners',
  35193. value: function disableEventListeners$$1() {
  35194. return disableEventListeners.call(this);
  35195. }
  35196. /**
  35197. * Schedules an update. It will run on the next UI update available.
  35198. * @method scheduleUpdate
  35199. * @memberof Popper
  35200. */
  35201. /**
  35202. * Collection of utilities useful when writing custom modifiers.
  35203. * Starting from version 1.7, this method is available only if you
  35204. * include `popper-utils.js` before `popper.js`.
  35205. *
  35206. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35207. * and will be removed in v2! Use the PopperUtils module directly instead.
  35208. * Due to the high instability of the methods contained in Utils, we can't
  35209. * guarantee them to follow semver. Use them at your own risk!
  35210. * @static
  35211. * @private
  35212. * @type {Object}
  35213. * @deprecated since version 1.8
  35214. * @member Utils
  35215. * @memberof Popper
  35216. */
  35217. }]);
  35218. return Popper;
  35219. }();
  35220. /**
  35221. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35222. * and lets you use it as replacement of a real DOM node.<br />
  35223. * You can use this method to position a popper relatively to a set of coordinates
  35224. * in case you don't have a DOM node to use as reference.
  35225. *
  35226. * ```
  35227. * new Popper(referenceObject, popperNode);
  35228. * ```
  35229. *
  35230. * NB: This feature isn't supported in Internet Explorer 10.
  35231. * @name referenceObject
  35232. * @property {Function} data.getBoundingClientRect
  35233. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35234. * @property {number} data.clientWidth
  35235. * An ES6 getter that will return the width of the virtual reference element.
  35236. * @property {number} data.clientHeight
  35237. * An ES6 getter that will return the height of the virtual reference element.
  35238. */
  35239. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35240. Popper.placements = placements;
  35241. Popper.Defaults = Defaults;
  35242. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35243. //# sourceMappingURL=popper.js.map
  35244. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35245. /***/ }),
  35246. /***/ "./node_modules/process/browser.js":
  35247. /*!*****************************************!*\
  35248. !*** ./node_modules/process/browser.js ***!
  35249. \*****************************************/
  35250. /*! no static exports found */
  35251. /***/ (function(module, exports) {
  35252. // shim for using process in browser
  35253. var process = module.exports = {};
  35254. // cached from whatever global is present so that test runners that stub it
  35255. // don't break things. But we need to wrap it in a try catch in case it is
  35256. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35257. // function because try/catches deoptimize in certain engines.
  35258. var cachedSetTimeout;
  35259. var cachedClearTimeout;
  35260. function defaultSetTimout() {
  35261. throw new Error('setTimeout has not been defined');
  35262. }
  35263. function defaultClearTimeout () {
  35264. throw new Error('clearTimeout has not been defined');
  35265. }
  35266. (function () {
  35267. try {
  35268. if (typeof setTimeout === 'function') {
  35269. cachedSetTimeout = setTimeout;
  35270. } else {
  35271. cachedSetTimeout = defaultSetTimout;
  35272. }
  35273. } catch (e) {
  35274. cachedSetTimeout = defaultSetTimout;
  35275. }
  35276. try {
  35277. if (typeof clearTimeout === 'function') {
  35278. cachedClearTimeout = clearTimeout;
  35279. } else {
  35280. cachedClearTimeout = defaultClearTimeout;
  35281. }
  35282. } catch (e) {
  35283. cachedClearTimeout = defaultClearTimeout;
  35284. }
  35285. } ())
  35286. function runTimeout(fun) {
  35287. if (cachedSetTimeout === setTimeout) {
  35288. //normal enviroments in sane situations
  35289. return setTimeout(fun, 0);
  35290. }
  35291. // if setTimeout wasn't available but was latter defined
  35292. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35293. cachedSetTimeout = setTimeout;
  35294. return setTimeout(fun, 0);
  35295. }
  35296. try {
  35297. // when when somebody has screwed with setTimeout but no I.E. maddness
  35298. return cachedSetTimeout(fun, 0);
  35299. } catch(e){
  35300. try {
  35301. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35302. return cachedSetTimeout.call(null, fun, 0);
  35303. } catch(e){
  35304. // 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
  35305. return cachedSetTimeout.call(this, fun, 0);
  35306. }
  35307. }
  35308. }
  35309. function runClearTimeout(marker) {
  35310. if (cachedClearTimeout === clearTimeout) {
  35311. //normal enviroments in sane situations
  35312. return clearTimeout(marker);
  35313. }
  35314. // if clearTimeout wasn't available but was latter defined
  35315. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35316. cachedClearTimeout = clearTimeout;
  35317. return clearTimeout(marker);
  35318. }
  35319. try {
  35320. // when when somebody has screwed with setTimeout but no I.E. maddness
  35321. return cachedClearTimeout(marker);
  35322. } catch (e){
  35323. try {
  35324. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35325. return cachedClearTimeout.call(null, marker);
  35326. } catch (e){
  35327. // 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.
  35328. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35329. return cachedClearTimeout.call(this, marker);
  35330. }
  35331. }
  35332. }
  35333. var queue = [];
  35334. var draining = false;
  35335. var currentQueue;
  35336. var queueIndex = -1;
  35337. function cleanUpNextTick() {
  35338. if (!draining || !currentQueue) {
  35339. return;
  35340. }
  35341. draining = false;
  35342. if (currentQueue.length) {
  35343. queue = currentQueue.concat(queue);
  35344. } else {
  35345. queueIndex = -1;
  35346. }
  35347. if (queue.length) {
  35348. drainQueue();
  35349. }
  35350. }
  35351. function drainQueue() {
  35352. if (draining) {
  35353. return;
  35354. }
  35355. var timeout = runTimeout(cleanUpNextTick);
  35356. draining = true;
  35357. var len = queue.length;
  35358. while(len) {
  35359. currentQueue = queue;
  35360. queue = [];
  35361. while (++queueIndex < len) {
  35362. if (currentQueue) {
  35363. currentQueue[queueIndex].run();
  35364. }
  35365. }
  35366. queueIndex = -1;
  35367. len = queue.length;
  35368. }
  35369. currentQueue = null;
  35370. draining = false;
  35371. runClearTimeout(timeout);
  35372. }
  35373. process.nextTick = function (fun) {
  35374. var args = new Array(arguments.length - 1);
  35375. if (arguments.length > 1) {
  35376. for (var i = 1; i < arguments.length; i++) {
  35377. args[i - 1] = arguments[i];
  35378. }
  35379. }
  35380. queue.push(new Item(fun, args));
  35381. if (queue.length === 1 && !draining) {
  35382. runTimeout(drainQueue);
  35383. }
  35384. };
  35385. // v8 likes predictible objects
  35386. function Item(fun, array) {
  35387. this.fun = fun;
  35388. this.array = array;
  35389. }
  35390. Item.prototype.run = function () {
  35391. this.fun.apply(null, this.array);
  35392. };
  35393. process.title = 'browser';
  35394. process.browser = true;
  35395. process.env = {};
  35396. process.argv = [];
  35397. process.version = ''; // empty string to avoid regexp issues
  35398. process.versions = {};
  35399. function noop() {}
  35400. process.on = noop;
  35401. process.addListener = noop;
  35402. process.once = noop;
  35403. process.off = noop;
  35404. process.removeListener = noop;
  35405. process.removeAllListeners = noop;
  35406. process.emit = noop;
  35407. process.prependListener = noop;
  35408. process.prependOnceListener = noop;
  35409. process.listeners = function (name) { return [] }
  35410. process.binding = function (name) {
  35411. throw new Error('process.binding is not supported');
  35412. };
  35413. process.cwd = function () { return '/' };
  35414. process.chdir = function (dir) {
  35415. throw new Error('process.chdir is not supported');
  35416. };
  35417. process.umask = function() { return 0; };
  35418. /***/ }),
  35419. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35420. /*!***************************************************!*\
  35421. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35422. \***************************************************/
  35423. /*! no static exports found */
  35424. /***/ (function(module, exports, __webpack_require__) {
  35425. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35426. * Pusher JavaScript Library v5.0.3
  35427. * https://pusher.com/
  35428. *
  35429. * Copyright 2017, Pusher
  35430. * Released under the MIT licence.
  35431. */
  35432. (function webpackUniversalModuleDefinition(root, factory) {
  35433. if(true)
  35434. module.exports = factory();
  35435. else {}
  35436. })(window, function() {
  35437. return /******/ (function(modules) { // webpackBootstrap
  35438. /******/ // The module cache
  35439. /******/ var installedModules = {};
  35440. /******/
  35441. /******/ // The require function
  35442. /******/ function __webpack_require__(moduleId) {
  35443. /******/
  35444. /******/ // Check if module is in cache
  35445. /******/ if(installedModules[moduleId]) {
  35446. /******/ return installedModules[moduleId].exports;
  35447. /******/ }
  35448. /******/ // Create a new module (and put it into the cache)
  35449. /******/ var module = installedModules[moduleId] = {
  35450. /******/ i: moduleId,
  35451. /******/ l: false,
  35452. /******/ exports: {}
  35453. /******/ };
  35454. /******/
  35455. /******/ // Execute the module function
  35456. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35457. /******/
  35458. /******/ // Flag the module as loaded
  35459. /******/ module.l = true;
  35460. /******/
  35461. /******/ // Return the exports of the module
  35462. /******/ return module.exports;
  35463. /******/ }
  35464. /******/
  35465. /******/
  35466. /******/ // expose the modules object (__webpack_modules__)
  35467. /******/ __webpack_require__.m = modules;
  35468. /******/
  35469. /******/ // expose the module cache
  35470. /******/ __webpack_require__.c = installedModules;
  35471. /******/
  35472. /******/ // define getter function for harmony exports
  35473. /******/ __webpack_require__.d = function(exports, name, getter) {
  35474. /******/ if(!__webpack_require__.o(exports, name)) {
  35475. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35476. /******/ }
  35477. /******/ };
  35478. /******/
  35479. /******/ // define __esModule on exports
  35480. /******/ __webpack_require__.r = function(exports) {
  35481. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35482. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35483. /******/ }
  35484. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35485. /******/ };
  35486. /******/
  35487. /******/ // create a fake namespace object
  35488. /******/ // mode & 1: value is a module id, require it
  35489. /******/ // mode & 2: merge all properties of value into the ns
  35490. /******/ // mode & 4: return value when already ns object
  35491. /******/ // mode & 8|1: behave like require
  35492. /******/ __webpack_require__.t = function(value, mode) {
  35493. /******/ if(mode & 1) value = __webpack_require__(value);
  35494. /******/ if(mode & 8) return value;
  35495. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35496. /******/ var ns = Object.create(null);
  35497. /******/ __webpack_require__.r(ns);
  35498. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35499. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35500. /******/ return ns;
  35501. /******/ };
  35502. /******/
  35503. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35504. /******/ __webpack_require__.n = function(module) {
  35505. /******/ var getter = module && module.__esModule ?
  35506. /******/ function getDefault() { return module['default']; } :
  35507. /******/ function getModuleExports() { return module; };
  35508. /******/ __webpack_require__.d(getter, 'a', getter);
  35509. /******/ return getter;
  35510. /******/ };
  35511. /******/
  35512. /******/ // Object.prototype.hasOwnProperty.call
  35513. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35514. /******/
  35515. /******/ // __webpack_public_path__
  35516. /******/ __webpack_require__.p = "";
  35517. /******/
  35518. /******/
  35519. /******/ // Load entry module and return exports
  35520. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35521. /******/ })
  35522. /************************************************************************/
  35523. /******/ ([
  35524. /* 0 */
  35525. /***/ (function(module, exports, __webpack_require__) {
  35526. (function(nacl) {
  35527. 'use strict';
  35528. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35529. // Public domain.
  35530. //
  35531. // Implementation derived from TweetNaCl version 20140427.
  35532. // See for details: http://tweetnacl.cr.yp.to/
  35533. var gf = function(init) {
  35534. var i, r = new Float64Array(16);
  35535. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35536. return r;
  35537. };
  35538. // Pluggable, initialized in high-level API below.
  35539. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35540. var _0 = new Uint8Array(16);
  35541. var _9 = new Uint8Array(32); _9[0] = 9;
  35542. var gf0 = gf(),
  35543. gf1 = gf([1]),
  35544. _121665 = gf([0xdb41, 1]),
  35545. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35546. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35547. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35548. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35549. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35550. function ts64(x, i, h, l) {
  35551. x[i] = (h >> 24) & 0xff;
  35552. x[i+1] = (h >> 16) & 0xff;
  35553. x[i+2] = (h >> 8) & 0xff;
  35554. x[i+3] = h & 0xff;
  35555. x[i+4] = (l >> 24) & 0xff;
  35556. x[i+5] = (l >> 16) & 0xff;
  35557. x[i+6] = (l >> 8) & 0xff;
  35558. x[i+7] = l & 0xff;
  35559. }
  35560. function vn(x, xi, y, yi, n) {
  35561. var i,d = 0;
  35562. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35563. return (1 & ((d - 1) >>> 8)) - 1;
  35564. }
  35565. function crypto_verify_16(x, xi, y, yi) {
  35566. return vn(x,xi,y,yi,16);
  35567. }
  35568. function crypto_verify_32(x, xi, y, yi) {
  35569. return vn(x,xi,y,yi,32);
  35570. }
  35571. function core_salsa20(o, p, k, c) {
  35572. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35573. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35574. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35575. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35576. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35577. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35578. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35579. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35580. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35581. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35582. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35583. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35584. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35585. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35586. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35587. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35588. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35589. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35590. x15 = j15, u;
  35591. for (var i = 0; i < 20; i += 2) {
  35592. u = x0 + x12 | 0;
  35593. x4 ^= u<<7 | u>>>(32-7);
  35594. u = x4 + x0 | 0;
  35595. x8 ^= u<<9 | u>>>(32-9);
  35596. u = x8 + x4 | 0;
  35597. x12 ^= u<<13 | u>>>(32-13);
  35598. u = x12 + x8 | 0;
  35599. x0 ^= u<<18 | u>>>(32-18);
  35600. u = x5 + x1 | 0;
  35601. x9 ^= u<<7 | u>>>(32-7);
  35602. u = x9 + x5 | 0;
  35603. x13 ^= u<<9 | u>>>(32-9);
  35604. u = x13 + x9 | 0;
  35605. x1 ^= u<<13 | u>>>(32-13);
  35606. u = x1 + x13 | 0;
  35607. x5 ^= u<<18 | u>>>(32-18);
  35608. u = x10 + x6 | 0;
  35609. x14 ^= u<<7 | u>>>(32-7);
  35610. u = x14 + x10 | 0;
  35611. x2 ^= u<<9 | u>>>(32-9);
  35612. u = x2 + x14 | 0;
  35613. x6 ^= u<<13 | u>>>(32-13);
  35614. u = x6 + x2 | 0;
  35615. x10 ^= u<<18 | u>>>(32-18);
  35616. u = x15 + x11 | 0;
  35617. x3 ^= u<<7 | u>>>(32-7);
  35618. u = x3 + x15 | 0;
  35619. x7 ^= u<<9 | u>>>(32-9);
  35620. u = x7 + x3 | 0;
  35621. x11 ^= u<<13 | u>>>(32-13);
  35622. u = x11 + x7 | 0;
  35623. x15 ^= u<<18 | u>>>(32-18);
  35624. u = x0 + x3 | 0;
  35625. x1 ^= u<<7 | u>>>(32-7);
  35626. u = x1 + x0 | 0;
  35627. x2 ^= u<<9 | u>>>(32-9);
  35628. u = x2 + x1 | 0;
  35629. x3 ^= u<<13 | u>>>(32-13);
  35630. u = x3 + x2 | 0;
  35631. x0 ^= u<<18 | u>>>(32-18);
  35632. u = x5 + x4 | 0;
  35633. x6 ^= u<<7 | u>>>(32-7);
  35634. u = x6 + x5 | 0;
  35635. x7 ^= u<<9 | u>>>(32-9);
  35636. u = x7 + x6 | 0;
  35637. x4 ^= u<<13 | u>>>(32-13);
  35638. u = x4 + x7 | 0;
  35639. x5 ^= u<<18 | u>>>(32-18);
  35640. u = x10 + x9 | 0;
  35641. x11 ^= u<<7 | u>>>(32-7);
  35642. u = x11 + x10 | 0;
  35643. x8 ^= u<<9 | u>>>(32-9);
  35644. u = x8 + x11 | 0;
  35645. x9 ^= u<<13 | u>>>(32-13);
  35646. u = x9 + x8 | 0;
  35647. x10 ^= u<<18 | u>>>(32-18);
  35648. u = x15 + x14 | 0;
  35649. x12 ^= u<<7 | u>>>(32-7);
  35650. u = x12 + x15 | 0;
  35651. x13 ^= u<<9 | u>>>(32-9);
  35652. u = x13 + x12 | 0;
  35653. x14 ^= u<<13 | u>>>(32-13);
  35654. u = x14 + x13 | 0;
  35655. x15 ^= u<<18 | u>>>(32-18);
  35656. }
  35657. x0 = x0 + j0 | 0;
  35658. x1 = x1 + j1 | 0;
  35659. x2 = x2 + j2 | 0;
  35660. x3 = x3 + j3 | 0;
  35661. x4 = x4 + j4 | 0;
  35662. x5 = x5 + j5 | 0;
  35663. x6 = x6 + j6 | 0;
  35664. x7 = x7 + j7 | 0;
  35665. x8 = x8 + j8 | 0;
  35666. x9 = x9 + j9 | 0;
  35667. x10 = x10 + j10 | 0;
  35668. x11 = x11 + j11 | 0;
  35669. x12 = x12 + j12 | 0;
  35670. x13 = x13 + j13 | 0;
  35671. x14 = x14 + j14 | 0;
  35672. x15 = x15 + j15 | 0;
  35673. o[ 0] = x0 >>> 0 & 0xff;
  35674. o[ 1] = x0 >>> 8 & 0xff;
  35675. o[ 2] = x0 >>> 16 & 0xff;
  35676. o[ 3] = x0 >>> 24 & 0xff;
  35677. o[ 4] = x1 >>> 0 & 0xff;
  35678. o[ 5] = x1 >>> 8 & 0xff;
  35679. o[ 6] = x1 >>> 16 & 0xff;
  35680. o[ 7] = x1 >>> 24 & 0xff;
  35681. o[ 8] = x2 >>> 0 & 0xff;
  35682. o[ 9] = x2 >>> 8 & 0xff;
  35683. o[10] = x2 >>> 16 & 0xff;
  35684. o[11] = x2 >>> 24 & 0xff;
  35685. o[12] = x3 >>> 0 & 0xff;
  35686. o[13] = x3 >>> 8 & 0xff;
  35687. o[14] = x3 >>> 16 & 0xff;
  35688. o[15] = x3 >>> 24 & 0xff;
  35689. o[16] = x4 >>> 0 & 0xff;
  35690. o[17] = x4 >>> 8 & 0xff;
  35691. o[18] = x4 >>> 16 & 0xff;
  35692. o[19] = x4 >>> 24 & 0xff;
  35693. o[20] = x5 >>> 0 & 0xff;
  35694. o[21] = x5 >>> 8 & 0xff;
  35695. o[22] = x5 >>> 16 & 0xff;
  35696. o[23] = x5 >>> 24 & 0xff;
  35697. o[24] = x6 >>> 0 & 0xff;
  35698. o[25] = x6 >>> 8 & 0xff;
  35699. o[26] = x6 >>> 16 & 0xff;
  35700. o[27] = x6 >>> 24 & 0xff;
  35701. o[28] = x7 >>> 0 & 0xff;
  35702. o[29] = x7 >>> 8 & 0xff;
  35703. o[30] = x7 >>> 16 & 0xff;
  35704. o[31] = x7 >>> 24 & 0xff;
  35705. o[32] = x8 >>> 0 & 0xff;
  35706. o[33] = x8 >>> 8 & 0xff;
  35707. o[34] = x8 >>> 16 & 0xff;
  35708. o[35] = x8 >>> 24 & 0xff;
  35709. o[36] = x9 >>> 0 & 0xff;
  35710. o[37] = x9 >>> 8 & 0xff;
  35711. o[38] = x9 >>> 16 & 0xff;
  35712. o[39] = x9 >>> 24 & 0xff;
  35713. o[40] = x10 >>> 0 & 0xff;
  35714. o[41] = x10 >>> 8 & 0xff;
  35715. o[42] = x10 >>> 16 & 0xff;
  35716. o[43] = x10 >>> 24 & 0xff;
  35717. o[44] = x11 >>> 0 & 0xff;
  35718. o[45] = x11 >>> 8 & 0xff;
  35719. o[46] = x11 >>> 16 & 0xff;
  35720. o[47] = x11 >>> 24 & 0xff;
  35721. o[48] = x12 >>> 0 & 0xff;
  35722. o[49] = x12 >>> 8 & 0xff;
  35723. o[50] = x12 >>> 16 & 0xff;
  35724. o[51] = x12 >>> 24 & 0xff;
  35725. o[52] = x13 >>> 0 & 0xff;
  35726. o[53] = x13 >>> 8 & 0xff;
  35727. o[54] = x13 >>> 16 & 0xff;
  35728. o[55] = x13 >>> 24 & 0xff;
  35729. o[56] = x14 >>> 0 & 0xff;
  35730. o[57] = x14 >>> 8 & 0xff;
  35731. o[58] = x14 >>> 16 & 0xff;
  35732. o[59] = x14 >>> 24 & 0xff;
  35733. o[60] = x15 >>> 0 & 0xff;
  35734. o[61] = x15 >>> 8 & 0xff;
  35735. o[62] = x15 >>> 16 & 0xff;
  35736. o[63] = x15 >>> 24 & 0xff;
  35737. }
  35738. function core_hsalsa20(o,p,k,c) {
  35739. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35740. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35741. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35742. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35743. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35744. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35745. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35746. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35747. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35748. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35749. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35750. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35751. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35752. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35753. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35754. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35755. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35756. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35757. x15 = j15, u;
  35758. for (var i = 0; i < 20; i += 2) {
  35759. u = x0 + x12 | 0;
  35760. x4 ^= u<<7 | u>>>(32-7);
  35761. u = x4 + x0 | 0;
  35762. x8 ^= u<<9 | u>>>(32-9);
  35763. u = x8 + x4 | 0;
  35764. x12 ^= u<<13 | u>>>(32-13);
  35765. u = x12 + x8 | 0;
  35766. x0 ^= u<<18 | u>>>(32-18);
  35767. u = x5 + x1 | 0;
  35768. x9 ^= u<<7 | u>>>(32-7);
  35769. u = x9 + x5 | 0;
  35770. x13 ^= u<<9 | u>>>(32-9);
  35771. u = x13 + x9 | 0;
  35772. x1 ^= u<<13 | u>>>(32-13);
  35773. u = x1 + x13 | 0;
  35774. x5 ^= u<<18 | u>>>(32-18);
  35775. u = x10 + x6 | 0;
  35776. x14 ^= u<<7 | u>>>(32-7);
  35777. u = x14 + x10 | 0;
  35778. x2 ^= u<<9 | u>>>(32-9);
  35779. u = x2 + x14 | 0;
  35780. x6 ^= u<<13 | u>>>(32-13);
  35781. u = x6 + x2 | 0;
  35782. x10 ^= u<<18 | u>>>(32-18);
  35783. u = x15 + x11 | 0;
  35784. x3 ^= u<<7 | u>>>(32-7);
  35785. u = x3 + x15 | 0;
  35786. x7 ^= u<<9 | u>>>(32-9);
  35787. u = x7 + x3 | 0;
  35788. x11 ^= u<<13 | u>>>(32-13);
  35789. u = x11 + x7 | 0;
  35790. x15 ^= u<<18 | u>>>(32-18);
  35791. u = x0 + x3 | 0;
  35792. x1 ^= u<<7 | u>>>(32-7);
  35793. u = x1 + x0 | 0;
  35794. x2 ^= u<<9 | u>>>(32-9);
  35795. u = x2 + x1 | 0;
  35796. x3 ^= u<<13 | u>>>(32-13);
  35797. u = x3 + x2 | 0;
  35798. x0 ^= u<<18 | u>>>(32-18);
  35799. u = x5 + x4 | 0;
  35800. x6 ^= u<<7 | u>>>(32-7);
  35801. u = x6 + x5 | 0;
  35802. x7 ^= u<<9 | u>>>(32-9);
  35803. u = x7 + x6 | 0;
  35804. x4 ^= u<<13 | u>>>(32-13);
  35805. u = x4 + x7 | 0;
  35806. x5 ^= u<<18 | u>>>(32-18);
  35807. u = x10 + x9 | 0;
  35808. x11 ^= u<<7 | u>>>(32-7);
  35809. u = x11 + x10 | 0;
  35810. x8 ^= u<<9 | u>>>(32-9);
  35811. u = x8 + x11 | 0;
  35812. x9 ^= u<<13 | u>>>(32-13);
  35813. u = x9 + x8 | 0;
  35814. x10 ^= u<<18 | u>>>(32-18);
  35815. u = x15 + x14 | 0;
  35816. x12 ^= u<<7 | u>>>(32-7);
  35817. u = x12 + x15 | 0;
  35818. x13 ^= u<<9 | u>>>(32-9);
  35819. u = x13 + x12 | 0;
  35820. x14 ^= u<<13 | u>>>(32-13);
  35821. u = x14 + x13 | 0;
  35822. x15 ^= u<<18 | u>>>(32-18);
  35823. }
  35824. o[ 0] = x0 >>> 0 & 0xff;
  35825. o[ 1] = x0 >>> 8 & 0xff;
  35826. o[ 2] = x0 >>> 16 & 0xff;
  35827. o[ 3] = x0 >>> 24 & 0xff;
  35828. o[ 4] = x5 >>> 0 & 0xff;
  35829. o[ 5] = x5 >>> 8 & 0xff;
  35830. o[ 6] = x5 >>> 16 & 0xff;
  35831. o[ 7] = x5 >>> 24 & 0xff;
  35832. o[ 8] = x10 >>> 0 & 0xff;
  35833. o[ 9] = x10 >>> 8 & 0xff;
  35834. o[10] = x10 >>> 16 & 0xff;
  35835. o[11] = x10 >>> 24 & 0xff;
  35836. o[12] = x15 >>> 0 & 0xff;
  35837. o[13] = x15 >>> 8 & 0xff;
  35838. o[14] = x15 >>> 16 & 0xff;
  35839. o[15] = x15 >>> 24 & 0xff;
  35840. o[16] = x6 >>> 0 & 0xff;
  35841. o[17] = x6 >>> 8 & 0xff;
  35842. o[18] = x6 >>> 16 & 0xff;
  35843. o[19] = x6 >>> 24 & 0xff;
  35844. o[20] = x7 >>> 0 & 0xff;
  35845. o[21] = x7 >>> 8 & 0xff;
  35846. o[22] = x7 >>> 16 & 0xff;
  35847. o[23] = x7 >>> 24 & 0xff;
  35848. o[24] = x8 >>> 0 & 0xff;
  35849. o[25] = x8 >>> 8 & 0xff;
  35850. o[26] = x8 >>> 16 & 0xff;
  35851. o[27] = x8 >>> 24 & 0xff;
  35852. o[28] = x9 >>> 0 & 0xff;
  35853. o[29] = x9 >>> 8 & 0xff;
  35854. o[30] = x9 >>> 16 & 0xff;
  35855. o[31] = x9 >>> 24 & 0xff;
  35856. }
  35857. function crypto_core_salsa20(out,inp,k,c) {
  35858. core_salsa20(out,inp,k,c);
  35859. }
  35860. function crypto_core_hsalsa20(out,inp,k,c) {
  35861. core_hsalsa20(out,inp,k,c);
  35862. }
  35863. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35864. // "expand 32-byte k"
  35865. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35866. var z = new Uint8Array(16), x = new Uint8Array(64);
  35867. var u, i;
  35868. for (i = 0; i < 16; i++) z[i] = 0;
  35869. for (i = 0; i < 8; i++) z[i] = n[i];
  35870. while (b >= 64) {
  35871. crypto_core_salsa20(x,z,k,sigma);
  35872. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35873. u = 1;
  35874. for (i = 8; i < 16; i++) {
  35875. u = u + (z[i] & 0xff) | 0;
  35876. z[i] = u & 0xff;
  35877. u >>>= 8;
  35878. }
  35879. b -= 64;
  35880. cpos += 64;
  35881. mpos += 64;
  35882. }
  35883. if (b > 0) {
  35884. crypto_core_salsa20(x,z,k,sigma);
  35885. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35886. }
  35887. return 0;
  35888. }
  35889. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35890. var z = new Uint8Array(16), x = new Uint8Array(64);
  35891. var u, i;
  35892. for (i = 0; i < 16; i++) z[i] = 0;
  35893. for (i = 0; i < 8; i++) z[i] = n[i];
  35894. while (b >= 64) {
  35895. crypto_core_salsa20(x,z,k,sigma);
  35896. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35897. u = 1;
  35898. for (i = 8; i < 16; i++) {
  35899. u = u + (z[i] & 0xff) | 0;
  35900. z[i] = u & 0xff;
  35901. u >>>= 8;
  35902. }
  35903. b -= 64;
  35904. cpos += 64;
  35905. }
  35906. if (b > 0) {
  35907. crypto_core_salsa20(x,z,k,sigma);
  35908. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35909. }
  35910. return 0;
  35911. }
  35912. function crypto_stream(c,cpos,d,n,k) {
  35913. var s = new Uint8Array(32);
  35914. crypto_core_hsalsa20(s,n,k,sigma);
  35915. var sn = new Uint8Array(8);
  35916. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35917. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35918. }
  35919. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35920. var s = new Uint8Array(32);
  35921. crypto_core_hsalsa20(s,n,k,sigma);
  35922. var sn = new Uint8Array(8);
  35923. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35924. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35925. }
  35926. /*
  35927. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35928. * https://github.com/floodyberry/poly1305-donna
  35929. */
  35930. var poly1305 = function(key) {
  35931. this.buffer = new Uint8Array(16);
  35932. this.r = new Uint16Array(10);
  35933. this.h = new Uint16Array(10);
  35934. this.pad = new Uint16Array(8);
  35935. this.leftover = 0;
  35936. this.fin = 0;
  35937. var t0, t1, t2, t3, t4, t5, t6, t7;
  35938. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35939. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35940. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35941. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35942. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35943. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35944. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35945. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35946. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35947. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35948. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35949. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35950. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35951. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35952. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35953. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35954. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35955. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35956. };
  35957. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35958. var hibit = this.fin ? 0 : (1 << 11);
  35959. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35960. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35961. var h0 = this.h[0],
  35962. h1 = this.h[1],
  35963. h2 = this.h[2],
  35964. h3 = this.h[3],
  35965. h4 = this.h[4],
  35966. h5 = this.h[5],
  35967. h6 = this.h[6],
  35968. h7 = this.h[7],
  35969. h8 = this.h[8],
  35970. h9 = this.h[9];
  35971. var r0 = this.r[0],
  35972. r1 = this.r[1],
  35973. r2 = this.r[2],
  35974. r3 = this.r[3],
  35975. r4 = this.r[4],
  35976. r5 = this.r[5],
  35977. r6 = this.r[6],
  35978. r7 = this.r[7],
  35979. r8 = this.r[8],
  35980. r9 = this.r[9];
  35981. while (bytes >= 16) {
  35982. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35983. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35984. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35985. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35986. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35987. h5 += ((t4 >>> 1)) & 0x1fff;
  35988. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35989. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35990. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35991. h9 += ((t7 >>> 5)) | hibit;
  35992. c = 0;
  35993. d0 = c;
  35994. d0 += h0 * r0;
  35995. d0 += h1 * (5 * r9);
  35996. d0 += h2 * (5 * r8);
  35997. d0 += h3 * (5 * r7);
  35998. d0 += h4 * (5 * r6);
  35999. c = (d0 >>> 13); d0 &= 0x1fff;
  36000. d0 += h5 * (5 * r5);
  36001. d0 += h6 * (5 * r4);
  36002. d0 += h7 * (5 * r3);
  36003. d0 += h8 * (5 * r2);
  36004. d0 += h9 * (5 * r1);
  36005. c += (d0 >>> 13); d0 &= 0x1fff;
  36006. d1 = c;
  36007. d1 += h0 * r1;
  36008. d1 += h1 * r0;
  36009. d1 += h2 * (5 * r9);
  36010. d1 += h3 * (5 * r8);
  36011. d1 += h4 * (5 * r7);
  36012. c = (d1 >>> 13); d1 &= 0x1fff;
  36013. d1 += h5 * (5 * r6);
  36014. d1 += h6 * (5 * r5);
  36015. d1 += h7 * (5 * r4);
  36016. d1 += h8 * (5 * r3);
  36017. d1 += h9 * (5 * r2);
  36018. c += (d1 >>> 13); d1 &= 0x1fff;
  36019. d2 = c;
  36020. d2 += h0 * r2;
  36021. d2 += h1 * r1;
  36022. d2 += h2 * r0;
  36023. d2 += h3 * (5 * r9);
  36024. d2 += h4 * (5 * r8);
  36025. c = (d2 >>> 13); d2 &= 0x1fff;
  36026. d2 += h5 * (5 * r7);
  36027. d2 += h6 * (5 * r6);
  36028. d2 += h7 * (5 * r5);
  36029. d2 += h8 * (5 * r4);
  36030. d2 += h9 * (5 * r3);
  36031. c += (d2 >>> 13); d2 &= 0x1fff;
  36032. d3 = c;
  36033. d3 += h0 * r3;
  36034. d3 += h1 * r2;
  36035. d3 += h2 * r1;
  36036. d3 += h3 * r0;
  36037. d3 += h4 * (5 * r9);
  36038. c = (d3 >>> 13); d3 &= 0x1fff;
  36039. d3 += h5 * (5 * r8);
  36040. d3 += h6 * (5 * r7);
  36041. d3 += h7 * (5 * r6);
  36042. d3 += h8 * (5 * r5);
  36043. d3 += h9 * (5 * r4);
  36044. c += (d3 >>> 13); d3 &= 0x1fff;
  36045. d4 = c;
  36046. d4 += h0 * r4;
  36047. d4 += h1 * r3;
  36048. d4 += h2 * r2;
  36049. d4 += h3 * r1;
  36050. d4 += h4 * r0;
  36051. c = (d4 >>> 13); d4 &= 0x1fff;
  36052. d4 += h5 * (5 * r9);
  36053. d4 += h6 * (5 * r8);
  36054. d4 += h7 * (5 * r7);
  36055. d4 += h8 * (5 * r6);
  36056. d4 += h9 * (5 * r5);
  36057. c += (d4 >>> 13); d4 &= 0x1fff;
  36058. d5 = c;
  36059. d5 += h0 * r5;
  36060. d5 += h1 * r4;
  36061. d5 += h2 * r3;
  36062. d5 += h3 * r2;
  36063. d5 += h4 * r1;
  36064. c = (d5 >>> 13); d5 &= 0x1fff;
  36065. d5 += h5 * r0;
  36066. d5 += h6 * (5 * r9);
  36067. d5 += h7 * (5 * r8);
  36068. d5 += h8 * (5 * r7);
  36069. d5 += h9 * (5 * r6);
  36070. c += (d5 >>> 13); d5 &= 0x1fff;
  36071. d6 = c;
  36072. d6 += h0 * r6;
  36073. d6 += h1 * r5;
  36074. d6 += h2 * r4;
  36075. d6 += h3 * r3;
  36076. d6 += h4 * r2;
  36077. c = (d6 >>> 13); d6 &= 0x1fff;
  36078. d6 += h5 * r1;
  36079. d6 += h6 * r0;
  36080. d6 += h7 * (5 * r9);
  36081. d6 += h8 * (5 * r8);
  36082. d6 += h9 * (5 * r7);
  36083. c += (d6 >>> 13); d6 &= 0x1fff;
  36084. d7 = c;
  36085. d7 += h0 * r7;
  36086. d7 += h1 * r6;
  36087. d7 += h2 * r5;
  36088. d7 += h3 * r4;
  36089. d7 += h4 * r3;
  36090. c = (d7 >>> 13); d7 &= 0x1fff;
  36091. d7 += h5 * r2;
  36092. d7 += h6 * r1;
  36093. d7 += h7 * r0;
  36094. d7 += h8 * (5 * r9);
  36095. d7 += h9 * (5 * r8);
  36096. c += (d7 >>> 13); d7 &= 0x1fff;
  36097. d8 = c;
  36098. d8 += h0 * r8;
  36099. d8 += h1 * r7;
  36100. d8 += h2 * r6;
  36101. d8 += h3 * r5;
  36102. d8 += h4 * r4;
  36103. c = (d8 >>> 13); d8 &= 0x1fff;
  36104. d8 += h5 * r3;
  36105. d8 += h6 * r2;
  36106. d8 += h7 * r1;
  36107. d8 += h8 * r0;
  36108. d8 += h9 * (5 * r9);
  36109. c += (d8 >>> 13); d8 &= 0x1fff;
  36110. d9 = c;
  36111. d9 += h0 * r9;
  36112. d9 += h1 * r8;
  36113. d9 += h2 * r7;
  36114. d9 += h3 * r6;
  36115. d9 += h4 * r5;
  36116. c = (d9 >>> 13); d9 &= 0x1fff;
  36117. d9 += h5 * r4;
  36118. d9 += h6 * r3;
  36119. d9 += h7 * r2;
  36120. d9 += h8 * r1;
  36121. d9 += h9 * r0;
  36122. c += (d9 >>> 13); d9 &= 0x1fff;
  36123. c = (((c << 2) + c)) | 0;
  36124. c = (c + d0) | 0;
  36125. d0 = c & 0x1fff;
  36126. c = (c >>> 13);
  36127. d1 += c;
  36128. h0 = d0;
  36129. h1 = d1;
  36130. h2 = d2;
  36131. h3 = d3;
  36132. h4 = d4;
  36133. h5 = d5;
  36134. h6 = d6;
  36135. h7 = d7;
  36136. h8 = d8;
  36137. h9 = d9;
  36138. mpos += 16;
  36139. bytes -= 16;
  36140. }
  36141. this.h[0] = h0;
  36142. this.h[1] = h1;
  36143. this.h[2] = h2;
  36144. this.h[3] = h3;
  36145. this.h[4] = h4;
  36146. this.h[5] = h5;
  36147. this.h[6] = h6;
  36148. this.h[7] = h7;
  36149. this.h[8] = h8;
  36150. this.h[9] = h9;
  36151. };
  36152. poly1305.prototype.finish = function(mac, macpos) {
  36153. var g = new Uint16Array(10);
  36154. var c, mask, f, i;
  36155. if (this.leftover) {
  36156. i = this.leftover;
  36157. this.buffer[i++] = 1;
  36158. for (; i < 16; i++) this.buffer[i] = 0;
  36159. this.fin = 1;
  36160. this.blocks(this.buffer, 0, 16);
  36161. }
  36162. c = this.h[1] >>> 13;
  36163. this.h[1] &= 0x1fff;
  36164. for (i = 2; i < 10; i++) {
  36165. this.h[i] += c;
  36166. c = this.h[i] >>> 13;
  36167. this.h[i] &= 0x1fff;
  36168. }
  36169. this.h[0] += (c * 5);
  36170. c = this.h[0] >>> 13;
  36171. this.h[0] &= 0x1fff;
  36172. this.h[1] += c;
  36173. c = this.h[1] >>> 13;
  36174. this.h[1] &= 0x1fff;
  36175. this.h[2] += c;
  36176. g[0] = this.h[0] + 5;
  36177. c = g[0] >>> 13;
  36178. g[0] &= 0x1fff;
  36179. for (i = 1; i < 10; i++) {
  36180. g[i] = this.h[i] + c;
  36181. c = g[i] >>> 13;
  36182. g[i] &= 0x1fff;
  36183. }
  36184. g[9] -= (1 << 13);
  36185. mask = (c ^ 1) - 1;
  36186. for (i = 0; i < 10; i++) g[i] &= mask;
  36187. mask = ~mask;
  36188. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36189. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36190. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36191. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36192. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36193. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36194. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36195. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36196. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36197. f = this.h[0] + this.pad[0];
  36198. this.h[0] = f & 0xffff;
  36199. for (i = 1; i < 8; i++) {
  36200. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36201. this.h[i] = f & 0xffff;
  36202. }
  36203. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36204. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36205. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36206. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36207. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36208. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36209. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36210. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36211. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36212. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36213. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36214. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36215. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36216. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36217. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36218. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36219. };
  36220. poly1305.prototype.update = function(m, mpos, bytes) {
  36221. var i, want;
  36222. if (this.leftover) {
  36223. want = (16 - this.leftover);
  36224. if (want > bytes)
  36225. want = bytes;
  36226. for (i = 0; i < want; i++)
  36227. this.buffer[this.leftover + i] = m[mpos+i];
  36228. bytes -= want;
  36229. mpos += want;
  36230. this.leftover += want;
  36231. if (this.leftover < 16)
  36232. return;
  36233. this.blocks(this.buffer, 0, 16);
  36234. this.leftover = 0;
  36235. }
  36236. if (bytes >= 16) {
  36237. want = bytes - (bytes % 16);
  36238. this.blocks(m, mpos, want);
  36239. mpos += want;
  36240. bytes -= want;
  36241. }
  36242. if (bytes) {
  36243. for (i = 0; i < bytes; i++)
  36244. this.buffer[this.leftover + i] = m[mpos+i];
  36245. this.leftover += bytes;
  36246. }
  36247. };
  36248. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36249. var s = new poly1305(k);
  36250. s.update(m, mpos, n);
  36251. s.finish(out, outpos);
  36252. return 0;
  36253. }
  36254. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36255. var x = new Uint8Array(16);
  36256. crypto_onetimeauth(x,0,m,mpos,n,k);
  36257. return crypto_verify_16(h,hpos,x,0);
  36258. }
  36259. function crypto_secretbox(c,m,d,n,k) {
  36260. var i;
  36261. if (d < 32) return -1;
  36262. crypto_stream_xor(c,0,m,0,d,n,k);
  36263. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36264. for (i = 0; i < 16; i++) c[i] = 0;
  36265. return 0;
  36266. }
  36267. function crypto_secretbox_open(m,c,d,n,k) {
  36268. var i;
  36269. var x = new Uint8Array(32);
  36270. if (d < 32) return -1;
  36271. crypto_stream(x,0,32,n,k);
  36272. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36273. crypto_stream_xor(m,0,c,0,d,n,k);
  36274. for (i = 0; i < 32; i++) m[i] = 0;
  36275. return 0;
  36276. }
  36277. function set25519(r, a) {
  36278. var i;
  36279. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36280. }
  36281. function car25519(o) {
  36282. var i, v, c = 1;
  36283. for (i = 0; i < 16; i++) {
  36284. v = o[i] + c + 65535;
  36285. c = Math.floor(v / 65536);
  36286. o[i] = v - c * 65536;
  36287. }
  36288. o[0] += c-1 + 37 * (c-1);
  36289. }
  36290. function sel25519(p, q, b) {
  36291. var t, c = ~(b-1);
  36292. for (var i = 0; i < 16; i++) {
  36293. t = c & (p[i] ^ q[i]);
  36294. p[i] ^= t;
  36295. q[i] ^= t;
  36296. }
  36297. }
  36298. function pack25519(o, n) {
  36299. var i, j, b;
  36300. var m = gf(), t = gf();
  36301. for (i = 0; i < 16; i++) t[i] = n[i];
  36302. car25519(t);
  36303. car25519(t);
  36304. car25519(t);
  36305. for (j = 0; j < 2; j++) {
  36306. m[0] = t[0] - 0xffed;
  36307. for (i = 1; i < 15; i++) {
  36308. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36309. m[i-1] &= 0xffff;
  36310. }
  36311. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36312. b = (m[15]>>16) & 1;
  36313. m[14] &= 0xffff;
  36314. sel25519(t, m, 1-b);
  36315. }
  36316. for (i = 0; i < 16; i++) {
  36317. o[2*i] = t[i] & 0xff;
  36318. o[2*i+1] = t[i]>>8;
  36319. }
  36320. }
  36321. function neq25519(a, b) {
  36322. var c = new Uint8Array(32), d = new Uint8Array(32);
  36323. pack25519(c, a);
  36324. pack25519(d, b);
  36325. return crypto_verify_32(c, 0, d, 0);
  36326. }
  36327. function par25519(a) {
  36328. var d = new Uint8Array(32);
  36329. pack25519(d, a);
  36330. return d[0] & 1;
  36331. }
  36332. function unpack25519(o, n) {
  36333. var i;
  36334. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36335. o[15] &= 0x7fff;
  36336. }
  36337. function A(o, a, b) {
  36338. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36339. }
  36340. function Z(o, a, b) {
  36341. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36342. }
  36343. function M(o, a, b) {
  36344. var v, c,
  36345. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36346. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36347. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36348. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36349. b0 = b[0],
  36350. b1 = b[1],
  36351. b2 = b[2],
  36352. b3 = b[3],
  36353. b4 = b[4],
  36354. b5 = b[5],
  36355. b6 = b[6],
  36356. b7 = b[7],
  36357. b8 = b[8],
  36358. b9 = b[9],
  36359. b10 = b[10],
  36360. b11 = b[11],
  36361. b12 = b[12],
  36362. b13 = b[13],
  36363. b14 = b[14],
  36364. b15 = b[15];
  36365. v = a[0];
  36366. t0 += v * b0;
  36367. t1 += v * b1;
  36368. t2 += v * b2;
  36369. t3 += v * b3;
  36370. t4 += v * b4;
  36371. t5 += v * b5;
  36372. t6 += v * b6;
  36373. t7 += v * b7;
  36374. t8 += v * b8;
  36375. t9 += v * b9;
  36376. t10 += v * b10;
  36377. t11 += v * b11;
  36378. t12 += v * b12;
  36379. t13 += v * b13;
  36380. t14 += v * b14;
  36381. t15 += v * b15;
  36382. v = a[1];
  36383. t1 += v * b0;
  36384. t2 += v * b1;
  36385. t3 += v * b2;
  36386. t4 += v * b3;
  36387. t5 += v * b4;
  36388. t6 += v * b5;
  36389. t7 += v * b6;
  36390. t8 += v * b7;
  36391. t9 += v * b8;
  36392. t10 += v * b9;
  36393. t11 += v * b10;
  36394. t12 += v * b11;
  36395. t13 += v * b12;
  36396. t14 += v * b13;
  36397. t15 += v * b14;
  36398. t16 += v * b15;
  36399. v = a[2];
  36400. t2 += v * b0;
  36401. t3 += v * b1;
  36402. t4 += v * b2;
  36403. t5 += v * b3;
  36404. t6 += v * b4;
  36405. t7 += v * b5;
  36406. t8 += v * b6;
  36407. t9 += v * b7;
  36408. t10 += v * b8;
  36409. t11 += v * b9;
  36410. t12 += v * b10;
  36411. t13 += v * b11;
  36412. t14 += v * b12;
  36413. t15 += v * b13;
  36414. t16 += v * b14;
  36415. t17 += v * b15;
  36416. v = a[3];
  36417. t3 += v * b0;
  36418. t4 += v * b1;
  36419. t5 += v * b2;
  36420. t6 += v * b3;
  36421. t7 += v * b4;
  36422. t8 += v * b5;
  36423. t9 += v * b6;
  36424. t10 += v * b7;
  36425. t11 += v * b8;
  36426. t12 += v * b9;
  36427. t13 += v * b10;
  36428. t14 += v * b11;
  36429. t15 += v * b12;
  36430. t16 += v * b13;
  36431. t17 += v * b14;
  36432. t18 += v * b15;
  36433. v = a[4];
  36434. t4 += v * b0;
  36435. t5 += v * b1;
  36436. t6 += v * b2;
  36437. t7 += v * b3;
  36438. t8 += v * b4;
  36439. t9 += v * b5;
  36440. t10 += v * b6;
  36441. t11 += v * b7;
  36442. t12 += v * b8;
  36443. t13 += v * b9;
  36444. t14 += v * b10;
  36445. t15 += v * b11;
  36446. t16 += v * b12;
  36447. t17 += v * b13;
  36448. t18 += v * b14;
  36449. t19 += v * b15;
  36450. v = a[5];
  36451. t5 += v * b0;
  36452. t6 += v * b1;
  36453. t7 += v * b2;
  36454. t8 += v * b3;
  36455. t9 += v * b4;
  36456. t10 += v * b5;
  36457. t11 += v * b6;
  36458. t12 += v * b7;
  36459. t13 += v * b8;
  36460. t14 += v * b9;
  36461. t15 += v * b10;
  36462. t16 += v * b11;
  36463. t17 += v * b12;
  36464. t18 += v * b13;
  36465. t19 += v * b14;
  36466. t20 += v * b15;
  36467. v = a[6];
  36468. t6 += v * b0;
  36469. t7 += v * b1;
  36470. t8 += v * b2;
  36471. t9 += v * b3;
  36472. t10 += v * b4;
  36473. t11 += v * b5;
  36474. t12 += v * b6;
  36475. t13 += v * b7;
  36476. t14 += v * b8;
  36477. t15 += v * b9;
  36478. t16 += v * b10;
  36479. t17 += v * b11;
  36480. t18 += v * b12;
  36481. t19 += v * b13;
  36482. t20 += v * b14;
  36483. t21 += v * b15;
  36484. v = a[7];
  36485. t7 += v * b0;
  36486. t8 += v * b1;
  36487. t9 += v * b2;
  36488. t10 += v * b3;
  36489. t11 += v * b4;
  36490. t12 += v * b5;
  36491. t13 += v * b6;
  36492. t14 += v * b7;
  36493. t15 += v * b8;
  36494. t16 += v * b9;
  36495. t17 += v * b10;
  36496. t18 += v * b11;
  36497. t19 += v * b12;
  36498. t20 += v * b13;
  36499. t21 += v * b14;
  36500. t22 += v * b15;
  36501. v = a[8];
  36502. t8 += v * b0;
  36503. t9 += v * b1;
  36504. t10 += v * b2;
  36505. t11 += v * b3;
  36506. t12 += v * b4;
  36507. t13 += v * b5;
  36508. t14 += v * b6;
  36509. t15 += v * b7;
  36510. t16 += v * b8;
  36511. t17 += v * b9;
  36512. t18 += v * b10;
  36513. t19 += v * b11;
  36514. t20 += v * b12;
  36515. t21 += v * b13;
  36516. t22 += v * b14;
  36517. t23 += v * b15;
  36518. v = a[9];
  36519. t9 += v * b0;
  36520. t10 += v * b1;
  36521. t11 += v * b2;
  36522. t12 += v * b3;
  36523. t13 += v * b4;
  36524. t14 += v * b5;
  36525. t15 += v * b6;
  36526. t16 += v * b7;
  36527. t17 += v * b8;
  36528. t18 += v * b9;
  36529. t19 += v * b10;
  36530. t20 += v * b11;
  36531. t21 += v * b12;
  36532. t22 += v * b13;
  36533. t23 += v * b14;
  36534. t24 += v * b15;
  36535. v = a[10];
  36536. t10 += v * b0;
  36537. t11 += v * b1;
  36538. t12 += v * b2;
  36539. t13 += v * b3;
  36540. t14 += v * b4;
  36541. t15 += v * b5;
  36542. t16 += v * b6;
  36543. t17 += v * b7;
  36544. t18 += v * b8;
  36545. t19 += v * b9;
  36546. t20 += v * b10;
  36547. t21 += v * b11;
  36548. t22 += v * b12;
  36549. t23 += v * b13;
  36550. t24 += v * b14;
  36551. t25 += v * b15;
  36552. v = a[11];
  36553. t11 += v * b0;
  36554. t12 += v * b1;
  36555. t13 += v * b2;
  36556. t14 += v * b3;
  36557. t15 += v * b4;
  36558. t16 += v * b5;
  36559. t17 += v * b6;
  36560. t18 += v * b7;
  36561. t19 += v * b8;
  36562. t20 += v * b9;
  36563. t21 += v * b10;
  36564. t22 += v * b11;
  36565. t23 += v * b12;
  36566. t24 += v * b13;
  36567. t25 += v * b14;
  36568. t26 += v * b15;
  36569. v = a[12];
  36570. t12 += v * b0;
  36571. t13 += v * b1;
  36572. t14 += v * b2;
  36573. t15 += v * b3;
  36574. t16 += v * b4;
  36575. t17 += v * b5;
  36576. t18 += v * b6;
  36577. t19 += v * b7;
  36578. t20 += v * b8;
  36579. t21 += v * b9;
  36580. t22 += v * b10;
  36581. t23 += v * b11;
  36582. t24 += v * b12;
  36583. t25 += v * b13;
  36584. t26 += v * b14;
  36585. t27 += v * b15;
  36586. v = a[13];
  36587. t13 += v * b0;
  36588. t14 += v * b1;
  36589. t15 += v * b2;
  36590. t16 += v * b3;
  36591. t17 += v * b4;
  36592. t18 += v * b5;
  36593. t19 += v * b6;
  36594. t20 += v * b7;
  36595. t21 += v * b8;
  36596. t22 += v * b9;
  36597. t23 += v * b10;
  36598. t24 += v * b11;
  36599. t25 += v * b12;
  36600. t26 += v * b13;
  36601. t27 += v * b14;
  36602. t28 += v * b15;
  36603. v = a[14];
  36604. t14 += v * b0;
  36605. t15 += v * b1;
  36606. t16 += v * b2;
  36607. t17 += v * b3;
  36608. t18 += v * b4;
  36609. t19 += v * b5;
  36610. t20 += v * b6;
  36611. t21 += v * b7;
  36612. t22 += v * b8;
  36613. t23 += v * b9;
  36614. t24 += v * b10;
  36615. t25 += v * b11;
  36616. t26 += v * b12;
  36617. t27 += v * b13;
  36618. t28 += v * b14;
  36619. t29 += v * b15;
  36620. v = a[15];
  36621. t15 += v * b0;
  36622. t16 += v * b1;
  36623. t17 += v * b2;
  36624. t18 += v * b3;
  36625. t19 += v * b4;
  36626. t20 += v * b5;
  36627. t21 += v * b6;
  36628. t22 += v * b7;
  36629. t23 += v * b8;
  36630. t24 += v * b9;
  36631. t25 += v * b10;
  36632. t26 += v * b11;
  36633. t27 += v * b12;
  36634. t28 += v * b13;
  36635. t29 += v * b14;
  36636. t30 += v * b15;
  36637. t0 += 38 * t16;
  36638. t1 += 38 * t17;
  36639. t2 += 38 * t18;
  36640. t3 += 38 * t19;
  36641. t4 += 38 * t20;
  36642. t5 += 38 * t21;
  36643. t6 += 38 * t22;
  36644. t7 += 38 * t23;
  36645. t8 += 38 * t24;
  36646. t9 += 38 * t25;
  36647. t10 += 38 * t26;
  36648. t11 += 38 * t27;
  36649. t12 += 38 * t28;
  36650. t13 += 38 * t29;
  36651. t14 += 38 * t30;
  36652. // t15 left as is
  36653. // first car
  36654. c = 1;
  36655. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36656. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36657. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36658. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36659. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36660. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36661. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36662. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36663. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36664. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36665. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36666. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36667. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36668. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36669. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36670. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36671. t0 += c-1 + 37 * (c-1);
  36672. // second car
  36673. c = 1;
  36674. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36675. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36676. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36677. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36678. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36679. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36680. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36681. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36682. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36683. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36684. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36685. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36686. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36687. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36688. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36689. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36690. t0 += c-1 + 37 * (c-1);
  36691. o[ 0] = t0;
  36692. o[ 1] = t1;
  36693. o[ 2] = t2;
  36694. o[ 3] = t3;
  36695. o[ 4] = t4;
  36696. o[ 5] = t5;
  36697. o[ 6] = t6;
  36698. o[ 7] = t7;
  36699. o[ 8] = t8;
  36700. o[ 9] = t9;
  36701. o[10] = t10;
  36702. o[11] = t11;
  36703. o[12] = t12;
  36704. o[13] = t13;
  36705. o[14] = t14;
  36706. o[15] = t15;
  36707. }
  36708. function S(o, a) {
  36709. M(o, a, a);
  36710. }
  36711. function inv25519(o, i) {
  36712. var c = gf();
  36713. var a;
  36714. for (a = 0; a < 16; a++) c[a] = i[a];
  36715. for (a = 253; a >= 0; a--) {
  36716. S(c, c);
  36717. if(a !== 2 && a !== 4) M(c, c, i);
  36718. }
  36719. for (a = 0; a < 16; a++) o[a] = c[a];
  36720. }
  36721. function pow2523(o, i) {
  36722. var c = gf();
  36723. var a;
  36724. for (a = 0; a < 16; a++) c[a] = i[a];
  36725. for (a = 250; a >= 0; a--) {
  36726. S(c, c);
  36727. if(a !== 1) M(c, c, i);
  36728. }
  36729. for (a = 0; a < 16; a++) o[a] = c[a];
  36730. }
  36731. function crypto_scalarmult(q, n, p) {
  36732. var z = new Uint8Array(32);
  36733. var x = new Float64Array(80), r, i;
  36734. var a = gf(), b = gf(), c = gf(),
  36735. d = gf(), e = gf(), f = gf();
  36736. for (i = 0; i < 31; i++) z[i] = n[i];
  36737. z[31]=(n[31]&127)|64;
  36738. z[0]&=248;
  36739. unpack25519(x,p);
  36740. for (i = 0; i < 16; i++) {
  36741. b[i]=x[i];
  36742. d[i]=a[i]=c[i]=0;
  36743. }
  36744. a[0]=d[0]=1;
  36745. for (i=254; i>=0; --i) {
  36746. r=(z[i>>>3]>>>(i&7))&1;
  36747. sel25519(a,b,r);
  36748. sel25519(c,d,r);
  36749. A(e,a,c);
  36750. Z(a,a,c);
  36751. A(c,b,d);
  36752. Z(b,b,d);
  36753. S(d,e);
  36754. S(f,a);
  36755. M(a,c,a);
  36756. M(c,b,e);
  36757. A(e,a,c);
  36758. Z(a,a,c);
  36759. S(b,a);
  36760. Z(c,d,f);
  36761. M(a,c,_121665);
  36762. A(a,a,d);
  36763. M(c,c,a);
  36764. M(a,d,f);
  36765. M(d,b,x);
  36766. S(b,e);
  36767. sel25519(a,b,r);
  36768. sel25519(c,d,r);
  36769. }
  36770. for (i = 0; i < 16; i++) {
  36771. x[i+16]=a[i];
  36772. x[i+32]=c[i];
  36773. x[i+48]=b[i];
  36774. x[i+64]=d[i];
  36775. }
  36776. var x32 = x.subarray(32);
  36777. var x16 = x.subarray(16);
  36778. inv25519(x32,x32);
  36779. M(x16,x16,x32);
  36780. pack25519(q,x16);
  36781. return 0;
  36782. }
  36783. function crypto_scalarmult_base(q, n) {
  36784. return crypto_scalarmult(q, n, _9);
  36785. }
  36786. function crypto_box_keypair(y, x) {
  36787. randombytes(x, 32);
  36788. return crypto_scalarmult_base(y, x);
  36789. }
  36790. function crypto_box_beforenm(k, y, x) {
  36791. var s = new Uint8Array(32);
  36792. crypto_scalarmult(s, x, y);
  36793. return crypto_core_hsalsa20(k, _0, s, sigma);
  36794. }
  36795. var crypto_box_afternm = crypto_secretbox;
  36796. var crypto_box_open_afternm = crypto_secretbox_open;
  36797. function crypto_box(c, m, d, n, y, x) {
  36798. var k = new Uint8Array(32);
  36799. crypto_box_beforenm(k, y, x);
  36800. return crypto_box_afternm(c, m, d, n, k);
  36801. }
  36802. function crypto_box_open(m, c, d, n, y, x) {
  36803. var k = new Uint8Array(32);
  36804. crypto_box_beforenm(k, y, x);
  36805. return crypto_box_open_afternm(m, c, d, n, k);
  36806. }
  36807. var K = [
  36808. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36809. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36810. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36811. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36812. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36813. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36814. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36815. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36816. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36817. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36818. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36819. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36820. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36821. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36822. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36823. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36824. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36825. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36826. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36827. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36828. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36829. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36830. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36831. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36832. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36833. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36834. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36835. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36836. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36837. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36838. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36839. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36840. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36841. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36842. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36843. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36844. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36845. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36846. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36847. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36848. ];
  36849. function crypto_hashblocks_hl(hh, hl, m, n) {
  36850. var wh = new Int32Array(16), wl = new Int32Array(16),
  36851. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36852. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36853. th, tl, i, j, h, l, a, b, c, d;
  36854. var ah0 = hh[0],
  36855. ah1 = hh[1],
  36856. ah2 = hh[2],
  36857. ah3 = hh[3],
  36858. ah4 = hh[4],
  36859. ah5 = hh[5],
  36860. ah6 = hh[6],
  36861. ah7 = hh[7],
  36862. al0 = hl[0],
  36863. al1 = hl[1],
  36864. al2 = hl[2],
  36865. al3 = hl[3],
  36866. al4 = hl[4],
  36867. al5 = hl[5],
  36868. al6 = hl[6],
  36869. al7 = hl[7];
  36870. var pos = 0;
  36871. while (n >= 128) {
  36872. for (i = 0; i < 16; i++) {
  36873. j = 8 * i + pos;
  36874. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36875. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36876. }
  36877. for (i = 0; i < 80; i++) {
  36878. bh0 = ah0;
  36879. bh1 = ah1;
  36880. bh2 = ah2;
  36881. bh3 = ah3;
  36882. bh4 = ah4;
  36883. bh5 = ah5;
  36884. bh6 = ah6;
  36885. bh7 = ah7;
  36886. bl0 = al0;
  36887. bl1 = al1;
  36888. bl2 = al2;
  36889. bl3 = al3;
  36890. bl4 = al4;
  36891. bl5 = al5;
  36892. bl6 = al6;
  36893. bl7 = al7;
  36894. // add
  36895. h = ah7;
  36896. l = al7;
  36897. a = l & 0xffff; b = l >>> 16;
  36898. c = h & 0xffff; d = h >>> 16;
  36899. // Sigma1
  36900. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36901. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36902. a += l & 0xffff; b += l >>> 16;
  36903. c += h & 0xffff; d += h >>> 16;
  36904. // Ch
  36905. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36906. l = (al4 & al5) ^ (~al4 & al6);
  36907. a += l & 0xffff; b += l >>> 16;
  36908. c += h & 0xffff; d += h >>> 16;
  36909. // K
  36910. h = K[i*2];
  36911. l = K[i*2+1];
  36912. a += l & 0xffff; b += l >>> 16;
  36913. c += h & 0xffff; d += h >>> 16;
  36914. // w
  36915. h = wh[i%16];
  36916. l = wl[i%16];
  36917. a += l & 0xffff; b += l >>> 16;
  36918. c += h & 0xffff; d += h >>> 16;
  36919. b += a >>> 16;
  36920. c += b >>> 16;
  36921. d += c >>> 16;
  36922. th = c & 0xffff | d << 16;
  36923. tl = a & 0xffff | b << 16;
  36924. // add
  36925. h = th;
  36926. l = tl;
  36927. a = l & 0xffff; b = l >>> 16;
  36928. c = h & 0xffff; d = h >>> 16;
  36929. // Sigma0
  36930. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36931. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36932. a += l & 0xffff; b += l >>> 16;
  36933. c += h & 0xffff; d += h >>> 16;
  36934. // Maj
  36935. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36936. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36937. a += l & 0xffff; b += l >>> 16;
  36938. c += h & 0xffff; d += h >>> 16;
  36939. b += a >>> 16;
  36940. c += b >>> 16;
  36941. d += c >>> 16;
  36942. bh7 = (c & 0xffff) | (d << 16);
  36943. bl7 = (a & 0xffff) | (b << 16);
  36944. // add
  36945. h = bh3;
  36946. l = bl3;
  36947. a = l & 0xffff; b = l >>> 16;
  36948. c = h & 0xffff; d = h >>> 16;
  36949. h = th;
  36950. l = tl;
  36951. a += l & 0xffff; b += l >>> 16;
  36952. c += h & 0xffff; d += h >>> 16;
  36953. b += a >>> 16;
  36954. c += b >>> 16;
  36955. d += c >>> 16;
  36956. bh3 = (c & 0xffff) | (d << 16);
  36957. bl3 = (a & 0xffff) | (b << 16);
  36958. ah1 = bh0;
  36959. ah2 = bh1;
  36960. ah3 = bh2;
  36961. ah4 = bh3;
  36962. ah5 = bh4;
  36963. ah6 = bh5;
  36964. ah7 = bh6;
  36965. ah0 = bh7;
  36966. al1 = bl0;
  36967. al2 = bl1;
  36968. al3 = bl2;
  36969. al4 = bl3;
  36970. al5 = bl4;
  36971. al6 = bl5;
  36972. al7 = bl6;
  36973. al0 = bl7;
  36974. if (i%16 === 15) {
  36975. for (j = 0; j < 16; j++) {
  36976. // add
  36977. h = wh[j];
  36978. l = wl[j];
  36979. a = l & 0xffff; b = l >>> 16;
  36980. c = h & 0xffff; d = h >>> 16;
  36981. h = wh[(j+9)%16];
  36982. l = wl[(j+9)%16];
  36983. a += l & 0xffff; b += l >>> 16;
  36984. c += h & 0xffff; d += h >>> 16;
  36985. // sigma0
  36986. th = wh[(j+1)%16];
  36987. tl = wl[(j+1)%16];
  36988. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36989. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36990. a += l & 0xffff; b += l >>> 16;
  36991. c += h & 0xffff; d += h >>> 16;
  36992. // sigma1
  36993. th = wh[(j+14)%16];
  36994. tl = wl[(j+14)%16];
  36995. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36996. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36997. a += l & 0xffff; b += l >>> 16;
  36998. c += h & 0xffff; d += h >>> 16;
  36999. b += a >>> 16;
  37000. c += b >>> 16;
  37001. d += c >>> 16;
  37002. wh[j] = (c & 0xffff) | (d << 16);
  37003. wl[j] = (a & 0xffff) | (b << 16);
  37004. }
  37005. }
  37006. }
  37007. // add
  37008. h = ah0;
  37009. l = al0;
  37010. a = l & 0xffff; b = l >>> 16;
  37011. c = h & 0xffff; d = h >>> 16;
  37012. h = hh[0];
  37013. l = hl[0];
  37014. a += l & 0xffff; b += l >>> 16;
  37015. c += h & 0xffff; d += h >>> 16;
  37016. b += a >>> 16;
  37017. c += b >>> 16;
  37018. d += c >>> 16;
  37019. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37020. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37021. h = ah1;
  37022. l = al1;
  37023. a = l & 0xffff; b = l >>> 16;
  37024. c = h & 0xffff; d = h >>> 16;
  37025. h = hh[1];
  37026. l = hl[1];
  37027. a += l & 0xffff; b += l >>> 16;
  37028. c += h & 0xffff; d += h >>> 16;
  37029. b += a >>> 16;
  37030. c += b >>> 16;
  37031. d += c >>> 16;
  37032. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37033. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37034. h = ah2;
  37035. l = al2;
  37036. a = l & 0xffff; b = l >>> 16;
  37037. c = h & 0xffff; d = h >>> 16;
  37038. h = hh[2];
  37039. l = hl[2];
  37040. a += l & 0xffff; b += l >>> 16;
  37041. c += h & 0xffff; d += h >>> 16;
  37042. b += a >>> 16;
  37043. c += b >>> 16;
  37044. d += c >>> 16;
  37045. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37046. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37047. h = ah3;
  37048. l = al3;
  37049. a = l & 0xffff; b = l >>> 16;
  37050. c = h & 0xffff; d = h >>> 16;
  37051. h = hh[3];
  37052. l = hl[3];
  37053. a += l & 0xffff; b += l >>> 16;
  37054. c += h & 0xffff; d += h >>> 16;
  37055. b += a >>> 16;
  37056. c += b >>> 16;
  37057. d += c >>> 16;
  37058. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37059. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37060. h = ah4;
  37061. l = al4;
  37062. a = l & 0xffff; b = l >>> 16;
  37063. c = h & 0xffff; d = h >>> 16;
  37064. h = hh[4];
  37065. l = hl[4];
  37066. a += l & 0xffff; b += l >>> 16;
  37067. c += h & 0xffff; d += h >>> 16;
  37068. b += a >>> 16;
  37069. c += b >>> 16;
  37070. d += c >>> 16;
  37071. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37072. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37073. h = ah5;
  37074. l = al5;
  37075. a = l & 0xffff; b = l >>> 16;
  37076. c = h & 0xffff; d = h >>> 16;
  37077. h = hh[5];
  37078. l = hl[5];
  37079. a += l & 0xffff; b += l >>> 16;
  37080. c += h & 0xffff; d += h >>> 16;
  37081. b += a >>> 16;
  37082. c += b >>> 16;
  37083. d += c >>> 16;
  37084. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37085. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37086. h = ah6;
  37087. l = al6;
  37088. a = l & 0xffff; b = l >>> 16;
  37089. c = h & 0xffff; d = h >>> 16;
  37090. h = hh[6];
  37091. l = hl[6];
  37092. a += l & 0xffff; b += l >>> 16;
  37093. c += h & 0xffff; d += h >>> 16;
  37094. b += a >>> 16;
  37095. c += b >>> 16;
  37096. d += c >>> 16;
  37097. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37098. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37099. h = ah7;
  37100. l = al7;
  37101. a = l & 0xffff; b = l >>> 16;
  37102. c = h & 0xffff; d = h >>> 16;
  37103. h = hh[7];
  37104. l = hl[7];
  37105. a += l & 0xffff; b += l >>> 16;
  37106. c += h & 0xffff; d += h >>> 16;
  37107. b += a >>> 16;
  37108. c += b >>> 16;
  37109. d += c >>> 16;
  37110. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37111. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37112. pos += 128;
  37113. n -= 128;
  37114. }
  37115. return n;
  37116. }
  37117. function crypto_hash(out, m, n) {
  37118. var hh = new Int32Array(8),
  37119. hl = new Int32Array(8),
  37120. x = new Uint8Array(256),
  37121. i, b = n;
  37122. hh[0] = 0x6a09e667;
  37123. hh[1] = 0xbb67ae85;
  37124. hh[2] = 0x3c6ef372;
  37125. hh[3] = 0xa54ff53a;
  37126. hh[4] = 0x510e527f;
  37127. hh[5] = 0x9b05688c;
  37128. hh[6] = 0x1f83d9ab;
  37129. hh[7] = 0x5be0cd19;
  37130. hl[0] = 0xf3bcc908;
  37131. hl[1] = 0x84caa73b;
  37132. hl[2] = 0xfe94f82b;
  37133. hl[3] = 0x5f1d36f1;
  37134. hl[4] = 0xade682d1;
  37135. hl[5] = 0x2b3e6c1f;
  37136. hl[6] = 0xfb41bd6b;
  37137. hl[7] = 0x137e2179;
  37138. crypto_hashblocks_hl(hh, hl, m, n);
  37139. n %= 128;
  37140. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37141. x[n] = 128;
  37142. n = 256-128*(n<112?1:0);
  37143. x[n-9] = 0;
  37144. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37145. crypto_hashblocks_hl(hh, hl, x, n);
  37146. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37147. return 0;
  37148. }
  37149. function add(p, q) {
  37150. var a = gf(), b = gf(), c = gf(),
  37151. d = gf(), e = gf(), f = gf(),
  37152. g = gf(), h = gf(), t = gf();
  37153. Z(a, p[1], p[0]);
  37154. Z(t, q[1], q[0]);
  37155. M(a, a, t);
  37156. A(b, p[0], p[1]);
  37157. A(t, q[0], q[1]);
  37158. M(b, b, t);
  37159. M(c, p[3], q[3]);
  37160. M(c, c, D2);
  37161. M(d, p[2], q[2]);
  37162. A(d, d, d);
  37163. Z(e, b, a);
  37164. Z(f, d, c);
  37165. A(g, d, c);
  37166. A(h, b, a);
  37167. M(p[0], e, f);
  37168. M(p[1], h, g);
  37169. M(p[2], g, f);
  37170. M(p[3], e, h);
  37171. }
  37172. function cswap(p, q, b) {
  37173. var i;
  37174. for (i = 0; i < 4; i++) {
  37175. sel25519(p[i], q[i], b);
  37176. }
  37177. }
  37178. function pack(r, p) {
  37179. var tx = gf(), ty = gf(), zi = gf();
  37180. inv25519(zi, p[2]);
  37181. M(tx, p[0], zi);
  37182. M(ty, p[1], zi);
  37183. pack25519(r, ty);
  37184. r[31] ^= par25519(tx) << 7;
  37185. }
  37186. function scalarmult(p, q, s) {
  37187. var b, i;
  37188. set25519(p[0], gf0);
  37189. set25519(p[1], gf1);
  37190. set25519(p[2], gf1);
  37191. set25519(p[3], gf0);
  37192. for (i = 255; i >= 0; --i) {
  37193. b = (s[(i/8)|0] >> (i&7)) & 1;
  37194. cswap(p, q, b);
  37195. add(q, p);
  37196. add(p, p);
  37197. cswap(p, q, b);
  37198. }
  37199. }
  37200. function scalarbase(p, s) {
  37201. var q = [gf(), gf(), gf(), gf()];
  37202. set25519(q[0], X);
  37203. set25519(q[1], Y);
  37204. set25519(q[2], gf1);
  37205. M(q[3], X, Y);
  37206. scalarmult(p, q, s);
  37207. }
  37208. function crypto_sign_keypair(pk, sk, seeded) {
  37209. var d = new Uint8Array(64);
  37210. var p = [gf(), gf(), gf(), gf()];
  37211. var i;
  37212. if (!seeded) randombytes(sk, 32);
  37213. crypto_hash(d, sk, 32);
  37214. d[0] &= 248;
  37215. d[31] &= 127;
  37216. d[31] |= 64;
  37217. scalarbase(p, d);
  37218. pack(pk, p);
  37219. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37220. return 0;
  37221. }
  37222. 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]);
  37223. function modL(r, x) {
  37224. var carry, i, j, k;
  37225. for (i = 63; i >= 32; --i) {
  37226. carry = 0;
  37227. for (j = i - 32, k = i - 12; j < k; ++j) {
  37228. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37229. carry = (x[j] + 128) >> 8;
  37230. x[j] -= carry * 256;
  37231. }
  37232. x[j] += carry;
  37233. x[i] = 0;
  37234. }
  37235. carry = 0;
  37236. for (j = 0; j < 32; j++) {
  37237. x[j] += carry - (x[31] >> 4) * L[j];
  37238. carry = x[j] >> 8;
  37239. x[j] &= 255;
  37240. }
  37241. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37242. for (i = 0; i < 32; i++) {
  37243. x[i+1] += x[i] >> 8;
  37244. r[i] = x[i] & 255;
  37245. }
  37246. }
  37247. function reduce(r) {
  37248. var x = new Float64Array(64), i;
  37249. for (i = 0; i < 64; i++) x[i] = r[i];
  37250. for (i = 0; i < 64; i++) r[i] = 0;
  37251. modL(r, x);
  37252. }
  37253. // Note: difference from C - smlen returned, not passed as argument.
  37254. function crypto_sign(sm, m, n, sk) {
  37255. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37256. var i, j, x = new Float64Array(64);
  37257. var p = [gf(), gf(), gf(), gf()];
  37258. crypto_hash(d, sk, 32);
  37259. d[0] &= 248;
  37260. d[31] &= 127;
  37261. d[31] |= 64;
  37262. var smlen = n + 64;
  37263. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37264. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37265. crypto_hash(r, sm.subarray(32), n+32);
  37266. reduce(r);
  37267. scalarbase(p, r);
  37268. pack(sm, p);
  37269. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37270. crypto_hash(h, sm, n + 64);
  37271. reduce(h);
  37272. for (i = 0; i < 64; i++) x[i] = 0;
  37273. for (i = 0; i < 32; i++) x[i] = r[i];
  37274. for (i = 0; i < 32; i++) {
  37275. for (j = 0; j < 32; j++) {
  37276. x[i+j] += h[i] * d[j];
  37277. }
  37278. }
  37279. modL(sm.subarray(32), x);
  37280. return smlen;
  37281. }
  37282. function unpackneg(r, p) {
  37283. var t = gf(), chk = gf(), num = gf(),
  37284. den = gf(), den2 = gf(), den4 = gf(),
  37285. den6 = gf();
  37286. set25519(r[2], gf1);
  37287. unpack25519(r[1], p);
  37288. S(num, r[1]);
  37289. M(den, num, D);
  37290. Z(num, num, r[2]);
  37291. A(den, r[2], den);
  37292. S(den2, den);
  37293. S(den4, den2);
  37294. M(den6, den4, den2);
  37295. M(t, den6, num);
  37296. M(t, t, den);
  37297. pow2523(t, t);
  37298. M(t, t, num);
  37299. M(t, t, den);
  37300. M(t, t, den);
  37301. M(r[0], t, den);
  37302. S(chk, r[0]);
  37303. M(chk, chk, den);
  37304. if (neq25519(chk, num)) M(r[0], r[0], I);
  37305. S(chk, r[0]);
  37306. M(chk, chk, den);
  37307. if (neq25519(chk, num)) return -1;
  37308. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37309. M(r[3], r[0], r[1]);
  37310. return 0;
  37311. }
  37312. function crypto_sign_open(m, sm, n, pk) {
  37313. var i, mlen;
  37314. var t = new Uint8Array(32), h = new Uint8Array(64);
  37315. var p = [gf(), gf(), gf(), gf()],
  37316. q = [gf(), gf(), gf(), gf()];
  37317. mlen = -1;
  37318. if (n < 64) return -1;
  37319. if (unpackneg(q, pk)) return -1;
  37320. for (i = 0; i < n; i++) m[i] = sm[i];
  37321. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37322. crypto_hash(h, m, n);
  37323. reduce(h);
  37324. scalarmult(p, q, h);
  37325. scalarbase(q, sm.subarray(32));
  37326. add(p, q);
  37327. pack(t, p);
  37328. n -= 64;
  37329. if (crypto_verify_32(sm, 0, t, 0)) {
  37330. for (i = 0; i < n; i++) m[i] = 0;
  37331. return -1;
  37332. }
  37333. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37334. mlen = n;
  37335. return mlen;
  37336. }
  37337. var crypto_secretbox_KEYBYTES = 32,
  37338. crypto_secretbox_NONCEBYTES = 24,
  37339. crypto_secretbox_ZEROBYTES = 32,
  37340. crypto_secretbox_BOXZEROBYTES = 16,
  37341. crypto_scalarmult_BYTES = 32,
  37342. crypto_scalarmult_SCALARBYTES = 32,
  37343. crypto_box_PUBLICKEYBYTES = 32,
  37344. crypto_box_SECRETKEYBYTES = 32,
  37345. crypto_box_BEFORENMBYTES = 32,
  37346. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37347. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37348. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37349. crypto_sign_BYTES = 64,
  37350. crypto_sign_PUBLICKEYBYTES = 32,
  37351. crypto_sign_SECRETKEYBYTES = 64,
  37352. crypto_sign_SEEDBYTES = 32,
  37353. crypto_hash_BYTES = 64;
  37354. nacl.lowlevel = {
  37355. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37356. crypto_stream_xor: crypto_stream_xor,
  37357. crypto_stream: crypto_stream,
  37358. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37359. crypto_stream_salsa20: crypto_stream_salsa20,
  37360. crypto_onetimeauth: crypto_onetimeauth,
  37361. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37362. crypto_verify_16: crypto_verify_16,
  37363. crypto_verify_32: crypto_verify_32,
  37364. crypto_secretbox: crypto_secretbox,
  37365. crypto_secretbox_open: crypto_secretbox_open,
  37366. crypto_scalarmult: crypto_scalarmult,
  37367. crypto_scalarmult_base: crypto_scalarmult_base,
  37368. crypto_box_beforenm: crypto_box_beforenm,
  37369. crypto_box_afternm: crypto_box_afternm,
  37370. crypto_box: crypto_box,
  37371. crypto_box_open: crypto_box_open,
  37372. crypto_box_keypair: crypto_box_keypair,
  37373. crypto_hash: crypto_hash,
  37374. crypto_sign: crypto_sign,
  37375. crypto_sign_keypair: crypto_sign_keypair,
  37376. crypto_sign_open: crypto_sign_open,
  37377. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37378. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37379. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37380. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37381. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37382. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37383. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37384. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37385. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37386. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37387. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37388. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37389. crypto_sign_BYTES: crypto_sign_BYTES,
  37390. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37391. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37392. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37393. crypto_hash_BYTES: crypto_hash_BYTES
  37394. };
  37395. /* High-level API */
  37396. function checkLengths(k, n) {
  37397. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37398. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37399. }
  37400. function checkBoxLengths(pk, sk) {
  37401. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37402. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37403. }
  37404. function checkArrayTypes() {
  37405. for (var i = 0; i < arguments.length; i++) {
  37406. if (!(arguments[i] instanceof Uint8Array))
  37407. throw new TypeError('unexpected type, use Uint8Array');
  37408. }
  37409. }
  37410. function cleanup(arr) {
  37411. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37412. }
  37413. nacl.randomBytes = function(n) {
  37414. var b = new Uint8Array(n);
  37415. randombytes(b, n);
  37416. return b;
  37417. };
  37418. nacl.secretbox = function(msg, nonce, key) {
  37419. checkArrayTypes(msg, nonce, key);
  37420. checkLengths(key, nonce);
  37421. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37422. var c = new Uint8Array(m.length);
  37423. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37424. crypto_secretbox(c, m, m.length, nonce, key);
  37425. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37426. };
  37427. nacl.secretbox.open = function(box, nonce, key) {
  37428. checkArrayTypes(box, nonce, key);
  37429. checkLengths(key, nonce);
  37430. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37431. var m = new Uint8Array(c.length);
  37432. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37433. if (c.length < 32) return null;
  37434. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37435. return m.subarray(crypto_secretbox_ZEROBYTES);
  37436. };
  37437. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37438. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37439. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37440. nacl.scalarMult = function(n, p) {
  37441. checkArrayTypes(n, p);
  37442. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37443. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37444. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37445. crypto_scalarmult(q, n, p);
  37446. return q;
  37447. };
  37448. nacl.scalarMult.base = function(n) {
  37449. checkArrayTypes(n);
  37450. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37451. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37452. crypto_scalarmult_base(q, n);
  37453. return q;
  37454. };
  37455. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37456. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37457. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37458. var k = nacl.box.before(publicKey, secretKey);
  37459. return nacl.secretbox(msg, nonce, k);
  37460. };
  37461. nacl.box.before = function(publicKey, secretKey) {
  37462. checkArrayTypes(publicKey, secretKey);
  37463. checkBoxLengths(publicKey, secretKey);
  37464. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37465. crypto_box_beforenm(k, publicKey, secretKey);
  37466. return k;
  37467. };
  37468. nacl.box.after = nacl.secretbox;
  37469. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37470. var k = nacl.box.before(publicKey, secretKey);
  37471. return nacl.secretbox.open(msg, nonce, k);
  37472. };
  37473. nacl.box.open.after = nacl.secretbox.open;
  37474. nacl.box.keyPair = function() {
  37475. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37476. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37477. crypto_box_keypair(pk, sk);
  37478. return {publicKey: pk, secretKey: sk};
  37479. };
  37480. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37481. checkArrayTypes(secretKey);
  37482. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37483. throw new Error('bad secret key size');
  37484. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37485. crypto_scalarmult_base(pk, secretKey);
  37486. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37487. };
  37488. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37489. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37490. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37491. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37492. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37493. nacl.sign = function(msg, secretKey) {
  37494. checkArrayTypes(msg, secretKey);
  37495. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37496. throw new Error('bad secret key size');
  37497. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37498. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37499. return signedMsg;
  37500. };
  37501. nacl.sign.open = function(signedMsg, publicKey) {
  37502. checkArrayTypes(signedMsg, publicKey);
  37503. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37504. throw new Error('bad public key size');
  37505. var tmp = new Uint8Array(signedMsg.length);
  37506. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37507. if (mlen < 0) return null;
  37508. var m = new Uint8Array(mlen);
  37509. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37510. return m;
  37511. };
  37512. nacl.sign.detached = function(msg, secretKey) {
  37513. var signedMsg = nacl.sign(msg, secretKey);
  37514. var sig = new Uint8Array(crypto_sign_BYTES);
  37515. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37516. return sig;
  37517. };
  37518. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37519. checkArrayTypes(msg, sig, publicKey);
  37520. if (sig.length !== crypto_sign_BYTES)
  37521. throw new Error('bad signature size');
  37522. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37523. throw new Error('bad public key size');
  37524. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37525. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37526. var i;
  37527. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37528. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37529. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37530. };
  37531. nacl.sign.keyPair = function() {
  37532. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37533. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37534. crypto_sign_keypair(pk, sk);
  37535. return {publicKey: pk, secretKey: sk};
  37536. };
  37537. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37538. checkArrayTypes(secretKey);
  37539. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37540. throw new Error('bad secret key size');
  37541. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37542. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37543. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37544. };
  37545. nacl.sign.keyPair.fromSeed = function(seed) {
  37546. checkArrayTypes(seed);
  37547. if (seed.length !== crypto_sign_SEEDBYTES)
  37548. throw new Error('bad seed size');
  37549. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37550. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37551. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37552. crypto_sign_keypair(pk, sk, true);
  37553. return {publicKey: pk, secretKey: sk};
  37554. };
  37555. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37556. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37557. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37558. nacl.sign.signatureLength = crypto_sign_BYTES;
  37559. nacl.hash = function(msg) {
  37560. checkArrayTypes(msg);
  37561. var h = new Uint8Array(crypto_hash_BYTES);
  37562. crypto_hash(h, msg, msg.length);
  37563. return h;
  37564. };
  37565. nacl.hash.hashLength = crypto_hash_BYTES;
  37566. nacl.verify = function(x, y) {
  37567. checkArrayTypes(x, y);
  37568. // Zero length arguments are considered not equal.
  37569. if (x.length === 0 || y.length === 0) return false;
  37570. if (x.length !== y.length) return false;
  37571. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37572. };
  37573. nacl.setPRNG = function(fn) {
  37574. randombytes = fn;
  37575. };
  37576. (function() {
  37577. // Initialize PRNG if environment provides CSPRNG.
  37578. // If not, methods calling randombytes will throw.
  37579. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37580. if (crypto && crypto.getRandomValues) {
  37581. // Browsers.
  37582. var QUOTA = 65536;
  37583. nacl.setPRNG(function(x, n) {
  37584. var i, v = new Uint8Array(n);
  37585. for (i = 0; i < n; i += QUOTA) {
  37586. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37587. }
  37588. for (i = 0; i < n; i++) x[i] = v[i];
  37589. cleanup(v);
  37590. });
  37591. } else if (true) {
  37592. // Node.js.
  37593. crypto = __webpack_require__(3);
  37594. if (crypto && crypto.randomBytes) {
  37595. nacl.setPRNG(function(x, n) {
  37596. var i, v = crypto.randomBytes(n);
  37597. for (i = 0; i < n; i++) x[i] = v[i];
  37598. cleanup(v);
  37599. });
  37600. }
  37601. }
  37602. })();
  37603. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37604. /***/ }),
  37605. /* 1 */
  37606. /***/ (function(module, exports, __webpack_require__) {
  37607. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37608. // Public domain.
  37609. (function(root, f) {
  37610. 'use strict';
  37611. if ( true && module.exports) module.exports = f();
  37612. else if (root.nacl) root.nacl.util = f();
  37613. else {
  37614. root.nacl = {};
  37615. root.nacl.util = f();
  37616. }
  37617. }(this, function() {
  37618. 'use strict';
  37619. var util = {};
  37620. function validateBase64(s) {
  37621. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37622. throw new TypeError('invalid encoding');
  37623. }
  37624. }
  37625. util.decodeUTF8 = function(s) {
  37626. if (typeof s !== 'string') throw new TypeError('expected string');
  37627. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37628. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37629. return b;
  37630. };
  37631. util.encodeUTF8 = function(arr) {
  37632. var i, s = [];
  37633. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37634. return decodeURIComponent(escape(s.join('')));
  37635. };
  37636. if (typeof atob === 'undefined') {
  37637. // Node.js
  37638. if (typeof Buffer.from !== 'undefined') {
  37639. // Node v6 and later
  37640. util.encodeBase64 = function (arr) { // v6 and later
  37641. return Buffer.from(arr).toString('base64');
  37642. };
  37643. util.decodeBase64 = function (s) {
  37644. validateBase64(s);
  37645. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37646. };
  37647. } else {
  37648. // Node earlier than v6
  37649. util.encodeBase64 = function (arr) { // v6 and later
  37650. return (new Buffer(arr)).toString('base64');
  37651. };
  37652. util.decodeBase64 = function(s) {
  37653. validateBase64(s);
  37654. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37655. };
  37656. }
  37657. } else {
  37658. // Browsers
  37659. util.encodeBase64 = function(arr) {
  37660. var i, s = [], len = arr.length;
  37661. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37662. return btoa(s.join(''));
  37663. };
  37664. util.decodeBase64 = function(s) {
  37665. validateBase64(s);
  37666. var i, d = atob(s), b = new Uint8Array(d.length);
  37667. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37668. return b;
  37669. };
  37670. }
  37671. return util;
  37672. }));
  37673. /***/ }),
  37674. /* 2 */
  37675. /***/ (function(module, exports, __webpack_require__) {
  37676. // required so we don't have to do require('pusher').default etc.
  37677. module.exports = __webpack_require__(4).default;
  37678. /***/ }),
  37679. /* 3 */
  37680. /***/ (function(module, exports) {
  37681. /* (ignored) */
  37682. /***/ }),
  37683. /* 4 */
  37684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37685. "use strict";
  37686. __webpack_require__.r(__webpack_exports__);
  37687. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37688. var ScriptReceiverFactory = (function () {
  37689. function ScriptReceiverFactory(prefix, name) {
  37690. this.lastId = 0;
  37691. this.prefix = prefix;
  37692. this.name = name;
  37693. }
  37694. ScriptReceiverFactory.prototype.create = function (callback) {
  37695. this.lastId++;
  37696. var number = this.lastId;
  37697. var id = this.prefix + number;
  37698. var name = this.name + "[" + number + "]";
  37699. var called = false;
  37700. var callbackWrapper = function () {
  37701. if (!called) {
  37702. callback.apply(null, arguments);
  37703. called = true;
  37704. }
  37705. };
  37706. this[number] = callbackWrapper;
  37707. return { number: number, id: id, name: name, callback: callbackWrapper };
  37708. };
  37709. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37710. delete this[receiver.number];
  37711. };
  37712. return ScriptReceiverFactory;
  37713. }());
  37714. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37715. // CONCATENATED MODULE: ./src/core/defaults.ts
  37716. var Defaults = {
  37717. VERSION: "5.0.3",
  37718. PROTOCOL: 7,
  37719. host: 'ws.pusherapp.com',
  37720. ws_port: 80,
  37721. wss_port: 443,
  37722. ws_path: '',
  37723. sockjs_host: 'sockjs.pusher.com',
  37724. sockjs_http_port: 80,
  37725. sockjs_https_port: 443,
  37726. sockjs_path: '/pusher',
  37727. stats_host: 'stats.pusher.com',
  37728. channel_auth_endpoint: '/pusher/auth',
  37729. channel_auth_transport: 'ajax',
  37730. activity_timeout: 120000,
  37731. pong_timeout: 30000,
  37732. unavailable_timeout: 10000,
  37733. cdn_http: "http://js.pusher.com",
  37734. cdn_https: "https://js.pusher.com",
  37735. dependency_suffix: ""
  37736. };
  37737. /* harmony default export */ var defaults = (Defaults);
  37738. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37739. var dependency_loader_DependencyLoader = (function () {
  37740. function DependencyLoader(options) {
  37741. this.options = options;
  37742. this.receivers = options.receivers || ScriptReceivers;
  37743. this.loading = {};
  37744. }
  37745. DependencyLoader.prototype.load = function (name, options, callback) {
  37746. var self = this;
  37747. if (self.loading[name] && self.loading[name].length > 0) {
  37748. self.loading[name].push(callback);
  37749. }
  37750. else {
  37751. self.loading[name] = [callback];
  37752. var request = runtime.createScriptRequest(self.getPath(name, options));
  37753. var receiver = self.receivers.create(function (error) {
  37754. self.receivers.remove(receiver);
  37755. if (self.loading[name]) {
  37756. var callbacks = self.loading[name];
  37757. delete self.loading[name];
  37758. var successCallback = function (wasSuccessful) {
  37759. if (!wasSuccessful) {
  37760. request.cleanup();
  37761. }
  37762. };
  37763. for (var i = 0; i < callbacks.length; i++) {
  37764. callbacks[i](error, successCallback);
  37765. }
  37766. }
  37767. });
  37768. request.send(receiver);
  37769. }
  37770. };
  37771. DependencyLoader.prototype.getRoot = function (options) {
  37772. var cdn;
  37773. var protocol = runtime.getDocument().location.protocol;
  37774. if ((options && options.useTLS) || protocol === "https:") {
  37775. cdn = this.options.cdn_https;
  37776. }
  37777. else {
  37778. cdn = this.options.cdn_http;
  37779. }
  37780. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37781. };
  37782. DependencyLoader.prototype.getPath = function (name, options) {
  37783. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37784. };
  37785. ;
  37786. return DependencyLoader;
  37787. }());
  37788. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37789. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37790. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37791. var Dependencies = new dependency_loader({
  37792. cdn_http: defaults.cdn_http,
  37793. cdn_https: defaults.cdn_https,
  37794. version: defaults.VERSION,
  37795. suffix: defaults.dependency_suffix,
  37796. receivers: DependenciesReceivers
  37797. });
  37798. // CONCATENATED MODULE: ./src/core/base64.ts
  37799. function encode(s) {
  37800. return btoa(utob(s));
  37801. }
  37802. var fromCharCode = String.fromCharCode;
  37803. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37804. var b64tab = {};
  37805. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37806. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37807. }
  37808. var cb_utob = function (c) {
  37809. var cc = c.charCodeAt(0);
  37810. return cc < 0x80
  37811. ? c
  37812. : cc < 0x800
  37813. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37814. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37815. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37816. fromCharCode(0x80 | (cc & 0x3f));
  37817. };
  37818. var utob = function (u) {
  37819. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37820. };
  37821. var cb_encode = function (ccc) {
  37822. var padlen = [0, 2, 1][ccc.length % 3];
  37823. var ord = (ccc.charCodeAt(0) << 16) |
  37824. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37825. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37826. var chars = [
  37827. b64chars.charAt(ord >>> 18),
  37828. b64chars.charAt((ord >>> 12) & 63),
  37829. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37830. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37831. ];
  37832. return chars.join('');
  37833. };
  37834. var btoa = window.btoa ||
  37835. function (b) {
  37836. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37837. };
  37838. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37839. var Timer = (function () {
  37840. function Timer(set, clear, delay, callback) {
  37841. var _this = this;
  37842. this.clear = clear;
  37843. this.timer = set(function () {
  37844. if (_this.timer) {
  37845. _this.timer = callback(_this.timer);
  37846. }
  37847. }, delay);
  37848. }
  37849. Timer.prototype.isRunning = function () {
  37850. return this.timer !== null;
  37851. };
  37852. Timer.prototype.ensureAborted = function () {
  37853. if (this.timer) {
  37854. this.clear(this.timer);
  37855. this.timer = null;
  37856. }
  37857. };
  37858. return Timer;
  37859. }());
  37860. /* harmony default export */ var abstract_timer = (Timer);
  37861. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37862. var __extends = (undefined && undefined.__extends) || (function () {
  37863. var extendStatics = function (d, b) {
  37864. extendStatics = Object.setPrototypeOf ||
  37865. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37866. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37867. return extendStatics(d, b);
  37868. };
  37869. return function (d, b) {
  37870. extendStatics(d, b);
  37871. function __() { this.constructor = d; }
  37872. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37873. };
  37874. })();
  37875. function timers_clearTimeout(timer) {
  37876. window.clearTimeout(timer);
  37877. }
  37878. function timers_clearInterval(timer) {
  37879. window.clearInterval(timer);
  37880. }
  37881. var OneOffTimer = (function (_super) {
  37882. __extends(OneOffTimer, _super);
  37883. function OneOffTimer(delay, callback) {
  37884. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37885. callback();
  37886. return null;
  37887. }) || this;
  37888. }
  37889. return OneOffTimer;
  37890. }(abstract_timer));
  37891. var PeriodicTimer = (function (_super) {
  37892. __extends(PeriodicTimer, _super);
  37893. function PeriodicTimer(delay, callback) {
  37894. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37895. callback();
  37896. return timer;
  37897. }) || this;
  37898. }
  37899. return PeriodicTimer;
  37900. }(abstract_timer));
  37901. // CONCATENATED MODULE: ./src/core/util.ts
  37902. var Util = {
  37903. now: function () {
  37904. if (Date.now) {
  37905. return Date.now();
  37906. }
  37907. else {
  37908. return new Date().valueOf();
  37909. }
  37910. },
  37911. defer: function (callback) {
  37912. return new OneOffTimer(0, callback);
  37913. },
  37914. method: function (name) {
  37915. var args = [];
  37916. for (var _i = 1; _i < arguments.length; _i++) {
  37917. args[_i - 1] = arguments[_i];
  37918. }
  37919. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37920. return function (object) {
  37921. return object[name].apply(object, boundArguments.concat(arguments));
  37922. };
  37923. }
  37924. };
  37925. /* harmony default export */ var util = (Util);
  37926. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37927. function extend(target) {
  37928. var sources = [];
  37929. for (var _i = 1; _i < arguments.length; _i++) {
  37930. sources[_i - 1] = arguments[_i];
  37931. }
  37932. for (var i = 0; i < sources.length; i++) {
  37933. var extensions = sources[i];
  37934. for (var property in extensions) {
  37935. if (extensions[property] && extensions[property].constructor &&
  37936. extensions[property].constructor === Object) {
  37937. target[property] = extend(target[property] || {}, extensions[property]);
  37938. }
  37939. else {
  37940. target[property] = extensions[property];
  37941. }
  37942. }
  37943. }
  37944. return target;
  37945. }
  37946. function stringify() {
  37947. var m = ["Pusher"];
  37948. for (var i = 0; i < arguments.length; i++) {
  37949. if (typeof arguments[i] === "string") {
  37950. m.push(arguments[i]);
  37951. }
  37952. else {
  37953. m.push(safeJSONStringify(arguments[i]));
  37954. }
  37955. }
  37956. return m.join(" : ");
  37957. }
  37958. function arrayIndexOf(array, item) {
  37959. var nativeIndexOf = Array.prototype.indexOf;
  37960. if (array === null) {
  37961. return -1;
  37962. }
  37963. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37964. return array.indexOf(item);
  37965. }
  37966. for (var i = 0, l = array.length; i < l; i++) {
  37967. if (array[i] === item) {
  37968. return i;
  37969. }
  37970. }
  37971. return -1;
  37972. }
  37973. function objectApply(object, f) {
  37974. for (var key in object) {
  37975. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37976. f(object[key], key, object);
  37977. }
  37978. }
  37979. }
  37980. function keys(object) {
  37981. var keys = [];
  37982. objectApply(object, function (_, key) {
  37983. keys.push(key);
  37984. });
  37985. return keys;
  37986. }
  37987. function values(object) {
  37988. var values = [];
  37989. objectApply(object, function (value) {
  37990. values.push(value);
  37991. });
  37992. return values;
  37993. }
  37994. function apply(array, f, context) {
  37995. for (var i = 0; i < array.length; i++) {
  37996. f.call(context || window, array[i], i, array);
  37997. }
  37998. }
  37999. function map(array, f) {
  38000. var result = [];
  38001. for (var i = 0; i < array.length; i++) {
  38002. result.push(f(array[i], i, array, result));
  38003. }
  38004. return result;
  38005. }
  38006. function mapObject(object, f) {
  38007. var result = {};
  38008. objectApply(object, function (value, key) {
  38009. result[key] = f(value);
  38010. });
  38011. return result;
  38012. }
  38013. function filter(array, test) {
  38014. test = test || function (value) { return !!value; };
  38015. var result = [];
  38016. for (var i = 0; i < array.length; i++) {
  38017. if (test(array[i], i, array, result)) {
  38018. result.push(array[i]);
  38019. }
  38020. }
  38021. return result;
  38022. }
  38023. function filterObject(object, test) {
  38024. var result = {};
  38025. objectApply(object, function (value, key) {
  38026. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38027. result[key] = value;
  38028. }
  38029. });
  38030. return result;
  38031. }
  38032. function flatten(object) {
  38033. var result = [];
  38034. objectApply(object, function (value, key) {
  38035. result.push([key, value]);
  38036. });
  38037. return result;
  38038. }
  38039. function any(array, test) {
  38040. for (var i = 0; i < array.length; i++) {
  38041. if (test(array[i], i, array)) {
  38042. return true;
  38043. }
  38044. }
  38045. return false;
  38046. }
  38047. function collections_all(array, test) {
  38048. for (var i = 0; i < array.length; i++) {
  38049. if (!test(array[i], i, array)) {
  38050. return false;
  38051. }
  38052. }
  38053. return true;
  38054. }
  38055. function encodeParamsObject(data) {
  38056. return mapObject(data, function (value) {
  38057. if (typeof value === "object") {
  38058. value = safeJSONStringify(value);
  38059. }
  38060. return encodeURIComponent(encode(value.toString()));
  38061. });
  38062. }
  38063. function buildQueryString(data) {
  38064. var params = filterObject(data, function (value) {
  38065. return value !== undefined;
  38066. });
  38067. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38068. return query;
  38069. }
  38070. function decycleObject(object) {
  38071. var objects = [], paths = [];
  38072. return (function derez(value, path) {
  38073. var i, name, nu;
  38074. switch (typeof value) {
  38075. case 'object':
  38076. if (!value) {
  38077. return null;
  38078. }
  38079. for (i = 0; i < objects.length; i += 1) {
  38080. if (objects[i] === value) {
  38081. return { $ref: paths[i] };
  38082. }
  38083. }
  38084. objects.push(value);
  38085. paths.push(path);
  38086. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38087. nu = [];
  38088. for (i = 0; i < value.length; i += 1) {
  38089. nu[i] = derez(value[i], path + '[' + i + ']');
  38090. }
  38091. }
  38092. else {
  38093. nu = {};
  38094. for (name in value) {
  38095. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38096. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38097. }
  38098. }
  38099. }
  38100. return nu;
  38101. case 'number':
  38102. case 'string':
  38103. case 'boolean':
  38104. return value;
  38105. }
  38106. }(object, '$'));
  38107. }
  38108. function safeJSONStringify(source) {
  38109. try {
  38110. return JSON.stringify(source);
  38111. }
  38112. catch (e) {
  38113. return JSON.stringify(decycleObject(source));
  38114. }
  38115. }
  38116. // CONCATENATED MODULE: ./src/core/logger.ts
  38117. var logger_Logger = (function () {
  38118. function Logger() {
  38119. this.globalLog = function (message) {
  38120. if (window.console && window.console.log) {
  38121. window.console.log(message);
  38122. }
  38123. };
  38124. }
  38125. Logger.prototype.debug = function () {
  38126. var args = [];
  38127. for (var _i = 0; _i < arguments.length; _i++) {
  38128. args[_i] = arguments[_i];
  38129. }
  38130. this.log(this.globalLog, args);
  38131. };
  38132. Logger.prototype.warn = function () {
  38133. var args = [];
  38134. for (var _i = 0; _i < arguments.length; _i++) {
  38135. args[_i] = arguments[_i];
  38136. }
  38137. this.log(this.globalLogWarn, args);
  38138. };
  38139. Logger.prototype.error = function () {
  38140. var args = [];
  38141. for (var _i = 0; _i < arguments.length; _i++) {
  38142. args[_i] = arguments[_i];
  38143. }
  38144. this.log(this.globalLogError, args);
  38145. };
  38146. Logger.prototype.globalLogWarn = function (message) {
  38147. if (window.console && window.console.warn) {
  38148. window.console.warn(message);
  38149. }
  38150. else {
  38151. this.globalLog(message);
  38152. }
  38153. };
  38154. Logger.prototype.globalLogError = function (message) {
  38155. if (window.console && window.console.error) {
  38156. window.console.error(message);
  38157. }
  38158. else {
  38159. this.globalLogWarn(message);
  38160. }
  38161. };
  38162. Logger.prototype.log = function (defaultLoggingFunction) {
  38163. var args = [];
  38164. for (var _i = 1; _i < arguments.length; _i++) {
  38165. args[_i - 1] = arguments[_i];
  38166. }
  38167. var message = stringify.apply(this, arguments);
  38168. if (core_pusher.log) {
  38169. core_pusher.log(message);
  38170. }
  38171. else if (core_pusher.logToConsole) {
  38172. var log = defaultLoggingFunction.bind(this);
  38173. log(message);
  38174. }
  38175. };
  38176. return Logger;
  38177. }());
  38178. /* harmony default export */ var logger = (new logger_Logger());
  38179. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38180. var urlStore = {
  38181. baseUrl: "https://pusher.com",
  38182. urls: {
  38183. authenticationEndpoint: {
  38184. path: "/docs/authenticating_users",
  38185. },
  38186. javascriptQuickStart: {
  38187. path: "/docs/javascript_quick_start"
  38188. },
  38189. triggeringClientEvents: {
  38190. path: "/docs/client_api_guide/client_events#trigger-events"
  38191. }
  38192. }
  38193. };
  38194. var buildLogSuffix = function (key) {
  38195. var urlPrefix = "See:";
  38196. var urlObj = urlStore.urls[key];
  38197. if (!urlObj)
  38198. return "";
  38199. var url;
  38200. if (urlObj.fullUrl) {
  38201. url = urlObj.fullUrl;
  38202. }
  38203. else if (urlObj.path) {
  38204. url = urlStore.baseUrl + urlObj.path;
  38205. }
  38206. if (!url)
  38207. return "";
  38208. return urlPrefix + " " + url;
  38209. };
  38210. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38211. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38212. var ajax = function (context, socketId, callback) {
  38213. var self = this, xhr;
  38214. xhr = runtime.createXHR();
  38215. xhr.open("POST", self.options.authEndpoint, true);
  38216. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38217. for (var headerName in this.authOptions.headers) {
  38218. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38219. }
  38220. xhr.onreadystatechange = function () {
  38221. if (xhr.readyState === 4) {
  38222. if (xhr.status === 200) {
  38223. var data, parsed = false;
  38224. try {
  38225. data = JSON.parse(xhr.responseText);
  38226. parsed = true;
  38227. }
  38228. catch (e) {
  38229. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38230. }
  38231. if (parsed) {
  38232. callback(false, data);
  38233. }
  38234. }
  38235. else {
  38236. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38237. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38238. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38239. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38240. callback(true, xhr.status);
  38241. }
  38242. }
  38243. };
  38244. xhr.send(this.composeQuery(socketId));
  38245. return xhr;
  38246. };
  38247. /* harmony default export */ var xhr_auth = (ajax);
  38248. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38249. var jsonp = function (context, socketId, callback) {
  38250. if (this.authOptions.headers !== undefined) {
  38251. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38252. }
  38253. var callbackName = context.nextAuthCallbackID.toString();
  38254. context.nextAuthCallbackID++;
  38255. var document = context.getDocument();
  38256. var script = document.createElement("script");
  38257. context.auth_callbacks[callbackName] = function (data) {
  38258. callback(false, data);
  38259. };
  38260. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38261. script.src = this.options.authEndpoint +
  38262. '?callback=' +
  38263. encodeURIComponent(callback_name) +
  38264. '&' +
  38265. this.composeQuery(socketId);
  38266. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38267. head.insertBefore(script, head.firstChild);
  38268. };
  38269. /* harmony default export */ var jsonp_auth = (jsonp);
  38270. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38271. var ScriptRequest = (function () {
  38272. function ScriptRequest(src) {
  38273. this.src = src;
  38274. }
  38275. ScriptRequest.prototype.send = function (receiver) {
  38276. var self = this;
  38277. var errorString = "Error loading " + self.src;
  38278. self.script = document.createElement("script");
  38279. self.script.id = receiver.id;
  38280. self.script.src = self.src;
  38281. self.script.type = "text/javascript";
  38282. self.script.charset = "UTF-8";
  38283. if (self.script.addEventListener) {
  38284. self.script.onerror = function () {
  38285. receiver.callback(errorString);
  38286. };
  38287. self.script.onload = function () {
  38288. receiver.callback(null);
  38289. };
  38290. }
  38291. else {
  38292. self.script.onreadystatechange = function () {
  38293. if (self.script.readyState === 'loaded' ||
  38294. self.script.readyState === 'complete') {
  38295. receiver.callback(null);
  38296. }
  38297. };
  38298. }
  38299. if (self.script.async === undefined && document.attachEvent &&
  38300. /opera/i.test(navigator.userAgent)) {
  38301. self.errorScript = document.createElement("script");
  38302. self.errorScript.id = receiver.id + "_error";
  38303. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38304. self.script.async = self.errorScript.async = false;
  38305. }
  38306. else {
  38307. self.script.async = true;
  38308. }
  38309. var head = document.getElementsByTagName('head')[0];
  38310. head.insertBefore(self.script, head.firstChild);
  38311. if (self.errorScript) {
  38312. head.insertBefore(self.errorScript, self.script.nextSibling);
  38313. }
  38314. };
  38315. ScriptRequest.prototype.cleanup = function () {
  38316. if (this.script) {
  38317. this.script.onload = this.script.onerror = null;
  38318. this.script.onreadystatechange = null;
  38319. }
  38320. if (this.script && this.script.parentNode) {
  38321. this.script.parentNode.removeChild(this.script);
  38322. }
  38323. if (this.errorScript && this.errorScript.parentNode) {
  38324. this.errorScript.parentNode.removeChild(this.errorScript);
  38325. }
  38326. this.script = null;
  38327. this.errorScript = null;
  38328. };
  38329. return ScriptRequest;
  38330. }());
  38331. /* harmony default export */ var script_request = (ScriptRequest);
  38332. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38333. var jsonp_request_JSONPRequest = (function () {
  38334. function JSONPRequest(url, data) {
  38335. this.url = url;
  38336. this.data = data;
  38337. }
  38338. JSONPRequest.prototype.send = function (receiver) {
  38339. if (this.request) {
  38340. return;
  38341. }
  38342. var query = buildQueryString(this.data);
  38343. var url = this.url + "/" + receiver.number + "?" + query;
  38344. this.request = runtime.createScriptRequest(url);
  38345. this.request.send(receiver);
  38346. };
  38347. JSONPRequest.prototype.cleanup = function () {
  38348. if (this.request) {
  38349. this.request.cleanup();
  38350. }
  38351. };
  38352. return JSONPRequest;
  38353. }());
  38354. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38355. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38356. var getAgent = function (sender, useTLS) {
  38357. return function (data, callback) {
  38358. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38359. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38360. var request = runtime.createJSONPRequest(url, data);
  38361. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38362. ScriptReceivers.remove(receiver);
  38363. request.cleanup();
  38364. if (result && result.host) {
  38365. sender.host = result.host;
  38366. }
  38367. if (callback) {
  38368. callback(error, result);
  38369. }
  38370. });
  38371. request.send(receiver);
  38372. };
  38373. };
  38374. var jsonp_timeline_jsonp = {
  38375. name: 'jsonp',
  38376. getAgent: getAgent
  38377. };
  38378. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38379. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38380. function getGenericURL(baseScheme, params, path) {
  38381. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38382. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38383. return scheme + "://" + host + path;
  38384. }
  38385. function getGenericPath(key, queryString) {
  38386. var path = "/app/" + key;
  38387. var query = "?protocol=" + defaults.PROTOCOL +
  38388. "&client=js" +
  38389. "&version=" + defaults.VERSION +
  38390. (queryString ? ("&" + queryString) : "");
  38391. return path + query;
  38392. }
  38393. var ws = {
  38394. getInitial: function (key, params) {
  38395. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38396. return getGenericURL("ws", params, path);
  38397. }
  38398. };
  38399. var http = {
  38400. getInitial: function (key, params) {
  38401. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38402. return getGenericURL("http", params, path);
  38403. }
  38404. };
  38405. var sockjs = {
  38406. getInitial: function (key, params) {
  38407. return getGenericURL("http", params, params.httpPath || "/pusher");
  38408. },
  38409. getPath: function (key, params) {
  38410. return getGenericPath(key);
  38411. }
  38412. };
  38413. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38414. var callback_registry_CallbackRegistry = (function () {
  38415. function CallbackRegistry() {
  38416. this._callbacks = {};
  38417. }
  38418. CallbackRegistry.prototype.get = function (name) {
  38419. return this._callbacks[prefix(name)];
  38420. };
  38421. CallbackRegistry.prototype.add = function (name, callback, context) {
  38422. var prefixedEventName = prefix(name);
  38423. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38424. this._callbacks[prefixedEventName].push({
  38425. fn: callback,
  38426. context: context
  38427. });
  38428. };
  38429. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38430. if (!name && !callback && !context) {
  38431. this._callbacks = {};
  38432. return;
  38433. }
  38434. var names = name ? [prefix(name)] : keys(this._callbacks);
  38435. if (callback || context) {
  38436. this.removeCallback(names, callback, context);
  38437. }
  38438. else {
  38439. this.removeAllCallbacks(names);
  38440. }
  38441. };
  38442. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38443. apply(names, function (name) {
  38444. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38445. return (callback && callback !== binding.fn) ||
  38446. (context && context !== binding.context);
  38447. });
  38448. if (this._callbacks[name].length === 0) {
  38449. delete this._callbacks[name];
  38450. }
  38451. }, this);
  38452. };
  38453. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38454. apply(names, function (name) {
  38455. delete this._callbacks[name];
  38456. }, this);
  38457. };
  38458. return CallbackRegistry;
  38459. }());
  38460. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38461. function prefix(name) {
  38462. return "_" + name;
  38463. }
  38464. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38465. var dispatcher_Dispatcher = (function () {
  38466. function Dispatcher(failThrough) {
  38467. this.callbacks = new callback_registry();
  38468. this.global_callbacks = [];
  38469. this.failThrough = failThrough;
  38470. }
  38471. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38472. this.callbacks.add(eventName, callback, context);
  38473. return this;
  38474. };
  38475. Dispatcher.prototype.bind_global = function (callback) {
  38476. this.global_callbacks.push(callback);
  38477. return this;
  38478. };
  38479. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38480. this.callbacks.remove(eventName, callback, context);
  38481. return this;
  38482. };
  38483. Dispatcher.prototype.unbind_global = function (callback) {
  38484. if (!callback) {
  38485. this.global_callbacks = [];
  38486. return this;
  38487. }
  38488. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38489. return this;
  38490. };
  38491. Dispatcher.prototype.unbind_all = function () {
  38492. this.unbind();
  38493. this.unbind_global();
  38494. return this;
  38495. };
  38496. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38497. for (var i = 0; i < this.global_callbacks.length; i++) {
  38498. this.global_callbacks[i](eventName, data);
  38499. }
  38500. var callbacks = this.callbacks.get(eventName);
  38501. var args = [];
  38502. if (metadata) {
  38503. args.push(data, metadata);
  38504. }
  38505. else if (data) {
  38506. args.push(data);
  38507. }
  38508. if (callbacks && callbacks.length > 0) {
  38509. for (var i = 0; i < callbacks.length; i++) {
  38510. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38511. }
  38512. }
  38513. else if (this.failThrough) {
  38514. this.failThrough(eventName, data);
  38515. }
  38516. return this;
  38517. };
  38518. return Dispatcher;
  38519. }());
  38520. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38521. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38522. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38523. var extendStatics = function (d, b) {
  38524. extendStatics = Object.setPrototypeOf ||
  38525. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38526. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38527. return extendStatics(d, b);
  38528. };
  38529. return function (d, b) {
  38530. extendStatics(d, b);
  38531. function __() { this.constructor = d; }
  38532. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38533. };
  38534. })();
  38535. var transport_connection_TransportConnection = (function (_super) {
  38536. transport_connection_extends(TransportConnection, _super);
  38537. function TransportConnection(hooks, name, priority, key, options) {
  38538. var _this = _super.call(this) || this;
  38539. _this.initialize = runtime.transportConnectionInitializer;
  38540. _this.hooks = hooks;
  38541. _this.name = name;
  38542. _this.priority = priority;
  38543. _this.key = key;
  38544. _this.options = options;
  38545. _this.state = "new";
  38546. _this.timeline = options.timeline;
  38547. _this.activityTimeout = options.activityTimeout;
  38548. _this.id = _this.timeline.generateUniqueID();
  38549. return _this;
  38550. }
  38551. TransportConnection.prototype.handlesActivityChecks = function () {
  38552. return Boolean(this.hooks.handlesActivityChecks);
  38553. };
  38554. TransportConnection.prototype.supportsPing = function () {
  38555. return Boolean(this.hooks.supportsPing);
  38556. };
  38557. TransportConnection.prototype.connect = function () {
  38558. var _this = this;
  38559. if (this.socket || this.state !== "initialized") {
  38560. return false;
  38561. }
  38562. var url = this.hooks.urls.getInitial(this.key, this.options);
  38563. try {
  38564. this.socket = this.hooks.getSocket(url, this.options);
  38565. }
  38566. catch (e) {
  38567. util.defer(function () {
  38568. _this.onError(e);
  38569. _this.changeState("closed");
  38570. });
  38571. return false;
  38572. }
  38573. this.bindListeners();
  38574. logger.debug("Connecting", { transport: this.name, url: url });
  38575. this.changeState("connecting");
  38576. return true;
  38577. };
  38578. TransportConnection.prototype.close = function () {
  38579. if (this.socket) {
  38580. this.socket.close();
  38581. return true;
  38582. }
  38583. else {
  38584. return false;
  38585. }
  38586. };
  38587. TransportConnection.prototype.send = function (data) {
  38588. var _this = this;
  38589. if (this.state === "open") {
  38590. util.defer(function () {
  38591. if (_this.socket) {
  38592. _this.socket.send(data);
  38593. }
  38594. });
  38595. return true;
  38596. }
  38597. else {
  38598. return false;
  38599. }
  38600. };
  38601. TransportConnection.prototype.ping = function () {
  38602. if (this.state === "open" && this.supportsPing()) {
  38603. this.socket.ping();
  38604. }
  38605. };
  38606. TransportConnection.prototype.onOpen = function () {
  38607. if (this.hooks.beforeOpen) {
  38608. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38609. }
  38610. this.changeState("open");
  38611. this.socket.onopen = undefined;
  38612. };
  38613. TransportConnection.prototype.onError = function (error) {
  38614. this.emit("error", { type: 'WebSocketError', error: error });
  38615. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38616. };
  38617. TransportConnection.prototype.onClose = function (closeEvent) {
  38618. if (closeEvent) {
  38619. this.changeState("closed", {
  38620. code: closeEvent.code,
  38621. reason: closeEvent.reason,
  38622. wasClean: closeEvent.wasClean
  38623. });
  38624. }
  38625. else {
  38626. this.changeState("closed");
  38627. }
  38628. this.unbindListeners();
  38629. this.socket = undefined;
  38630. };
  38631. TransportConnection.prototype.onMessage = function (message) {
  38632. this.emit("message", message);
  38633. };
  38634. TransportConnection.prototype.onActivity = function () {
  38635. this.emit("activity");
  38636. };
  38637. TransportConnection.prototype.bindListeners = function () {
  38638. var _this = this;
  38639. this.socket.onopen = function () {
  38640. _this.onOpen();
  38641. };
  38642. this.socket.onerror = function (error) {
  38643. _this.onError(error);
  38644. };
  38645. this.socket.onclose = function (closeEvent) {
  38646. _this.onClose(closeEvent);
  38647. };
  38648. this.socket.onmessage = function (message) {
  38649. _this.onMessage(message);
  38650. };
  38651. if (this.supportsPing()) {
  38652. this.socket.onactivity = function () { _this.onActivity(); };
  38653. }
  38654. };
  38655. TransportConnection.prototype.unbindListeners = function () {
  38656. if (this.socket) {
  38657. this.socket.onopen = undefined;
  38658. this.socket.onerror = undefined;
  38659. this.socket.onclose = undefined;
  38660. this.socket.onmessage = undefined;
  38661. if (this.supportsPing()) {
  38662. this.socket.onactivity = undefined;
  38663. }
  38664. }
  38665. };
  38666. TransportConnection.prototype.changeState = function (state, params) {
  38667. this.state = state;
  38668. this.timeline.info(this.buildTimelineMessage({
  38669. state: state,
  38670. params: params
  38671. }));
  38672. this.emit(state, params);
  38673. };
  38674. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38675. return extend({ cid: this.id }, message);
  38676. };
  38677. return TransportConnection;
  38678. }(dispatcher));
  38679. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38680. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38681. var transport_Transport = (function () {
  38682. function Transport(hooks) {
  38683. this.hooks = hooks;
  38684. }
  38685. Transport.prototype.isSupported = function (environment) {
  38686. return this.hooks.isSupported(environment);
  38687. };
  38688. Transport.prototype.createConnection = function (name, priority, key, options) {
  38689. return new transport_connection(this.hooks, name, priority, key, options);
  38690. };
  38691. return Transport;
  38692. }());
  38693. /* harmony default export */ var transports_transport = (transport_Transport);
  38694. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38695. var WSTransport = new transports_transport({
  38696. urls: ws,
  38697. handlesActivityChecks: false,
  38698. supportsPing: false,
  38699. isInitialized: function () {
  38700. return Boolean(runtime.getWebSocketAPI());
  38701. },
  38702. isSupported: function () {
  38703. return Boolean(runtime.getWebSocketAPI());
  38704. },
  38705. getSocket: function (url) {
  38706. return runtime.createWebSocket(url);
  38707. }
  38708. });
  38709. var httpConfiguration = {
  38710. urls: http,
  38711. handlesActivityChecks: false,
  38712. supportsPing: true,
  38713. isInitialized: function () {
  38714. return true;
  38715. }
  38716. };
  38717. var streamingConfiguration = extend({ getSocket: function (url) {
  38718. return runtime.HTTPFactory.createStreamingSocket(url);
  38719. }
  38720. }, httpConfiguration);
  38721. var pollingConfiguration = extend({ getSocket: function (url) {
  38722. return runtime.HTTPFactory.createPollingSocket(url);
  38723. }
  38724. }, httpConfiguration);
  38725. var xhrConfiguration = {
  38726. isSupported: function () {
  38727. return runtime.isXHRSupported();
  38728. }
  38729. };
  38730. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38731. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38732. var Transports = {
  38733. ws: WSTransport,
  38734. xhr_streaming: XHRStreamingTransport,
  38735. xhr_polling: XHRPollingTransport
  38736. };
  38737. /* harmony default export */ var transports = (Transports);
  38738. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38739. var SockJSTransport = new transports_transport({
  38740. file: "sockjs",
  38741. urls: sockjs,
  38742. handlesActivityChecks: true,
  38743. supportsPing: false,
  38744. isSupported: function () {
  38745. return true;
  38746. },
  38747. isInitialized: function () {
  38748. return window.SockJS !== undefined;
  38749. },
  38750. getSocket: function (url, options) {
  38751. return new window.SockJS(url, null, {
  38752. js_path: Dependencies.getPath("sockjs", {
  38753. useTLS: options.useTLS
  38754. }),
  38755. ignore_null_origin: options.ignoreNullOrigin
  38756. });
  38757. },
  38758. beforeOpen: function (socket, path) {
  38759. socket.send(JSON.stringify({
  38760. path: path
  38761. }));
  38762. }
  38763. });
  38764. var xdrConfiguration = {
  38765. isSupported: function (environment) {
  38766. var yes = runtime.isXDRSupported(environment.useTLS);
  38767. return yes;
  38768. }
  38769. };
  38770. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38771. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38772. transports.xdr_streaming = XDRStreamingTransport;
  38773. transports.xdr_polling = XDRPollingTransport;
  38774. transports.sockjs = SockJSTransport;
  38775. /* harmony default export */ var transports_transports = (transports);
  38776. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38777. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38778. var extendStatics = function (d, b) {
  38779. extendStatics = Object.setPrototypeOf ||
  38780. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38781. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38782. return extendStatics(d, b);
  38783. };
  38784. return function (d, b) {
  38785. extendStatics(d, b);
  38786. function __() { this.constructor = d; }
  38787. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38788. };
  38789. })();
  38790. var NetInfo = (function (_super) {
  38791. net_info_extends(NetInfo, _super);
  38792. function NetInfo() {
  38793. var _this = _super.call(this) || this;
  38794. var self = _this;
  38795. if (window.addEventListener !== undefined) {
  38796. window.addEventListener("online", function () {
  38797. self.emit('online');
  38798. }, false);
  38799. window.addEventListener("offline", function () {
  38800. self.emit('offline');
  38801. }, false);
  38802. }
  38803. return _this;
  38804. }
  38805. NetInfo.prototype.isOnline = function () {
  38806. if (window.navigator.onLine === undefined) {
  38807. return true;
  38808. }
  38809. else {
  38810. return window.navigator.onLine;
  38811. }
  38812. };
  38813. return NetInfo;
  38814. }(dispatcher));
  38815. var net_info_Network = new NetInfo();
  38816. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38817. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38818. function AssistantToTheTransportManager(manager, transport, options) {
  38819. this.manager = manager;
  38820. this.transport = transport;
  38821. this.minPingDelay = options.minPingDelay;
  38822. this.maxPingDelay = options.maxPingDelay;
  38823. this.pingDelay = undefined;
  38824. }
  38825. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38826. var _this = this;
  38827. options = extend({}, options, {
  38828. activityTimeout: this.pingDelay
  38829. });
  38830. var connection = this.transport.createConnection(name, priority, key, options);
  38831. var openTimestamp = null;
  38832. var onOpen = function () {
  38833. connection.unbind("open", onOpen);
  38834. connection.bind("closed", onClosed);
  38835. openTimestamp = util.now();
  38836. };
  38837. var onClosed = function (closeEvent) {
  38838. connection.unbind("closed", onClosed);
  38839. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38840. _this.manager.reportDeath();
  38841. }
  38842. else if (!closeEvent.wasClean && openTimestamp) {
  38843. var lifespan = util.now() - openTimestamp;
  38844. if (lifespan < 2 * _this.maxPingDelay) {
  38845. _this.manager.reportDeath();
  38846. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38847. }
  38848. }
  38849. };
  38850. connection.bind("open", onOpen);
  38851. return connection;
  38852. };
  38853. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38854. return this.manager.isAlive() && this.transport.isSupported(environment);
  38855. };
  38856. return AssistantToTheTransportManager;
  38857. }());
  38858. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38859. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38860. var Protocol = {
  38861. decodeMessage: function (messageEvent) {
  38862. try {
  38863. var messageData = JSON.parse(messageEvent.data);
  38864. var pusherEventData = messageData.data;
  38865. if (typeof pusherEventData === 'string') {
  38866. try {
  38867. pusherEventData = JSON.parse(messageData.data);
  38868. }
  38869. catch (e) { }
  38870. }
  38871. var pusherEvent = {
  38872. event: messageData.event,
  38873. channel: messageData.channel,
  38874. data: pusherEventData,
  38875. };
  38876. if (messageData.user_id) {
  38877. pusherEvent.user_id = messageData.user_id;
  38878. }
  38879. return pusherEvent;
  38880. }
  38881. catch (e) {
  38882. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38883. }
  38884. },
  38885. encodeMessage: function (event) {
  38886. return JSON.stringify(event);
  38887. },
  38888. processHandshake: function (messageEvent) {
  38889. var message = Protocol.decodeMessage(messageEvent);
  38890. if (message.event === "pusher:connection_established") {
  38891. if (!message.data.activity_timeout) {
  38892. throw "No activity timeout specified in handshake";
  38893. }
  38894. return {
  38895. action: "connected",
  38896. id: message.data.socket_id,
  38897. activityTimeout: message.data.activity_timeout * 1000
  38898. };
  38899. }
  38900. else if (message.event === "pusher:error") {
  38901. return {
  38902. action: this.getCloseAction(message.data),
  38903. error: this.getCloseError(message.data)
  38904. };
  38905. }
  38906. else {
  38907. throw "Invalid handshake";
  38908. }
  38909. },
  38910. getCloseAction: function (closeEvent) {
  38911. if (closeEvent.code < 4000) {
  38912. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38913. return "backoff";
  38914. }
  38915. else {
  38916. return null;
  38917. }
  38918. }
  38919. else if (closeEvent.code === 4000) {
  38920. return "tls_only";
  38921. }
  38922. else if (closeEvent.code < 4100) {
  38923. return "refused";
  38924. }
  38925. else if (closeEvent.code < 4200) {
  38926. return "backoff";
  38927. }
  38928. else if (closeEvent.code < 4300) {
  38929. return "retry";
  38930. }
  38931. else {
  38932. return "refused";
  38933. }
  38934. },
  38935. getCloseError: function (closeEvent) {
  38936. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38937. return {
  38938. type: 'PusherError',
  38939. data: {
  38940. code: closeEvent.code,
  38941. message: closeEvent.reason || closeEvent.message
  38942. }
  38943. };
  38944. }
  38945. else {
  38946. return null;
  38947. }
  38948. }
  38949. };
  38950. /* harmony default export */ var protocol_protocol = (Protocol);
  38951. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38952. var connection_extends = (undefined && undefined.__extends) || (function () {
  38953. var extendStatics = function (d, b) {
  38954. extendStatics = Object.setPrototypeOf ||
  38955. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38956. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38957. return extendStatics(d, b);
  38958. };
  38959. return function (d, b) {
  38960. extendStatics(d, b);
  38961. function __() { this.constructor = d; }
  38962. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38963. };
  38964. })();
  38965. var connection_Connection = (function (_super) {
  38966. connection_extends(Connection, _super);
  38967. function Connection(id, transport) {
  38968. var _this = _super.call(this) || this;
  38969. _this.id = id;
  38970. _this.transport = transport;
  38971. _this.activityTimeout = transport.activityTimeout;
  38972. _this.bindListeners();
  38973. return _this;
  38974. }
  38975. Connection.prototype.handlesActivityChecks = function () {
  38976. return this.transport.handlesActivityChecks();
  38977. };
  38978. Connection.prototype.send = function (data) {
  38979. return this.transport.send(data);
  38980. };
  38981. Connection.prototype.send_event = function (name, data, channel) {
  38982. var event = { event: name, data: data };
  38983. if (channel) {
  38984. event.channel = channel;
  38985. }
  38986. logger.debug('Event sent', event);
  38987. return this.send(protocol_protocol.encodeMessage(event));
  38988. };
  38989. Connection.prototype.ping = function () {
  38990. if (this.transport.supportsPing()) {
  38991. this.transport.ping();
  38992. }
  38993. else {
  38994. this.send_event('pusher:ping', {});
  38995. }
  38996. };
  38997. Connection.prototype.close = function () {
  38998. this.transport.close();
  38999. };
  39000. Connection.prototype.bindListeners = function () {
  39001. var _this = this;
  39002. var listeners = {
  39003. message: function (messageEvent) {
  39004. var pusherEvent;
  39005. try {
  39006. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39007. }
  39008. catch (e) {
  39009. _this.emit('error', {
  39010. type: 'MessageParseError',
  39011. error: e,
  39012. data: messageEvent.data
  39013. });
  39014. }
  39015. if (pusherEvent !== undefined) {
  39016. logger.debug('Event recd', pusherEvent);
  39017. switch (pusherEvent.event) {
  39018. case 'pusher:error':
  39019. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39020. break;
  39021. case 'pusher:ping':
  39022. _this.emit("ping");
  39023. break;
  39024. case 'pusher:pong':
  39025. _this.emit("pong");
  39026. break;
  39027. }
  39028. _this.emit('message', pusherEvent);
  39029. }
  39030. },
  39031. activity: function () {
  39032. _this.emit("activity");
  39033. },
  39034. error: function (error) {
  39035. _this.emit("error", { type: "WebSocketError", error: error });
  39036. },
  39037. closed: function (closeEvent) {
  39038. unbindListeners();
  39039. if (closeEvent && closeEvent.code) {
  39040. _this.handleCloseEvent(closeEvent);
  39041. }
  39042. _this.transport = null;
  39043. _this.emit("closed");
  39044. }
  39045. };
  39046. var unbindListeners = function () {
  39047. objectApply(listeners, function (listener, event) {
  39048. _this.transport.unbind(event, listener);
  39049. });
  39050. };
  39051. objectApply(listeners, function (listener, event) {
  39052. _this.transport.bind(event, listener);
  39053. });
  39054. };
  39055. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39056. var action = protocol_protocol.getCloseAction(closeEvent);
  39057. var error = protocol_protocol.getCloseError(closeEvent);
  39058. if (error) {
  39059. this.emit('error', error);
  39060. }
  39061. if (action) {
  39062. this.emit(action, { action: action, error: error });
  39063. }
  39064. };
  39065. return Connection;
  39066. }(dispatcher));
  39067. /* harmony default export */ var connection_connection = (connection_Connection);
  39068. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39069. var handshake_Handshake = (function () {
  39070. function Handshake(transport, callback) {
  39071. this.transport = transport;
  39072. this.callback = callback;
  39073. this.bindListeners();
  39074. }
  39075. Handshake.prototype.close = function () {
  39076. this.unbindListeners();
  39077. this.transport.close();
  39078. };
  39079. Handshake.prototype.bindListeners = function () {
  39080. var _this = this;
  39081. this.onMessage = function (m) {
  39082. _this.unbindListeners();
  39083. var result;
  39084. try {
  39085. result = protocol_protocol.processHandshake(m);
  39086. }
  39087. catch (e) {
  39088. _this.finish("error", { error: e });
  39089. _this.transport.close();
  39090. return;
  39091. }
  39092. if (result.action === "connected") {
  39093. _this.finish("connected", {
  39094. connection: new connection_connection(result.id, _this.transport),
  39095. activityTimeout: result.activityTimeout
  39096. });
  39097. }
  39098. else {
  39099. _this.finish(result.action, { error: result.error });
  39100. _this.transport.close();
  39101. }
  39102. };
  39103. this.onClosed = function (closeEvent) {
  39104. _this.unbindListeners();
  39105. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39106. var error = protocol_protocol.getCloseError(closeEvent);
  39107. _this.finish(action, { error: error });
  39108. };
  39109. this.transport.bind("message", this.onMessage);
  39110. this.transport.bind("closed", this.onClosed);
  39111. };
  39112. Handshake.prototype.unbindListeners = function () {
  39113. this.transport.unbind("message", this.onMessage);
  39114. this.transport.unbind("closed", this.onClosed);
  39115. };
  39116. Handshake.prototype.finish = function (action, params) {
  39117. this.callback(extend({ transport: this.transport, action: action }, params));
  39118. };
  39119. return Handshake;
  39120. }());
  39121. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39122. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39123. var pusher_authorizer_PusherAuthorizer = (function () {
  39124. function PusherAuthorizer(channel, options) {
  39125. this.channel = channel;
  39126. var authTransport = options.authTransport;
  39127. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39128. throw "'" + authTransport + "' is not a recognized auth transport";
  39129. }
  39130. this.type = authTransport;
  39131. this.options = options;
  39132. this.authOptions = (options || {}).auth || {};
  39133. }
  39134. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39135. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39136. '&channel_name=' + encodeURIComponent(this.channel.name);
  39137. for (var i in this.authOptions.params) {
  39138. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39139. }
  39140. return query;
  39141. };
  39142. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39143. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39144. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39145. };
  39146. return PusherAuthorizer;
  39147. }());
  39148. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39149. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39150. var timeline_sender_TimelineSender = (function () {
  39151. function TimelineSender(timeline, options) {
  39152. this.timeline = timeline;
  39153. this.options = options || {};
  39154. }
  39155. TimelineSender.prototype.send = function (useTLS, callback) {
  39156. if (this.timeline.isEmpty()) {
  39157. return;
  39158. }
  39159. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39160. };
  39161. return TimelineSender;
  39162. }());
  39163. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39164. // CONCATENATED MODULE: ./src/core/errors.ts
  39165. var errors_extends = (undefined && undefined.__extends) || (function () {
  39166. var extendStatics = function (d, b) {
  39167. extendStatics = Object.setPrototypeOf ||
  39168. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39169. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39170. return extendStatics(d, b);
  39171. };
  39172. return function (d, b) {
  39173. extendStatics(d, b);
  39174. function __() { this.constructor = d; }
  39175. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39176. };
  39177. })();
  39178. var BadEventName = (function (_super) {
  39179. errors_extends(BadEventName, _super);
  39180. function BadEventName(msg) {
  39181. var _newTarget = this.constructor;
  39182. var _this = _super.call(this, msg) || this;
  39183. Object.setPrototypeOf(_this, _newTarget.prototype);
  39184. return _this;
  39185. }
  39186. return BadEventName;
  39187. }(Error));
  39188. var RequestTimedOut = (function (_super) {
  39189. errors_extends(RequestTimedOut, _super);
  39190. function RequestTimedOut(msg) {
  39191. var _newTarget = this.constructor;
  39192. var _this = _super.call(this, msg) || this;
  39193. Object.setPrototypeOf(_this, _newTarget.prototype);
  39194. return _this;
  39195. }
  39196. return RequestTimedOut;
  39197. }(Error));
  39198. var TransportPriorityTooLow = (function (_super) {
  39199. errors_extends(TransportPriorityTooLow, _super);
  39200. function TransportPriorityTooLow(msg) {
  39201. var _newTarget = this.constructor;
  39202. var _this = _super.call(this, msg) || this;
  39203. Object.setPrototypeOf(_this, _newTarget.prototype);
  39204. return _this;
  39205. }
  39206. return TransportPriorityTooLow;
  39207. }(Error));
  39208. var TransportClosed = (function (_super) {
  39209. errors_extends(TransportClosed, _super);
  39210. function TransportClosed(msg) {
  39211. var _newTarget = this.constructor;
  39212. var _this = _super.call(this, msg) || this;
  39213. Object.setPrototypeOf(_this, _newTarget.prototype);
  39214. return _this;
  39215. }
  39216. return TransportClosed;
  39217. }(Error));
  39218. var UnsupportedFeature = (function (_super) {
  39219. errors_extends(UnsupportedFeature, _super);
  39220. function UnsupportedFeature(msg) {
  39221. var _newTarget = this.constructor;
  39222. var _this = _super.call(this, msg) || this;
  39223. Object.setPrototypeOf(_this, _newTarget.prototype);
  39224. return _this;
  39225. }
  39226. return UnsupportedFeature;
  39227. }(Error));
  39228. var UnsupportedTransport = (function (_super) {
  39229. errors_extends(UnsupportedTransport, _super);
  39230. function UnsupportedTransport(msg) {
  39231. var _newTarget = this.constructor;
  39232. var _this = _super.call(this, msg) || this;
  39233. Object.setPrototypeOf(_this, _newTarget.prototype);
  39234. return _this;
  39235. }
  39236. return UnsupportedTransport;
  39237. }(Error));
  39238. var UnsupportedStrategy = (function (_super) {
  39239. errors_extends(UnsupportedStrategy, _super);
  39240. function UnsupportedStrategy(msg) {
  39241. var _newTarget = this.constructor;
  39242. var _this = _super.call(this, msg) || this;
  39243. Object.setPrototypeOf(_this, _newTarget.prototype);
  39244. return _this;
  39245. }
  39246. return UnsupportedStrategy;
  39247. }(Error));
  39248. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39249. var channel_extends = (undefined && undefined.__extends) || (function () {
  39250. var extendStatics = function (d, b) {
  39251. extendStatics = Object.setPrototypeOf ||
  39252. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39253. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39254. return extendStatics(d, b);
  39255. };
  39256. return function (d, b) {
  39257. extendStatics(d, b);
  39258. function __() { this.constructor = d; }
  39259. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39260. };
  39261. })();
  39262. var channel_Channel = (function (_super) {
  39263. channel_extends(Channel, _super);
  39264. function Channel(name, pusher) {
  39265. var _this = _super.call(this, function (event, data) {
  39266. logger.debug('No callbacks on ' + name + ' for ' + event);
  39267. }) || this;
  39268. _this.name = name;
  39269. _this.pusher = pusher;
  39270. _this.subscribed = false;
  39271. _this.subscriptionPending = false;
  39272. _this.subscriptionCancelled = false;
  39273. return _this;
  39274. }
  39275. Channel.prototype.authorize = function (socketId, callback) {
  39276. return callback(false, {});
  39277. };
  39278. Channel.prototype.trigger = function (event, data) {
  39279. if (event.indexOf("client-") !== 0) {
  39280. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39281. }
  39282. if (!this.subscribed) {
  39283. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39284. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39285. }
  39286. return this.pusher.send_event(event, data, this.name);
  39287. };
  39288. Channel.prototype.disconnect = function () {
  39289. this.subscribed = false;
  39290. this.subscriptionPending = false;
  39291. };
  39292. Channel.prototype.handleEvent = function (event) {
  39293. var eventName = event.event;
  39294. var data = event.data;
  39295. if (eventName === "pusher_internal:subscription_succeeded") {
  39296. this.handleSubscriptionSucceededEvent(event);
  39297. }
  39298. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39299. var metadata = {};
  39300. this.emit(eventName, data, metadata);
  39301. }
  39302. };
  39303. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39304. this.subscriptionPending = false;
  39305. this.subscribed = true;
  39306. if (this.subscriptionCancelled) {
  39307. this.pusher.unsubscribe(this.name);
  39308. }
  39309. else {
  39310. this.emit("pusher:subscription_succeeded", event.data);
  39311. }
  39312. };
  39313. Channel.prototype.subscribe = function () {
  39314. var _this = this;
  39315. if (this.subscribed) {
  39316. return;
  39317. }
  39318. this.subscriptionPending = true;
  39319. this.subscriptionCancelled = false;
  39320. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39321. if (error) {
  39322. logger.error(data);
  39323. _this.emit('pusher:subscription_error', data);
  39324. }
  39325. else {
  39326. _this.pusher.send_event('pusher:subscribe', {
  39327. auth: data.auth,
  39328. channel_data: data.channel_data,
  39329. channel: _this.name
  39330. });
  39331. }
  39332. });
  39333. };
  39334. Channel.prototype.unsubscribe = function () {
  39335. this.subscribed = false;
  39336. this.pusher.send_event('pusher:unsubscribe', {
  39337. channel: this.name
  39338. });
  39339. };
  39340. Channel.prototype.cancelSubscription = function () {
  39341. this.subscriptionCancelled = true;
  39342. };
  39343. Channel.prototype.reinstateSubscription = function () {
  39344. this.subscriptionCancelled = false;
  39345. };
  39346. return Channel;
  39347. }(dispatcher));
  39348. /* harmony default export */ var channels_channel = (channel_Channel);
  39349. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39350. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39351. var extendStatics = function (d, b) {
  39352. extendStatics = Object.setPrototypeOf ||
  39353. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39354. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39355. return extendStatics(d, b);
  39356. };
  39357. return function (d, b) {
  39358. extendStatics(d, b);
  39359. function __() { this.constructor = d; }
  39360. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39361. };
  39362. })();
  39363. var private_channel_PrivateChannel = (function (_super) {
  39364. private_channel_extends(PrivateChannel, _super);
  39365. function PrivateChannel() {
  39366. return _super !== null && _super.apply(this, arguments) || this;
  39367. }
  39368. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39369. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39370. return authorizer.authorize(socketId, callback);
  39371. };
  39372. return PrivateChannel;
  39373. }(channels_channel));
  39374. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39375. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39376. var members_Members = (function () {
  39377. function Members() {
  39378. this.reset();
  39379. }
  39380. Members.prototype.get = function (id) {
  39381. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39382. return {
  39383. id: id,
  39384. info: this.members[id]
  39385. };
  39386. }
  39387. else {
  39388. return null;
  39389. }
  39390. };
  39391. Members.prototype.each = function (callback) {
  39392. var _this = this;
  39393. objectApply(this.members, function (member, id) {
  39394. callback(_this.get(id));
  39395. });
  39396. };
  39397. Members.prototype.setMyID = function (id) {
  39398. this.myID = id;
  39399. };
  39400. Members.prototype.onSubscription = function (subscriptionData) {
  39401. this.members = subscriptionData.presence.hash;
  39402. this.count = subscriptionData.presence.count;
  39403. this.me = this.get(this.myID);
  39404. };
  39405. Members.prototype.addMember = function (memberData) {
  39406. if (this.get(memberData.user_id) === null) {
  39407. this.count++;
  39408. }
  39409. this.members[memberData.user_id] = memberData.user_info;
  39410. return this.get(memberData.user_id);
  39411. };
  39412. Members.prototype.removeMember = function (memberData) {
  39413. var member = this.get(memberData.user_id);
  39414. if (member) {
  39415. delete this.members[memberData.user_id];
  39416. this.count--;
  39417. }
  39418. return member;
  39419. };
  39420. Members.prototype.reset = function () {
  39421. this.members = {};
  39422. this.count = 0;
  39423. this.myID = null;
  39424. this.me = null;
  39425. };
  39426. return Members;
  39427. }());
  39428. /* harmony default export */ var members = (members_Members);
  39429. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39430. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39431. var extendStatics = function (d, b) {
  39432. extendStatics = Object.setPrototypeOf ||
  39433. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39434. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39435. return extendStatics(d, b);
  39436. };
  39437. return function (d, b) {
  39438. extendStatics(d, b);
  39439. function __() { this.constructor = d; }
  39440. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39441. };
  39442. })();
  39443. var presence_channel_PresenceChannel = (function (_super) {
  39444. presence_channel_extends(PresenceChannel, _super);
  39445. function PresenceChannel(name, pusher) {
  39446. var _this = _super.call(this, name, pusher) || this;
  39447. _this.members = new members();
  39448. return _this;
  39449. }
  39450. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39451. var _this = this;
  39452. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39453. if (!error) {
  39454. if (authData.channel_data === undefined) {
  39455. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39456. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39457. ("expected 'channel_data' field. " + suffix));
  39458. callback("Invalid auth response");
  39459. return;
  39460. }
  39461. var channelData = JSON.parse(authData.channel_data);
  39462. _this.members.setMyID(channelData.user_id);
  39463. }
  39464. callback(error, authData);
  39465. });
  39466. };
  39467. PresenceChannel.prototype.handleEvent = function (event) {
  39468. var eventName = event.event;
  39469. if (eventName.indexOf("pusher_internal:") === 0) {
  39470. this.handleInternalEvent(event);
  39471. }
  39472. else {
  39473. var data = event.data;
  39474. var metadata = {};
  39475. if (event.user_id) {
  39476. metadata.user_id = event.user_id;
  39477. }
  39478. this.emit(eventName, data, metadata);
  39479. }
  39480. };
  39481. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39482. var eventName = event.event;
  39483. var data = event.data;
  39484. switch (eventName) {
  39485. case "pusher_internal:subscription_succeeded":
  39486. this.handleSubscriptionSucceededEvent(event);
  39487. break;
  39488. case "pusher_internal:member_added":
  39489. var addedMember = this.members.addMember(data);
  39490. this.emit('pusher:member_added', addedMember);
  39491. break;
  39492. case "pusher_internal:member_removed":
  39493. var removedMember = this.members.removeMember(data);
  39494. if (removedMember) {
  39495. this.emit('pusher:member_removed', removedMember);
  39496. }
  39497. break;
  39498. }
  39499. };
  39500. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39501. this.subscriptionPending = false;
  39502. this.subscribed = true;
  39503. if (this.subscriptionCancelled) {
  39504. this.pusher.unsubscribe(this.name);
  39505. }
  39506. else {
  39507. this.members.onSubscription(event.data);
  39508. this.emit("pusher:subscription_succeeded", this.members);
  39509. }
  39510. };
  39511. PresenceChannel.prototype.disconnect = function () {
  39512. this.members.reset();
  39513. _super.prototype.disconnect.call(this);
  39514. };
  39515. return PresenceChannel;
  39516. }(private_channel));
  39517. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39518. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39519. var nacl_fast = __webpack_require__(0);
  39520. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39521. var nacl_util = __webpack_require__(1);
  39522. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39523. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39524. var extendStatics = function (d, b) {
  39525. extendStatics = Object.setPrototypeOf ||
  39526. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39527. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39528. return extendStatics(d, b);
  39529. };
  39530. return function (d, b) {
  39531. extendStatics(d, b);
  39532. function __() { this.constructor = d; }
  39533. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39534. };
  39535. })();
  39536. var encrypted_channel_EncryptedChannel = (function (_super) {
  39537. encrypted_channel_extends(EncryptedChannel, _super);
  39538. function EncryptedChannel() {
  39539. var _this = _super !== null && _super.apply(this, arguments) || this;
  39540. _this.key = null;
  39541. return _this;
  39542. }
  39543. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39544. var _this = this;
  39545. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39546. if (error) {
  39547. callback(true, authData);
  39548. return;
  39549. }
  39550. var sharedSecret = authData["shared_secret"];
  39551. if (!sharedSecret) {
  39552. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39553. callback(true, errorMsg);
  39554. return;
  39555. }
  39556. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39557. delete authData["shared_secret"];
  39558. callback(false, authData);
  39559. });
  39560. };
  39561. EncryptedChannel.prototype.trigger = function (event, data) {
  39562. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39563. };
  39564. EncryptedChannel.prototype.handleEvent = function (event) {
  39565. var eventName = event.event;
  39566. var data = event.data;
  39567. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39568. _super.prototype.handleEvent.call(this, event);
  39569. return;
  39570. }
  39571. this.handleEncryptedEvent(eventName, data);
  39572. };
  39573. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39574. var _this = this;
  39575. if (!this.key) {
  39576. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39577. return;
  39578. }
  39579. if (!data.ciphertext || !data.nonce) {
  39580. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39581. return;
  39582. }
  39583. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39584. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39585. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39586. return;
  39587. }
  39588. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39589. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39590. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39591. return;
  39592. }
  39593. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39594. if (bytes === null) {
  39595. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39596. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39597. if (error) {
  39598. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39599. return;
  39600. }
  39601. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39602. if (bytes === null) {
  39603. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39604. return;
  39605. }
  39606. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39607. return;
  39608. });
  39609. return;
  39610. }
  39611. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39612. };
  39613. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39614. try {
  39615. this.emit(eventName, JSON.parse(data));
  39616. }
  39617. catch (e) {
  39618. this.emit(eventName, data);
  39619. }
  39620. return this;
  39621. };
  39622. return EncryptedChannel;
  39623. }(private_channel));
  39624. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39625. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39626. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39627. var extendStatics = function (d, b) {
  39628. extendStatics = Object.setPrototypeOf ||
  39629. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39630. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39631. return extendStatics(d, b);
  39632. };
  39633. return function (d, b) {
  39634. extendStatics(d, b);
  39635. function __() { this.constructor = d; }
  39636. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39637. };
  39638. })();
  39639. var connection_manager_ConnectionManager = (function (_super) {
  39640. connection_manager_extends(ConnectionManager, _super);
  39641. function ConnectionManager(key, options) {
  39642. var _this = _super.call(this) || this;
  39643. _this.key = key;
  39644. _this.options = options || {};
  39645. _this.state = "initialized";
  39646. _this.connection = null;
  39647. _this.usingTLS = !!options.useTLS;
  39648. _this.timeline = _this.options.timeline;
  39649. _this.errorCallbacks = _this.buildErrorCallbacks();
  39650. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39651. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39652. var Network = runtime.getNetwork();
  39653. Network.bind("online", function () {
  39654. _this.timeline.info({ netinfo: "online" });
  39655. if (_this.state === "connecting" || _this.state === "unavailable") {
  39656. _this.retryIn(0);
  39657. }
  39658. });
  39659. Network.bind("offline", function () {
  39660. _this.timeline.info({ netinfo: "offline" });
  39661. if (_this.connection) {
  39662. _this.sendActivityCheck();
  39663. }
  39664. });
  39665. _this.updateStrategy();
  39666. return _this;
  39667. }
  39668. ConnectionManager.prototype.connect = function () {
  39669. if (this.connection || this.runner) {
  39670. return;
  39671. }
  39672. if (!this.strategy.isSupported()) {
  39673. this.updateState("failed");
  39674. return;
  39675. }
  39676. this.updateState("connecting");
  39677. this.startConnecting();
  39678. this.setUnavailableTimer();
  39679. };
  39680. ;
  39681. ConnectionManager.prototype.send = function (data) {
  39682. if (this.connection) {
  39683. return this.connection.send(data);
  39684. }
  39685. else {
  39686. return false;
  39687. }
  39688. };
  39689. ;
  39690. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39691. if (this.connection) {
  39692. return this.connection.send_event(name, data, channel);
  39693. }
  39694. else {
  39695. return false;
  39696. }
  39697. };
  39698. ;
  39699. ConnectionManager.prototype.disconnect = function () {
  39700. this.disconnectInternally();
  39701. this.updateState("disconnected");
  39702. };
  39703. ;
  39704. ConnectionManager.prototype.isUsingTLS = function () {
  39705. return this.usingTLS;
  39706. };
  39707. ;
  39708. ConnectionManager.prototype.startConnecting = function () {
  39709. var _this = this;
  39710. var callback = function (error, handshake) {
  39711. if (error) {
  39712. _this.runner = _this.strategy.connect(0, callback);
  39713. }
  39714. else {
  39715. if (handshake.action === "error") {
  39716. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39717. _this.timeline.error({ handshakeError: handshake.error });
  39718. }
  39719. else {
  39720. _this.abortConnecting();
  39721. _this.handshakeCallbacks[handshake.action](handshake);
  39722. }
  39723. }
  39724. };
  39725. this.runner = this.strategy.connect(0, callback);
  39726. };
  39727. ;
  39728. ConnectionManager.prototype.abortConnecting = function () {
  39729. if (this.runner) {
  39730. this.runner.abort();
  39731. this.runner = null;
  39732. }
  39733. };
  39734. ;
  39735. ConnectionManager.prototype.disconnectInternally = function () {
  39736. this.abortConnecting();
  39737. this.clearRetryTimer();
  39738. this.clearUnavailableTimer();
  39739. if (this.connection) {
  39740. var connection = this.abandonConnection();
  39741. connection.close();
  39742. }
  39743. };
  39744. ;
  39745. ConnectionManager.prototype.updateStrategy = function () {
  39746. this.strategy = this.options.getStrategy({
  39747. key: this.key,
  39748. timeline: this.timeline,
  39749. useTLS: this.usingTLS
  39750. });
  39751. };
  39752. ;
  39753. ConnectionManager.prototype.retryIn = function (delay) {
  39754. var _this = this;
  39755. this.timeline.info({ action: "retry", delay: delay });
  39756. if (delay > 0) {
  39757. this.emit("connecting_in", Math.round(delay / 1000));
  39758. }
  39759. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39760. _this.disconnectInternally();
  39761. _this.connect();
  39762. });
  39763. };
  39764. ;
  39765. ConnectionManager.prototype.clearRetryTimer = function () {
  39766. if (this.retryTimer) {
  39767. this.retryTimer.ensureAborted();
  39768. this.retryTimer = null;
  39769. }
  39770. };
  39771. ;
  39772. ConnectionManager.prototype.setUnavailableTimer = function () {
  39773. var _this = this;
  39774. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39775. _this.updateState("unavailable");
  39776. });
  39777. };
  39778. ;
  39779. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39780. if (this.unavailableTimer) {
  39781. this.unavailableTimer.ensureAborted();
  39782. }
  39783. };
  39784. ;
  39785. ConnectionManager.prototype.sendActivityCheck = function () {
  39786. var _this = this;
  39787. this.stopActivityCheck();
  39788. this.connection.ping();
  39789. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39790. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39791. _this.retryIn(0);
  39792. });
  39793. };
  39794. ;
  39795. ConnectionManager.prototype.resetActivityCheck = function () {
  39796. var _this = this;
  39797. this.stopActivityCheck();
  39798. if (this.connection && !this.connection.handlesActivityChecks()) {
  39799. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39800. _this.sendActivityCheck();
  39801. });
  39802. }
  39803. };
  39804. ;
  39805. ConnectionManager.prototype.stopActivityCheck = function () {
  39806. if (this.activityTimer) {
  39807. this.activityTimer.ensureAborted();
  39808. }
  39809. };
  39810. ;
  39811. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39812. var _this = this;
  39813. return extend({}, errorCallbacks, {
  39814. message: function (message) {
  39815. _this.resetActivityCheck();
  39816. _this.emit('message', message);
  39817. },
  39818. ping: function () {
  39819. _this.send_event('pusher:pong', {});
  39820. },
  39821. activity: function () {
  39822. _this.resetActivityCheck();
  39823. },
  39824. error: function (error) {
  39825. _this.emit("error", { type: "WebSocketError", error: error });
  39826. },
  39827. closed: function () {
  39828. _this.abandonConnection();
  39829. if (_this.shouldRetry()) {
  39830. _this.retryIn(1000);
  39831. }
  39832. }
  39833. });
  39834. };
  39835. ;
  39836. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39837. var _this = this;
  39838. return extend({}, errorCallbacks, {
  39839. connected: function (handshake) {
  39840. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39841. _this.clearUnavailableTimer();
  39842. _this.setConnection(handshake.connection);
  39843. _this.socket_id = _this.connection.id;
  39844. _this.updateState("connected", { socket_id: _this.socket_id });
  39845. }
  39846. });
  39847. };
  39848. ;
  39849. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39850. var _this = this;
  39851. var withErrorEmitted = function (callback) {
  39852. return function (result) {
  39853. if (result.error) {
  39854. _this.emit("error", { type: "WebSocketError", error: result.error });
  39855. }
  39856. callback(result);
  39857. };
  39858. };
  39859. return {
  39860. tls_only: withErrorEmitted(function () {
  39861. _this.usingTLS = true;
  39862. _this.updateStrategy();
  39863. _this.retryIn(0);
  39864. }),
  39865. refused: withErrorEmitted(function () {
  39866. _this.disconnect();
  39867. }),
  39868. backoff: withErrorEmitted(function () {
  39869. _this.retryIn(1000);
  39870. }),
  39871. retry: withErrorEmitted(function () {
  39872. _this.retryIn(0);
  39873. })
  39874. };
  39875. };
  39876. ;
  39877. ConnectionManager.prototype.setConnection = function (connection) {
  39878. this.connection = connection;
  39879. for (var event in this.connectionCallbacks) {
  39880. this.connection.bind(event, this.connectionCallbacks[event]);
  39881. }
  39882. this.resetActivityCheck();
  39883. };
  39884. ;
  39885. ConnectionManager.prototype.abandonConnection = function () {
  39886. if (!this.connection) {
  39887. return;
  39888. }
  39889. this.stopActivityCheck();
  39890. for (var event in this.connectionCallbacks) {
  39891. this.connection.unbind(event, this.connectionCallbacks[event]);
  39892. }
  39893. var connection = this.connection;
  39894. this.connection = null;
  39895. return connection;
  39896. };
  39897. ConnectionManager.prototype.updateState = function (newState, data) {
  39898. var previousState = this.state;
  39899. this.state = newState;
  39900. if (previousState !== newState) {
  39901. var newStateDescription = newState;
  39902. if (newStateDescription === "connected") {
  39903. newStateDescription += " with new socket ID " + data.socket_id;
  39904. }
  39905. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39906. this.timeline.info({ state: newState, params: data });
  39907. this.emit('state_change', { previous: previousState, current: newState });
  39908. this.emit(newState, data);
  39909. }
  39910. };
  39911. ConnectionManager.prototype.shouldRetry = function () {
  39912. return this.state === "connecting" || this.state === "connected";
  39913. };
  39914. return ConnectionManager;
  39915. }(dispatcher));
  39916. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39917. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39918. var channels_Channels = (function () {
  39919. function Channels() {
  39920. this.channels = {};
  39921. }
  39922. Channels.prototype.add = function (name, pusher) {
  39923. if (!this.channels[name]) {
  39924. this.channels[name] = createChannel(name, pusher);
  39925. }
  39926. return this.channels[name];
  39927. };
  39928. Channels.prototype.all = function () {
  39929. return values(this.channels);
  39930. };
  39931. Channels.prototype.find = function (name) {
  39932. return this.channels[name];
  39933. };
  39934. Channels.prototype.remove = function (name) {
  39935. var channel = this.channels[name];
  39936. delete this.channels[name];
  39937. return channel;
  39938. };
  39939. Channels.prototype.disconnect = function () {
  39940. objectApply(this.channels, function (channel) {
  39941. channel.disconnect();
  39942. });
  39943. };
  39944. return Channels;
  39945. }());
  39946. /* harmony default export */ var channels = (channels_Channels);
  39947. function createChannel(name, pusher) {
  39948. if (name.indexOf('private-encrypted-') === 0) {
  39949. if (false) { var errorMsg; }
  39950. return factory.createEncryptedChannel(name, pusher);
  39951. }
  39952. else if (name.indexOf('private-') === 0) {
  39953. return factory.createPrivateChannel(name, pusher);
  39954. }
  39955. else if (name.indexOf('presence-') === 0) {
  39956. return factory.createPresenceChannel(name, pusher);
  39957. }
  39958. else {
  39959. return factory.createChannel(name, pusher);
  39960. }
  39961. }
  39962. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39963. var Factory = {
  39964. createChannels: function () {
  39965. return new channels();
  39966. },
  39967. createConnectionManager: function (key, options) {
  39968. return new connection_manager(key, options);
  39969. },
  39970. createChannel: function (name, pusher) {
  39971. return new channels_channel(name, pusher);
  39972. },
  39973. createPrivateChannel: function (name, pusher) {
  39974. return new private_channel(name, pusher);
  39975. },
  39976. createPresenceChannel: function (name, pusher) {
  39977. return new presence_channel(name, pusher);
  39978. },
  39979. createEncryptedChannel: function (name, pusher) {
  39980. return new encrypted_channel(name, pusher);
  39981. },
  39982. createTimelineSender: function (timeline, options) {
  39983. return new timeline_sender(timeline, options);
  39984. },
  39985. createAuthorizer: function (channel, options) {
  39986. if (options.authorizer) {
  39987. return options.authorizer(channel, options);
  39988. }
  39989. return new pusher_authorizer(channel, options);
  39990. },
  39991. createHandshake: function (transport, callback) {
  39992. return new connection_handshake(transport, callback);
  39993. },
  39994. createAssistantToTheTransportManager: function (manager, transport, options) {
  39995. return new assistant_to_the_transport_manager(manager, transport, options);
  39996. }
  39997. };
  39998. /* harmony default export */ var factory = (Factory);
  39999. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40000. var transport_manager_TransportManager = (function () {
  40001. function TransportManager(options) {
  40002. this.options = options || {};
  40003. this.livesLeft = this.options.lives || Infinity;
  40004. }
  40005. TransportManager.prototype.getAssistant = function (transport) {
  40006. return factory.createAssistantToTheTransportManager(this, transport, {
  40007. minPingDelay: this.options.minPingDelay,
  40008. maxPingDelay: this.options.maxPingDelay
  40009. });
  40010. };
  40011. TransportManager.prototype.isAlive = function () {
  40012. return this.livesLeft > 0;
  40013. };
  40014. TransportManager.prototype.reportDeath = function () {
  40015. this.livesLeft -= 1;
  40016. };
  40017. return TransportManager;
  40018. }());
  40019. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40020. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40021. var sequential_strategy_SequentialStrategy = (function () {
  40022. function SequentialStrategy(strategies, options) {
  40023. this.strategies = strategies;
  40024. this.loop = Boolean(options.loop);
  40025. this.failFast = Boolean(options.failFast);
  40026. this.timeout = options.timeout;
  40027. this.timeoutLimit = options.timeoutLimit;
  40028. }
  40029. SequentialStrategy.prototype.isSupported = function () {
  40030. return any(this.strategies, util.method("isSupported"));
  40031. };
  40032. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40033. var _this = this;
  40034. var strategies = this.strategies;
  40035. var current = 0;
  40036. var timeout = this.timeout;
  40037. var runner = null;
  40038. var tryNextStrategy = function (error, handshake) {
  40039. if (handshake) {
  40040. callback(null, handshake);
  40041. }
  40042. else {
  40043. current = current + 1;
  40044. if (_this.loop) {
  40045. current = current % strategies.length;
  40046. }
  40047. if (current < strategies.length) {
  40048. if (timeout) {
  40049. timeout = timeout * 2;
  40050. if (_this.timeoutLimit) {
  40051. timeout = Math.min(timeout, _this.timeoutLimit);
  40052. }
  40053. }
  40054. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40055. }
  40056. else {
  40057. callback(true);
  40058. }
  40059. }
  40060. };
  40061. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40062. return {
  40063. abort: function () {
  40064. runner.abort();
  40065. },
  40066. forceMinPriority: function (p) {
  40067. minPriority = p;
  40068. if (runner) {
  40069. runner.forceMinPriority(p);
  40070. }
  40071. }
  40072. };
  40073. };
  40074. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40075. var timer = null;
  40076. var runner = null;
  40077. if (options.timeout > 0) {
  40078. timer = new OneOffTimer(options.timeout, function () {
  40079. runner.abort();
  40080. callback(true);
  40081. });
  40082. }
  40083. runner = strategy.connect(minPriority, function (error, handshake) {
  40084. if (error && timer && timer.isRunning() && !options.failFast) {
  40085. return;
  40086. }
  40087. if (timer) {
  40088. timer.ensureAborted();
  40089. }
  40090. callback(error, handshake);
  40091. });
  40092. return {
  40093. abort: function () {
  40094. if (timer) {
  40095. timer.ensureAborted();
  40096. }
  40097. runner.abort();
  40098. },
  40099. forceMinPriority: function (p) {
  40100. runner.forceMinPriority(p);
  40101. }
  40102. };
  40103. };
  40104. return SequentialStrategy;
  40105. }());
  40106. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40107. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40108. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40109. function BestConnectedEverStrategy(strategies) {
  40110. this.strategies = strategies;
  40111. }
  40112. BestConnectedEverStrategy.prototype.isSupported = function () {
  40113. return any(this.strategies, util.method("isSupported"));
  40114. };
  40115. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40116. return connect(this.strategies, minPriority, function (i, runners) {
  40117. return function (error, handshake) {
  40118. runners[i].error = error;
  40119. if (error) {
  40120. if (allRunnersFailed(runners)) {
  40121. callback(true);
  40122. }
  40123. return;
  40124. }
  40125. apply(runners, function (runner) {
  40126. runner.forceMinPriority(handshake.transport.priority);
  40127. });
  40128. callback(null, handshake);
  40129. };
  40130. });
  40131. };
  40132. return BestConnectedEverStrategy;
  40133. }());
  40134. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40135. function connect(strategies, minPriority, callbackBuilder) {
  40136. var runners = map(strategies, function (strategy, i, _, rs) {
  40137. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40138. });
  40139. return {
  40140. abort: function () {
  40141. apply(runners, abortRunner);
  40142. },
  40143. forceMinPriority: function (p) {
  40144. apply(runners, function (runner) {
  40145. runner.forceMinPriority(p);
  40146. });
  40147. }
  40148. };
  40149. }
  40150. function allRunnersFailed(runners) {
  40151. return collections_all(runners, function (runner) {
  40152. return Boolean(runner.error);
  40153. });
  40154. }
  40155. function abortRunner(runner) {
  40156. if (!runner.error && !runner.aborted) {
  40157. runner.abort();
  40158. runner.aborted = true;
  40159. }
  40160. }
  40161. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40162. var cached_strategy_CachedStrategy = (function () {
  40163. function CachedStrategy(strategy, transports, options) {
  40164. this.strategy = strategy;
  40165. this.transports = transports;
  40166. this.ttl = options.ttl || 1800 * 1000;
  40167. this.usingTLS = options.useTLS;
  40168. this.timeline = options.timeline;
  40169. }
  40170. CachedStrategy.prototype.isSupported = function () {
  40171. return this.strategy.isSupported();
  40172. };
  40173. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40174. var usingTLS = this.usingTLS;
  40175. var info = fetchTransportCache(usingTLS);
  40176. var strategies = [this.strategy];
  40177. if (info && info.timestamp + this.ttl >= util.now()) {
  40178. var transport = this.transports[info.transport];
  40179. if (transport) {
  40180. this.timeline.info({
  40181. cached: true,
  40182. transport: info.transport,
  40183. latency: info.latency
  40184. });
  40185. strategies.push(new sequential_strategy([transport], {
  40186. timeout: info.latency * 2 + 1000,
  40187. failFast: true
  40188. }));
  40189. }
  40190. }
  40191. var startTimestamp = util.now();
  40192. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40193. if (error) {
  40194. flushTransportCache(usingTLS);
  40195. if (strategies.length > 0) {
  40196. startTimestamp = util.now();
  40197. runner = strategies.pop().connect(minPriority, cb);
  40198. }
  40199. else {
  40200. callback(error);
  40201. }
  40202. }
  40203. else {
  40204. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40205. callback(null, handshake);
  40206. }
  40207. });
  40208. return {
  40209. abort: function () {
  40210. runner.abort();
  40211. },
  40212. forceMinPriority: function (p) {
  40213. minPriority = p;
  40214. if (runner) {
  40215. runner.forceMinPriority(p);
  40216. }
  40217. }
  40218. };
  40219. };
  40220. return CachedStrategy;
  40221. }());
  40222. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40223. function getTransportCacheKey(usingTLS) {
  40224. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40225. }
  40226. function fetchTransportCache(usingTLS) {
  40227. var storage = runtime.getLocalStorage();
  40228. if (storage) {
  40229. try {
  40230. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40231. if (serializedCache) {
  40232. return JSON.parse(serializedCache);
  40233. }
  40234. }
  40235. catch (e) {
  40236. flushTransportCache(usingTLS);
  40237. }
  40238. }
  40239. return null;
  40240. }
  40241. function storeTransportCache(usingTLS, transport, latency) {
  40242. var storage = runtime.getLocalStorage();
  40243. if (storage) {
  40244. try {
  40245. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40246. timestamp: util.now(),
  40247. transport: transport,
  40248. latency: latency
  40249. });
  40250. }
  40251. catch (e) {
  40252. }
  40253. }
  40254. }
  40255. function flushTransportCache(usingTLS) {
  40256. var storage = runtime.getLocalStorage();
  40257. if (storage) {
  40258. try {
  40259. delete storage[getTransportCacheKey(usingTLS)];
  40260. }
  40261. catch (e) {
  40262. }
  40263. }
  40264. }
  40265. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40266. var delayed_strategy_DelayedStrategy = (function () {
  40267. function DelayedStrategy(strategy, _a) {
  40268. var number = _a.delay;
  40269. this.strategy = strategy;
  40270. this.options = { delay: number };
  40271. }
  40272. DelayedStrategy.prototype.isSupported = function () {
  40273. return this.strategy.isSupported();
  40274. };
  40275. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40276. var strategy = this.strategy;
  40277. var runner;
  40278. var timer = new OneOffTimer(this.options.delay, function () {
  40279. runner = strategy.connect(minPriority, callback);
  40280. });
  40281. return {
  40282. abort: function () {
  40283. timer.ensureAborted();
  40284. if (runner) {
  40285. runner.abort();
  40286. }
  40287. },
  40288. forceMinPriority: function (p) {
  40289. minPriority = p;
  40290. if (runner) {
  40291. runner.forceMinPriority(p);
  40292. }
  40293. }
  40294. };
  40295. };
  40296. return DelayedStrategy;
  40297. }());
  40298. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40299. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40300. var IfStrategy = (function () {
  40301. function IfStrategy(test, trueBranch, falseBranch) {
  40302. this.test = test;
  40303. this.trueBranch = trueBranch;
  40304. this.falseBranch = falseBranch;
  40305. }
  40306. IfStrategy.prototype.isSupported = function () {
  40307. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40308. return branch.isSupported();
  40309. };
  40310. IfStrategy.prototype.connect = function (minPriority, callback) {
  40311. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40312. return branch.connect(minPriority, callback);
  40313. };
  40314. return IfStrategy;
  40315. }());
  40316. /* harmony default export */ var if_strategy = (IfStrategy);
  40317. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40318. var FirstConnectedStrategy = (function () {
  40319. function FirstConnectedStrategy(strategy) {
  40320. this.strategy = strategy;
  40321. }
  40322. FirstConnectedStrategy.prototype.isSupported = function () {
  40323. return this.strategy.isSupported();
  40324. };
  40325. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40326. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40327. if (handshake) {
  40328. runner.abort();
  40329. }
  40330. callback(error, handshake);
  40331. });
  40332. return runner;
  40333. };
  40334. return FirstConnectedStrategy;
  40335. }());
  40336. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40337. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40338. function testSupportsStrategy(strategy) {
  40339. return function () {
  40340. return strategy.isSupported();
  40341. };
  40342. }
  40343. var getDefaultStrategy = function (config, defineTransport) {
  40344. var definedTransports = {};
  40345. function defineTransportStrategy(name, type, priority, options, manager) {
  40346. var transport = defineTransport(config, name, type, priority, options, manager);
  40347. definedTransports[name] = transport;
  40348. return transport;
  40349. }
  40350. var ws_options = {
  40351. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40352. hostTLS: config.wsHost + ":" + config.wssPort,
  40353. httpPath: config.wsPath
  40354. };
  40355. var wss_options = extend({}, ws_options, {
  40356. useTLS: true
  40357. });
  40358. var sockjs_options = {
  40359. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40360. hostTLS: config.httpHost + ":" + config.httpsPort,
  40361. httpPath: config.httpPath
  40362. };
  40363. var timeouts = {
  40364. loop: true,
  40365. timeout: 15000,
  40366. timeoutLimit: 60000
  40367. };
  40368. var ws_manager = new transport_manager({
  40369. lives: 2,
  40370. minPingDelay: 10000,
  40371. maxPingDelay: config.activity_timeout
  40372. });
  40373. var streaming_manager = new transport_manager({
  40374. lives: 2,
  40375. minPingDelay: 10000,
  40376. maxPingDelay: config.activity_timeout
  40377. });
  40378. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40379. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40380. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40381. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40382. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40383. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40384. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40385. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40386. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40387. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40388. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40389. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40390. 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);
  40391. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40392. var wsStrategy;
  40393. if (config.useTLS) {
  40394. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40395. }
  40396. else {
  40397. wsStrategy = new best_connected_ever_strategy([
  40398. ws_loop,
  40399. new delayed_strategy(wss_loop, { delay: 2000 }),
  40400. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40401. ]);
  40402. }
  40403. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40404. ttl: 1800000,
  40405. timeline: config.timeline,
  40406. useTLS: config.useTLS
  40407. });
  40408. };
  40409. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40410. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40411. /* harmony default export */ var transport_connection_initializer = (function () {
  40412. var self = this;
  40413. self.timeline.info(self.buildTimelineMessage({
  40414. transport: self.name + (self.options.useTLS ? "s" : "")
  40415. }));
  40416. if (self.hooks.isInitialized()) {
  40417. self.changeState("initialized");
  40418. }
  40419. else if (self.hooks.file) {
  40420. self.changeState("initializing");
  40421. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40422. if (self.hooks.isInitialized()) {
  40423. self.changeState("initialized");
  40424. callback(true);
  40425. }
  40426. else {
  40427. if (error) {
  40428. self.onError(error);
  40429. }
  40430. self.onClose();
  40431. callback(false);
  40432. }
  40433. });
  40434. }
  40435. else {
  40436. self.onClose();
  40437. }
  40438. });
  40439. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40440. var http_xdomain_request_hooks = {
  40441. getRequest: function (socket) {
  40442. var xdr = new window.XDomainRequest();
  40443. xdr.ontimeout = function () {
  40444. socket.emit("error", new RequestTimedOut());
  40445. socket.close();
  40446. };
  40447. xdr.onerror = function (e) {
  40448. socket.emit("error", e);
  40449. socket.close();
  40450. };
  40451. xdr.onprogress = function () {
  40452. if (xdr.responseText && xdr.responseText.length > 0) {
  40453. socket.onChunk(200, xdr.responseText);
  40454. }
  40455. };
  40456. xdr.onload = function () {
  40457. if (xdr.responseText && xdr.responseText.length > 0) {
  40458. socket.onChunk(200, xdr.responseText);
  40459. }
  40460. socket.emit("finished", 200);
  40461. socket.close();
  40462. };
  40463. return xdr;
  40464. },
  40465. abortRequest: function (xdr) {
  40466. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40467. xdr.abort();
  40468. }
  40469. };
  40470. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40471. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40472. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40473. var extendStatics = function (d, b) {
  40474. extendStatics = Object.setPrototypeOf ||
  40475. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40476. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40477. return extendStatics(d, b);
  40478. };
  40479. return function (d, b) {
  40480. extendStatics(d, b);
  40481. function __() { this.constructor = d; }
  40482. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40483. };
  40484. })();
  40485. var MAX_BUFFER_LENGTH = 256 * 1024;
  40486. var http_request_HTTPRequest = (function (_super) {
  40487. http_request_extends(HTTPRequest, _super);
  40488. function HTTPRequest(hooks, method, url) {
  40489. var _this = _super.call(this) || this;
  40490. _this.hooks = hooks;
  40491. _this.method = method;
  40492. _this.url = url;
  40493. return _this;
  40494. }
  40495. HTTPRequest.prototype.start = function (payload) {
  40496. var _this = this;
  40497. this.position = 0;
  40498. this.xhr = this.hooks.getRequest(this);
  40499. this.unloader = function () {
  40500. _this.close();
  40501. };
  40502. runtime.addUnloadListener(this.unloader);
  40503. this.xhr.open(this.method, this.url, true);
  40504. if (this.xhr.setRequestHeader) {
  40505. this.xhr.setRequestHeader("Content-Type", "application/json");
  40506. }
  40507. this.xhr.send(payload);
  40508. };
  40509. HTTPRequest.prototype.close = function () {
  40510. if (this.unloader) {
  40511. runtime.removeUnloadListener(this.unloader);
  40512. this.unloader = null;
  40513. }
  40514. if (this.xhr) {
  40515. this.hooks.abortRequest(this.xhr);
  40516. this.xhr = null;
  40517. }
  40518. };
  40519. HTTPRequest.prototype.onChunk = function (status, data) {
  40520. while (true) {
  40521. var chunk = this.advanceBuffer(data);
  40522. if (chunk) {
  40523. this.emit("chunk", { status: status, data: chunk });
  40524. }
  40525. else {
  40526. break;
  40527. }
  40528. }
  40529. if (this.isBufferTooLong(data)) {
  40530. this.emit("buffer_too_long");
  40531. }
  40532. };
  40533. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40534. var unreadData = buffer.slice(this.position);
  40535. var endOfLinePosition = unreadData.indexOf("\n");
  40536. if (endOfLinePosition !== -1) {
  40537. this.position += endOfLinePosition + 1;
  40538. return unreadData.slice(0, endOfLinePosition);
  40539. }
  40540. else {
  40541. return null;
  40542. }
  40543. };
  40544. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40545. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40546. };
  40547. return HTTPRequest;
  40548. }(dispatcher));
  40549. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40550. // CONCATENATED MODULE: ./src/core/http/state.ts
  40551. var State;
  40552. (function (State) {
  40553. State[State["CONNECTING"] = 0] = "CONNECTING";
  40554. State[State["OPEN"] = 1] = "OPEN";
  40555. State[State["CLOSED"] = 3] = "CLOSED";
  40556. })(State || (State = {}));
  40557. /* harmony default export */ var state = (State);
  40558. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40559. var autoIncrement = 1;
  40560. var http_socket_HTTPSocket = (function () {
  40561. function HTTPSocket(hooks, url) {
  40562. this.hooks = hooks;
  40563. this.session = randomNumber(1000) + "/" + randomString(8);
  40564. this.location = getLocation(url);
  40565. this.readyState = state.CONNECTING;
  40566. this.openStream();
  40567. }
  40568. HTTPSocket.prototype.send = function (payload) {
  40569. return this.sendRaw(JSON.stringify([payload]));
  40570. };
  40571. HTTPSocket.prototype.ping = function () {
  40572. this.hooks.sendHeartbeat(this);
  40573. };
  40574. HTTPSocket.prototype.close = function (code, reason) {
  40575. this.onClose(code, reason, true);
  40576. };
  40577. HTTPSocket.prototype.sendRaw = function (payload) {
  40578. if (this.readyState === state.OPEN) {
  40579. try {
  40580. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40581. return true;
  40582. }
  40583. catch (e) {
  40584. return false;
  40585. }
  40586. }
  40587. else {
  40588. return false;
  40589. }
  40590. };
  40591. HTTPSocket.prototype.reconnect = function () {
  40592. this.closeStream();
  40593. this.openStream();
  40594. };
  40595. ;
  40596. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40597. this.closeStream();
  40598. this.readyState = state.CLOSED;
  40599. if (this.onclose) {
  40600. this.onclose({
  40601. code: code,
  40602. reason: reason,
  40603. wasClean: wasClean
  40604. });
  40605. }
  40606. };
  40607. HTTPSocket.prototype.onChunk = function (chunk) {
  40608. if (chunk.status !== 200) {
  40609. return;
  40610. }
  40611. if (this.readyState === state.OPEN) {
  40612. this.onActivity();
  40613. }
  40614. var payload;
  40615. var type = chunk.data.slice(0, 1);
  40616. switch (type) {
  40617. case 'o':
  40618. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40619. this.onOpen(payload);
  40620. break;
  40621. case 'a':
  40622. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40623. for (var i = 0; i < payload.length; i++) {
  40624. this.onEvent(payload[i]);
  40625. }
  40626. break;
  40627. case 'm':
  40628. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40629. this.onEvent(payload);
  40630. break;
  40631. case 'h':
  40632. this.hooks.onHeartbeat(this);
  40633. break;
  40634. case 'c':
  40635. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40636. this.onClose(payload[0], payload[1], true);
  40637. break;
  40638. }
  40639. };
  40640. HTTPSocket.prototype.onOpen = function (options) {
  40641. if (this.readyState === state.CONNECTING) {
  40642. if (options && options.hostname) {
  40643. this.location.base = replaceHost(this.location.base, options.hostname);
  40644. }
  40645. this.readyState = state.OPEN;
  40646. if (this.onopen) {
  40647. this.onopen();
  40648. }
  40649. }
  40650. else {
  40651. this.onClose(1006, "Server lost session", true);
  40652. }
  40653. };
  40654. HTTPSocket.prototype.onEvent = function (event) {
  40655. if (this.readyState === state.OPEN && this.onmessage) {
  40656. this.onmessage({ data: event });
  40657. }
  40658. };
  40659. HTTPSocket.prototype.onActivity = function () {
  40660. if (this.onactivity) {
  40661. this.onactivity();
  40662. }
  40663. };
  40664. HTTPSocket.prototype.onError = function (error) {
  40665. if (this.onerror) {
  40666. this.onerror(error);
  40667. }
  40668. };
  40669. HTTPSocket.prototype.openStream = function () {
  40670. var _this = this;
  40671. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40672. this.stream.bind("chunk", function (chunk) {
  40673. _this.onChunk(chunk);
  40674. });
  40675. this.stream.bind("finished", function (status) {
  40676. _this.hooks.onFinished(_this, status);
  40677. });
  40678. this.stream.bind("buffer_too_long", function () {
  40679. _this.reconnect();
  40680. });
  40681. try {
  40682. this.stream.start();
  40683. }
  40684. catch (error) {
  40685. util.defer(function () {
  40686. _this.onError(error);
  40687. _this.onClose(1006, "Could not start streaming", false);
  40688. });
  40689. }
  40690. };
  40691. HTTPSocket.prototype.closeStream = function () {
  40692. if (this.stream) {
  40693. this.stream.unbind_all();
  40694. this.stream.close();
  40695. this.stream = null;
  40696. }
  40697. };
  40698. return HTTPSocket;
  40699. }());
  40700. function getLocation(url) {
  40701. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40702. return {
  40703. base: parts[1],
  40704. queryString: parts[2]
  40705. };
  40706. }
  40707. function getSendURL(url, session) {
  40708. return url.base + "/" + session + "/xhr_send";
  40709. }
  40710. function getUniqueURL(url) {
  40711. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40712. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40713. }
  40714. function replaceHost(url, hostname) {
  40715. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40716. return urlParts[1] + hostname + urlParts[3];
  40717. }
  40718. function randomNumber(max) {
  40719. return Math.floor(Math.random() * max);
  40720. }
  40721. function randomString(length) {
  40722. var result = [];
  40723. for (var i = 0; i < length; i++) {
  40724. result.push(randomNumber(32).toString(32));
  40725. }
  40726. return result.join('');
  40727. }
  40728. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40729. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40730. var http_streaming_socket_hooks = {
  40731. getReceiveURL: function (url, session) {
  40732. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40733. },
  40734. onHeartbeat: function (socket) {
  40735. socket.sendRaw("[]");
  40736. },
  40737. sendHeartbeat: function (socket) {
  40738. socket.sendRaw("[]");
  40739. },
  40740. onFinished: function (socket, status) {
  40741. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40742. }
  40743. };
  40744. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40745. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40746. var http_polling_socket_hooks = {
  40747. getReceiveURL: function (url, session) {
  40748. return url.base + "/" + session + "/xhr" + url.queryString;
  40749. },
  40750. onHeartbeat: function () {
  40751. },
  40752. sendHeartbeat: function (socket) {
  40753. socket.sendRaw("[]");
  40754. },
  40755. onFinished: function (socket, status) {
  40756. if (status === 200) {
  40757. socket.reconnect();
  40758. }
  40759. else {
  40760. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40761. }
  40762. }
  40763. };
  40764. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40765. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40766. var http_xhr_request_hooks = {
  40767. getRequest: function (socket) {
  40768. var Constructor = runtime.getXHRAPI();
  40769. var xhr = new Constructor();
  40770. xhr.onreadystatechange = xhr.onprogress = function () {
  40771. switch (xhr.readyState) {
  40772. case 3:
  40773. if (xhr.responseText && xhr.responseText.length > 0) {
  40774. socket.onChunk(xhr.status, xhr.responseText);
  40775. }
  40776. break;
  40777. case 4:
  40778. if (xhr.responseText && xhr.responseText.length > 0) {
  40779. socket.onChunk(xhr.status, xhr.responseText);
  40780. }
  40781. socket.emit("finished", xhr.status);
  40782. socket.close();
  40783. break;
  40784. }
  40785. };
  40786. return xhr;
  40787. },
  40788. abortRequest: function (xhr) {
  40789. xhr.onreadystatechange = null;
  40790. xhr.abort();
  40791. }
  40792. };
  40793. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40794. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40795. var HTTP = {
  40796. createStreamingSocket: function (url) {
  40797. return this.createSocket(http_streaming_socket, url);
  40798. },
  40799. createPollingSocket: function (url) {
  40800. return this.createSocket(http_polling_socket, url);
  40801. },
  40802. createSocket: function (hooks, url) {
  40803. return new http_socket(hooks, url);
  40804. },
  40805. createXHR: function (method, url) {
  40806. return this.createRequest(http_xhr_request, method, url);
  40807. },
  40808. createRequest: function (hooks, method, url) {
  40809. return new http_request(hooks, method, url);
  40810. }
  40811. };
  40812. /* harmony default export */ var http_http = (HTTP);
  40813. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40814. http_http.createXDR = function (method, url) {
  40815. return this.createRequest(http_xdomain_request, method, url);
  40816. };
  40817. /* harmony default export */ var web_http_http = (http_http);
  40818. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40819. var Runtime = {
  40820. nextAuthCallbackID: 1,
  40821. auth_callbacks: {},
  40822. ScriptReceivers: ScriptReceivers,
  40823. DependenciesReceivers: DependenciesReceivers,
  40824. getDefaultStrategy: default_strategy,
  40825. Transports: transports_transports,
  40826. transportConnectionInitializer: transport_connection_initializer,
  40827. HTTPFactory: web_http_http,
  40828. TimelineTransport: jsonp_timeline,
  40829. getXHRAPI: function () {
  40830. return window.XMLHttpRequest;
  40831. },
  40832. getWebSocketAPI: function () {
  40833. return window.WebSocket || window.MozWebSocket;
  40834. },
  40835. setup: function (PusherClass) {
  40836. var _this = this;
  40837. window.Pusher = PusherClass;
  40838. var initializeOnDocumentBody = function () {
  40839. _this.onDocumentBody(PusherClass.ready);
  40840. };
  40841. if (!window.JSON) {
  40842. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40843. }
  40844. else {
  40845. initializeOnDocumentBody();
  40846. }
  40847. },
  40848. getDocument: function () {
  40849. return document;
  40850. },
  40851. getProtocol: function () {
  40852. return this.getDocument().location.protocol;
  40853. },
  40854. getAuthorizers: function () {
  40855. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40856. },
  40857. onDocumentBody: function (callback) {
  40858. var _this = this;
  40859. if (document.body) {
  40860. callback();
  40861. }
  40862. else {
  40863. setTimeout(function () {
  40864. _this.onDocumentBody(callback);
  40865. }, 0);
  40866. }
  40867. },
  40868. createJSONPRequest: function (url, data) {
  40869. return new jsonp_request(url, data);
  40870. },
  40871. createScriptRequest: function (src) {
  40872. return new script_request(src);
  40873. },
  40874. getLocalStorage: function () {
  40875. try {
  40876. return window.localStorage;
  40877. }
  40878. catch (e) {
  40879. return undefined;
  40880. }
  40881. },
  40882. createXHR: function () {
  40883. if (this.getXHRAPI()) {
  40884. return this.createXMLHttpRequest();
  40885. }
  40886. else {
  40887. return this.createMicrosoftXHR();
  40888. }
  40889. },
  40890. createXMLHttpRequest: function () {
  40891. var Constructor = this.getXHRAPI();
  40892. return new Constructor();
  40893. },
  40894. createMicrosoftXHR: function () {
  40895. return new ActiveXObject("Microsoft.XMLHTTP");
  40896. },
  40897. getNetwork: function () {
  40898. return net_info_Network;
  40899. },
  40900. createWebSocket: function (url) {
  40901. var Constructor = this.getWebSocketAPI();
  40902. return new Constructor(url);
  40903. },
  40904. createSocketRequest: function (method, url) {
  40905. if (this.isXHRSupported()) {
  40906. return this.HTTPFactory.createXHR(method, url);
  40907. }
  40908. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40909. return this.HTTPFactory.createXDR(method, url);
  40910. }
  40911. else {
  40912. throw "Cross-origin HTTP requests are not supported";
  40913. }
  40914. },
  40915. isXHRSupported: function () {
  40916. var Constructor = this.getXHRAPI();
  40917. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40918. },
  40919. isXDRSupported: function (useTLS) {
  40920. var protocol = useTLS ? "https:" : "http:";
  40921. var documentProtocol = this.getProtocol();
  40922. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40923. },
  40924. addUnloadListener: function (listener) {
  40925. if (window.addEventListener !== undefined) {
  40926. window.addEventListener("unload", listener, false);
  40927. }
  40928. else if (window.attachEvent !== undefined) {
  40929. window.attachEvent("onunload", listener);
  40930. }
  40931. },
  40932. removeUnloadListener: function (listener) {
  40933. if (window.addEventListener !== undefined) {
  40934. window.removeEventListener("unload", listener, false);
  40935. }
  40936. else if (window.detachEvent !== undefined) {
  40937. window.detachEvent("onunload", listener);
  40938. }
  40939. }
  40940. };
  40941. /* harmony default export */ var runtime = (Runtime);
  40942. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40943. var TimelineLevel;
  40944. (function (TimelineLevel) {
  40945. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40946. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40947. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40948. })(TimelineLevel || (TimelineLevel = {}));
  40949. /* harmony default export */ var timeline_level = (TimelineLevel);
  40950. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40951. var timeline_Timeline = (function () {
  40952. function Timeline(key, session, options) {
  40953. this.key = key;
  40954. this.session = session;
  40955. this.events = [];
  40956. this.options = options || {};
  40957. this.sent = 0;
  40958. this.uniqueID = 0;
  40959. }
  40960. Timeline.prototype.log = function (level, event) {
  40961. if (level <= this.options.level) {
  40962. this.events.push(extend({}, event, { timestamp: util.now() }));
  40963. if (this.options.limit && this.events.length > this.options.limit) {
  40964. this.events.shift();
  40965. }
  40966. }
  40967. };
  40968. Timeline.prototype.error = function (event) {
  40969. this.log(timeline_level.ERROR, event);
  40970. };
  40971. Timeline.prototype.info = function (event) {
  40972. this.log(timeline_level.INFO, event);
  40973. };
  40974. Timeline.prototype.debug = function (event) {
  40975. this.log(timeline_level.DEBUG, event);
  40976. };
  40977. Timeline.prototype.isEmpty = function () {
  40978. return this.events.length === 0;
  40979. };
  40980. Timeline.prototype.send = function (sendfn, callback) {
  40981. var _this = this;
  40982. var data = extend({
  40983. session: this.session,
  40984. bundle: this.sent + 1,
  40985. key: this.key,
  40986. lib: "js",
  40987. version: this.options.version,
  40988. cluster: this.options.cluster,
  40989. features: this.options.features,
  40990. timeline: this.events
  40991. }, this.options.params);
  40992. this.events = [];
  40993. sendfn(data, function (error, result) {
  40994. if (!error) {
  40995. _this.sent++;
  40996. }
  40997. if (callback) {
  40998. callback(error, result);
  40999. }
  41000. });
  41001. return true;
  41002. };
  41003. Timeline.prototype.generateUniqueID = function () {
  41004. this.uniqueID++;
  41005. return this.uniqueID;
  41006. };
  41007. return Timeline;
  41008. }());
  41009. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41010. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41011. var transport_strategy_TransportStrategy = (function () {
  41012. function TransportStrategy(name, priority, transport, options) {
  41013. this.name = name;
  41014. this.priority = priority;
  41015. this.transport = transport;
  41016. this.options = options || {};
  41017. }
  41018. TransportStrategy.prototype.isSupported = function () {
  41019. return this.transport.isSupported({
  41020. useTLS: this.options.useTLS
  41021. });
  41022. };
  41023. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41024. var _this = this;
  41025. if (!this.isSupported()) {
  41026. return failAttempt(new UnsupportedStrategy(), callback);
  41027. }
  41028. else if (this.priority < minPriority) {
  41029. return failAttempt(new TransportPriorityTooLow(), callback);
  41030. }
  41031. var connected = false;
  41032. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41033. var handshake = null;
  41034. var onInitialized = function () {
  41035. transport.unbind("initialized", onInitialized);
  41036. transport.connect();
  41037. };
  41038. var onOpen = function () {
  41039. handshake = factory.createHandshake(transport, function (result) {
  41040. connected = true;
  41041. unbindListeners();
  41042. callback(null, result);
  41043. });
  41044. };
  41045. var onError = function (error) {
  41046. unbindListeners();
  41047. callback(error);
  41048. };
  41049. var onClosed = function () {
  41050. unbindListeners();
  41051. var serializedTransport;
  41052. serializedTransport = safeJSONStringify(transport);
  41053. callback(new TransportClosed(serializedTransport));
  41054. };
  41055. var unbindListeners = function () {
  41056. transport.unbind("initialized", onInitialized);
  41057. transport.unbind("open", onOpen);
  41058. transport.unbind("error", onError);
  41059. transport.unbind("closed", onClosed);
  41060. };
  41061. transport.bind("initialized", onInitialized);
  41062. transport.bind("open", onOpen);
  41063. transport.bind("error", onError);
  41064. transport.bind("closed", onClosed);
  41065. transport.initialize();
  41066. return {
  41067. abort: function () {
  41068. if (connected) {
  41069. return;
  41070. }
  41071. unbindListeners();
  41072. if (handshake) {
  41073. handshake.close();
  41074. }
  41075. else {
  41076. transport.close();
  41077. }
  41078. },
  41079. forceMinPriority: function (p) {
  41080. if (connected) {
  41081. return;
  41082. }
  41083. if (_this.priority < p) {
  41084. if (handshake) {
  41085. handshake.close();
  41086. }
  41087. else {
  41088. transport.close();
  41089. }
  41090. }
  41091. }
  41092. };
  41093. };
  41094. return TransportStrategy;
  41095. }());
  41096. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41097. function failAttempt(error, callback) {
  41098. util.defer(function () {
  41099. callback(error);
  41100. });
  41101. return {
  41102. abort: function () { },
  41103. forceMinPriority: function () { }
  41104. };
  41105. }
  41106. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41107. var strategy_builder_Transports = runtime.Transports;
  41108. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41109. var transportClass = strategy_builder_Transports[type];
  41110. if (!transportClass) {
  41111. throw new UnsupportedTransport(type);
  41112. }
  41113. var enabled = (!config.enabledTransports ||
  41114. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41115. (!config.disabledTransports ||
  41116. arrayIndexOf(config.disabledTransports, name) === -1);
  41117. var transport;
  41118. if (enabled) {
  41119. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41120. key: config.key,
  41121. useTLS: config.useTLS,
  41122. timeline: config.timeline,
  41123. ignoreNullOrigin: config.ignoreNullOrigin
  41124. }, options));
  41125. }
  41126. else {
  41127. transport = strategy_builder_UnsupportedStrategy;
  41128. }
  41129. return transport;
  41130. };
  41131. var strategy_builder_UnsupportedStrategy = {
  41132. isSupported: function () {
  41133. return false;
  41134. },
  41135. connect: function (_, callback) {
  41136. var deferred = util.defer(function () {
  41137. callback(new UnsupportedStrategy());
  41138. });
  41139. return {
  41140. abort: function () {
  41141. deferred.ensureAborted();
  41142. },
  41143. forceMinPriority: function () { }
  41144. };
  41145. }
  41146. };
  41147. // CONCATENATED MODULE: ./src/core/config.ts
  41148. var getGlobalConfig = function () {
  41149. return {
  41150. wsHost: defaults.host,
  41151. wsPort: defaults.ws_port,
  41152. wssPort: defaults.wss_port,
  41153. wsPath: defaults.ws_path,
  41154. httpHost: defaults.sockjs_host,
  41155. httpPort: defaults.sockjs_http_port,
  41156. httpsPort: defaults.sockjs_https_port,
  41157. httpPath: defaults.sockjs_path,
  41158. statsHost: defaults.stats_host,
  41159. authEndpoint: defaults.channel_auth_endpoint,
  41160. authTransport: defaults.channel_auth_transport,
  41161. activity_timeout: defaults.activity_timeout,
  41162. pong_timeout: defaults.pong_timeout,
  41163. unavailable_timeout: defaults.unavailable_timeout
  41164. };
  41165. };
  41166. var getClusterConfig = function (clusterName) {
  41167. return {
  41168. wsHost: 'ws-' + clusterName + '.pusher.com',
  41169. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41170. };
  41171. };
  41172. // CONCATENATED MODULE: ./src/core/pusher.ts
  41173. var pusher_Pusher = (function () {
  41174. function Pusher(app_key, options) {
  41175. var _this = this;
  41176. checkAppKey(app_key);
  41177. options = options || {};
  41178. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41179. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41180. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41181. }
  41182. this.key = app_key;
  41183. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41184. this.channels = factory.createChannels();
  41185. this.global_emitter = new dispatcher();
  41186. this.sessionID = Math.floor(Math.random() * 1000000000);
  41187. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41188. cluster: this.config.cluster,
  41189. features: Pusher.getClientFeatures(),
  41190. params: this.config.timelineParams || {},
  41191. limit: 50,
  41192. level: timeline_level.INFO,
  41193. version: defaults.VERSION
  41194. });
  41195. if (!this.config.disableStats) {
  41196. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41197. host: this.config.statsHost,
  41198. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41199. });
  41200. }
  41201. var getStrategy = function (options) {
  41202. var config = extend({}, _this.config, options);
  41203. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41204. };
  41205. this.connection = factory.createConnectionManager(this.key, extend({
  41206. getStrategy: getStrategy,
  41207. timeline: this.timeline,
  41208. activityTimeout: this.config.activity_timeout,
  41209. pongTimeout: this.config.pong_timeout,
  41210. unavailableTimeout: this.config.unavailable_timeout
  41211. }, this.config, { useTLS: this.shouldUseTLS() }));
  41212. this.connection.bind('connected', function () {
  41213. _this.subscribeAll();
  41214. if (_this.timelineSender) {
  41215. _this.timelineSender.send(_this.connection.isUsingTLS());
  41216. }
  41217. });
  41218. this.connection.bind('message', function (event) {
  41219. var eventName = event.event;
  41220. var internal = eventName.indexOf('pusher_internal:') === 0;
  41221. if (event.channel) {
  41222. var channel = _this.channel(event.channel);
  41223. if (channel) {
  41224. channel.handleEvent(event);
  41225. }
  41226. }
  41227. if (!internal) {
  41228. _this.global_emitter.emit(event.event, event.data);
  41229. }
  41230. });
  41231. this.connection.bind('connecting', function () {
  41232. _this.channels.disconnect();
  41233. });
  41234. this.connection.bind('disconnected', function () {
  41235. _this.channels.disconnect();
  41236. });
  41237. this.connection.bind('error', function (err) {
  41238. logger.warn(err);
  41239. });
  41240. Pusher.instances.push(this);
  41241. this.timeline.info({ instances: Pusher.instances.length });
  41242. if (Pusher.isReady) {
  41243. this.connect();
  41244. }
  41245. }
  41246. Pusher.ready = function () {
  41247. Pusher.isReady = true;
  41248. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41249. Pusher.instances[i].connect();
  41250. }
  41251. };
  41252. Pusher.getClientFeatures = function () {
  41253. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41254. return t.isSupported({});
  41255. }));
  41256. };
  41257. Pusher.prototype.channel = function (name) {
  41258. return this.channels.find(name);
  41259. };
  41260. Pusher.prototype.allChannels = function () {
  41261. return this.channels.all();
  41262. };
  41263. Pusher.prototype.connect = function () {
  41264. this.connection.connect();
  41265. if (this.timelineSender) {
  41266. if (!this.timelineSenderTimer) {
  41267. var usingTLS = this.connection.isUsingTLS();
  41268. var timelineSender = this.timelineSender;
  41269. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41270. timelineSender.send(usingTLS);
  41271. });
  41272. }
  41273. }
  41274. };
  41275. Pusher.prototype.disconnect = function () {
  41276. this.connection.disconnect();
  41277. if (this.timelineSenderTimer) {
  41278. this.timelineSenderTimer.ensureAborted();
  41279. this.timelineSenderTimer = null;
  41280. }
  41281. };
  41282. Pusher.prototype.bind = function (event_name, callback, context) {
  41283. this.global_emitter.bind(event_name, callback, context);
  41284. return this;
  41285. };
  41286. Pusher.prototype.unbind = function (event_name, callback, context) {
  41287. this.global_emitter.unbind(event_name, callback, context);
  41288. return this;
  41289. };
  41290. Pusher.prototype.bind_global = function (callback) {
  41291. this.global_emitter.bind_global(callback);
  41292. return this;
  41293. };
  41294. Pusher.prototype.unbind_global = function (callback) {
  41295. this.global_emitter.unbind_global(callback);
  41296. return this;
  41297. };
  41298. Pusher.prototype.unbind_all = function (callback) {
  41299. this.global_emitter.unbind_all();
  41300. return this;
  41301. };
  41302. Pusher.prototype.subscribeAll = function () {
  41303. var channelName;
  41304. for (channelName in this.channels.channels) {
  41305. if (this.channels.channels.hasOwnProperty(channelName)) {
  41306. this.subscribe(channelName);
  41307. }
  41308. }
  41309. };
  41310. Pusher.prototype.subscribe = function (channel_name) {
  41311. var channel = this.channels.add(channel_name, this);
  41312. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41313. channel.reinstateSubscription();
  41314. }
  41315. else if (!channel.subscriptionPending &&
  41316. this.connection.state === 'connected') {
  41317. channel.subscribe();
  41318. }
  41319. return channel;
  41320. };
  41321. Pusher.prototype.unsubscribe = function (channel_name) {
  41322. var channel = this.channels.find(channel_name);
  41323. if (channel && channel.subscriptionPending) {
  41324. channel.cancelSubscription();
  41325. }
  41326. else {
  41327. channel = this.channels.remove(channel_name);
  41328. if (channel && this.connection.state === 'connected') {
  41329. channel.unsubscribe();
  41330. }
  41331. }
  41332. };
  41333. Pusher.prototype.send_event = function (event_name, data, channel) {
  41334. return this.connection.send_event(event_name, data, channel);
  41335. };
  41336. Pusher.prototype.shouldUseTLS = function () {
  41337. if (runtime.getProtocol() === 'https:') {
  41338. return true;
  41339. }
  41340. else if (this.config.forceTLS === true) {
  41341. return true;
  41342. }
  41343. else {
  41344. return Boolean(this.config.encrypted);
  41345. }
  41346. };
  41347. Pusher.instances = [];
  41348. Pusher.isReady = false;
  41349. Pusher.logToConsole = false;
  41350. Pusher.Runtime = runtime;
  41351. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41352. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41353. Pusher.auth_callbacks = runtime.auth_callbacks;
  41354. return Pusher;
  41355. }());
  41356. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41357. function checkAppKey(key) {
  41358. if (key === null || key === undefined) {
  41359. throw 'You must pass your app key when you instantiate Pusher.';
  41360. }
  41361. }
  41362. runtime.setup(pusher_Pusher);
  41363. /***/ })
  41364. /******/ ]);
  41365. });
  41366. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41367. /***/ }),
  41368. /***/ "./node_modules/setimmediate/setImmediate.js":
  41369. /*!***************************************************!*\
  41370. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41371. \***************************************************/
  41372. /*! no static exports found */
  41373. /***/ (function(module, exports, __webpack_require__) {
  41374. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41375. "use strict";
  41376. if (global.setImmediate) {
  41377. return;
  41378. }
  41379. var nextHandle = 1; // Spec says greater than zero
  41380. var tasksByHandle = {};
  41381. var currentlyRunningATask = false;
  41382. var doc = global.document;
  41383. var registerImmediate;
  41384. function setImmediate(callback) {
  41385. // Callback can either be a function or a string
  41386. if (typeof callback !== "function") {
  41387. callback = new Function("" + callback);
  41388. }
  41389. // Copy function arguments
  41390. var args = new Array(arguments.length - 1);
  41391. for (var i = 0; i < args.length; i++) {
  41392. args[i] = arguments[i + 1];
  41393. }
  41394. // Store and register the task
  41395. var task = { callback: callback, args: args };
  41396. tasksByHandle[nextHandle] = task;
  41397. registerImmediate(nextHandle);
  41398. return nextHandle++;
  41399. }
  41400. function clearImmediate(handle) {
  41401. delete tasksByHandle[handle];
  41402. }
  41403. function run(task) {
  41404. var callback = task.callback;
  41405. var args = task.args;
  41406. switch (args.length) {
  41407. case 0:
  41408. callback();
  41409. break;
  41410. case 1:
  41411. callback(args[0]);
  41412. break;
  41413. case 2:
  41414. callback(args[0], args[1]);
  41415. break;
  41416. case 3:
  41417. callback(args[0], args[1], args[2]);
  41418. break;
  41419. default:
  41420. callback.apply(undefined, args);
  41421. break;
  41422. }
  41423. }
  41424. function runIfPresent(handle) {
  41425. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41426. // So if we're currently running a task, we'll need to delay this invocation.
  41427. if (currentlyRunningATask) {
  41428. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41429. // "too much recursion" error.
  41430. setTimeout(runIfPresent, 0, handle);
  41431. } else {
  41432. var task = tasksByHandle[handle];
  41433. if (task) {
  41434. currentlyRunningATask = true;
  41435. try {
  41436. run(task);
  41437. } finally {
  41438. clearImmediate(handle);
  41439. currentlyRunningATask = false;
  41440. }
  41441. }
  41442. }
  41443. }
  41444. function installNextTickImplementation() {
  41445. registerImmediate = function(handle) {
  41446. process.nextTick(function () { runIfPresent(handle); });
  41447. };
  41448. }
  41449. function canUsePostMessage() {
  41450. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41451. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41452. if (global.postMessage && !global.importScripts) {
  41453. var postMessageIsAsynchronous = true;
  41454. var oldOnMessage = global.onmessage;
  41455. global.onmessage = function() {
  41456. postMessageIsAsynchronous = false;
  41457. };
  41458. global.postMessage("", "*");
  41459. global.onmessage = oldOnMessage;
  41460. return postMessageIsAsynchronous;
  41461. }
  41462. }
  41463. function installPostMessageImplementation() {
  41464. // Installs an event handler on `global` for the `message` event: see
  41465. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41466. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41467. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41468. var onGlobalMessage = function(event) {
  41469. if (event.source === global &&
  41470. typeof event.data === "string" &&
  41471. event.data.indexOf(messagePrefix) === 0) {
  41472. runIfPresent(+event.data.slice(messagePrefix.length));
  41473. }
  41474. };
  41475. if (global.addEventListener) {
  41476. global.addEventListener("message", onGlobalMessage, false);
  41477. } else {
  41478. global.attachEvent("onmessage", onGlobalMessage);
  41479. }
  41480. registerImmediate = function(handle) {
  41481. global.postMessage(messagePrefix + handle, "*");
  41482. };
  41483. }
  41484. function installMessageChannelImplementation() {
  41485. var channel = new MessageChannel();
  41486. channel.port1.onmessage = function(event) {
  41487. var handle = event.data;
  41488. runIfPresent(handle);
  41489. };
  41490. registerImmediate = function(handle) {
  41491. channel.port2.postMessage(handle);
  41492. };
  41493. }
  41494. function installReadyStateChangeImplementation() {
  41495. var html = doc.documentElement;
  41496. registerImmediate = function(handle) {
  41497. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41498. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41499. var script = doc.createElement("script");
  41500. script.onreadystatechange = function () {
  41501. runIfPresent(handle);
  41502. script.onreadystatechange = null;
  41503. html.removeChild(script);
  41504. script = null;
  41505. };
  41506. html.appendChild(script);
  41507. };
  41508. }
  41509. function installSetTimeoutImplementation() {
  41510. registerImmediate = function(handle) {
  41511. setTimeout(runIfPresent, 0, handle);
  41512. };
  41513. }
  41514. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41515. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41516. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41517. // Don't get fooled by e.g. browserify environments.
  41518. if ({}.toString.call(global.process) === "[object process]") {
  41519. // For Node.js before 0.9
  41520. installNextTickImplementation();
  41521. } else if (canUsePostMessage()) {
  41522. // For non-IE10 modern browsers
  41523. installPostMessageImplementation();
  41524. } else if (global.MessageChannel) {
  41525. // For web workers, where supported
  41526. installMessageChannelImplementation();
  41527. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41528. // For IE 6–8
  41529. installReadyStateChangeImplementation();
  41530. } else {
  41531. // For older browsers
  41532. installSetTimeoutImplementation();
  41533. }
  41534. attachTo.setImmediate = setImmediate;
  41535. attachTo.clearImmediate = clearImmediate;
  41536. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41537. /* 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")))
  41538. /***/ }),
  41539. /***/ "./node_modules/timers-browserify/main.js":
  41540. /*!************************************************!*\
  41541. !*** ./node_modules/timers-browserify/main.js ***!
  41542. \************************************************/
  41543. /*! no static exports found */
  41544. /***/ (function(module, exports, __webpack_require__) {
  41545. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41546. (typeof self !== "undefined" && self) ||
  41547. window;
  41548. var apply = Function.prototype.apply;
  41549. // DOM APIs, for completeness
  41550. exports.setTimeout = function() {
  41551. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41552. };
  41553. exports.setInterval = function() {
  41554. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41555. };
  41556. exports.clearTimeout =
  41557. exports.clearInterval = function(timeout) {
  41558. if (timeout) {
  41559. timeout.close();
  41560. }
  41561. };
  41562. function Timeout(id, clearFn) {
  41563. this._id = id;
  41564. this._clearFn = clearFn;
  41565. }
  41566. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41567. Timeout.prototype.close = function() {
  41568. this._clearFn.call(scope, this._id);
  41569. };
  41570. // Does not start the time, just sets up the members needed.
  41571. exports.enroll = function(item, msecs) {
  41572. clearTimeout(item._idleTimeoutId);
  41573. item._idleTimeout = msecs;
  41574. };
  41575. exports.unenroll = function(item) {
  41576. clearTimeout(item._idleTimeoutId);
  41577. item._idleTimeout = -1;
  41578. };
  41579. exports._unrefActive = exports.active = function(item) {
  41580. clearTimeout(item._idleTimeoutId);
  41581. var msecs = item._idleTimeout;
  41582. if (msecs >= 0) {
  41583. item._idleTimeoutId = setTimeout(function onTimeout() {
  41584. if (item._onTimeout)
  41585. item._onTimeout();
  41586. }, msecs);
  41587. }
  41588. };
  41589. // setimmediate attaches itself to the global object
  41590. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41591. // On some exotic environments, it's not clear which object `setimmediate` was
  41592. // able to install onto. Search each possibility in the same order as the
  41593. // `setimmediate` library.
  41594. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41595. (typeof global !== "undefined" && global.setImmediate) ||
  41596. (this && this.setImmediate);
  41597. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41598. (typeof global !== "undefined" && global.clearImmediate) ||
  41599. (this && this.clearImmediate);
  41600. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41601. /***/ }),
  41602. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  41603. /*!*******************************************************************************************************************************************************************************************************************!*\
  41604. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  41605. \*******************************************************************************************************************************************************************************************************************/
  41606. /*! exports provided: render, staticRenderFns */
  41607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41608. "use strict";
  41609. __webpack_require__.r(__webpack_exports__);
  41610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41612. var render = function() {
  41613. var _vm = this
  41614. var _h = _vm.$createElement
  41615. var _c = _vm._self._c || _h
  41616. return _vm._m(0)
  41617. }
  41618. var staticRenderFns = [
  41619. function() {
  41620. var _vm = this
  41621. var _h = _vm.$createElement
  41622. var _c = _vm._self._c || _h
  41623. return _c("div", { staticClass: "container" }, [
  41624. _c("div", { staticClass: "row justify-content-center" }, [
  41625. _c("div", { staticClass: "col-md-8" }, [
  41626. _c("div", { staticClass: "card" }, [
  41627. _c("div", { staticClass: "card-header" }, [
  41628. _vm._v("Example Component")
  41629. ]),
  41630. _vm._v(" "),
  41631. _c("div", { staticClass: "card-body" }, [
  41632. _vm._v(
  41633. "\n I'm an example component.\n "
  41634. )
  41635. ])
  41636. ])
  41637. ])
  41638. ])
  41639. ])
  41640. }
  41641. ]
  41642. render._withStripped = true
  41643. /***/ }),
  41644. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  41645. /*!************************************************************************************************************************************************************************************************************!*\
  41646. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  41647. \************************************************************************************************************************************************************************************************************/
  41648. /*! exports provided: render, staticRenderFns */
  41649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41650. "use strict";
  41651. __webpack_require__.r(__webpack_exports__);
  41652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41654. var render = function() {
  41655. var _vm = this
  41656. var _h = _vm.$createElement
  41657. var _c = _vm._self._c || _h
  41658. return _c("div", [
  41659. _c("h4", { staticClass: "text-center" }, [
  41660. _vm._v(_vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "),
  41661. _c("small", { staticClass: "text-muted" }, [
  41662. _vm._v(_vm._s(this.data.pcnickname))
  41663. ])
  41664. ]),
  41665. _vm._v(" "),
  41666. _c("p", [_vm._v("S/N: " + _vm._s(this.data.pcserial))]),
  41667. _vm._v(" "),
  41668. _c("p", [_vm._v("CPU: " + _vm._s(this.data.pcproc))]),
  41669. _vm._v(" "),
  41670. _c("p", [_vm._v("RAM: " + _vm._s(this.data.pcram))]),
  41671. _vm._v(" "),
  41672. _c("p", [_vm._v("OS: " + _vm._s(this.data.pcos))])
  41673. ])
  41674. }
  41675. var staticRenderFns = []
  41676. render._withStripped = true
  41677. /***/ }),
  41678. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  41679. /*!*************************************************************************************************************************************************************************************************************!*\
  41680. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  41681. \*************************************************************************************************************************************************************************************************************/
  41682. /*! exports provided: render, staticRenderFns */
  41683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41684. "use strict";
  41685. __webpack_require__.r(__webpack_exports__);
  41686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41688. var render = function() {
  41689. var _vm = this
  41690. var _h = _vm.$createElement
  41691. var _c = _vm._self._c || _h
  41692. return _c("div", [
  41693. _c("p", { staticClass: "h6" }, [_vm._v(_vm._s(this.data.creddesc))]),
  41694. _vm._v(" "),
  41695. _vm._m(0),
  41696. _vm._v(" "),
  41697. _c("input", {
  41698. attrs: { type: "text", id: "username", readonly: "" },
  41699. domProps: { value: this.data.creduser }
  41700. }),
  41701. _vm._v(" "),
  41702. _vm._m(1),
  41703. _vm._v(" "),
  41704. _c("input", {
  41705. attrs: { type: "text", id: "password", readonly: "" },
  41706. domProps: { value: this.data.credpass }
  41707. })
  41708. ])
  41709. }
  41710. var staticRenderFns = [
  41711. function() {
  41712. var _vm = this
  41713. var _h = _vm.$createElement
  41714. var _c = _vm._self._c || _h
  41715. return _c("label", { attrs: { for: "username" } }, [
  41716. _c("i", { staticClass: "fas fa-user" })
  41717. ])
  41718. },
  41719. function() {
  41720. var _vm = this
  41721. var _h = _vm.$createElement
  41722. var _c = _vm._self._c || _h
  41723. return _c("label", { attrs: { for: "password" } }, [
  41724. _c("i", { staticClass: "fas fa-key" })
  41725. ])
  41726. }
  41727. ]
  41728. render._withStripped = true
  41729. /***/ }),
  41730. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  41731. /*!*********************************************************************************************************************************************************************************************************!*\
  41732. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  41733. \*********************************************************************************************************************************************************************************************************/
  41734. /*! exports provided: render, staticRenderFns */
  41735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41736. "use strict";
  41737. __webpack_require__.r(__webpack_exports__);
  41738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41740. var render = function() {
  41741. var _vm = this
  41742. var _h = _vm.$createElement
  41743. var _c = _vm._self._c || _h
  41744. return _c("div", [
  41745. _c("p", [
  41746. _c("i", { staticClass: "fas fa-info-circle" }),
  41747. _vm._v(" "),
  41748. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  41749. ]),
  41750. _vm._v(" "),
  41751. _c("p", [
  41752. _c("i", { staticClass: "far fa-lightbulb" }),
  41753. _vm._v(" "),
  41754. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  41755. ]),
  41756. _vm._v(" "),
  41757. _c("p", [
  41758. _c("i", { staticClass: "fas fa-paste" }),
  41759. _vm._v(" "),
  41760. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  41761. ]),
  41762. _vm._v(" "),
  41763. _c("p", [
  41764. _c("i", { staticClass: "fas fa-building" }),
  41765. _vm._v(" "),
  41766. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  41767. ]),
  41768. _vm._v(" "),
  41769. _c("p", [
  41770. _c("i", { staticClass: "fas fa-sign-in-alt" }),
  41771. _vm._v(" "),
  41772. _c(
  41773. "span",
  41774. {
  41775. staticClass: "dashed-underline",
  41776. attrs: {
  41777. "data-toggle": "tooltip",
  41778. "data-placement": "bottom",
  41779. title: this.getHRDate(this.data.dropdate)
  41780. }
  41781. },
  41782. [
  41783. _vm._v(
  41784. "\n " +
  41785. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  41786. " days ago\n "
  41787. )
  41788. ]
  41789. )
  41790. ]),
  41791. _vm._v(" "),
  41792. _c("p", [
  41793. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  41794. _vm._v(" "),
  41795. !this.isZero(this.data.pickupdate)
  41796. ? _c(
  41797. "span",
  41798. {
  41799. staticClass: "dashed-underline",
  41800. attrs: {
  41801. "data-toggle": "tooltip",
  41802. "data-placement": "bottom",
  41803. tittle: this.getHRDate(this.data.pickupdate)
  41804. }
  41805. },
  41806. [
  41807. _vm._v(
  41808. "\n " +
  41809. _vm._s(
  41810. Math.floor(this.daysSinceToday(this.data.pickupdate))
  41811. ) +
  41812. " days ago\n "
  41813. )
  41814. ]
  41815. )
  41816. : _vm._e()
  41817. ])
  41818. ])
  41819. }
  41820. var staticRenderFns = []
  41821. render._withStripped = true
  41822. /***/ }),
  41823. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41824. /*!********************************************************************!*\
  41825. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41826. \********************************************************************/
  41827. /*! exports provided: default */
  41828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41829. "use strict";
  41830. __webpack_require__.r(__webpack_exports__);
  41831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41832. /* globals __VUE_SSR_CONTEXT__ */
  41833. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41834. // This module is a runtime utility for cleaner component module output and will
  41835. // be included in the final webpack user bundle.
  41836. function normalizeComponent (
  41837. scriptExports,
  41838. render,
  41839. staticRenderFns,
  41840. functionalTemplate,
  41841. injectStyles,
  41842. scopeId,
  41843. moduleIdentifier, /* server only */
  41844. shadowMode /* vue-cli only */
  41845. ) {
  41846. // Vue.extend constructor export interop
  41847. var options = typeof scriptExports === 'function'
  41848. ? scriptExports.options
  41849. : scriptExports
  41850. // render functions
  41851. if (render) {
  41852. options.render = render
  41853. options.staticRenderFns = staticRenderFns
  41854. options._compiled = true
  41855. }
  41856. // functional template
  41857. if (functionalTemplate) {
  41858. options.functional = true
  41859. }
  41860. // scopedId
  41861. if (scopeId) {
  41862. options._scopeId = 'data-v-' + scopeId
  41863. }
  41864. var hook
  41865. if (moduleIdentifier) { // server build
  41866. hook = function (context) {
  41867. // 2.3 injection
  41868. context =
  41869. context || // cached call
  41870. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41871. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41872. // 2.2 with runInNewContext: true
  41873. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41874. context = __VUE_SSR_CONTEXT__
  41875. }
  41876. // inject component styles
  41877. if (injectStyles) {
  41878. injectStyles.call(this, context)
  41879. }
  41880. // register component module identifier for async chunk inferrence
  41881. if (context && context._registeredComponents) {
  41882. context._registeredComponents.add(moduleIdentifier)
  41883. }
  41884. }
  41885. // used by ssr in case component is cached and beforeCreate
  41886. // never gets called
  41887. options._ssrRegister = hook
  41888. } else if (injectStyles) {
  41889. hook = shadowMode
  41890. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41891. : injectStyles
  41892. }
  41893. if (hook) {
  41894. if (options.functional) {
  41895. // for template-only hot-reload because in that case the render fn doesn't
  41896. // go through the normalizer
  41897. options._injectStyles = hook
  41898. // register for functioal component in vue file
  41899. var originalRender = options.render
  41900. options.render = function renderWithStyleInjection (h, context) {
  41901. hook.call(context)
  41902. return originalRender(h, context)
  41903. }
  41904. } else {
  41905. // inject component registration as beforeCreate hook
  41906. var existing = options.beforeCreate
  41907. options.beforeCreate = existing
  41908. ? [].concat(existing, hook)
  41909. : [hook]
  41910. }
  41911. }
  41912. return {
  41913. exports: scriptExports,
  41914. options: options
  41915. }
  41916. }
  41917. /***/ }),
  41918. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41919. /*!*************************************************!*\
  41920. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41921. \*************************************************/
  41922. /*! no static exports found */
  41923. /***/ (function(module, exports, __webpack_require__) {
  41924. "use strict";
  41925. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41926. * Vue.js v2.6.11
  41927. * (c) 2014-2019 Evan You
  41928. * Released under the MIT License.
  41929. */
  41930. /* */
  41931. var emptyObject = Object.freeze({});
  41932. // These helpers produce better VM code in JS engines due to their
  41933. // explicitness and function inlining.
  41934. function isUndef (v) {
  41935. return v === undefined || v === null
  41936. }
  41937. function isDef (v) {
  41938. return v !== undefined && v !== null
  41939. }
  41940. function isTrue (v) {
  41941. return v === true
  41942. }
  41943. function isFalse (v) {
  41944. return v === false
  41945. }
  41946. /**
  41947. * Check if value is primitive.
  41948. */
  41949. function isPrimitive (value) {
  41950. return (
  41951. typeof value === 'string' ||
  41952. typeof value === 'number' ||
  41953. // $flow-disable-line
  41954. typeof value === 'symbol' ||
  41955. typeof value === 'boolean'
  41956. )
  41957. }
  41958. /**
  41959. * Quick object check - this is primarily used to tell
  41960. * Objects from primitive values when we know the value
  41961. * is a JSON-compliant type.
  41962. */
  41963. function isObject (obj) {
  41964. return obj !== null && typeof obj === 'object'
  41965. }
  41966. /**
  41967. * Get the raw type string of a value, e.g., [object Object].
  41968. */
  41969. var _toString = Object.prototype.toString;
  41970. function toRawType (value) {
  41971. return _toString.call(value).slice(8, -1)
  41972. }
  41973. /**
  41974. * Strict object type check. Only returns true
  41975. * for plain JavaScript objects.
  41976. */
  41977. function isPlainObject (obj) {
  41978. return _toString.call(obj) === '[object Object]'
  41979. }
  41980. function isRegExp (v) {
  41981. return _toString.call(v) === '[object RegExp]'
  41982. }
  41983. /**
  41984. * Check if val is a valid array index.
  41985. */
  41986. function isValidArrayIndex (val) {
  41987. var n = parseFloat(String(val));
  41988. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41989. }
  41990. function isPromise (val) {
  41991. return (
  41992. isDef(val) &&
  41993. typeof val.then === 'function' &&
  41994. typeof val.catch === 'function'
  41995. )
  41996. }
  41997. /**
  41998. * Convert a value to a string that is actually rendered.
  41999. */
  42000. function toString (val) {
  42001. return val == null
  42002. ? ''
  42003. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  42004. ? JSON.stringify(val, null, 2)
  42005. : String(val)
  42006. }
  42007. /**
  42008. * Convert an input value to a number for persistence.
  42009. * If the conversion fails, return original string.
  42010. */
  42011. function toNumber (val) {
  42012. var n = parseFloat(val);
  42013. return isNaN(n) ? val : n
  42014. }
  42015. /**
  42016. * Make a map and return a function for checking if a key
  42017. * is in that map.
  42018. */
  42019. function makeMap (
  42020. str,
  42021. expectsLowerCase
  42022. ) {
  42023. var map = Object.create(null);
  42024. var list = str.split(',');
  42025. for (var i = 0; i < list.length; i++) {
  42026. map[list[i]] = true;
  42027. }
  42028. return expectsLowerCase
  42029. ? function (val) { return map[val.toLowerCase()]; }
  42030. : function (val) { return map[val]; }
  42031. }
  42032. /**
  42033. * Check if a tag is a built-in tag.
  42034. */
  42035. var isBuiltInTag = makeMap('slot,component', true);
  42036. /**
  42037. * Check if an attribute is a reserved attribute.
  42038. */
  42039. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  42040. /**
  42041. * Remove an item from an array.
  42042. */
  42043. function remove (arr, item) {
  42044. if (arr.length) {
  42045. var index = arr.indexOf(item);
  42046. if (index > -1) {
  42047. return arr.splice(index, 1)
  42048. }
  42049. }
  42050. }
  42051. /**
  42052. * Check whether an object has the property.
  42053. */
  42054. var hasOwnProperty = Object.prototype.hasOwnProperty;
  42055. function hasOwn (obj, key) {
  42056. return hasOwnProperty.call(obj, key)
  42057. }
  42058. /**
  42059. * Create a cached version of a pure function.
  42060. */
  42061. function cached (fn) {
  42062. var cache = Object.create(null);
  42063. return (function cachedFn (str) {
  42064. var hit = cache[str];
  42065. return hit || (cache[str] = fn(str))
  42066. })
  42067. }
  42068. /**
  42069. * Camelize a hyphen-delimited string.
  42070. */
  42071. var camelizeRE = /-(\w)/g;
  42072. var camelize = cached(function (str) {
  42073. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  42074. });
  42075. /**
  42076. * Capitalize a string.
  42077. */
  42078. var capitalize = cached(function (str) {
  42079. return str.charAt(0).toUpperCase() + str.slice(1)
  42080. });
  42081. /**
  42082. * Hyphenate a camelCase string.
  42083. */
  42084. var hyphenateRE = /\B([A-Z])/g;
  42085. var hyphenate = cached(function (str) {
  42086. return str.replace(hyphenateRE, '-$1').toLowerCase()
  42087. });
  42088. /**
  42089. * Simple bind polyfill for environments that do not support it,
  42090. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  42091. * since native bind is now performant enough in most browsers.
  42092. * But removing it would mean breaking code that was able to run in
  42093. * PhantomJS 1.x, so this must be kept for backward compatibility.
  42094. */
  42095. /* istanbul ignore next */
  42096. function polyfillBind (fn, ctx) {
  42097. function boundFn (a) {
  42098. var l = arguments.length;
  42099. return l
  42100. ? l > 1
  42101. ? fn.apply(ctx, arguments)
  42102. : fn.call(ctx, a)
  42103. : fn.call(ctx)
  42104. }
  42105. boundFn._length = fn.length;
  42106. return boundFn
  42107. }
  42108. function nativeBind (fn, ctx) {
  42109. return fn.bind(ctx)
  42110. }
  42111. var bind = Function.prototype.bind
  42112. ? nativeBind
  42113. : polyfillBind;
  42114. /**
  42115. * Convert an Array-like object to a real Array.
  42116. */
  42117. function toArray (list, start) {
  42118. start = start || 0;
  42119. var i = list.length - start;
  42120. var ret = new Array(i);
  42121. while (i--) {
  42122. ret[i] = list[i + start];
  42123. }
  42124. return ret
  42125. }
  42126. /**
  42127. * Mix properties into target object.
  42128. */
  42129. function extend (to, _from) {
  42130. for (var key in _from) {
  42131. to[key] = _from[key];
  42132. }
  42133. return to
  42134. }
  42135. /**
  42136. * Merge an Array of Objects into a single Object.
  42137. */
  42138. function toObject (arr) {
  42139. var res = {};
  42140. for (var i = 0; i < arr.length; i++) {
  42141. if (arr[i]) {
  42142. extend(res, arr[i]);
  42143. }
  42144. }
  42145. return res
  42146. }
  42147. /* eslint-disable no-unused-vars */
  42148. /**
  42149. * Perform no operation.
  42150. * Stubbing args to make Flow happy without leaving useless transpiled code
  42151. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  42152. */
  42153. function noop (a, b, c) {}
  42154. /**
  42155. * Always return false.
  42156. */
  42157. var no = function (a, b, c) { return false; };
  42158. /* eslint-enable no-unused-vars */
  42159. /**
  42160. * Return the same value.
  42161. */
  42162. var identity = function (_) { return _; };
  42163. /**
  42164. * Generate a string containing static keys from compiler modules.
  42165. */
  42166. function genStaticKeys (modules) {
  42167. return modules.reduce(function (keys, m) {
  42168. return keys.concat(m.staticKeys || [])
  42169. }, []).join(',')
  42170. }
  42171. /**
  42172. * Check if two values are loosely equal - that is,
  42173. * if they are plain objects, do they have the same shape?
  42174. */
  42175. function looseEqual (a, b) {
  42176. if (a === b) { return true }
  42177. var isObjectA = isObject(a);
  42178. var isObjectB = isObject(b);
  42179. if (isObjectA && isObjectB) {
  42180. try {
  42181. var isArrayA = Array.isArray(a);
  42182. var isArrayB = Array.isArray(b);
  42183. if (isArrayA && isArrayB) {
  42184. return a.length === b.length && a.every(function (e, i) {
  42185. return looseEqual(e, b[i])
  42186. })
  42187. } else if (a instanceof Date && b instanceof Date) {
  42188. return a.getTime() === b.getTime()
  42189. } else if (!isArrayA && !isArrayB) {
  42190. var keysA = Object.keys(a);
  42191. var keysB = Object.keys(b);
  42192. return keysA.length === keysB.length && keysA.every(function (key) {
  42193. return looseEqual(a[key], b[key])
  42194. })
  42195. } else {
  42196. /* istanbul ignore next */
  42197. return false
  42198. }
  42199. } catch (e) {
  42200. /* istanbul ignore next */
  42201. return false
  42202. }
  42203. } else if (!isObjectA && !isObjectB) {
  42204. return String(a) === String(b)
  42205. } else {
  42206. return false
  42207. }
  42208. }
  42209. /**
  42210. * Return the first index at which a loosely equal value can be
  42211. * found in the array (if value is a plain object, the array must
  42212. * contain an object of the same shape), or -1 if it is not present.
  42213. */
  42214. function looseIndexOf (arr, val) {
  42215. for (var i = 0; i < arr.length; i++) {
  42216. if (looseEqual(arr[i], val)) { return i }
  42217. }
  42218. return -1
  42219. }
  42220. /**
  42221. * Ensure a function is called only once.
  42222. */
  42223. function once (fn) {
  42224. var called = false;
  42225. return function () {
  42226. if (!called) {
  42227. called = true;
  42228. fn.apply(this, arguments);
  42229. }
  42230. }
  42231. }
  42232. var SSR_ATTR = 'data-server-rendered';
  42233. var ASSET_TYPES = [
  42234. 'component',
  42235. 'directive',
  42236. 'filter'
  42237. ];
  42238. var LIFECYCLE_HOOKS = [
  42239. 'beforeCreate',
  42240. 'created',
  42241. 'beforeMount',
  42242. 'mounted',
  42243. 'beforeUpdate',
  42244. 'updated',
  42245. 'beforeDestroy',
  42246. 'destroyed',
  42247. 'activated',
  42248. 'deactivated',
  42249. 'errorCaptured',
  42250. 'serverPrefetch'
  42251. ];
  42252. /* */
  42253. var config = ({
  42254. /**
  42255. * Option merge strategies (used in core/util/options)
  42256. */
  42257. // $flow-disable-line
  42258. optionMergeStrategies: Object.create(null),
  42259. /**
  42260. * Whether to suppress warnings.
  42261. */
  42262. silent: false,
  42263. /**
  42264. * Show production mode tip message on boot?
  42265. */
  42266. productionTip: "development" !== 'production',
  42267. /**
  42268. * Whether to enable devtools
  42269. */
  42270. devtools: "development" !== 'production',
  42271. /**
  42272. * Whether to record perf
  42273. */
  42274. performance: false,
  42275. /**
  42276. * Error handler for watcher errors
  42277. */
  42278. errorHandler: null,
  42279. /**
  42280. * Warn handler for watcher warns
  42281. */
  42282. warnHandler: null,
  42283. /**
  42284. * Ignore certain custom elements
  42285. */
  42286. ignoredElements: [],
  42287. /**
  42288. * Custom user key aliases for v-on
  42289. */
  42290. // $flow-disable-line
  42291. keyCodes: Object.create(null),
  42292. /**
  42293. * Check if a tag is reserved so that it cannot be registered as a
  42294. * component. This is platform-dependent and may be overwritten.
  42295. */
  42296. isReservedTag: no,
  42297. /**
  42298. * Check if an attribute is reserved so that it cannot be used as a component
  42299. * prop. This is platform-dependent and may be overwritten.
  42300. */
  42301. isReservedAttr: no,
  42302. /**
  42303. * Check if a tag is an unknown element.
  42304. * Platform-dependent.
  42305. */
  42306. isUnknownElement: no,
  42307. /**
  42308. * Get the namespace of an element
  42309. */
  42310. getTagNamespace: noop,
  42311. /**
  42312. * Parse the real tag name for the specific platform.
  42313. */
  42314. parsePlatformTagName: identity,
  42315. /**
  42316. * Check if an attribute must be bound using property, e.g. value
  42317. * Platform-dependent.
  42318. */
  42319. mustUseProp: no,
  42320. /**
  42321. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42322. * This will significantly reduce performance if set to false.
  42323. */
  42324. async: true,
  42325. /**
  42326. * Exposed for legacy reasons
  42327. */
  42328. _lifecycleHooks: LIFECYCLE_HOOKS
  42329. });
  42330. /* */
  42331. /**
  42332. * unicode letters used for parsing html tags, component names and property paths.
  42333. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42334. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42335. */
  42336. 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/;
  42337. /**
  42338. * Check if a string starts with $ or _
  42339. */
  42340. function isReserved (str) {
  42341. var c = (str + '').charCodeAt(0);
  42342. return c === 0x24 || c === 0x5F
  42343. }
  42344. /**
  42345. * Define a property.
  42346. */
  42347. function def (obj, key, val, enumerable) {
  42348. Object.defineProperty(obj, key, {
  42349. value: val,
  42350. enumerable: !!enumerable,
  42351. writable: true,
  42352. configurable: true
  42353. });
  42354. }
  42355. /**
  42356. * Parse simple path.
  42357. */
  42358. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42359. function parsePath (path) {
  42360. if (bailRE.test(path)) {
  42361. return
  42362. }
  42363. var segments = path.split('.');
  42364. return function (obj) {
  42365. for (var i = 0; i < segments.length; i++) {
  42366. if (!obj) { return }
  42367. obj = obj[segments[i]];
  42368. }
  42369. return obj
  42370. }
  42371. }
  42372. /* */
  42373. // can we use __proto__?
  42374. var hasProto = '__proto__' in {};
  42375. // Browser environment sniffing
  42376. var inBrowser = typeof window !== 'undefined';
  42377. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42378. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42379. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42380. var isIE = UA && /msie|trident/.test(UA);
  42381. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42382. var isEdge = UA && UA.indexOf('edge/') > 0;
  42383. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42384. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42385. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42386. var isPhantomJS = UA && /phantomjs/.test(UA);
  42387. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42388. // Firefox has a "watch" function on Object.prototype...
  42389. var nativeWatch = ({}).watch;
  42390. var supportsPassive = false;
  42391. if (inBrowser) {
  42392. try {
  42393. var opts = {};
  42394. Object.defineProperty(opts, 'passive', ({
  42395. get: function get () {
  42396. /* istanbul ignore next */
  42397. supportsPassive = true;
  42398. }
  42399. })); // https://github.com/facebook/flow/issues/285
  42400. window.addEventListener('test-passive', null, opts);
  42401. } catch (e) {}
  42402. }
  42403. // this needs to be lazy-evaled because vue may be required before
  42404. // vue-server-renderer can set VUE_ENV
  42405. var _isServer;
  42406. var isServerRendering = function () {
  42407. if (_isServer === undefined) {
  42408. /* istanbul ignore if */
  42409. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42410. // detect presence of vue-server-renderer and avoid
  42411. // Webpack shimming the process
  42412. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42413. } else {
  42414. _isServer = false;
  42415. }
  42416. }
  42417. return _isServer
  42418. };
  42419. // detect devtools
  42420. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42421. /* istanbul ignore next */
  42422. function isNative (Ctor) {
  42423. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42424. }
  42425. var hasSymbol =
  42426. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42427. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42428. var _Set;
  42429. /* istanbul ignore if */ // $flow-disable-line
  42430. if (typeof Set !== 'undefined' && isNative(Set)) {
  42431. // use native Set when available.
  42432. _Set = Set;
  42433. } else {
  42434. // a non-standard Set polyfill that only works with primitive keys.
  42435. _Set = /*@__PURE__*/(function () {
  42436. function Set () {
  42437. this.set = Object.create(null);
  42438. }
  42439. Set.prototype.has = function has (key) {
  42440. return this.set[key] === true
  42441. };
  42442. Set.prototype.add = function add (key) {
  42443. this.set[key] = true;
  42444. };
  42445. Set.prototype.clear = function clear () {
  42446. this.set = Object.create(null);
  42447. };
  42448. return Set;
  42449. }());
  42450. }
  42451. /* */
  42452. var warn = noop;
  42453. var tip = noop;
  42454. var generateComponentTrace = (noop); // work around flow check
  42455. var formatComponentName = (noop);
  42456. {
  42457. var hasConsole = typeof console !== 'undefined';
  42458. var classifyRE = /(?:^|[-_])(\w)/g;
  42459. var classify = function (str) { return str
  42460. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42461. .replace(/[-_]/g, ''); };
  42462. warn = function (msg, vm) {
  42463. var trace = vm ? generateComponentTrace(vm) : '';
  42464. if (config.warnHandler) {
  42465. config.warnHandler.call(null, msg, vm, trace);
  42466. } else if (hasConsole && (!config.silent)) {
  42467. console.error(("[Vue warn]: " + msg + trace));
  42468. }
  42469. };
  42470. tip = function (msg, vm) {
  42471. if (hasConsole && (!config.silent)) {
  42472. console.warn("[Vue tip]: " + msg + (
  42473. vm ? generateComponentTrace(vm) : ''
  42474. ));
  42475. }
  42476. };
  42477. formatComponentName = function (vm, includeFile) {
  42478. if (vm.$root === vm) {
  42479. return '<Root>'
  42480. }
  42481. var options = typeof vm === 'function' && vm.cid != null
  42482. ? vm.options
  42483. : vm._isVue
  42484. ? vm.$options || vm.constructor.options
  42485. : vm;
  42486. var name = options.name || options._componentTag;
  42487. var file = options.__file;
  42488. if (!name && file) {
  42489. var match = file.match(/([^/\\]+)\.vue$/);
  42490. name = match && match[1];
  42491. }
  42492. return (
  42493. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42494. (file && includeFile !== false ? (" at " + file) : '')
  42495. )
  42496. };
  42497. var repeat = function (str, n) {
  42498. var res = '';
  42499. while (n) {
  42500. if (n % 2 === 1) { res += str; }
  42501. if (n > 1) { str += str; }
  42502. n >>= 1;
  42503. }
  42504. return res
  42505. };
  42506. generateComponentTrace = function (vm) {
  42507. if (vm._isVue && vm.$parent) {
  42508. var tree = [];
  42509. var currentRecursiveSequence = 0;
  42510. while (vm) {
  42511. if (tree.length > 0) {
  42512. var last = tree[tree.length - 1];
  42513. if (last.constructor === vm.constructor) {
  42514. currentRecursiveSequence++;
  42515. vm = vm.$parent;
  42516. continue
  42517. } else if (currentRecursiveSequence > 0) {
  42518. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42519. currentRecursiveSequence = 0;
  42520. }
  42521. }
  42522. tree.push(vm);
  42523. vm = vm.$parent;
  42524. }
  42525. return '\n\nfound in\n\n' + tree
  42526. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42527. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42528. : formatComponentName(vm))); })
  42529. .join('\n')
  42530. } else {
  42531. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42532. }
  42533. };
  42534. }
  42535. /* */
  42536. var uid = 0;
  42537. /**
  42538. * A dep is an observable that can have multiple
  42539. * directives subscribing to it.
  42540. */
  42541. var Dep = function Dep () {
  42542. this.id = uid++;
  42543. this.subs = [];
  42544. };
  42545. Dep.prototype.addSub = function addSub (sub) {
  42546. this.subs.push(sub);
  42547. };
  42548. Dep.prototype.removeSub = function removeSub (sub) {
  42549. remove(this.subs, sub);
  42550. };
  42551. Dep.prototype.depend = function depend () {
  42552. if (Dep.target) {
  42553. Dep.target.addDep(this);
  42554. }
  42555. };
  42556. Dep.prototype.notify = function notify () {
  42557. // stabilize the subscriber list first
  42558. var subs = this.subs.slice();
  42559. if (!config.async) {
  42560. // subs aren't sorted in scheduler if not running async
  42561. // we need to sort them now to make sure they fire in correct
  42562. // order
  42563. subs.sort(function (a, b) { return a.id - b.id; });
  42564. }
  42565. for (var i = 0, l = subs.length; i < l; i++) {
  42566. subs[i].update();
  42567. }
  42568. };
  42569. // The current target watcher being evaluated.
  42570. // This is globally unique because only one watcher
  42571. // can be evaluated at a time.
  42572. Dep.target = null;
  42573. var targetStack = [];
  42574. function pushTarget (target) {
  42575. targetStack.push(target);
  42576. Dep.target = target;
  42577. }
  42578. function popTarget () {
  42579. targetStack.pop();
  42580. Dep.target = targetStack[targetStack.length - 1];
  42581. }
  42582. /* */
  42583. var VNode = function VNode (
  42584. tag,
  42585. data,
  42586. children,
  42587. text,
  42588. elm,
  42589. context,
  42590. componentOptions,
  42591. asyncFactory
  42592. ) {
  42593. this.tag = tag;
  42594. this.data = data;
  42595. this.children = children;
  42596. this.text = text;
  42597. this.elm = elm;
  42598. this.ns = undefined;
  42599. this.context = context;
  42600. this.fnContext = undefined;
  42601. this.fnOptions = undefined;
  42602. this.fnScopeId = undefined;
  42603. this.key = data && data.key;
  42604. this.componentOptions = componentOptions;
  42605. this.componentInstance = undefined;
  42606. this.parent = undefined;
  42607. this.raw = false;
  42608. this.isStatic = false;
  42609. this.isRootInsert = true;
  42610. this.isComment = false;
  42611. this.isCloned = false;
  42612. this.isOnce = false;
  42613. this.asyncFactory = asyncFactory;
  42614. this.asyncMeta = undefined;
  42615. this.isAsyncPlaceholder = false;
  42616. };
  42617. var prototypeAccessors = { child: { configurable: true } };
  42618. // DEPRECATED: alias for componentInstance for backwards compat.
  42619. /* istanbul ignore next */
  42620. prototypeAccessors.child.get = function () {
  42621. return this.componentInstance
  42622. };
  42623. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42624. var createEmptyVNode = function (text) {
  42625. if ( text === void 0 ) text = '';
  42626. var node = new VNode();
  42627. node.text = text;
  42628. node.isComment = true;
  42629. return node
  42630. };
  42631. function createTextVNode (val) {
  42632. return new VNode(undefined, undefined, undefined, String(val))
  42633. }
  42634. // optimized shallow clone
  42635. // used for static nodes and slot nodes because they may be reused across
  42636. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42637. // on their elm reference.
  42638. function cloneVNode (vnode) {
  42639. var cloned = new VNode(
  42640. vnode.tag,
  42641. vnode.data,
  42642. // #7975
  42643. // clone children array to avoid mutating original in case of cloning
  42644. // a child.
  42645. vnode.children && vnode.children.slice(),
  42646. vnode.text,
  42647. vnode.elm,
  42648. vnode.context,
  42649. vnode.componentOptions,
  42650. vnode.asyncFactory
  42651. );
  42652. cloned.ns = vnode.ns;
  42653. cloned.isStatic = vnode.isStatic;
  42654. cloned.key = vnode.key;
  42655. cloned.isComment = vnode.isComment;
  42656. cloned.fnContext = vnode.fnContext;
  42657. cloned.fnOptions = vnode.fnOptions;
  42658. cloned.fnScopeId = vnode.fnScopeId;
  42659. cloned.asyncMeta = vnode.asyncMeta;
  42660. cloned.isCloned = true;
  42661. return cloned
  42662. }
  42663. /*
  42664. * not type checking this file because flow doesn't play well with
  42665. * dynamically accessing methods on Array prototype
  42666. */
  42667. var arrayProto = Array.prototype;
  42668. var arrayMethods = Object.create(arrayProto);
  42669. var methodsToPatch = [
  42670. 'push',
  42671. 'pop',
  42672. 'shift',
  42673. 'unshift',
  42674. 'splice',
  42675. 'sort',
  42676. 'reverse'
  42677. ];
  42678. /**
  42679. * Intercept mutating methods and emit events
  42680. */
  42681. methodsToPatch.forEach(function (method) {
  42682. // cache original method
  42683. var original = arrayProto[method];
  42684. def(arrayMethods, method, function mutator () {
  42685. var args = [], len = arguments.length;
  42686. while ( len-- ) args[ len ] = arguments[ len ];
  42687. var result = original.apply(this, args);
  42688. var ob = this.__ob__;
  42689. var inserted;
  42690. switch (method) {
  42691. case 'push':
  42692. case 'unshift':
  42693. inserted = args;
  42694. break
  42695. case 'splice':
  42696. inserted = args.slice(2);
  42697. break
  42698. }
  42699. if (inserted) { ob.observeArray(inserted); }
  42700. // notify change
  42701. ob.dep.notify();
  42702. return result
  42703. });
  42704. });
  42705. /* */
  42706. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42707. /**
  42708. * In some cases we may want to disable observation inside a component's
  42709. * update computation.
  42710. */
  42711. var shouldObserve = true;
  42712. function toggleObserving (value) {
  42713. shouldObserve = value;
  42714. }
  42715. /**
  42716. * Observer class that is attached to each observed
  42717. * object. Once attached, the observer converts the target
  42718. * object's property keys into getter/setters that
  42719. * collect dependencies and dispatch updates.
  42720. */
  42721. var Observer = function Observer (value) {
  42722. this.value = value;
  42723. this.dep = new Dep();
  42724. this.vmCount = 0;
  42725. def(value, '__ob__', this);
  42726. if (Array.isArray(value)) {
  42727. if (hasProto) {
  42728. protoAugment(value, arrayMethods);
  42729. } else {
  42730. copyAugment(value, arrayMethods, arrayKeys);
  42731. }
  42732. this.observeArray(value);
  42733. } else {
  42734. this.walk(value);
  42735. }
  42736. };
  42737. /**
  42738. * Walk through all properties and convert them into
  42739. * getter/setters. This method should only be called when
  42740. * value type is Object.
  42741. */
  42742. Observer.prototype.walk = function walk (obj) {
  42743. var keys = Object.keys(obj);
  42744. for (var i = 0; i < keys.length; i++) {
  42745. defineReactive$$1(obj, keys[i]);
  42746. }
  42747. };
  42748. /**
  42749. * Observe a list of Array items.
  42750. */
  42751. Observer.prototype.observeArray = function observeArray (items) {
  42752. for (var i = 0, l = items.length; i < l; i++) {
  42753. observe(items[i]);
  42754. }
  42755. };
  42756. // helpers
  42757. /**
  42758. * Augment a target Object or Array by intercepting
  42759. * the prototype chain using __proto__
  42760. */
  42761. function protoAugment (target, src) {
  42762. /* eslint-disable no-proto */
  42763. target.__proto__ = src;
  42764. /* eslint-enable no-proto */
  42765. }
  42766. /**
  42767. * Augment a target Object or Array by defining
  42768. * hidden properties.
  42769. */
  42770. /* istanbul ignore next */
  42771. function copyAugment (target, src, keys) {
  42772. for (var i = 0, l = keys.length; i < l; i++) {
  42773. var key = keys[i];
  42774. def(target, key, src[key]);
  42775. }
  42776. }
  42777. /**
  42778. * Attempt to create an observer instance for a value,
  42779. * returns the new observer if successfully observed,
  42780. * or the existing observer if the value already has one.
  42781. */
  42782. function observe (value, asRootData) {
  42783. if (!isObject(value) || value instanceof VNode) {
  42784. return
  42785. }
  42786. var ob;
  42787. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42788. ob = value.__ob__;
  42789. } else if (
  42790. shouldObserve &&
  42791. !isServerRendering() &&
  42792. (Array.isArray(value) || isPlainObject(value)) &&
  42793. Object.isExtensible(value) &&
  42794. !value._isVue
  42795. ) {
  42796. ob = new Observer(value);
  42797. }
  42798. if (asRootData && ob) {
  42799. ob.vmCount++;
  42800. }
  42801. return ob
  42802. }
  42803. /**
  42804. * Define a reactive property on an Object.
  42805. */
  42806. function defineReactive$$1 (
  42807. obj,
  42808. key,
  42809. val,
  42810. customSetter,
  42811. shallow
  42812. ) {
  42813. var dep = new Dep();
  42814. var property = Object.getOwnPropertyDescriptor(obj, key);
  42815. if (property && property.configurable === false) {
  42816. return
  42817. }
  42818. // cater for pre-defined getter/setters
  42819. var getter = property && property.get;
  42820. var setter = property && property.set;
  42821. if ((!getter || setter) && arguments.length === 2) {
  42822. val = obj[key];
  42823. }
  42824. var childOb = !shallow && observe(val);
  42825. Object.defineProperty(obj, key, {
  42826. enumerable: true,
  42827. configurable: true,
  42828. get: function reactiveGetter () {
  42829. var value = getter ? getter.call(obj) : val;
  42830. if (Dep.target) {
  42831. dep.depend();
  42832. if (childOb) {
  42833. childOb.dep.depend();
  42834. if (Array.isArray(value)) {
  42835. dependArray(value);
  42836. }
  42837. }
  42838. }
  42839. return value
  42840. },
  42841. set: function reactiveSetter (newVal) {
  42842. var value = getter ? getter.call(obj) : val;
  42843. /* eslint-disable no-self-compare */
  42844. if (newVal === value || (newVal !== newVal && value !== value)) {
  42845. return
  42846. }
  42847. /* eslint-enable no-self-compare */
  42848. if (customSetter) {
  42849. customSetter();
  42850. }
  42851. // #7981: for accessor properties without setter
  42852. if (getter && !setter) { return }
  42853. if (setter) {
  42854. setter.call(obj, newVal);
  42855. } else {
  42856. val = newVal;
  42857. }
  42858. childOb = !shallow && observe(newVal);
  42859. dep.notify();
  42860. }
  42861. });
  42862. }
  42863. /**
  42864. * Set a property on an object. Adds the new property and
  42865. * triggers change notification if the property doesn't
  42866. * already exist.
  42867. */
  42868. function set (target, key, val) {
  42869. if (isUndef(target) || isPrimitive(target)
  42870. ) {
  42871. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42872. }
  42873. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42874. target.length = Math.max(target.length, key);
  42875. target.splice(key, 1, val);
  42876. return val
  42877. }
  42878. if (key in target && !(key in Object.prototype)) {
  42879. target[key] = val;
  42880. return val
  42881. }
  42882. var ob = (target).__ob__;
  42883. if (target._isVue || (ob && ob.vmCount)) {
  42884. warn(
  42885. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42886. 'at runtime - declare it upfront in the data option.'
  42887. );
  42888. return val
  42889. }
  42890. if (!ob) {
  42891. target[key] = val;
  42892. return val
  42893. }
  42894. defineReactive$$1(ob.value, key, val);
  42895. ob.dep.notify();
  42896. return val
  42897. }
  42898. /**
  42899. * Delete a property and trigger change if necessary.
  42900. */
  42901. function del (target, key) {
  42902. if (isUndef(target) || isPrimitive(target)
  42903. ) {
  42904. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42905. }
  42906. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42907. target.splice(key, 1);
  42908. return
  42909. }
  42910. var ob = (target).__ob__;
  42911. if (target._isVue || (ob && ob.vmCount)) {
  42912. warn(
  42913. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42914. '- just set it to null.'
  42915. );
  42916. return
  42917. }
  42918. if (!hasOwn(target, key)) {
  42919. return
  42920. }
  42921. delete target[key];
  42922. if (!ob) {
  42923. return
  42924. }
  42925. ob.dep.notify();
  42926. }
  42927. /**
  42928. * Collect dependencies on array elements when the array is touched, since
  42929. * we cannot intercept array element access like property getters.
  42930. */
  42931. function dependArray (value) {
  42932. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42933. e = value[i];
  42934. e && e.__ob__ && e.__ob__.dep.depend();
  42935. if (Array.isArray(e)) {
  42936. dependArray(e);
  42937. }
  42938. }
  42939. }
  42940. /* */
  42941. /**
  42942. * Option overwriting strategies are functions that handle
  42943. * how to merge a parent option value and a child option
  42944. * value into the final value.
  42945. */
  42946. var strats = config.optionMergeStrategies;
  42947. /**
  42948. * Options with restrictions
  42949. */
  42950. {
  42951. strats.el = strats.propsData = function (parent, child, vm, key) {
  42952. if (!vm) {
  42953. warn(
  42954. "option \"" + key + "\" can only be used during instance " +
  42955. 'creation with the `new` keyword.'
  42956. );
  42957. }
  42958. return defaultStrat(parent, child)
  42959. };
  42960. }
  42961. /**
  42962. * Helper that recursively merges two data objects together.
  42963. */
  42964. function mergeData (to, from) {
  42965. if (!from) { return to }
  42966. var key, toVal, fromVal;
  42967. var keys = hasSymbol
  42968. ? Reflect.ownKeys(from)
  42969. : Object.keys(from);
  42970. for (var i = 0; i < keys.length; i++) {
  42971. key = keys[i];
  42972. // in case the object is already observed...
  42973. if (key === '__ob__') { continue }
  42974. toVal = to[key];
  42975. fromVal = from[key];
  42976. if (!hasOwn(to, key)) {
  42977. set(to, key, fromVal);
  42978. } else if (
  42979. toVal !== fromVal &&
  42980. isPlainObject(toVal) &&
  42981. isPlainObject(fromVal)
  42982. ) {
  42983. mergeData(toVal, fromVal);
  42984. }
  42985. }
  42986. return to
  42987. }
  42988. /**
  42989. * Data
  42990. */
  42991. function mergeDataOrFn (
  42992. parentVal,
  42993. childVal,
  42994. vm
  42995. ) {
  42996. if (!vm) {
  42997. // in a Vue.extend merge, both should be functions
  42998. if (!childVal) {
  42999. return parentVal
  43000. }
  43001. if (!parentVal) {
  43002. return childVal
  43003. }
  43004. // when parentVal & childVal are both present,
  43005. // we need to return a function that returns the
  43006. // merged result of both functions... no need to
  43007. // check if parentVal is a function here because
  43008. // it has to be a function to pass previous merges.
  43009. return function mergedDataFn () {
  43010. return mergeData(
  43011. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  43012. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  43013. )
  43014. }
  43015. } else {
  43016. return function mergedInstanceDataFn () {
  43017. // instance merge
  43018. var instanceData = typeof childVal === 'function'
  43019. ? childVal.call(vm, vm)
  43020. : childVal;
  43021. var defaultData = typeof parentVal === 'function'
  43022. ? parentVal.call(vm, vm)
  43023. : parentVal;
  43024. if (instanceData) {
  43025. return mergeData(instanceData, defaultData)
  43026. } else {
  43027. return defaultData
  43028. }
  43029. }
  43030. }
  43031. }
  43032. strats.data = function (
  43033. parentVal,
  43034. childVal,
  43035. vm
  43036. ) {
  43037. if (!vm) {
  43038. if (childVal && typeof childVal !== 'function') {
  43039. warn(
  43040. 'The "data" option should be a function ' +
  43041. 'that returns a per-instance value in component ' +
  43042. 'definitions.',
  43043. vm
  43044. );
  43045. return parentVal
  43046. }
  43047. return mergeDataOrFn(parentVal, childVal)
  43048. }
  43049. return mergeDataOrFn(parentVal, childVal, vm)
  43050. };
  43051. /**
  43052. * Hooks and props are merged as arrays.
  43053. */
  43054. function mergeHook (
  43055. parentVal,
  43056. childVal
  43057. ) {
  43058. var res = childVal
  43059. ? parentVal
  43060. ? parentVal.concat(childVal)
  43061. : Array.isArray(childVal)
  43062. ? childVal
  43063. : [childVal]
  43064. : parentVal;
  43065. return res
  43066. ? dedupeHooks(res)
  43067. : res
  43068. }
  43069. function dedupeHooks (hooks) {
  43070. var res = [];
  43071. for (var i = 0; i < hooks.length; i++) {
  43072. if (res.indexOf(hooks[i]) === -1) {
  43073. res.push(hooks[i]);
  43074. }
  43075. }
  43076. return res
  43077. }
  43078. LIFECYCLE_HOOKS.forEach(function (hook) {
  43079. strats[hook] = mergeHook;
  43080. });
  43081. /**
  43082. * Assets
  43083. *
  43084. * When a vm is present (instance creation), we need to do
  43085. * a three-way merge between constructor options, instance
  43086. * options and parent options.
  43087. */
  43088. function mergeAssets (
  43089. parentVal,
  43090. childVal,
  43091. vm,
  43092. key
  43093. ) {
  43094. var res = Object.create(parentVal || null);
  43095. if (childVal) {
  43096. assertObjectType(key, childVal, vm);
  43097. return extend(res, childVal)
  43098. } else {
  43099. return res
  43100. }
  43101. }
  43102. ASSET_TYPES.forEach(function (type) {
  43103. strats[type + 's'] = mergeAssets;
  43104. });
  43105. /**
  43106. * Watchers.
  43107. *
  43108. * Watchers hashes should not overwrite one
  43109. * another, so we merge them as arrays.
  43110. */
  43111. strats.watch = function (
  43112. parentVal,
  43113. childVal,
  43114. vm,
  43115. key
  43116. ) {
  43117. // work around Firefox's Object.prototype.watch...
  43118. if (parentVal === nativeWatch) { parentVal = undefined; }
  43119. if (childVal === nativeWatch) { childVal = undefined; }
  43120. /* istanbul ignore if */
  43121. if (!childVal) { return Object.create(parentVal || null) }
  43122. {
  43123. assertObjectType(key, childVal, vm);
  43124. }
  43125. if (!parentVal) { return childVal }
  43126. var ret = {};
  43127. extend(ret, parentVal);
  43128. for (var key$1 in childVal) {
  43129. var parent = ret[key$1];
  43130. var child = childVal[key$1];
  43131. if (parent && !Array.isArray(parent)) {
  43132. parent = [parent];
  43133. }
  43134. ret[key$1] = parent
  43135. ? parent.concat(child)
  43136. : Array.isArray(child) ? child : [child];
  43137. }
  43138. return ret
  43139. };
  43140. /**
  43141. * Other object hashes.
  43142. */
  43143. strats.props =
  43144. strats.methods =
  43145. strats.inject =
  43146. strats.computed = function (
  43147. parentVal,
  43148. childVal,
  43149. vm,
  43150. key
  43151. ) {
  43152. if (childVal && "development" !== 'production') {
  43153. assertObjectType(key, childVal, vm);
  43154. }
  43155. if (!parentVal) { return childVal }
  43156. var ret = Object.create(null);
  43157. extend(ret, parentVal);
  43158. if (childVal) { extend(ret, childVal); }
  43159. return ret
  43160. };
  43161. strats.provide = mergeDataOrFn;
  43162. /**
  43163. * Default strategy.
  43164. */
  43165. var defaultStrat = function (parentVal, childVal) {
  43166. return childVal === undefined
  43167. ? parentVal
  43168. : childVal
  43169. };
  43170. /**
  43171. * Validate component names
  43172. */
  43173. function checkComponents (options) {
  43174. for (var key in options.components) {
  43175. validateComponentName(key);
  43176. }
  43177. }
  43178. function validateComponentName (name) {
  43179. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  43180. warn(
  43181. 'Invalid component name: "' + name + '". Component names ' +
  43182. 'should conform to valid custom element name in html5 specification.'
  43183. );
  43184. }
  43185. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  43186. warn(
  43187. 'Do not use built-in or reserved HTML elements as component ' +
  43188. 'id: ' + name
  43189. );
  43190. }
  43191. }
  43192. /**
  43193. * Ensure all props option syntax are normalized into the
  43194. * Object-based format.
  43195. */
  43196. function normalizeProps (options, vm) {
  43197. var props = options.props;
  43198. if (!props) { return }
  43199. var res = {};
  43200. var i, val, name;
  43201. if (Array.isArray(props)) {
  43202. i = props.length;
  43203. while (i--) {
  43204. val = props[i];
  43205. if (typeof val === 'string') {
  43206. name = camelize(val);
  43207. res[name] = { type: null };
  43208. } else {
  43209. warn('props must be strings when using array syntax.');
  43210. }
  43211. }
  43212. } else if (isPlainObject(props)) {
  43213. for (var key in props) {
  43214. val = props[key];
  43215. name = camelize(key);
  43216. res[name] = isPlainObject(val)
  43217. ? val
  43218. : { type: val };
  43219. }
  43220. } else {
  43221. warn(
  43222. "Invalid value for option \"props\": expected an Array or an Object, " +
  43223. "but got " + (toRawType(props)) + ".",
  43224. vm
  43225. );
  43226. }
  43227. options.props = res;
  43228. }
  43229. /**
  43230. * Normalize all injections into Object-based format
  43231. */
  43232. function normalizeInject (options, vm) {
  43233. var inject = options.inject;
  43234. if (!inject) { return }
  43235. var normalized = options.inject = {};
  43236. if (Array.isArray(inject)) {
  43237. for (var i = 0; i < inject.length; i++) {
  43238. normalized[inject[i]] = { from: inject[i] };
  43239. }
  43240. } else if (isPlainObject(inject)) {
  43241. for (var key in inject) {
  43242. var val = inject[key];
  43243. normalized[key] = isPlainObject(val)
  43244. ? extend({ from: key }, val)
  43245. : { from: val };
  43246. }
  43247. } else {
  43248. warn(
  43249. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43250. "but got " + (toRawType(inject)) + ".",
  43251. vm
  43252. );
  43253. }
  43254. }
  43255. /**
  43256. * Normalize raw function directives into object format.
  43257. */
  43258. function normalizeDirectives (options) {
  43259. var dirs = options.directives;
  43260. if (dirs) {
  43261. for (var key in dirs) {
  43262. var def$$1 = dirs[key];
  43263. if (typeof def$$1 === 'function') {
  43264. dirs[key] = { bind: def$$1, update: def$$1 };
  43265. }
  43266. }
  43267. }
  43268. }
  43269. function assertObjectType (name, value, vm) {
  43270. if (!isPlainObject(value)) {
  43271. warn(
  43272. "Invalid value for option \"" + name + "\": expected an Object, " +
  43273. "but got " + (toRawType(value)) + ".",
  43274. vm
  43275. );
  43276. }
  43277. }
  43278. /**
  43279. * Merge two option objects into a new one.
  43280. * Core utility used in both instantiation and inheritance.
  43281. */
  43282. function mergeOptions (
  43283. parent,
  43284. child,
  43285. vm
  43286. ) {
  43287. {
  43288. checkComponents(child);
  43289. }
  43290. if (typeof child === 'function') {
  43291. child = child.options;
  43292. }
  43293. normalizeProps(child, vm);
  43294. normalizeInject(child, vm);
  43295. normalizeDirectives(child);
  43296. // Apply extends and mixins on the child options,
  43297. // but only if it is a raw options object that isn't
  43298. // the result of another mergeOptions call.
  43299. // Only merged options has the _base property.
  43300. if (!child._base) {
  43301. if (child.extends) {
  43302. parent = mergeOptions(parent, child.extends, vm);
  43303. }
  43304. if (child.mixins) {
  43305. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43306. parent = mergeOptions(parent, child.mixins[i], vm);
  43307. }
  43308. }
  43309. }
  43310. var options = {};
  43311. var key;
  43312. for (key in parent) {
  43313. mergeField(key);
  43314. }
  43315. for (key in child) {
  43316. if (!hasOwn(parent, key)) {
  43317. mergeField(key);
  43318. }
  43319. }
  43320. function mergeField (key) {
  43321. var strat = strats[key] || defaultStrat;
  43322. options[key] = strat(parent[key], child[key], vm, key);
  43323. }
  43324. return options
  43325. }
  43326. /**
  43327. * Resolve an asset.
  43328. * This function is used because child instances need access
  43329. * to assets defined in its ancestor chain.
  43330. */
  43331. function resolveAsset (
  43332. options,
  43333. type,
  43334. id,
  43335. warnMissing
  43336. ) {
  43337. /* istanbul ignore if */
  43338. if (typeof id !== 'string') {
  43339. return
  43340. }
  43341. var assets = options[type];
  43342. // check local registration variations first
  43343. if (hasOwn(assets, id)) { return assets[id] }
  43344. var camelizedId = camelize(id);
  43345. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43346. var PascalCaseId = capitalize(camelizedId);
  43347. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43348. // fallback to prototype chain
  43349. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43350. if (warnMissing && !res) {
  43351. warn(
  43352. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43353. options
  43354. );
  43355. }
  43356. return res
  43357. }
  43358. /* */
  43359. function validateProp (
  43360. key,
  43361. propOptions,
  43362. propsData,
  43363. vm
  43364. ) {
  43365. var prop = propOptions[key];
  43366. var absent = !hasOwn(propsData, key);
  43367. var value = propsData[key];
  43368. // boolean casting
  43369. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43370. if (booleanIndex > -1) {
  43371. if (absent && !hasOwn(prop, 'default')) {
  43372. value = false;
  43373. } else if (value === '' || value === hyphenate(key)) {
  43374. // only cast empty string / same name to boolean if
  43375. // boolean has higher priority
  43376. var stringIndex = getTypeIndex(String, prop.type);
  43377. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43378. value = true;
  43379. }
  43380. }
  43381. }
  43382. // check default value
  43383. if (value === undefined) {
  43384. value = getPropDefaultValue(vm, prop, key);
  43385. // since the default value is a fresh copy,
  43386. // make sure to observe it.
  43387. var prevShouldObserve = shouldObserve;
  43388. toggleObserving(true);
  43389. observe(value);
  43390. toggleObserving(prevShouldObserve);
  43391. }
  43392. {
  43393. assertProp(prop, key, value, vm, absent);
  43394. }
  43395. return value
  43396. }
  43397. /**
  43398. * Get the default value of a prop.
  43399. */
  43400. function getPropDefaultValue (vm, prop, key) {
  43401. // no default, return undefined
  43402. if (!hasOwn(prop, 'default')) {
  43403. return undefined
  43404. }
  43405. var def = prop.default;
  43406. // warn against non-factory defaults for Object & Array
  43407. if (isObject(def)) {
  43408. warn(
  43409. 'Invalid default value for prop "' + key + '": ' +
  43410. 'Props with type Object/Array must use a factory function ' +
  43411. 'to return the default value.',
  43412. vm
  43413. );
  43414. }
  43415. // the raw prop value was also undefined from previous render,
  43416. // return previous default value to avoid unnecessary watcher trigger
  43417. if (vm && vm.$options.propsData &&
  43418. vm.$options.propsData[key] === undefined &&
  43419. vm._props[key] !== undefined
  43420. ) {
  43421. return vm._props[key]
  43422. }
  43423. // call factory function for non-Function types
  43424. // a value is Function if its prototype is function even across different execution context
  43425. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43426. ? def.call(vm)
  43427. : def
  43428. }
  43429. /**
  43430. * Assert whether a prop is valid.
  43431. */
  43432. function assertProp (
  43433. prop,
  43434. name,
  43435. value,
  43436. vm,
  43437. absent
  43438. ) {
  43439. if (prop.required && absent) {
  43440. warn(
  43441. 'Missing required prop: "' + name + '"',
  43442. vm
  43443. );
  43444. return
  43445. }
  43446. if (value == null && !prop.required) {
  43447. return
  43448. }
  43449. var type = prop.type;
  43450. var valid = !type || type === true;
  43451. var expectedTypes = [];
  43452. if (type) {
  43453. if (!Array.isArray(type)) {
  43454. type = [type];
  43455. }
  43456. for (var i = 0; i < type.length && !valid; i++) {
  43457. var assertedType = assertType(value, type[i]);
  43458. expectedTypes.push(assertedType.expectedType || '');
  43459. valid = assertedType.valid;
  43460. }
  43461. }
  43462. if (!valid) {
  43463. warn(
  43464. getInvalidTypeMessage(name, value, expectedTypes),
  43465. vm
  43466. );
  43467. return
  43468. }
  43469. var validator = prop.validator;
  43470. if (validator) {
  43471. if (!validator(value)) {
  43472. warn(
  43473. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43474. vm
  43475. );
  43476. }
  43477. }
  43478. }
  43479. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43480. function assertType (value, type) {
  43481. var valid;
  43482. var expectedType = getType(type);
  43483. if (simpleCheckRE.test(expectedType)) {
  43484. var t = typeof value;
  43485. valid = t === expectedType.toLowerCase();
  43486. // for primitive wrapper objects
  43487. if (!valid && t === 'object') {
  43488. valid = value instanceof type;
  43489. }
  43490. } else if (expectedType === 'Object') {
  43491. valid = isPlainObject(value);
  43492. } else if (expectedType === 'Array') {
  43493. valid = Array.isArray(value);
  43494. } else {
  43495. valid = value instanceof type;
  43496. }
  43497. return {
  43498. valid: valid,
  43499. expectedType: expectedType
  43500. }
  43501. }
  43502. /**
  43503. * Use function string name to check built-in types,
  43504. * because a simple equality check will fail when running
  43505. * across different vms / iframes.
  43506. */
  43507. function getType (fn) {
  43508. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43509. return match ? match[1] : ''
  43510. }
  43511. function isSameType (a, b) {
  43512. return getType(a) === getType(b)
  43513. }
  43514. function getTypeIndex (type, expectedTypes) {
  43515. if (!Array.isArray(expectedTypes)) {
  43516. return isSameType(expectedTypes, type) ? 0 : -1
  43517. }
  43518. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43519. if (isSameType(expectedTypes[i], type)) {
  43520. return i
  43521. }
  43522. }
  43523. return -1
  43524. }
  43525. function getInvalidTypeMessage (name, value, expectedTypes) {
  43526. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43527. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43528. var expectedType = expectedTypes[0];
  43529. var receivedType = toRawType(value);
  43530. var expectedValue = styleValue(value, expectedType);
  43531. var receivedValue = styleValue(value, receivedType);
  43532. // check if we need to specify expected value
  43533. if (expectedTypes.length === 1 &&
  43534. isExplicable(expectedType) &&
  43535. !isBoolean(expectedType, receivedType)) {
  43536. message += " with value " + expectedValue;
  43537. }
  43538. message += ", got " + receivedType + " ";
  43539. // check if we need to specify received value
  43540. if (isExplicable(receivedType)) {
  43541. message += "with value " + receivedValue + ".";
  43542. }
  43543. return message
  43544. }
  43545. function styleValue (value, type) {
  43546. if (type === 'String') {
  43547. return ("\"" + value + "\"")
  43548. } else if (type === 'Number') {
  43549. return ("" + (Number(value)))
  43550. } else {
  43551. return ("" + value)
  43552. }
  43553. }
  43554. function isExplicable (value) {
  43555. var explicitTypes = ['string', 'number', 'boolean'];
  43556. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43557. }
  43558. function isBoolean () {
  43559. var args = [], len = arguments.length;
  43560. while ( len-- ) args[ len ] = arguments[ len ];
  43561. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43562. }
  43563. /* */
  43564. function handleError (err, vm, info) {
  43565. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43566. // See: https://github.com/vuejs/vuex/issues/1505
  43567. pushTarget();
  43568. try {
  43569. if (vm) {
  43570. var cur = vm;
  43571. while ((cur = cur.$parent)) {
  43572. var hooks = cur.$options.errorCaptured;
  43573. if (hooks) {
  43574. for (var i = 0; i < hooks.length; i++) {
  43575. try {
  43576. var capture = hooks[i].call(cur, err, vm, info) === false;
  43577. if (capture) { return }
  43578. } catch (e) {
  43579. globalHandleError(e, cur, 'errorCaptured hook');
  43580. }
  43581. }
  43582. }
  43583. }
  43584. }
  43585. globalHandleError(err, vm, info);
  43586. } finally {
  43587. popTarget();
  43588. }
  43589. }
  43590. function invokeWithErrorHandling (
  43591. handler,
  43592. context,
  43593. args,
  43594. vm,
  43595. info
  43596. ) {
  43597. var res;
  43598. try {
  43599. res = args ? handler.apply(context, args) : handler.call(context);
  43600. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43601. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43602. // issue #9511
  43603. // avoid catch triggering multiple times when nested calls
  43604. res._handled = true;
  43605. }
  43606. } catch (e) {
  43607. handleError(e, vm, info);
  43608. }
  43609. return res
  43610. }
  43611. function globalHandleError (err, vm, info) {
  43612. if (config.errorHandler) {
  43613. try {
  43614. return config.errorHandler.call(null, err, vm, info)
  43615. } catch (e) {
  43616. // if the user intentionally throws the original error in the handler,
  43617. // do not log it twice
  43618. if (e !== err) {
  43619. logError(e, null, 'config.errorHandler');
  43620. }
  43621. }
  43622. }
  43623. logError(err, vm, info);
  43624. }
  43625. function logError (err, vm, info) {
  43626. {
  43627. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43628. }
  43629. /* istanbul ignore else */
  43630. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43631. console.error(err);
  43632. } else {
  43633. throw err
  43634. }
  43635. }
  43636. /* */
  43637. var isUsingMicroTask = false;
  43638. var callbacks = [];
  43639. var pending = false;
  43640. function flushCallbacks () {
  43641. pending = false;
  43642. var copies = callbacks.slice(0);
  43643. callbacks.length = 0;
  43644. for (var i = 0; i < copies.length; i++) {
  43645. copies[i]();
  43646. }
  43647. }
  43648. // Here we have async deferring wrappers using microtasks.
  43649. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43650. // However, it has subtle problems when state is changed right before repaint
  43651. // (e.g. #6813, out-in transitions).
  43652. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43653. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43654. // So we now use microtasks everywhere, again.
  43655. // A major drawback of this tradeoff is that there are some scenarios
  43656. // where microtasks have too high a priority and fire in between supposedly
  43657. // sequential events (e.g. #4521, #6690, which have workarounds)
  43658. // or even between bubbling of the same event (#6566).
  43659. var timerFunc;
  43660. // The nextTick behavior leverages the microtask queue, which can be accessed
  43661. // via either native Promise.then or MutationObserver.
  43662. // MutationObserver has wider support, however it is seriously bugged in
  43663. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43664. // completely stops working after triggering a few times... so, if native
  43665. // Promise is available, we will use it:
  43666. /* istanbul ignore next, $flow-disable-line */
  43667. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43668. var p = Promise.resolve();
  43669. timerFunc = function () {
  43670. p.then(flushCallbacks);
  43671. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43672. // it can get stuck in a weird state where callbacks are pushed into the
  43673. // microtask queue but the queue isn't being flushed, until the browser
  43674. // needs to do some other work, e.g. handle a timer. Therefore we can
  43675. // "force" the microtask queue to be flushed by adding an empty timer.
  43676. if (isIOS) { setTimeout(noop); }
  43677. };
  43678. isUsingMicroTask = true;
  43679. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43680. isNative(MutationObserver) ||
  43681. // PhantomJS and iOS 7.x
  43682. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43683. )) {
  43684. // Use MutationObserver where native Promise is not available,
  43685. // e.g. PhantomJS, iOS7, Android 4.4
  43686. // (#6466 MutationObserver is unreliable in IE11)
  43687. var counter = 1;
  43688. var observer = new MutationObserver(flushCallbacks);
  43689. var textNode = document.createTextNode(String(counter));
  43690. observer.observe(textNode, {
  43691. characterData: true
  43692. });
  43693. timerFunc = function () {
  43694. counter = (counter + 1) % 2;
  43695. textNode.data = String(counter);
  43696. };
  43697. isUsingMicroTask = true;
  43698. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43699. // Fallback to setImmediate.
  43700. // Technically it leverages the (macro) task queue,
  43701. // but it is still a better choice than setTimeout.
  43702. timerFunc = function () {
  43703. setImmediate(flushCallbacks);
  43704. };
  43705. } else {
  43706. // Fallback to setTimeout.
  43707. timerFunc = function () {
  43708. setTimeout(flushCallbacks, 0);
  43709. };
  43710. }
  43711. function nextTick (cb, ctx) {
  43712. var _resolve;
  43713. callbacks.push(function () {
  43714. if (cb) {
  43715. try {
  43716. cb.call(ctx);
  43717. } catch (e) {
  43718. handleError(e, ctx, 'nextTick');
  43719. }
  43720. } else if (_resolve) {
  43721. _resolve(ctx);
  43722. }
  43723. });
  43724. if (!pending) {
  43725. pending = true;
  43726. timerFunc();
  43727. }
  43728. // $flow-disable-line
  43729. if (!cb && typeof Promise !== 'undefined') {
  43730. return new Promise(function (resolve) {
  43731. _resolve = resolve;
  43732. })
  43733. }
  43734. }
  43735. /* */
  43736. var mark;
  43737. var measure;
  43738. {
  43739. var perf = inBrowser && window.performance;
  43740. /* istanbul ignore if */
  43741. if (
  43742. perf &&
  43743. perf.mark &&
  43744. perf.measure &&
  43745. perf.clearMarks &&
  43746. perf.clearMeasures
  43747. ) {
  43748. mark = function (tag) { return perf.mark(tag); };
  43749. measure = function (name, startTag, endTag) {
  43750. perf.measure(name, startTag, endTag);
  43751. perf.clearMarks(startTag);
  43752. perf.clearMarks(endTag);
  43753. // perf.clearMeasures(name)
  43754. };
  43755. }
  43756. }
  43757. /* not type checking this file because flow doesn't play well with Proxy */
  43758. var initProxy;
  43759. {
  43760. var allowedGlobals = makeMap(
  43761. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43762. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43763. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43764. 'require' // for Webpack/Browserify
  43765. );
  43766. var warnNonPresent = function (target, key) {
  43767. warn(
  43768. "Property or method \"" + key + "\" is not defined on the instance but " +
  43769. 'referenced during render. Make sure that this property is reactive, ' +
  43770. 'either in the data option, or for class-based components, by ' +
  43771. 'initializing the property. ' +
  43772. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43773. target
  43774. );
  43775. };
  43776. var warnReservedPrefix = function (target, key) {
  43777. warn(
  43778. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43779. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43780. 'prevent conflicts with Vue internals. ' +
  43781. 'See: https://vuejs.org/v2/api/#data',
  43782. target
  43783. );
  43784. };
  43785. var hasProxy =
  43786. typeof Proxy !== 'undefined' && isNative(Proxy);
  43787. if (hasProxy) {
  43788. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43789. config.keyCodes = new Proxy(config.keyCodes, {
  43790. set: function set (target, key, value) {
  43791. if (isBuiltInModifier(key)) {
  43792. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43793. return false
  43794. } else {
  43795. target[key] = value;
  43796. return true
  43797. }
  43798. }
  43799. });
  43800. }
  43801. var hasHandler = {
  43802. has: function has (target, key) {
  43803. var has = key in target;
  43804. var isAllowed = allowedGlobals(key) ||
  43805. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43806. if (!has && !isAllowed) {
  43807. if (key in target.$data) { warnReservedPrefix(target, key); }
  43808. else { warnNonPresent(target, key); }
  43809. }
  43810. return has || !isAllowed
  43811. }
  43812. };
  43813. var getHandler = {
  43814. get: function get (target, key) {
  43815. if (typeof key === 'string' && !(key in target)) {
  43816. if (key in target.$data) { warnReservedPrefix(target, key); }
  43817. else { warnNonPresent(target, key); }
  43818. }
  43819. return target[key]
  43820. }
  43821. };
  43822. initProxy = function initProxy (vm) {
  43823. if (hasProxy) {
  43824. // determine which proxy handler to use
  43825. var options = vm.$options;
  43826. var handlers = options.render && options.render._withStripped
  43827. ? getHandler
  43828. : hasHandler;
  43829. vm._renderProxy = new Proxy(vm, handlers);
  43830. } else {
  43831. vm._renderProxy = vm;
  43832. }
  43833. };
  43834. }
  43835. /* */
  43836. var seenObjects = new _Set();
  43837. /**
  43838. * Recursively traverse an object to evoke all converted
  43839. * getters, so that every nested property inside the object
  43840. * is collected as a "deep" dependency.
  43841. */
  43842. function traverse (val) {
  43843. _traverse(val, seenObjects);
  43844. seenObjects.clear();
  43845. }
  43846. function _traverse (val, seen) {
  43847. var i, keys;
  43848. var isA = Array.isArray(val);
  43849. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43850. return
  43851. }
  43852. if (val.__ob__) {
  43853. var depId = val.__ob__.dep.id;
  43854. if (seen.has(depId)) {
  43855. return
  43856. }
  43857. seen.add(depId);
  43858. }
  43859. if (isA) {
  43860. i = val.length;
  43861. while (i--) { _traverse(val[i], seen); }
  43862. } else {
  43863. keys = Object.keys(val);
  43864. i = keys.length;
  43865. while (i--) { _traverse(val[keys[i]], seen); }
  43866. }
  43867. }
  43868. /* */
  43869. var normalizeEvent = cached(function (name) {
  43870. var passive = name.charAt(0) === '&';
  43871. name = passive ? name.slice(1) : name;
  43872. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43873. name = once$$1 ? name.slice(1) : name;
  43874. var capture = name.charAt(0) === '!';
  43875. name = capture ? name.slice(1) : name;
  43876. return {
  43877. name: name,
  43878. once: once$$1,
  43879. capture: capture,
  43880. passive: passive
  43881. }
  43882. });
  43883. function createFnInvoker (fns, vm) {
  43884. function invoker () {
  43885. var arguments$1 = arguments;
  43886. var fns = invoker.fns;
  43887. if (Array.isArray(fns)) {
  43888. var cloned = fns.slice();
  43889. for (var i = 0; i < cloned.length; i++) {
  43890. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43891. }
  43892. } else {
  43893. // return handler return value for single handlers
  43894. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43895. }
  43896. }
  43897. invoker.fns = fns;
  43898. return invoker
  43899. }
  43900. function updateListeners (
  43901. on,
  43902. oldOn,
  43903. add,
  43904. remove$$1,
  43905. createOnceHandler,
  43906. vm
  43907. ) {
  43908. var name, def$$1, cur, old, event;
  43909. for (name in on) {
  43910. def$$1 = cur = on[name];
  43911. old = oldOn[name];
  43912. event = normalizeEvent(name);
  43913. if (isUndef(cur)) {
  43914. warn(
  43915. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43916. vm
  43917. );
  43918. } else if (isUndef(old)) {
  43919. if (isUndef(cur.fns)) {
  43920. cur = on[name] = createFnInvoker(cur, vm);
  43921. }
  43922. if (isTrue(event.once)) {
  43923. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43924. }
  43925. add(event.name, cur, event.capture, event.passive, event.params);
  43926. } else if (cur !== old) {
  43927. old.fns = cur;
  43928. on[name] = old;
  43929. }
  43930. }
  43931. for (name in oldOn) {
  43932. if (isUndef(on[name])) {
  43933. event = normalizeEvent(name);
  43934. remove$$1(event.name, oldOn[name], event.capture);
  43935. }
  43936. }
  43937. }
  43938. /* */
  43939. function mergeVNodeHook (def, hookKey, hook) {
  43940. if (def instanceof VNode) {
  43941. def = def.data.hook || (def.data.hook = {});
  43942. }
  43943. var invoker;
  43944. var oldHook = def[hookKey];
  43945. function wrappedHook () {
  43946. hook.apply(this, arguments);
  43947. // important: remove merged hook to ensure it's called only once
  43948. // and prevent memory leak
  43949. remove(invoker.fns, wrappedHook);
  43950. }
  43951. if (isUndef(oldHook)) {
  43952. // no existing hook
  43953. invoker = createFnInvoker([wrappedHook]);
  43954. } else {
  43955. /* istanbul ignore if */
  43956. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43957. // already a merged invoker
  43958. invoker = oldHook;
  43959. invoker.fns.push(wrappedHook);
  43960. } else {
  43961. // existing plain hook
  43962. invoker = createFnInvoker([oldHook, wrappedHook]);
  43963. }
  43964. }
  43965. invoker.merged = true;
  43966. def[hookKey] = invoker;
  43967. }
  43968. /* */
  43969. function extractPropsFromVNodeData (
  43970. data,
  43971. Ctor,
  43972. tag
  43973. ) {
  43974. // we are only extracting raw values here.
  43975. // validation and default values are handled in the child
  43976. // component itself.
  43977. var propOptions = Ctor.options.props;
  43978. if (isUndef(propOptions)) {
  43979. return
  43980. }
  43981. var res = {};
  43982. var attrs = data.attrs;
  43983. var props = data.props;
  43984. if (isDef(attrs) || isDef(props)) {
  43985. for (var key in propOptions) {
  43986. var altKey = hyphenate(key);
  43987. {
  43988. var keyInLowerCase = key.toLowerCase();
  43989. if (
  43990. key !== keyInLowerCase &&
  43991. attrs && hasOwn(attrs, keyInLowerCase)
  43992. ) {
  43993. tip(
  43994. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43995. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43996. " \"" + key + "\". " +
  43997. "Note that HTML attributes are case-insensitive and camelCased " +
  43998. "props need to use their kebab-case equivalents when using in-DOM " +
  43999. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  44000. );
  44001. }
  44002. }
  44003. checkProp(res, props, key, altKey, true) ||
  44004. checkProp(res, attrs, key, altKey, false);
  44005. }
  44006. }
  44007. return res
  44008. }
  44009. function checkProp (
  44010. res,
  44011. hash,
  44012. key,
  44013. altKey,
  44014. preserve
  44015. ) {
  44016. if (isDef(hash)) {
  44017. if (hasOwn(hash, key)) {
  44018. res[key] = hash[key];
  44019. if (!preserve) {
  44020. delete hash[key];
  44021. }
  44022. return true
  44023. } else if (hasOwn(hash, altKey)) {
  44024. res[key] = hash[altKey];
  44025. if (!preserve) {
  44026. delete hash[altKey];
  44027. }
  44028. return true
  44029. }
  44030. }
  44031. return false
  44032. }
  44033. /* */
  44034. // The template compiler attempts to minimize the need for normalization by
  44035. // statically analyzing the template at compile time.
  44036. //
  44037. // For plain HTML markup, normalization can be completely skipped because the
  44038. // generated render function is guaranteed to return Array<VNode>. There are
  44039. // two cases where extra normalization is needed:
  44040. // 1. When the children contains components - because a functional component
  44041. // may return an Array instead of a single root. In this case, just a simple
  44042. // normalization is needed - if any child is an Array, we flatten the whole
  44043. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  44044. // because functional components already normalize their own children.
  44045. function simpleNormalizeChildren (children) {
  44046. for (var i = 0; i < children.length; i++) {
  44047. if (Array.isArray(children[i])) {
  44048. return Array.prototype.concat.apply([], children)
  44049. }
  44050. }
  44051. return children
  44052. }
  44053. // 2. When the children contains constructs that always generated nested Arrays,
  44054. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  44055. // with hand-written render functions / JSX. In such cases a full normalization
  44056. // is needed to cater to all possible types of children values.
  44057. function normalizeChildren (children) {
  44058. return isPrimitive(children)
  44059. ? [createTextVNode(children)]
  44060. : Array.isArray(children)
  44061. ? normalizeArrayChildren(children)
  44062. : undefined
  44063. }
  44064. function isTextNode (node) {
  44065. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  44066. }
  44067. function normalizeArrayChildren (children, nestedIndex) {
  44068. var res = [];
  44069. var i, c, lastIndex, last;
  44070. for (i = 0; i < children.length; i++) {
  44071. c = children[i];
  44072. if (isUndef(c) || typeof c === 'boolean') { continue }
  44073. lastIndex = res.length - 1;
  44074. last = res[lastIndex];
  44075. // nested
  44076. if (Array.isArray(c)) {
  44077. if (c.length > 0) {
  44078. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  44079. // merge adjacent text nodes
  44080. if (isTextNode(c[0]) && isTextNode(last)) {
  44081. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  44082. c.shift();
  44083. }
  44084. res.push.apply(res, c);
  44085. }
  44086. } else if (isPrimitive(c)) {
  44087. if (isTextNode(last)) {
  44088. // merge adjacent text nodes
  44089. // this is necessary for SSR hydration because text nodes are
  44090. // essentially merged when rendered to HTML strings
  44091. res[lastIndex] = createTextVNode(last.text + c);
  44092. } else if (c !== '') {
  44093. // convert primitive to vnode
  44094. res.push(createTextVNode(c));
  44095. }
  44096. } else {
  44097. if (isTextNode(c) && isTextNode(last)) {
  44098. // merge adjacent text nodes
  44099. res[lastIndex] = createTextVNode(last.text + c.text);
  44100. } else {
  44101. // default key for nested array children (likely generated by v-for)
  44102. if (isTrue(children._isVList) &&
  44103. isDef(c.tag) &&
  44104. isUndef(c.key) &&
  44105. isDef(nestedIndex)) {
  44106. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  44107. }
  44108. res.push(c);
  44109. }
  44110. }
  44111. }
  44112. return res
  44113. }
  44114. /* */
  44115. function initProvide (vm) {
  44116. var provide = vm.$options.provide;
  44117. if (provide) {
  44118. vm._provided = typeof provide === 'function'
  44119. ? provide.call(vm)
  44120. : provide;
  44121. }
  44122. }
  44123. function initInjections (vm) {
  44124. var result = resolveInject(vm.$options.inject, vm);
  44125. if (result) {
  44126. toggleObserving(false);
  44127. Object.keys(result).forEach(function (key) {
  44128. /* istanbul ignore else */
  44129. {
  44130. defineReactive$$1(vm, key, result[key], function () {
  44131. warn(
  44132. "Avoid mutating an injected value directly since the changes will be " +
  44133. "overwritten whenever the provided component re-renders. " +
  44134. "injection being mutated: \"" + key + "\"",
  44135. vm
  44136. );
  44137. });
  44138. }
  44139. });
  44140. toggleObserving(true);
  44141. }
  44142. }
  44143. function resolveInject (inject, vm) {
  44144. if (inject) {
  44145. // inject is :any because flow is not smart enough to figure out cached
  44146. var result = Object.create(null);
  44147. var keys = hasSymbol
  44148. ? Reflect.ownKeys(inject)
  44149. : Object.keys(inject);
  44150. for (var i = 0; i < keys.length; i++) {
  44151. var key = keys[i];
  44152. // #6574 in case the inject object is observed...
  44153. if (key === '__ob__') { continue }
  44154. var provideKey = inject[key].from;
  44155. var source = vm;
  44156. while (source) {
  44157. if (source._provided && hasOwn(source._provided, provideKey)) {
  44158. result[key] = source._provided[provideKey];
  44159. break
  44160. }
  44161. source = source.$parent;
  44162. }
  44163. if (!source) {
  44164. if ('default' in inject[key]) {
  44165. var provideDefault = inject[key].default;
  44166. result[key] = typeof provideDefault === 'function'
  44167. ? provideDefault.call(vm)
  44168. : provideDefault;
  44169. } else {
  44170. warn(("Injection \"" + key + "\" not found"), vm);
  44171. }
  44172. }
  44173. }
  44174. return result
  44175. }
  44176. }
  44177. /* */
  44178. /**
  44179. * Runtime helper for resolving raw children VNodes into a slot object.
  44180. */
  44181. function resolveSlots (
  44182. children,
  44183. context
  44184. ) {
  44185. if (!children || !children.length) {
  44186. return {}
  44187. }
  44188. var slots = {};
  44189. for (var i = 0, l = children.length; i < l; i++) {
  44190. var child = children[i];
  44191. var data = child.data;
  44192. // remove slot attribute if the node is resolved as a Vue slot node
  44193. if (data && data.attrs && data.attrs.slot) {
  44194. delete data.attrs.slot;
  44195. }
  44196. // named slots should only be respected if the vnode was rendered in the
  44197. // same context.
  44198. if ((child.context === context || child.fnContext === context) &&
  44199. data && data.slot != null
  44200. ) {
  44201. var name = data.slot;
  44202. var slot = (slots[name] || (slots[name] = []));
  44203. if (child.tag === 'template') {
  44204. slot.push.apply(slot, child.children || []);
  44205. } else {
  44206. slot.push(child);
  44207. }
  44208. } else {
  44209. (slots.default || (slots.default = [])).push(child);
  44210. }
  44211. }
  44212. // ignore slots that contains only whitespace
  44213. for (var name$1 in slots) {
  44214. if (slots[name$1].every(isWhitespace)) {
  44215. delete slots[name$1];
  44216. }
  44217. }
  44218. return slots
  44219. }
  44220. function isWhitespace (node) {
  44221. return (node.isComment && !node.asyncFactory) || node.text === ' '
  44222. }
  44223. /* */
  44224. function normalizeScopedSlots (
  44225. slots,
  44226. normalSlots,
  44227. prevSlots
  44228. ) {
  44229. var res;
  44230. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44231. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44232. var key = slots && slots.$key;
  44233. if (!slots) {
  44234. res = {};
  44235. } else if (slots._normalized) {
  44236. // fast path 1: child component re-render only, parent did not change
  44237. return slots._normalized
  44238. } else if (
  44239. isStable &&
  44240. prevSlots &&
  44241. prevSlots !== emptyObject &&
  44242. key === prevSlots.$key &&
  44243. !hasNormalSlots &&
  44244. !prevSlots.$hasNormal
  44245. ) {
  44246. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44247. // only need to normalize once
  44248. return prevSlots
  44249. } else {
  44250. res = {};
  44251. for (var key$1 in slots) {
  44252. if (slots[key$1] && key$1[0] !== '$') {
  44253. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44254. }
  44255. }
  44256. }
  44257. // expose normal slots on scopedSlots
  44258. for (var key$2 in normalSlots) {
  44259. if (!(key$2 in res)) {
  44260. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44261. }
  44262. }
  44263. // avoriaz seems to mock a non-extensible $scopedSlots object
  44264. // and when that is passed down this would cause an error
  44265. if (slots && Object.isExtensible(slots)) {
  44266. (slots)._normalized = res;
  44267. }
  44268. def(res, '$stable', isStable);
  44269. def(res, '$key', key);
  44270. def(res, '$hasNormal', hasNormalSlots);
  44271. return res
  44272. }
  44273. function normalizeScopedSlot(normalSlots, key, fn) {
  44274. var normalized = function () {
  44275. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44276. res = res && typeof res === 'object' && !Array.isArray(res)
  44277. ? [res] // single vnode
  44278. : normalizeChildren(res);
  44279. return res && (
  44280. res.length === 0 ||
  44281. (res.length === 1 && res[0].isComment) // #9658
  44282. ) ? undefined
  44283. : res
  44284. };
  44285. // this is a slot using the new v-slot syntax without scope. although it is
  44286. // compiled as a scoped slot, render fn users would expect it to be present
  44287. // on this.$slots because the usage is semantically a normal slot.
  44288. if (fn.proxy) {
  44289. Object.defineProperty(normalSlots, key, {
  44290. get: normalized,
  44291. enumerable: true,
  44292. configurable: true
  44293. });
  44294. }
  44295. return normalized
  44296. }
  44297. function proxyNormalSlot(slots, key) {
  44298. return function () { return slots[key]; }
  44299. }
  44300. /* */
  44301. /**
  44302. * Runtime helper for rendering v-for lists.
  44303. */
  44304. function renderList (
  44305. val,
  44306. render
  44307. ) {
  44308. var ret, i, l, keys, key;
  44309. if (Array.isArray(val) || typeof val === 'string') {
  44310. ret = new Array(val.length);
  44311. for (i = 0, l = val.length; i < l; i++) {
  44312. ret[i] = render(val[i], i);
  44313. }
  44314. } else if (typeof val === 'number') {
  44315. ret = new Array(val);
  44316. for (i = 0; i < val; i++) {
  44317. ret[i] = render(i + 1, i);
  44318. }
  44319. } else if (isObject(val)) {
  44320. if (hasSymbol && val[Symbol.iterator]) {
  44321. ret = [];
  44322. var iterator = val[Symbol.iterator]();
  44323. var result = iterator.next();
  44324. while (!result.done) {
  44325. ret.push(render(result.value, ret.length));
  44326. result = iterator.next();
  44327. }
  44328. } else {
  44329. keys = Object.keys(val);
  44330. ret = new Array(keys.length);
  44331. for (i = 0, l = keys.length; i < l; i++) {
  44332. key = keys[i];
  44333. ret[i] = render(val[key], key, i);
  44334. }
  44335. }
  44336. }
  44337. if (!isDef(ret)) {
  44338. ret = [];
  44339. }
  44340. (ret)._isVList = true;
  44341. return ret
  44342. }
  44343. /* */
  44344. /**
  44345. * Runtime helper for rendering <slot>
  44346. */
  44347. function renderSlot (
  44348. name,
  44349. fallback,
  44350. props,
  44351. bindObject
  44352. ) {
  44353. var scopedSlotFn = this.$scopedSlots[name];
  44354. var nodes;
  44355. if (scopedSlotFn) { // scoped slot
  44356. props = props || {};
  44357. if (bindObject) {
  44358. if (!isObject(bindObject)) {
  44359. warn(
  44360. 'slot v-bind without argument expects an Object',
  44361. this
  44362. );
  44363. }
  44364. props = extend(extend({}, bindObject), props);
  44365. }
  44366. nodes = scopedSlotFn(props) || fallback;
  44367. } else {
  44368. nodes = this.$slots[name] || fallback;
  44369. }
  44370. var target = props && props.slot;
  44371. if (target) {
  44372. return this.$createElement('template', { slot: target }, nodes)
  44373. } else {
  44374. return nodes
  44375. }
  44376. }
  44377. /* */
  44378. /**
  44379. * Runtime helper for resolving filters
  44380. */
  44381. function resolveFilter (id) {
  44382. return resolveAsset(this.$options, 'filters', id, true) || identity
  44383. }
  44384. /* */
  44385. function isKeyNotMatch (expect, actual) {
  44386. if (Array.isArray(expect)) {
  44387. return expect.indexOf(actual) === -1
  44388. } else {
  44389. return expect !== actual
  44390. }
  44391. }
  44392. /**
  44393. * Runtime helper for checking keyCodes from config.
  44394. * exposed as Vue.prototype._k
  44395. * passing in eventKeyName as last argument separately for backwards compat
  44396. */
  44397. function checkKeyCodes (
  44398. eventKeyCode,
  44399. key,
  44400. builtInKeyCode,
  44401. eventKeyName,
  44402. builtInKeyName
  44403. ) {
  44404. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44405. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44406. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44407. } else if (mappedKeyCode) {
  44408. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44409. } else if (eventKeyName) {
  44410. return hyphenate(eventKeyName) !== key
  44411. }
  44412. }
  44413. /* */
  44414. /**
  44415. * Runtime helper for merging v-bind="object" into a VNode's data.
  44416. */
  44417. function bindObjectProps (
  44418. data,
  44419. tag,
  44420. value,
  44421. asProp,
  44422. isSync
  44423. ) {
  44424. if (value) {
  44425. if (!isObject(value)) {
  44426. warn(
  44427. 'v-bind without argument expects an Object or Array value',
  44428. this
  44429. );
  44430. } else {
  44431. if (Array.isArray(value)) {
  44432. value = toObject(value);
  44433. }
  44434. var hash;
  44435. var loop = function ( key ) {
  44436. if (
  44437. key === 'class' ||
  44438. key === 'style' ||
  44439. isReservedAttribute(key)
  44440. ) {
  44441. hash = data;
  44442. } else {
  44443. var type = data.attrs && data.attrs.type;
  44444. hash = asProp || config.mustUseProp(tag, type, key)
  44445. ? data.domProps || (data.domProps = {})
  44446. : data.attrs || (data.attrs = {});
  44447. }
  44448. var camelizedKey = camelize(key);
  44449. var hyphenatedKey = hyphenate(key);
  44450. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44451. hash[key] = value[key];
  44452. if (isSync) {
  44453. var on = data.on || (data.on = {});
  44454. on[("update:" + key)] = function ($event) {
  44455. value[key] = $event;
  44456. };
  44457. }
  44458. }
  44459. };
  44460. for (var key in value) loop( key );
  44461. }
  44462. }
  44463. return data
  44464. }
  44465. /* */
  44466. /**
  44467. * Runtime helper for rendering static trees.
  44468. */
  44469. function renderStatic (
  44470. index,
  44471. isInFor
  44472. ) {
  44473. var cached = this._staticTrees || (this._staticTrees = []);
  44474. var tree = cached[index];
  44475. // if has already-rendered static tree and not inside v-for,
  44476. // we can reuse the same tree.
  44477. if (tree && !isInFor) {
  44478. return tree
  44479. }
  44480. // otherwise, render a fresh tree.
  44481. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44482. this._renderProxy,
  44483. null,
  44484. this // for render fns generated for functional component templates
  44485. );
  44486. markStatic(tree, ("__static__" + index), false);
  44487. return tree
  44488. }
  44489. /**
  44490. * Runtime helper for v-once.
  44491. * Effectively it means marking the node as static with a unique key.
  44492. */
  44493. function markOnce (
  44494. tree,
  44495. index,
  44496. key
  44497. ) {
  44498. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44499. return tree
  44500. }
  44501. function markStatic (
  44502. tree,
  44503. key,
  44504. isOnce
  44505. ) {
  44506. if (Array.isArray(tree)) {
  44507. for (var i = 0; i < tree.length; i++) {
  44508. if (tree[i] && typeof tree[i] !== 'string') {
  44509. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44510. }
  44511. }
  44512. } else {
  44513. markStaticNode(tree, key, isOnce);
  44514. }
  44515. }
  44516. function markStaticNode (node, key, isOnce) {
  44517. node.isStatic = true;
  44518. node.key = key;
  44519. node.isOnce = isOnce;
  44520. }
  44521. /* */
  44522. function bindObjectListeners (data, value) {
  44523. if (value) {
  44524. if (!isPlainObject(value)) {
  44525. warn(
  44526. 'v-on without argument expects an Object value',
  44527. this
  44528. );
  44529. } else {
  44530. var on = data.on = data.on ? extend({}, data.on) : {};
  44531. for (var key in value) {
  44532. var existing = on[key];
  44533. var ours = value[key];
  44534. on[key] = existing ? [].concat(existing, ours) : ours;
  44535. }
  44536. }
  44537. }
  44538. return data
  44539. }
  44540. /* */
  44541. function resolveScopedSlots (
  44542. fns, // see flow/vnode
  44543. res,
  44544. // the following are added in 2.6
  44545. hasDynamicKeys,
  44546. contentHashKey
  44547. ) {
  44548. res = res || { $stable: !hasDynamicKeys };
  44549. for (var i = 0; i < fns.length; i++) {
  44550. var slot = fns[i];
  44551. if (Array.isArray(slot)) {
  44552. resolveScopedSlots(slot, res, hasDynamicKeys);
  44553. } else if (slot) {
  44554. // marker for reverse proxying v-slot without scope on this.$slots
  44555. if (slot.proxy) {
  44556. slot.fn.proxy = true;
  44557. }
  44558. res[slot.key] = slot.fn;
  44559. }
  44560. }
  44561. if (contentHashKey) {
  44562. (res).$key = contentHashKey;
  44563. }
  44564. return res
  44565. }
  44566. /* */
  44567. function bindDynamicKeys (baseObj, values) {
  44568. for (var i = 0; i < values.length; i += 2) {
  44569. var key = values[i];
  44570. if (typeof key === 'string' && key) {
  44571. baseObj[values[i]] = values[i + 1];
  44572. } else if (key !== '' && key !== null) {
  44573. // null is a special value for explicitly removing a binding
  44574. warn(
  44575. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44576. this
  44577. );
  44578. }
  44579. }
  44580. return baseObj
  44581. }
  44582. // helper to dynamically append modifier runtime markers to event names.
  44583. // ensure only append when value is already string, otherwise it will be cast
  44584. // to string and cause the type check to miss.
  44585. function prependModifier (value, symbol) {
  44586. return typeof value === 'string' ? symbol + value : value
  44587. }
  44588. /* */
  44589. function installRenderHelpers (target) {
  44590. target._o = markOnce;
  44591. target._n = toNumber;
  44592. target._s = toString;
  44593. target._l = renderList;
  44594. target._t = renderSlot;
  44595. target._q = looseEqual;
  44596. target._i = looseIndexOf;
  44597. target._m = renderStatic;
  44598. target._f = resolveFilter;
  44599. target._k = checkKeyCodes;
  44600. target._b = bindObjectProps;
  44601. target._v = createTextVNode;
  44602. target._e = createEmptyVNode;
  44603. target._u = resolveScopedSlots;
  44604. target._g = bindObjectListeners;
  44605. target._d = bindDynamicKeys;
  44606. target._p = prependModifier;
  44607. }
  44608. /* */
  44609. function FunctionalRenderContext (
  44610. data,
  44611. props,
  44612. children,
  44613. parent,
  44614. Ctor
  44615. ) {
  44616. var this$1 = this;
  44617. var options = Ctor.options;
  44618. // ensure the createElement function in functional components
  44619. // gets a unique context - this is necessary for correct named slot check
  44620. var contextVm;
  44621. if (hasOwn(parent, '_uid')) {
  44622. contextVm = Object.create(parent);
  44623. // $flow-disable-line
  44624. contextVm._original = parent;
  44625. } else {
  44626. // the context vm passed in is a functional context as well.
  44627. // in this case we want to make sure we are able to get a hold to the
  44628. // real context instance.
  44629. contextVm = parent;
  44630. // $flow-disable-line
  44631. parent = parent._original;
  44632. }
  44633. var isCompiled = isTrue(options._compiled);
  44634. var needNormalization = !isCompiled;
  44635. this.data = data;
  44636. this.props = props;
  44637. this.children = children;
  44638. this.parent = parent;
  44639. this.listeners = data.on || emptyObject;
  44640. this.injections = resolveInject(options.inject, parent);
  44641. this.slots = function () {
  44642. if (!this$1.$slots) {
  44643. normalizeScopedSlots(
  44644. data.scopedSlots,
  44645. this$1.$slots = resolveSlots(children, parent)
  44646. );
  44647. }
  44648. return this$1.$slots
  44649. };
  44650. Object.defineProperty(this, 'scopedSlots', ({
  44651. enumerable: true,
  44652. get: function get () {
  44653. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44654. }
  44655. }));
  44656. // support for compiled functional template
  44657. if (isCompiled) {
  44658. // exposing $options for renderStatic()
  44659. this.$options = options;
  44660. // pre-resolve slots for renderSlot()
  44661. this.$slots = this.slots();
  44662. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44663. }
  44664. if (options._scopeId) {
  44665. this._c = function (a, b, c, d) {
  44666. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44667. if (vnode && !Array.isArray(vnode)) {
  44668. vnode.fnScopeId = options._scopeId;
  44669. vnode.fnContext = parent;
  44670. }
  44671. return vnode
  44672. };
  44673. } else {
  44674. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44675. }
  44676. }
  44677. installRenderHelpers(FunctionalRenderContext.prototype);
  44678. function createFunctionalComponent (
  44679. Ctor,
  44680. propsData,
  44681. data,
  44682. contextVm,
  44683. children
  44684. ) {
  44685. var options = Ctor.options;
  44686. var props = {};
  44687. var propOptions = options.props;
  44688. if (isDef(propOptions)) {
  44689. for (var key in propOptions) {
  44690. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44691. }
  44692. } else {
  44693. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44694. if (isDef(data.props)) { mergeProps(props, data.props); }
  44695. }
  44696. var renderContext = new FunctionalRenderContext(
  44697. data,
  44698. props,
  44699. children,
  44700. contextVm,
  44701. Ctor
  44702. );
  44703. var vnode = options.render.call(null, renderContext._c, renderContext);
  44704. if (vnode instanceof VNode) {
  44705. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44706. } else if (Array.isArray(vnode)) {
  44707. var vnodes = normalizeChildren(vnode) || [];
  44708. var res = new Array(vnodes.length);
  44709. for (var i = 0; i < vnodes.length; i++) {
  44710. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44711. }
  44712. return res
  44713. }
  44714. }
  44715. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44716. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44717. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44718. // that should not be matched to match.
  44719. var clone = cloneVNode(vnode);
  44720. clone.fnContext = contextVm;
  44721. clone.fnOptions = options;
  44722. {
  44723. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44724. }
  44725. if (data.slot) {
  44726. (clone.data || (clone.data = {})).slot = data.slot;
  44727. }
  44728. return clone
  44729. }
  44730. function mergeProps (to, from) {
  44731. for (var key in from) {
  44732. to[camelize(key)] = from[key];
  44733. }
  44734. }
  44735. /* */
  44736. /* */
  44737. /* */
  44738. /* */
  44739. // inline hooks to be invoked on component VNodes during patch
  44740. var componentVNodeHooks = {
  44741. init: function init (vnode, hydrating) {
  44742. if (
  44743. vnode.componentInstance &&
  44744. !vnode.componentInstance._isDestroyed &&
  44745. vnode.data.keepAlive
  44746. ) {
  44747. // kept-alive components, treat as a patch
  44748. var mountedNode = vnode; // work around flow
  44749. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44750. } else {
  44751. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44752. vnode,
  44753. activeInstance
  44754. );
  44755. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44756. }
  44757. },
  44758. prepatch: function prepatch (oldVnode, vnode) {
  44759. var options = vnode.componentOptions;
  44760. var child = vnode.componentInstance = oldVnode.componentInstance;
  44761. updateChildComponent(
  44762. child,
  44763. options.propsData, // updated props
  44764. options.listeners, // updated listeners
  44765. vnode, // new parent vnode
  44766. options.children // new children
  44767. );
  44768. },
  44769. insert: function insert (vnode) {
  44770. var context = vnode.context;
  44771. var componentInstance = vnode.componentInstance;
  44772. if (!componentInstance._isMounted) {
  44773. componentInstance._isMounted = true;
  44774. callHook(componentInstance, 'mounted');
  44775. }
  44776. if (vnode.data.keepAlive) {
  44777. if (context._isMounted) {
  44778. // vue-router#1212
  44779. // During updates, a kept-alive component's child components may
  44780. // change, so directly walking the tree here may call activated hooks
  44781. // on incorrect children. Instead we push them into a queue which will
  44782. // be processed after the whole patch process ended.
  44783. queueActivatedComponent(componentInstance);
  44784. } else {
  44785. activateChildComponent(componentInstance, true /* direct */);
  44786. }
  44787. }
  44788. },
  44789. destroy: function destroy (vnode) {
  44790. var componentInstance = vnode.componentInstance;
  44791. if (!componentInstance._isDestroyed) {
  44792. if (!vnode.data.keepAlive) {
  44793. componentInstance.$destroy();
  44794. } else {
  44795. deactivateChildComponent(componentInstance, true /* direct */);
  44796. }
  44797. }
  44798. }
  44799. };
  44800. var hooksToMerge = Object.keys(componentVNodeHooks);
  44801. function createComponent (
  44802. Ctor,
  44803. data,
  44804. context,
  44805. children,
  44806. tag
  44807. ) {
  44808. if (isUndef(Ctor)) {
  44809. return
  44810. }
  44811. var baseCtor = context.$options._base;
  44812. // plain options object: turn it into a constructor
  44813. if (isObject(Ctor)) {
  44814. Ctor = baseCtor.extend(Ctor);
  44815. }
  44816. // if at this stage it's not a constructor or an async component factory,
  44817. // reject.
  44818. if (typeof Ctor !== 'function') {
  44819. {
  44820. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44821. }
  44822. return
  44823. }
  44824. // async component
  44825. var asyncFactory;
  44826. if (isUndef(Ctor.cid)) {
  44827. asyncFactory = Ctor;
  44828. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44829. if (Ctor === undefined) {
  44830. // return a placeholder node for async component, which is rendered
  44831. // as a comment node but preserves all the raw information for the node.
  44832. // the information will be used for async server-rendering and hydration.
  44833. return createAsyncPlaceholder(
  44834. asyncFactory,
  44835. data,
  44836. context,
  44837. children,
  44838. tag
  44839. )
  44840. }
  44841. }
  44842. data = data || {};
  44843. // resolve constructor options in case global mixins are applied after
  44844. // component constructor creation
  44845. resolveConstructorOptions(Ctor);
  44846. // transform component v-model data into props & events
  44847. if (isDef(data.model)) {
  44848. transformModel(Ctor.options, data);
  44849. }
  44850. // extract props
  44851. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44852. // functional component
  44853. if (isTrue(Ctor.options.functional)) {
  44854. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44855. }
  44856. // extract listeners, since these needs to be treated as
  44857. // child component listeners instead of DOM listeners
  44858. var listeners = data.on;
  44859. // replace with listeners with .native modifier
  44860. // so it gets processed during parent component patch.
  44861. data.on = data.nativeOn;
  44862. if (isTrue(Ctor.options.abstract)) {
  44863. // abstract components do not keep anything
  44864. // other than props & listeners & slot
  44865. // work around flow
  44866. var slot = data.slot;
  44867. data = {};
  44868. if (slot) {
  44869. data.slot = slot;
  44870. }
  44871. }
  44872. // install component management hooks onto the placeholder node
  44873. installComponentHooks(data);
  44874. // return a placeholder vnode
  44875. var name = Ctor.options.name || tag;
  44876. var vnode = new VNode(
  44877. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44878. data, undefined, undefined, undefined, context,
  44879. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44880. asyncFactory
  44881. );
  44882. return vnode
  44883. }
  44884. function createComponentInstanceForVnode (
  44885. vnode, // we know it's MountedComponentVNode but flow doesn't
  44886. parent // activeInstance in lifecycle state
  44887. ) {
  44888. var options = {
  44889. _isComponent: true,
  44890. _parentVnode: vnode,
  44891. parent: parent
  44892. };
  44893. // check inline-template render functions
  44894. var inlineTemplate = vnode.data.inlineTemplate;
  44895. if (isDef(inlineTemplate)) {
  44896. options.render = inlineTemplate.render;
  44897. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44898. }
  44899. return new vnode.componentOptions.Ctor(options)
  44900. }
  44901. function installComponentHooks (data) {
  44902. var hooks = data.hook || (data.hook = {});
  44903. for (var i = 0; i < hooksToMerge.length; i++) {
  44904. var key = hooksToMerge[i];
  44905. var existing = hooks[key];
  44906. var toMerge = componentVNodeHooks[key];
  44907. if (existing !== toMerge && !(existing && existing._merged)) {
  44908. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44909. }
  44910. }
  44911. }
  44912. function mergeHook$1 (f1, f2) {
  44913. var merged = function (a, b) {
  44914. // flow complains about extra args which is why we use any
  44915. f1(a, b);
  44916. f2(a, b);
  44917. };
  44918. merged._merged = true;
  44919. return merged
  44920. }
  44921. // transform component v-model info (value and callback) into
  44922. // prop and event handler respectively.
  44923. function transformModel (options, data) {
  44924. var prop = (options.model && options.model.prop) || 'value';
  44925. var event = (options.model && options.model.event) || 'input'
  44926. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44927. var on = data.on || (data.on = {});
  44928. var existing = on[event];
  44929. var callback = data.model.callback;
  44930. if (isDef(existing)) {
  44931. if (
  44932. Array.isArray(existing)
  44933. ? existing.indexOf(callback) === -1
  44934. : existing !== callback
  44935. ) {
  44936. on[event] = [callback].concat(existing);
  44937. }
  44938. } else {
  44939. on[event] = callback;
  44940. }
  44941. }
  44942. /* */
  44943. var SIMPLE_NORMALIZE = 1;
  44944. var ALWAYS_NORMALIZE = 2;
  44945. // wrapper function for providing a more flexible interface
  44946. // without getting yelled at by flow
  44947. function createElement (
  44948. context,
  44949. tag,
  44950. data,
  44951. children,
  44952. normalizationType,
  44953. alwaysNormalize
  44954. ) {
  44955. if (Array.isArray(data) || isPrimitive(data)) {
  44956. normalizationType = children;
  44957. children = data;
  44958. data = undefined;
  44959. }
  44960. if (isTrue(alwaysNormalize)) {
  44961. normalizationType = ALWAYS_NORMALIZE;
  44962. }
  44963. return _createElement(context, tag, data, children, normalizationType)
  44964. }
  44965. function _createElement (
  44966. context,
  44967. tag,
  44968. data,
  44969. children,
  44970. normalizationType
  44971. ) {
  44972. if (isDef(data) && isDef((data).__ob__)) {
  44973. warn(
  44974. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44975. 'Always create fresh vnode data objects in each render!',
  44976. context
  44977. );
  44978. return createEmptyVNode()
  44979. }
  44980. // object syntax in v-bind
  44981. if (isDef(data) && isDef(data.is)) {
  44982. tag = data.is;
  44983. }
  44984. if (!tag) {
  44985. // in case of component :is set to falsy value
  44986. return createEmptyVNode()
  44987. }
  44988. // warn against non-primitive key
  44989. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44990. ) {
  44991. {
  44992. warn(
  44993. 'Avoid using non-primitive value as key, ' +
  44994. 'use string/number value instead.',
  44995. context
  44996. );
  44997. }
  44998. }
  44999. // support single function children as default scoped slot
  45000. if (Array.isArray(children) &&
  45001. typeof children[0] === 'function'
  45002. ) {
  45003. data = data || {};
  45004. data.scopedSlots = { default: children[0] };
  45005. children.length = 0;
  45006. }
  45007. if (normalizationType === ALWAYS_NORMALIZE) {
  45008. children = normalizeChildren(children);
  45009. } else if (normalizationType === SIMPLE_NORMALIZE) {
  45010. children = simpleNormalizeChildren(children);
  45011. }
  45012. var vnode, ns;
  45013. if (typeof tag === 'string') {
  45014. var Ctor;
  45015. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  45016. if (config.isReservedTag(tag)) {
  45017. // platform built-in elements
  45018. if (isDef(data) && isDef(data.nativeOn)) {
  45019. warn(
  45020. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  45021. context
  45022. );
  45023. }
  45024. vnode = new VNode(
  45025. config.parsePlatformTagName(tag), data, children,
  45026. undefined, undefined, context
  45027. );
  45028. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  45029. // component
  45030. vnode = createComponent(Ctor, data, context, children, tag);
  45031. } else {
  45032. // unknown or unlisted namespaced elements
  45033. // check at runtime because it may get assigned a namespace when its
  45034. // parent normalizes children
  45035. vnode = new VNode(
  45036. tag, data, children,
  45037. undefined, undefined, context
  45038. );
  45039. }
  45040. } else {
  45041. // direct component options / constructor
  45042. vnode = createComponent(tag, data, context, children);
  45043. }
  45044. if (Array.isArray(vnode)) {
  45045. return vnode
  45046. } else if (isDef(vnode)) {
  45047. if (isDef(ns)) { applyNS(vnode, ns); }
  45048. if (isDef(data)) { registerDeepBindings(data); }
  45049. return vnode
  45050. } else {
  45051. return createEmptyVNode()
  45052. }
  45053. }
  45054. function applyNS (vnode, ns, force) {
  45055. vnode.ns = ns;
  45056. if (vnode.tag === 'foreignObject') {
  45057. // use default namespace inside foreignObject
  45058. ns = undefined;
  45059. force = true;
  45060. }
  45061. if (isDef(vnode.children)) {
  45062. for (var i = 0, l = vnode.children.length; i < l; i++) {
  45063. var child = vnode.children[i];
  45064. if (isDef(child.tag) && (
  45065. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  45066. applyNS(child, ns, force);
  45067. }
  45068. }
  45069. }
  45070. }
  45071. // ref #5318
  45072. // necessary to ensure parent re-render when deep bindings like :style and
  45073. // :class are used on slot nodes
  45074. function registerDeepBindings (data) {
  45075. if (isObject(data.style)) {
  45076. traverse(data.style);
  45077. }
  45078. if (isObject(data.class)) {
  45079. traverse(data.class);
  45080. }
  45081. }
  45082. /* */
  45083. function initRender (vm) {
  45084. vm._vnode = null; // the root of the child tree
  45085. vm._staticTrees = null; // v-once cached trees
  45086. var options = vm.$options;
  45087. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  45088. var renderContext = parentVnode && parentVnode.context;
  45089. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  45090. vm.$scopedSlots = emptyObject;
  45091. // bind the createElement fn to this instance
  45092. // so that we get proper render context inside it.
  45093. // args order: tag, data, children, normalizationType, alwaysNormalize
  45094. // internal version is used by render functions compiled from templates
  45095. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  45096. // normalization is always applied for the public version, used in
  45097. // user-written render functions.
  45098. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  45099. // $attrs & $listeners are exposed for easier HOC creation.
  45100. // they need to be reactive so that HOCs using them are always updated
  45101. var parentData = parentVnode && parentVnode.data;
  45102. /* istanbul ignore else */
  45103. {
  45104. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  45105. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  45106. }, true);
  45107. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  45108. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  45109. }, true);
  45110. }
  45111. }
  45112. var currentRenderingInstance = null;
  45113. function renderMixin (Vue) {
  45114. // install runtime convenience helpers
  45115. installRenderHelpers(Vue.prototype);
  45116. Vue.prototype.$nextTick = function (fn) {
  45117. return nextTick(fn, this)
  45118. };
  45119. Vue.prototype._render = function () {
  45120. var vm = this;
  45121. var ref = vm.$options;
  45122. var render = ref.render;
  45123. var _parentVnode = ref._parentVnode;
  45124. if (_parentVnode) {
  45125. vm.$scopedSlots = normalizeScopedSlots(
  45126. _parentVnode.data.scopedSlots,
  45127. vm.$slots,
  45128. vm.$scopedSlots
  45129. );
  45130. }
  45131. // set parent vnode. this allows render functions to have access
  45132. // to the data on the placeholder node.
  45133. vm.$vnode = _parentVnode;
  45134. // render self
  45135. var vnode;
  45136. try {
  45137. // There's no need to maintain a stack because all render fns are called
  45138. // separately from one another. Nested component's render fns are called
  45139. // when parent component is patched.
  45140. currentRenderingInstance = vm;
  45141. vnode = render.call(vm._renderProxy, vm.$createElement);
  45142. } catch (e) {
  45143. handleError(e, vm, "render");
  45144. // return error render result,
  45145. // or previous vnode to prevent render error causing blank component
  45146. /* istanbul ignore else */
  45147. if (vm.$options.renderError) {
  45148. try {
  45149. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  45150. } catch (e) {
  45151. handleError(e, vm, "renderError");
  45152. vnode = vm._vnode;
  45153. }
  45154. } else {
  45155. vnode = vm._vnode;
  45156. }
  45157. } finally {
  45158. currentRenderingInstance = null;
  45159. }
  45160. // if the returned array contains only a single node, allow it
  45161. if (Array.isArray(vnode) && vnode.length === 1) {
  45162. vnode = vnode[0];
  45163. }
  45164. // return empty vnode in case the render function errored out
  45165. if (!(vnode instanceof VNode)) {
  45166. if (Array.isArray(vnode)) {
  45167. warn(
  45168. 'Multiple root nodes returned from render function. Render function ' +
  45169. 'should return a single root node.',
  45170. vm
  45171. );
  45172. }
  45173. vnode = createEmptyVNode();
  45174. }
  45175. // set parent
  45176. vnode.parent = _parentVnode;
  45177. return vnode
  45178. };
  45179. }
  45180. /* */
  45181. function ensureCtor (comp, base) {
  45182. if (
  45183. comp.__esModule ||
  45184. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  45185. ) {
  45186. comp = comp.default;
  45187. }
  45188. return isObject(comp)
  45189. ? base.extend(comp)
  45190. : comp
  45191. }
  45192. function createAsyncPlaceholder (
  45193. factory,
  45194. data,
  45195. context,
  45196. children,
  45197. tag
  45198. ) {
  45199. var node = createEmptyVNode();
  45200. node.asyncFactory = factory;
  45201. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  45202. return node
  45203. }
  45204. function resolveAsyncComponent (
  45205. factory,
  45206. baseCtor
  45207. ) {
  45208. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  45209. return factory.errorComp
  45210. }
  45211. if (isDef(factory.resolved)) {
  45212. return factory.resolved
  45213. }
  45214. var owner = currentRenderingInstance;
  45215. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  45216. // already pending
  45217. factory.owners.push(owner);
  45218. }
  45219. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  45220. return factory.loadingComp
  45221. }
  45222. if (owner && !isDef(factory.owners)) {
  45223. var owners = factory.owners = [owner];
  45224. var sync = true;
  45225. var timerLoading = null;
  45226. var timerTimeout = null
  45227. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45228. var forceRender = function (renderCompleted) {
  45229. for (var i = 0, l = owners.length; i < l; i++) {
  45230. (owners[i]).$forceUpdate();
  45231. }
  45232. if (renderCompleted) {
  45233. owners.length = 0;
  45234. if (timerLoading !== null) {
  45235. clearTimeout(timerLoading);
  45236. timerLoading = null;
  45237. }
  45238. if (timerTimeout !== null) {
  45239. clearTimeout(timerTimeout);
  45240. timerTimeout = null;
  45241. }
  45242. }
  45243. };
  45244. var resolve = once(function (res) {
  45245. // cache resolved
  45246. factory.resolved = ensureCtor(res, baseCtor);
  45247. // invoke callbacks only if this is not a synchronous resolve
  45248. // (async resolves are shimmed as synchronous during SSR)
  45249. if (!sync) {
  45250. forceRender(true);
  45251. } else {
  45252. owners.length = 0;
  45253. }
  45254. });
  45255. var reject = once(function (reason) {
  45256. warn(
  45257. "Failed to resolve async component: " + (String(factory)) +
  45258. (reason ? ("\nReason: " + reason) : '')
  45259. );
  45260. if (isDef(factory.errorComp)) {
  45261. factory.error = true;
  45262. forceRender(true);
  45263. }
  45264. });
  45265. var res = factory(resolve, reject);
  45266. if (isObject(res)) {
  45267. if (isPromise(res)) {
  45268. // () => Promise
  45269. if (isUndef(factory.resolved)) {
  45270. res.then(resolve, reject);
  45271. }
  45272. } else if (isPromise(res.component)) {
  45273. res.component.then(resolve, reject);
  45274. if (isDef(res.error)) {
  45275. factory.errorComp = ensureCtor(res.error, baseCtor);
  45276. }
  45277. if (isDef(res.loading)) {
  45278. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45279. if (res.delay === 0) {
  45280. factory.loading = true;
  45281. } else {
  45282. timerLoading = setTimeout(function () {
  45283. timerLoading = null;
  45284. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45285. factory.loading = true;
  45286. forceRender(false);
  45287. }
  45288. }, res.delay || 200);
  45289. }
  45290. }
  45291. if (isDef(res.timeout)) {
  45292. timerTimeout = setTimeout(function () {
  45293. timerTimeout = null;
  45294. if (isUndef(factory.resolved)) {
  45295. reject(
  45296. "timeout (" + (res.timeout) + "ms)"
  45297. );
  45298. }
  45299. }, res.timeout);
  45300. }
  45301. }
  45302. }
  45303. sync = false;
  45304. // return in case resolved synchronously
  45305. return factory.loading
  45306. ? factory.loadingComp
  45307. : factory.resolved
  45308. }
  45309. }
  45310. /* */
  45311. function isAsyncPlaceholder (node) {
  45312. return node.isComment && node.asyncFactory
  45313. }
  45314. /* */
  45315. function getFirstComponentChild (children) {
  45316. if (Array.isArray(children)) {
  45317. for (var i = 0; i < children.length; i++) {
  45318. var c = children[i];
  45319. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45320. return c
  45321. }
  45322. }
  45323. }
  45324. }
  45325. /* */
  45326. /* */
  45327. function initEvents (vm) {
  45328. vm._events = Object.create(null);
  45329. vm._hasHookEvent = false;
  45330. // init parent attached events
  45331. var listeners = vm.$options._parentListeners;
  45332. if (listeners) {
  45333. updateComponentListeners(vm, listeners);
  45334. }
  45335. }
  45336. var target;
  45337. function add (event, fn) {
  45338. target.$on(event, fn);
  45339. }
  45340. function remove$1 (event, fn) {
  45341. target.$off(event, fn);
  45342. }
  45343. function createOnceHandler (event, fn) {
  45344. var _target = target;
  45345. return function onceHandler () {
  45346. var res = fn.apply(null, arguments);
  45347. if (res !== null) {
  45348. _target.$off(event, onceHandler);
  45349. }
  45350. }
  45351. }
  45352. function updateComponentListeners (
  45353. vm,
  45354. listeners,
  45355. oldListeners
  45356. ) {
  45357. target = vm;
  45358. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45359. target = undefined;
  45360. }
  45361. function eventsMixin (Vue) {
  45362. var hookRE = /^hook:/;
  45363. Vue.prototype.$on = function (event, fn) {
  45364. var vm = this;
  45365. if (Array.isArray(event)) {
  45366. for (var i = 0, l = event.length; i < l; i++) {
  45367. vm.$on(event[i], fn);
  45368. }
  45369. } else {
  45370. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45371. // optimize hook:event cost by using a boolean flag marked at registration
  45372. // instead of a hash lookup
  45373. if (hookRE.test(event)) {
  45374. vm._hasHookEvent = true;
  45375. }
  45376. }
  45377. return vm
  45378. };
  45379. Vue.prototype.$once = function (event, fn) {
  45380. var vm = this;
  45381. function on () {
  45382. vm.$off(event, on);
  45383. fn.apply(vm, arguments);
  45384. }
  45385. on.fn = fn;
  45386. vm.$on(event, on);
  45387. return vm
  45388. };
  45389. Vue.prototype.$off = function (event, fn) {
  45390. var vm = this;
  45391. // all
  45392. if (!arguments.length) {
  45393. vm._events = Object.create(null);
  45394. return vm
  45395. }
  45396. // array of events
  45397. if (Array.isArray(event)) {
  45398. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45399. vm.$off(event[i$1], fn);
  45400. }
  45401. return vm
  45402. }
  45403. // specific event
  45404. var cbs = vm._events[event];
  45405. if (!cbs) {
  45406. return vm
  45407. }
  45408. if (!fn) {
  45409. vm._events[event] = null;
  45410. return vm
  45411. }
  45412. // specific handler
  45413. var cb;
  45414. var i = cbs.length;
  45415. while (i--) {
  45416. cb = cbs[i];
  45417. if (cb === fn || cb.fn === fn) {
  45418. cbs.splice(i, 1);
  45419. break
  45420. }
  45421. }
  45422. return vm
  45423. };
  45424. Vue.prototype.$emit = function (event) {
  45425. var vm = this;
  45426. {
  45427. var lowerCaseEvent = event.toLowerCase();
  45428. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45429. tip(
  45430. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45431. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45432. "Note that HTML attributes are case-insensitive and you cannot use " +
  45433. "v-on to listen to camelCase events when using in-DOM templates. " +
  45434. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45435. );
  45436. }
  45437. }
  45438. var cbs = vm._events[event];
  45439. if (cbs) {
  45440. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45441. var args = toArray(arguments, 1);
  45442. var info = "event handler for \"" + event + "\"";
  45443. for (var i = 0, l = cbs.length; i < l; i++) {
  45444. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45445. }
  45446. }
  45447. return vm
  45448. };
  45449. }
  45450. /* */
  45451. var activeInstance = null;
  45452. var isUpdatingChildComponent = false;
  45453. function setActiveInstance(vm) {
  45454. var prevActiveInstance = activeInstance;
  45455. activeInstance = vm;
  45456. return function () {
  45457. activeInstance = prevActiveInstance;
  45458. }
  45459. }
  45460. function initLifecycle (vm) {
  45461. var options = vm.$options;
  45462. // locate first non-abstract parent
  45463. var parent = options.parent;
  45464. if (parent && !options.abstract) {
  45465. while (parent.$options.abstract && parent.$parent) {
  45466. parent = parent.$parent;
  45467. }
  45468. parent.$children.push(vm);
  45469. }
  45470. vm.$parent = parent;
  45471. vm.$root = parent ? parent.$root : vm;
  45472. vm.$children = [];
  45473. vm.$refs = {};
  45474. vm._watcher = null;
  45475. vm._inactive = null;
  45476. vm._directInactive = false;
  45477. vm._isMounted = false;
  45478. vm._isDestroyed = false;
  45479. vm._isBeingDestroyed = false;
  45480. }
  45481. function lifecycleMixin (Vue) {
  45482. Vue.prototype._update = function (vnode, hydrating) {
  45483. var vm = this;
  45484. var prevEl = vm.$el;
  45485. var prevVnode = vm._vnode;
  45486. var restoreActiveInstance = setActiveInstance(vm);
  45487. vm._vnode = vnode;
  45488. // Vue.prototype.__patch__ is injected in entry points
  45489. // based on the rendering backend used.
  45490. if (!prevVnode) {
  45491. // initial render
  45492. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45493. } else {
  45494. // updates
  45495. vm.$el = vm.__patch__(prevVnode, vnode);
  45496. }
  45497. restoreActiveInstance();
  45498. // update __vue__ reference
  45499. if (prevEl) {
  45500. prevEl.__vue__ = null;
  45501. }
  45502. if (vm.$el) {
  45503. vm.$el.__vue__ = vm;
  45504. }
  45505. // if parent is an HOC, update its $el as well
  45506. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45507. vm.$parent.$el = vm.$el;
  45508. }
  45509. // updated hook is called by the scheduler to ensure that children are
  45510. // updated in a parent's updated hook.
  45511. };
  45512. Vue.prototype.$forceUpdate = function () {
  45513. var vm = this;
  45514. if (vm._watcher) {
  45515. vm._watcher.update();
  45516. }
  45517. };
  45518. Vue.prototype.$destroy = function () {
  45519. var vm = this;
  45520. if (vm._isBeingDestroyed) {
  45521. return
  45522. }
  45523. callHook(vm, 'beforeDestroy');
  45524. vm._isBeingDestroyed = true;
  45525. // remove self from parent
  45526. var parent = vm.$parent;
  45527. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45528. remove(parent.$children, vm);
  45529. }
  45530. // teardown watchers
  45531. if (vm._watcher) {
  45532. vm._watcher.teardown();
  45533. }
  45534. var i = vm._watchers.length;
  45535. while (i--) {
  45536. vm._watchers[i].teardown();
  45537. }
  45538. // remove reference from data ob
  45539. // frozen object may not have observer.
  45540. if (vm._data.__ob__) {
  45541. vm._data.__ob__.vmCount--;
  45542. }
  45543. // call the last hook...
  45544. vm._isDestroyed = true;
  45545. // invoke destroy hooks on current rendered tree
  45546. vm.__patch__(vm._vnode, null);
  45547. // fire destroyed hook
  45548. callHook(vm, 'destroyed');
  45549. // turn off all instance listeners.
  45550. vm.$off();
  45551. // remove __vue__ reference
  45552. if (vm.$el) {
  45553. vm.$el.__vue__ = null;
  45554. }
  45555. // release circular reference (#6759)
  45556. if (vm.$vnode) {
  45557. vm.$vnode.parent = null;
  45558. }
  45559. };
  45560. }
  45561. function mountComponent (
  45562. vm,
  45563. el,
  45564. hydrating
  45565. ) {
  45566. vm.$el = el;
  45567. if (!vm.$options.render) {
  45568. vm.$options.render = createEmptyVNode;
  45569. {
  45570. /* istanbul ignore if */
  45571. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45572. vm.$options.el || el) {
  45573. warn(
  45574. 'You are using the runtime-only build of Vue where the template ' +
  45575. 'compiler is not available. Either pre-compile the templates into ' +
  45576. 'render functions, or use the compiler-included build.',
  45577. vm
  45578. );
  45579. } else {
  45580. warn(
  45581. 'Failed to mount component: template or render function not defined.',
  45582. vm
  45583. );
  45584. }
  45585. }
  45586. }
  45587. callHook(vm, 'beforeMount');
  45588. var updateComponent;
  45589. /* istanbul ignore if */
  45590. if (config.performance && mark) {
  45591. updateComponent = function () {
  45592. var name = vm._name;
  45593. var id = vm._uid;
  45594. var startTag = "vue-perf-start:" + id;
  45595. var endTag = "vue-perf-end:" + id;
  45596. mark(startTag);
  45597. var vnode = vm._render();
  45598. mark(endTag);
  45599. measure(("vue " + name + " render"), startTag, endTag);
  45600. mark(startTag);
  45601. vm._update(vnode, hydrating);
  45602. mark(endTag);
  45603. measure(("vue " + name + " patch"), startTag, endTag);
  45604. };
  45605. } else {
  45606. updateComponent = function () {
  45607. vm._update(vm._render(), hydrating);
  45608. };
  45609. }
  45610. // we set this to vm._watcher inside the watcher's constructor
  45611. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45612. // component's mounted hook), which relies on vm._watcher being already defined
  45613. new Watcher(vm, updateComponent, noop, {
  45614. before: function before () {
  45615. if (vm._isMounted && !vm._isDestroyed) {
  45616. callHook(vm, 'beforeUpdate');
  45617. }
  45618. }
  45619. }, true /* isRenderWatcher */);
  45620. hydrating = false;
  45621. // manually mounted instance, call mounted on self
  45622. // mounted is called for render-created child components in its inserted hook
  45623. if (vm.$vnode == null) {
  45624. vm._isMounted = true;
  45625. callHook(vm, 'mounted');
  45626. }
  45627. return vm
  45628. }
  45629. function updateChildComponent (
  45630. vm,
  45631. propsData,
  45632. listeners,
  45633. parentVnode,
  45634. renderChildren
  45635. ) {
  45636. {
  45637. isUpdatingChildComponent = true;
  45638. }
  45639. // determine whether component has slot children
  45640. // we need to do this before overwriting $options._renderChildren.
  45641. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45642. // dynamic slot names). Static scoped slots compiled from template has the
  45643. // "$stable" marker.
  45644. var newScopedSlots = parentVnode.data.scopedSlots;
  45645. var oldScopedSlots = vm.$scopedSlots;
  45646. var hasDynamicScopedSlot = !!(
  45647. (newScopedSlots && !newScopedSlots.$stable) ||
  45648. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45649. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45650. );
  45651. // Any static slot children from the parent may have changed during parent's
  45652. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45653. // update is necessary to ensure correctness.
  45654. var needsForceUpdate = !!(
  45655. renderChildren || // has new static slots
  45656. vm.$options._renderChildren || // has old static slots
  45657. hasDynamicScopedSlot
  45658. );
  45659. vm.$options._parentVnode = parentVnode;
  45660. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45661. if (vm._vnode) { // update child tree's parent
  45662. vm._vnode.parent = parentVnode;
  45663. }
  45664. vm.$options._renderChildren = renderChildren;
  45665. // update $attrs and $listeners hash
  45666. // these are also reactive so they may trigger child update if the child
  45667. // used them during render
  45668. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45669. vm.$listeners = listeners || emptyObject;
  45670. // update props
  45671. if (propsData && vm.$options.props) {
  45672. toggleObserving(false);
  45673. var props = vm._props;
  45674. var propKeys = vm.$options._propKeys || [];
  45675. for (var i = 0; i < propKeys.length; i++) {
  45676. var key = propKeys[i];
  45677. var propOptions = vm.$options.props; // wtf flow?
  45678. props[key] = validateProp(key, propOptions, propsData, vm);
  45679. }
  45680. toggleObserving(true);
  45681. // keep a copy of raw propsData
  45682. vm.$options.propsData = propsData;
  45683. }
  45684. // update listeners
  45685. listeners = listeners || emptyObject;
  45686. var oldListeners = vm.$options._parentListeners;
  45687. vm.$options._parentListeners = listeners;
  45688. updateComponentListeners(vm, listeners, oldListeners);
  45689. // resolve slots + force update if has children
  45690. if (needsForceUpdate) {
  45691. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45692. vm.$forceUpdate();
  45693. }
  45694. {
  45695. isUpdatingChildComponent = false;
  45696. }
  45697. }
  45698. function isInInactiveTree (vm) {
  45699. while (vm && (vm = vm.$parent)) {
  45700. if (vm._inactive) { return true }
  45701. }
  45702. return false
  45703. }
  45704. function activateChildComponent (vm, direct) {
  45705. if (direct) {
  45706. vm._directInactive = false;
  45707. if (isInInactiveTree(vm)) {
  45708. return
  45709. }
  45710. } else if (vm._directInactive) {
  45711. return
  45712. }
  45713. if (vm._inactive || vm._inactive === null) {
  45714. vm._inactive = false;
  45715. for (var i = 0; i < vm.$children.length; i++) {
  45716. activateChildComponent(vm.$children[i]);
  45717. }
  45718. callHook(vm, 'activated');
  45719. }
  45720. }
  45721. function deactivateChildComponent (vm, direct) {
  45722. if (direct) {
  45723. vm._directInactive = true;
  45724. if (isInInactiveTree(vm)) {
  45725. return
  45726. }
  45727. }
  45728. if (!vm._inactive) {
  45729. vm._inactive = true;
  45730. for (var i = 0; i < vm.$children.length; i++) {
  45731. deactivateChildComponent(vm.$children[i]);
  45732. }
  45733. callHook(vm, 'deactivated');
  45734. }
  45735. }
  45736. function callHook (vm, hook) {
  45737. // #7573 disable dep collection when invoking lifecycle hooks
  45738. pushTarget();
  45739. var handlers = vm.$options[hook];
  45740. var info = hook + " hook";
  45741. if (handlers) {
  45742. for (var i = 0, j = handlers.length; i < j; i++) {
  45743. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45744. }
  45745. }
  45746. if (vm._hasHookEvent) {
  45747. vm.$emit('hook:' + hook);
  45748. }
  45749. popTarget();
  45750. }
  45751. /* */
  45752. var MAX_UPDATE_COUNT = 100;
  45753. var queue = [];
  45754. var activatedChildren = [];
  45755. var has = {};
  45756. var circular = {};
  45757. var waiting = false;
  45758. var flushing = false;
  45759. var index = 0;
  45760. /**
  45761. * Reset the scheduler's state.
  45762. */
  45763. function resetSchedulerState () {
  45764. index = queue.length = activatedChildren.length = 0;
  45765. has = {};
  45766. {
  45767. circular = {};
  45768. }
  45769. waiting = flushing = false;
  45770. }
  45771. // Async edge case #6566 requires saving the timestamp when event listeners are
  45772. // attached. However, calling performance.now() has a perf overhead especially
  45773. // if the page has thousands of event listeners. Instead, we take a timestamp
  45774. // every time the scheduler flushes and use that for all event listeners
  45775. // attached during that flush.
  45776. var currentFlushTimestamp = 0;
  45777. // Async edge case fix requires storing an event listener's attach timestamp.
  45778. var getNow = Date.now;
  45779. // Determine what event timestamp the browser is using. Annoyingly, the
  45780. // timestamp can either be hi-res (relative to page load) or low-res
  45781. // (relative to UNIX epoch), so in order to compare time we have to use the
  45782. // same timestamp type when saving the flush timestamp.
  45783. // All IE versions use low-res event timestamps, and have problematic clock
  45784. // implementations (#9632)
  45785. if (inBrowser && !isIE) {
  45786. var performance = window.performance;
  45787. if (
  45788. performance &&
  45789. typeof performance.now === 'function' &&
  45790. getNow() > document.createEvent('Event').timeStamp
  45791. ) {
  45792. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45793. // smaller than it, it means the event is using a hi-res timestamp,
  45794. // and we need to use the hi-res version for event listener timestamps as
  45795. // well.
  45796. getNow = function () { return performance.now(); };
  45797. }
  45798. }
  45799. /**
  45800. * Flush both queues and run the watchers.
  45801. */
  45802. function flushSchedulerQueue () {
  45803. currentFlushTimestamp = getNow();
  45804. flushing = true;
  45805. var watcher, id;
  45806. // Sort queue before flush.
  45807. // This ensures that:
  45808. // 1. Components are updated from parent to child. (because parent is always
  45809. // created before the child)
  45810. // 2. A component's user watchers are run before its render watcher (because
  45811. // user watchers are created before the render watcher)
  45812. // 3. If a component is destroyed during a parent component's watcher run,
  45813. // its watchers can be skipped.
  45814. queue.sort(function (a, b) { return a.id - b.id; });
  45815. // do not cache length because more watchers might be pushed
  45816. // as we run existing watchers
  45817. for (index = 0; index < queue.length; index++) {
  45818. watcher = queue[index];
  45819. if (watcher.before) {
  45820. watcher.before();
  45821. }
  45822. id = watcher.id;
  45823. has[id] = null;
  45824. watcher.run();
  45825. // in dev build, check and stop circular updates.
  45826. if (has[id] != null) {
  45827. circular[id] = (circular[id] || 0) + 1;
  45828. if (circular[id] > MAX_UPDATE_COUNT) {
  45829. warn(
  45830. 'You may have an infinite update loop ' + (
  45831. watcher.user
  45832. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45833. : "in a component render function."
  45834. ),
  45835. watcher.vm
  45836. );
  45837. break
  45838. }
  45839. }
  45840. }
  45841. // keep copies of post queues before resetting state
  45842. var activatedQueue = activatedChildren.slice();
  45843. var updatedQueue = queue.slice();
  45844. resetSchedulerState();
  45845. // call component updated and activated hooks
  45846. callActivatedHooks(activatedQueue);
  45847. callUpdatedHooks(updatedQueue);
  45848. // devtool hook
  45849. /* istanbul ignore if */
  45850. if (devtools && config.devtools) {
  45851. devtools.emit('flush');
  45852. }
  45853. }
  45854. function callUpdatedHooks (queue) {
  45855. var i = queue.length;
  45856. while (i--) {
  45857. var watcher = queue[i];
  45858. var vm = watcher.vm;
  45859. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45860. callHook(vm, 'updated');
  45861. }
  45862. }
  45863. }
  45864. /**
  45865. * Queue a kept-alive component that was activated during patch.
  45866. * The queue will be processed after the entire tree has been patched.
  45867. */
  45868. function queueActivatedComponent (vm) {
  45869. // setting _inactive to false here so that a render function can
  45870. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45871. vm._inactive = false;
  45872. activatedChildren.push(vm);
  45873. }
  45874. function callActivatedHooks (queue) {
  45875. for (var i = 0; i < queue.length; i++) {
  45876. queue[i]._inactive = true;
  45877. activateChildComponent(queue[i], true /* true */);
  45878. }
  45879. }
  45880. /**
  45881. * Push a watcher into the watcher queue.
  45882. * Jobs with duplicate IDs will be skipped unless it's
  45883. * pushed when the queue is being flushed.
  45884. */
  45885. function queueWatcher (watcher) {
  45886. var id = watcher.id;
  45887. if (has[id] == null) {
  45888. has[id] = true;
  45889. if (!flushing) {
  45890. queue.push(watcher);
  45891. } else {
  45892. // if already flushing, splice the watcher based on its id
  45893. // if already past its id, it will be run next immediately.
  45894. var i = queue.length - 1;
  45895. while (i > index && queue[i].id > watcher.id) {
  45896. i--;
  45897. }
  45898. queue.splice(i + 1, 0, watcher);
  45899. }
  45900. // queue the flush
  45901. if (!waiting) {
  45902. waiting = true;
  45903. if (!config.async) {
  45904. flushSchedulerQueue();
  45905. return
  45906. }
  45907. nextTick(flushSchedulerQueue);
  45908. }
  45909. }
  45910. }
  45911. /* */
  45912. var uid$2 = 0;
  45913. /**
  45914. * A watcher parses an expression, collects dependencies,
  45915. * and fires callback when the expression value changes.
  45916. * This is used for both the $watch() api and directives.
  45917. */
  45918. var Watcher = function Watcher (
  45919. vm,
  45920. expOrFn,
  45921. cb,
  45922. options,
  45923. isRenderWatcher
  45924. ) {
  45925. this.vm = vm;
  45926. if (isRenderWatcher) {
  45927. vm._watcher = this;
  45928. }
  45929. vm._watchers.push(this);
  45930. // options
  45931. if (options) {
  45932. this.deep = !!options.deep;
  45933. this.user = !!options.user;
  45934. this.lazy = !!options.lazy;
  45935. this.sync = !!options.sync;
  45936. this.before = options.before;
  45937. } else {
  45938. this.deep = this.user = this.lazy = this.sync = false;
  45939. }
  45940. this.cb = cb;
  45941. this.id = ++uid$2; // uid for batching
  45942. this.active = true;
  45943. this.dirty = this.lazy; // for lazy watchers
  45944. this.deps = [];
  45945. this.newDeps = [];
  45946. this.depIds = new _Set();
  45947. this.newDepIds = new _Set();
  45948. this.expression = expOrFn.toString();
  45949. // parse expression for getter
  45950. if (typeof expOrFn === 'function') {
  45951. this.getter = expOrFn;
  45952. } else {
  45953. this.getter = parsePath(expOrFn);
  45954. if (!this.getter) {
  45955. this.getter = noop;
  45956. warn(
  45957. "Failed watching path: \"" + expOrFn + "\" " +
  45958. 'Watcher only accepts simple dot-delimited paths. ' +
  45959. 'For full control, use a function instead.',
  45960. vm
  45961. );
  45962. }
  45963. }
  45964. this.value = this.lazy
  45965. ? undefined
  45966. : this.get();
  45967. };
  45968. /**
  45969. * Evaluate the getter, and re-collect dependencies.
  45970. */
  45971. Watcher.prototype.get = function get () {
  45972. pushTarget(this);
  45973. var value;
  45974. var vm = this.vm;
  45975. try {
  45976. value = this.getter.call(vm, vm);
  45977. } catch (e) {
  45978. if (this.user) {
  45979. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45980. } else {
  45981. throw e
  45982. }
  45983. } finally {
  45984. // "touch" every property so they are all tracked as
  45985. // dependencies for deep watching
  45986. if (this.deep) {
  45987. traverse(value);
  45988. }
  45989. popTarget();
  45990. this.cleanupDeps();
  45991. }
  45992. return value
  45993. };
  45994. /**
  45995. * Add a dependency to this directive.
  45996. */
  45997. Watcher.prototype.addDep = function addDep (dep) {
  45998. var id = dep.id;
  45999. if (!this.newDepIds.has(id)) {
  46000. this.newDepIds.add(id);
  46001. this.newDeps.push(dep);
  46002. if (!this.depIds.has(id)) {
  46003. dep.addSub(this);
  46004. }
  46005. }
  46006. };
  46007. /**
  46008. * Clean up for dependency collection.
  46009. */
  46010. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  46011. var i = this.deps.length;
  46012. while (i--) {
  46013. var dep = this.deps[i];
  46014. if (!this.newDepIds.has(dep.id)) {
  46015. dep.removeSub(this);
  46016. }
  46017. }
  46018. var tmp = this.depIds;
  46019. this.depIds = this.newDepIds;
  46020. this.newDepIds = tmp;
  46021. this.newDepIds.clear();
  46022. tmp = this.deps;
  46023. this.deps = this.newDeps;
  46024. this.newDeps = tmp;
  46025. this.newDeps.length = 0;
  46026. };
  46027. /**
  46028. * Subscriber interface.
  46029. * Will be called when a dependency changes.
  46030. */
  46031. Watcher.prototype.update = function update () {
  46032. /* istanbul ignore else */
  46033. if (this.lazy) {
  46034. this.dirty = true;
  46035. } else if (this.sync) {
  46036. this.run();
  46037. } else {
  46038. queueWatcher(this);
  46039. }
  46040. };
  46041. /**
  46042. * Scheduler job interface.
  46043. * Will be called by the scheduler.
  46044. */
  46045. Watcher.prototype.run = function run () {
  46046. if (this.active) {
  46047. var value = this.get();
  46048. if (
  46049. value !== this.value ||
  46050. // Deep watchers and watchers on Object/Arrays should fire even
  46051. // when the value is the same, because the value may
  46052. // have mutated.
  46053. isObject(value) ||
  46054. this.deep
  46055. ) {
  46056. // set new value
  46057. var oldValue = this.value;
  46058. this.value = value;
  46059. if (this.user) {
  46060. try {
  46061. this.cb.call(this.vm, value, oldValue);
  46062. } catch (e) {
  46063. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  46064. }
  46065. } else {
  46066. this.cb.call(this.vm, value, oldValue);
  46067. }
  46068. }
  46069. }
  46070. };
  46071. /**
  46072. * Evaluate the value of the watcher.
  46073. * This only gets called for lazy watchers.
  46074. */
  46075. Watcher.prototype.evaluate = function evaluate () {
  46076. this.value = this.get();
  46077. this.dirty = false;
  46078. };
  46079. /**
  46080. * Depend on all deps collected by this watcher.
  46081. */
  46082. Watcher.prototype.depend = function depend () {
  46083. var i = this.deps.length;
  46084. while (i--) {
  46085. this.deps[i].depend();
  46086. }
  46087. };
  46088. /**
  46089. * Remove self from all dependencies' subscriber list.
  46090. */
  46091. Watcher.prototype.teardown = function teardown () {
  46092. if (this.active) {
  46093. // remove self from vm's watcher list
  46094. // this is a somewhat expensive operation so we skip it
  46095. // if the vm is being destroyed.
  46096. if (!this.vm._isBeingDestroyed) {
  46097. remove(this.vm._watchers, this);
  46098. }
  46099. var i = this.deps.length;
  46100. while (i--) {
  46101. this.deps[i].removeSub(this);
  46102. }
  46103. this.active = false;
  46104. }
  46105. };
  46106. /* */
  46107. var sharedPropertyDefinition = {
  46108. enumerable: true,
  46109. configurable: true,
  46110. get: noop,
  46111. set: noop
  46112. };
  46113. function proxy (target, sourceKey, key) {
  46114. sharedPropertyDefinition.get = function proxyGetter () {
  46115. return this[sourceKey][key]
  46116. };
  46117. sharedPropertyDefinition.set = function proxySetter (val) {
  46118. this[sourceKey][key] = val;
  46119. };
  46120. Object.defineProperty(target, key, sharedPropertyDefinition);
  46121. }
  46122. function initState (vm) {
  46123. vm._watchers = [];
  46124. var opts = vm.$options;
  46125. if (opts.props) { initProps(vm, opts.props); }
  46126. if (opts.methods) { initMethods(vm, opts.methods); }
  46127. if (opts.data) {
  46128. initData(vm);
  46129. } else {
  46130. observe(vm._data = {}, true /* asRootData */);
  46131. }
  46132. if (opts.computed) { initComputed(vm, opts.computed); }
  46133. if (opts.watch && opts.watch !== nativeWatch) {
  46134. initWatch(vm, opts.watch);
  46135. }
  46136. }
  46137. function initProps (vm, propsOptions) {
  46138. var propsData = vm.$options.propsData || {};
  46139. var props = vm._props = {};
  46140. // cache prop keys so that future props updates can iterate using Array
  46141. // instead of dynamic object key enumeration.
  46142. var keys = vm.$options._propKeys = [];
  46143. var isRoot = !vm.$parent;
  46144. // root instance props should be converted
  46145. if (!isRoot) {
  46146. toggleObserving(false);
  46147. }
  46148. var loop = function ( key ) {
  46149. keys.push(key);
  46150. var value = validateProp(key, propsOptions, propsData, vm);
  46151. /* istanbul ignore else */
  46152. {
  46153. var hyphenatedKey = hyphenate(key);
  46154. if (isReservedAttribute(hyphenatedKey) ||
  46155. config.isReservedAttr(hyphenatedKey)) {
  46156. warn(
  46157. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  46158. vm
  46159. );
  46160. }
  46161. defineReactive$$1(props, key, value, function () {
  46162. if (!isRoot && !isUpdatingChildComponent) {
  46163. warn(
  46164. "Avoid mutating a prop directly since the value will be " +
  46165. "overwritten whenever the parent component re-renders. " +
  46166. "Instead, use a data or computed property based on the prop's " +
  46167. "value. Prop being mutated: \"" + key + "\"",
  46168. vm
  46169. );
  46170. }
  46171. });
  46172. }
  46173. // static props are already proxied on the component's prototype
  46174. // during Vue.extend(). We only need to proxy props defined at
  46175. // instantiation here.
  46176. if (!(key in vm)) {
  46177. proxy(vm, "_props", key);
  46178. }
  46179. };
  46180. for (var key in propsOptions) loop( key );
  46181. toggleObserving(true);
  46182. }
  46183. function initData (vm) {
  46184. var data = vm.$options.data;
  46185. data = vm._data = typeof data === 'function'
  46186. ? getData(data, vm)
  46187. : data || {};
  46188. if (!isPlainObject(data)) {
  46189. data = {};
  46190. warn(
  46191. 'data functions should return an object:\n' +
  46192. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  46193. vm
  46194. );
  46195. }
  46196. // proxy data on instance
  46197. var keys = Object.keys(data);
  46198. var props = vm.$options.props;
  46199. var methods = vm.$options.methods;
  46200. var i = keys.length;
  46201. while (i--) {
  46202. var key = keys[i];
  46203. {
  46204. if (methods && hasOwn(methods, key)) {
  46205. warn(
  46206. ("Method \"" + key + "\" has already been defined as a data property."),
  46207. vm
  46208. );
  46209. }
  46210. }
  46211. if (props && hasOwn(props, key)) {
  46212. warn(
  46213. "The data property \"" + key + "\" is already declared as a prop. " +
  46214. "Use prop default value instead.",
  46215. vm
  46216. );
  46217. } else if (!isReserved(key)) {
  46218. proxy(vm, "_data", key);
  46219. }
  46220. }
  46221. // observe data
  46222. observe(data, true /* asRootData */);
  46223. }
  46224. function getData (data, vm) {
  46225. // #7573 disable dep collection when invoking data getters
  46226. pushTarget();
  46227. try {
  46228. return data.call(vm, vm)
  46229. } catch (e) {
  46230. handleError(e, vm, "data()");
  46231. return {}
  46232. } finally {
  46233. popTarget();
  46234. }
  46235. }
  46236. var computedWatcherOptions = { lazy: true };
  46237. function initComputed (vm, computed) {
  46238. // $flow-disable-line
  46239. var watchers = vm._computedWatchers = Object.create(null);
  46240. // computed properties are just getters during SSR
  46241. var isSSR = isServerRendering();
  46242. for (var key in computed) {
  46243. var userDef = computed[key];
  46244. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46245. if (getter == null) {
  46246. warn(
  46247. ("Getter is missing for computed property \"" + key + "\"."),
  46248. vm
  46249. );
  46250. }
  46251. if (!isSSR) {
  46252. // create internal watcher for the computed property.
  46253. watchers[key] = new Watcher(
  46254. vm,
  46255. getter || noop,
  46256. noop,
  46257. computedWatcherOptions
  46258. );
  46259. }
  46260. // component-defined computed properties are already defined on the
  46261. // component prototype. We only need to define computed properties defined
  46262. // at instantiation here.
  46263. if (!(key in vm)) {
  46264. defineComputed(vm, key, userDef);
  46265. } else {
  46266. if (key in vm.$data) {
  46267. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46268. } else if (vm.$options.props && key in vm.$options.props) {
  46269. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46270. }
  46271. }
  46272. }
  46273. }
  46274. function defineComputed (
  46275. target,
  46276. key,
  46277. userDef
  46278. ) {
  46279. var shouldCache = !isServerRendering();
  46280. if (typeof userDef === 'function') {
  46281. sharedPropertyDefinition.get = shouldCache
  46282. ? createComputedGetter(key)
  46283. : createGetterInvoker(userDef);
  46284. sharedPropertyDefinition.set = noop;
  46285. } else {
  46286. sharedPropertyDefinition.get = userDef.get
  46287. ? shouldCache && userDef.cache !== false
  46288. ? createComputedGetter(key)
  46289. : createGetterInvoker(userDef.get)
  46290. : noop;
  46291. sharedPropertyDefinition.set = userDef.set || noop;
  46292. }
  46293. if (sharedPropertyDefinition.set === noop) {
  46294. sharedPropertyDefinition.set = function () {
  46295. warn(
  46296. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46297. this
  46298. );
  46299. };
  46300. }
  46301. Object.defineProperty(target, key, sharedPropertyDefinition);
  46302. }
  46303. function createComputedGetter (key) {
  46304. return function computedGetter () {
  46305. var watcher = this._computedWatchers && this._computedWatchers[key];
  46306. if (watcher) {
  46307. if (watcher.dirty) {
  46308. watcher.evaluate();
  46309. }
  46310. if (Dep.target) {
  46311. watcher.depend();
  46312. }
  46313. return watcher.value
  46314. }
  46315. }
  46316. }
  46317. function createGetterInvoker(fn) {
  46318. return function computedGetter () {
  46319. return fn.call(this, this)
  46320. }
  46321. }
  46322. function initMethods (vm, methods) {
  46323. var props = vm.$options.props;
  46324. for (var key in methods) {
  46325. {
  46326. if (typeof methods[key] !== 'function') {
  46327. warn(
  46328. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46329. "Did you reference the function correctly?",
  46330. vm
  46331. );
  46332. }
  46333. if (props && hasOwn(props, key)) {
  46334. warn(
  46335. ("Method \"" + key + "\" has already been defined as a prop."),
  46336. vm
  46337. );
  46338. }
  46339. if ((key in vm) && isReserved(key)) {
  46340. warn(
  46341. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46342. "Avoid defining component methods that start with _ or $."
  46343. );
  46344. }
  46345. }
  46346. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46347. }
  46348. }
  46349. function initWatch (vm, watch) {
  46350. for (var key in watch) {
  46351. var handler = watch[key];
  46352. if (Array.isArray(handler)) {
  46353. for (var i = 0; i < handler.length; i++) {
  46354. createWatcher(vm, key, handler[i]);
  46355. }
  46356. } else {
  46357. createWatcher(vm, key, handler);
  46358. }
  46359. }
  46360. }
  46361. function createWatcher (
  46362. vm,
  46363. expOrFn,
  46364. handler,
  46365. options
  46366. ) {
  46367. if (isPlainObject(handler)) {
  46368. options = handler;
  46369. handler = handler.handler;
  46370. }
  46371. if (typeof handler === 'string') {
  46372. handler = vm[handler];
  46373. }
  46374. return vm.$watch(expOrFn, handler, options)
  46375. }
  46376. function stateMixin (Vue) {
  46377. // flow somehow has problems with directly declared definition object
  46378. // when using Object.defineProperty, so we have to procedurally build up
  46379. // the object here.
  46380. var dataDef = {};
  46381. dataDef.get = function () { return this._data };
  46382. var propsDef = {};
  46383. propsDef.get = function () { return this._props };
  46384. {
  46385. dataDef.set = function () {
  46386. warn(
  46387. 'Avoid replacing instance root $data. ' +
  46388. 'Use nested data properties instead.',
  46389. this
  46390. );
  46391. };
  46392. propsDef.set = function () {
  46393. warn("$props is readonly.", this);
  46394. };
  46395. }
  46396. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46397. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46398. Vue.prototype.$set = set;
  46399. Vue.prototype.$delete = del;
  46400. Vue.prototype.$watch = function (
  46401. expOrFn,
  46402. cb,
  46403. options
  46404. ) {
  46405. var vm = this;
  46406. if (isPlainObject(cb)) {
  46407. return createWatcher(vm, expOrFn, cb, options)
  46408. }
  46409. options = options || {};
  46410. options.user = true;
  46411. var watcher = new Watcher(vm, expOrFn, cb, options);
  46412. if (options.immediate) {
  46413. try {
  46414. cb.call(vm, watcher.value);
  46415. } catch (error) {
  46416. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46417. }
  46418. }
  46419. return function unwatchFn () {
  46420. watcher.teardown();
  46421. }
  46422. };
  46423. }
  46424. /* */
  46425. var uid$3 = 0;
  46426. function initMixin (Vue) {
  46427. Vue.prototype._init = function (options) {
  46428. var vm = this;
  46429. // a uid
  46430. vm._uid = uid$3++;
  46431. var startTag, endTag;
  46432. /* istanbul ignore if */
  46433. if (config.performance && mark) {
  46434. startTag = "vue-perf-start:" + (vm._uid);
  46435. endTag = "vue-perf-end:" + (vm._uid);
  46436. mark(startTag);
  46437. }
  46438. // a flag to avoid this being observed
  46439. vm._isVue = true;
  46440. // merge options
  46441. if (options && options._isComponent) {
  46442. // optimize internal component instantiation
  46443. // since dynamic options merging is pretty slow, and none of the
  46444. // internal component options needs special treatment.
  46445. initInternalComponent(vm, options);
  46446. } else {
  46447. vm.$options = mergeOptions(
  46448. resolveConstructorOptions(vm.constructor),
  46449. options || {},
  46450. vm
  46451. );
  46452. }
  46453. /* istanbul ignore else */
  46454. {
  46455. initProxy(vm);
  46456. }
  46457. // expose real self
  46458. vm._self = vm;
  46459. initLifecycle(vm);
  46460. initEvents(vm);
  46461. initRender(vm);
  46462. callHook(vm, 'beforeCreate');
  46463. initInjections(vm); // resolve injections before data/props
  46464. initState(vm);
  46465. initProvide(vm); // resolve provide after data/props
  46466. callHook(vm, 'created');
  46467. /* istanbul ignore if */
  46468. if (config.performance && mark) {
  46469. vm._name = formatComponentName(vm, false);
  46470. mark(endTag);
  46471. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46472. }
  46473. if (vm.$options.el) {
  46474. vm.$mount(vm.$options.el);
  46475. }
  46476. };
  46477. }
  46478. function initInternalComponent (vm, options) {
  46479. var opts = vm.$options = Object.create(vm.constructor.options);
  46480. // doing this because it's faster than dynamic enumeration.
  46481. var parentVnode = options._parentVnode;
  46482. opts.parent = options.parent;
  46483. opts._parentVnode = parentVnode;
  46484. var vnodeComponentOptions = parentVnode.componentOptions;
  46485. opts.propsData = vnodeComponentOptions.propsData;
  46486. opts._parentListeners = vnodeComponentOptions.listeners;
  46487. opts._renderChildren = vnodeComponentOptions.children;
  46488. opts._componentTag = vnodeComponentOptions.tag;
  46489. if (options.render) {
  46490. opts.render = options.render;
  46491. opts.staticRenderFns = options.staticRenderFns;
  46492. }
  46493. }
  46494. function resolveConstructorOptions (Ctor) {
  46495. var options = Ctor.options;
  46496. if (Ctor.super) {
  46497. var superOptions = resolveConstructorOptions(Ctor.super);
  46498. var cachedSuperOptions = Ctor.superOptions;
  46499. if (superOptions !== cachedSuperOptions) {
  46500. // super option changed,
  46501. // need to resolve new options.
  46502. Ctor.superOptions = superOptions;
  46503. // check if there are any late-modified/attached options (#4976)
  46504. var modifiedOptions = resolveModifiedOptions(Ctor);
  46505. // update base extend options
  46506. if (modifiedOptions) {
  46507. extend(Ctor.extendOptions, modifiedOptions);
  46508. }
  46509. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46510. if (options.name) {
  46511. options.components[options.name] = Ctor;
  46512. }
  46513. }
  46514. }
  46515. return options
  46516. }
  46517. function resolveModifiedOptions (Ctor) {
  46518. var modified;
  46519. var latest = Ctor.options;
  46520. var sealed = Ctor.sealedOptions;
  46521. for (var key in latest) {
  46522. if (latest[key] !== sealed[key]) {
  46523. if (!modified) { modified = {}; }
  46524. modified[key] = latest[key];
  46525. }
  46526. }
  46527. return modified
  46528. }
  46529. function Vue (options) {
  46530. if (!(this instanceof Vue)
  46531. ) {
  46532. warn('Vue is a constructor and should be called with the `new` keyword');
  46533. }
  46534. this._init(options);
  46535. }
  46536. initMixin(Vue);
  46537. stateMixin(Vue);
  46538. eventsMixin(Vue);
  46539. lifecycleMixin(Vue);
  46540. renderMixin(Vue);
  46541. /* */
  46542. function initUse (Vue) {
  46543. Vue.use = function (plugin) {
  46544. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46545. if (installedPlugins.indexOf(plugin) > -1) {
  46546. return this
  46547. }
  46548. // additional parameters
  46549. var args = toArray(arguments, 1);
  46550. args.unshift(this);
  46551. if (typeof plugin.install === 'function') {
  46552. plugin.install.apply(plugin, args);
  46553. } else if (typeof plugin === 'function') {
  46554. plugin.apply(null, args);
  46555. }
  46556. installedPlugins.push(plugin);
  46557. return this
  46558. };
  46559. }
  46560. /* */
  46561. function initMixin$1 (Vue) {
  46562. Vue.mixin = function (mixin) {
  46563. this.options = mergeOptions(this.options, mixin);
  46564. return this
  46565. };
  46566. }
  46567. /* */
  46568. function initExtend (Vue) {
  46569. /**
  46570. * Each instance constructor, including Vue, has a unique
  46571. * cid. This enables us to create wrapped "child
  46572. * constructors" for prototypal inheritance and cache them.
  46573. */
  46574. Vue.cid = 0;
  46575. var cid = 1;
  46576. /**
  46577. * Class inheritance
  46578. */
  46579. Vue.extend = function (extendOptions) {
  46580. extendOptions = extendOptions || {};
  46581. var Super = this;
  46582. var SuperId = Super.cid;
  46583. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46584. if (cachedCtors[SuperId]) {
  46585. return cachedCtors[SuperId]
  46586. }
  46587. var name = extendOptions.name || Super.options.name;
  46588. if (name) {
  46589. validateComponentName(name);
  46590. }
  46591. var Sub = function VueComponent (options) {
  46592. this._init(options);
  46593. };
  46594. Sub.prototype = Object.create(Super.prototype);
  46595. Sub.prototype.constructor = Sub;
  46596. Sub.cid = cid++;
  46597. Sub.options = mergeOptions(
  46598. Super.options,
  46599. extendOptions
  46600. );
  46601. Sub['super'] = Super;
  46602. // For props and computed properties, we define the proxy getters on
  46603. // the Vue instances at extension time, on the extended prototype. This
  46604. // avoids Object.defineProperty calls for each instance created.
  46605. if (Sub.options.props) {
  46606. initProps$1(Sub);
  46607. }
  46608. if (Sub.options.computed) {
  46609. initComputed$1(Sub);
  46610. }
  46611. // allow further extension/mixin/plugin usage
  46612. Sub.extend = Super.extend;
  46613. Sub.mixin = Super.mixin;
  46614. Sub.use = Super.use;
  46615. // create asset registers, so extended classes
  46616. // can have their private assets too.
  46617. ASSET_TYPES.forEach(function (type) {
  46618. Sub[type] = Super[type];
  46619. });
  46620. // enable recursive self-lookup
  46621. if (name) {
  46622. Sub.options.components[name] = Sub;
  46623. }
  46624. // keep a reference to the super options at extension time.
  46625. // later at instantiation we can check if Super's options have
  46626. // been updated.
  46627. Sub.superOptions = Super.options;
  46628. Sub.extendOptions = extendOptions;
  46629. Sub.sealedOptions = extend({}, Sub.options);
  46630. // cache constructor
  46631. cachedCtors[SuperId] = Sub;
  46632. return Sub
  46633. };
  46634. }
  46635. function initProps$1 (Comp) {
  46636. var props = Comp.options.props;
  46637. for (var key in props) {
  46638. proxy(Comp.prototype, "_props", key);
  46639. }
  46640. }
  46641. function initComputed$1 (Comp) {
  46642. var computed = Comp.options.computed;
  46643. for (var key in computed) {
  46644. defineComputed(Comp.prototype, key, computed[key]);
  46645. }
  46646. }
  46647. /* */
  46648. function initAssetRegisters (Vue) {
  46649. /**
  46650. * Create asset registration methods.
  46651. */
  46652. ASSET_TYPES.forEach(function (type) {
  46653. Vue[type] = function (
  46654. id,
  46655. definition
  46656. ) {
  46657. if (!definition) {
  46658. return this.options[type + 's'][id]
  46659. } else {
  46660. /* istanbul ignore if */
  46661. if (type === 'component') {
  46662. validateComponentName(id);
  46663. }
  46664. if (type === 'component' && isPlainObject(definition)) {
  46665. definition.name = definition.name || id;
  46666. definition = this.options._base.extend(definition);
  46667. }
  46668. if (type === 'directive' && typeof definition === 'function') {
  46669. definition = { bind: definition, update: definition };
  46670. }
  46671. this.options[type + 's'][id] = definition;
  46672. return definition
  46673. }
  46674. };
  46675. });
  46676. }
  46677. /* */
  46678. function getComponentName (opts) {
  46679. return opts && (opts.Ctor.options.name || opts.tag)
  46680. }
  46681. function matches (pattern, name) {
  46682. if (Array.isArray(pattern)) {
  46683. return pattern.indexOf(name) > -1
  46684. } else if (typeof pattern === 'string') {
  46685. return pattern.split(',').indexOf(name) > -1
  46686. } else if (isRegExp(pattern)) {
  46687. return pattern.test(name)
  46688. }
  46689. /* istanbul ignore next */
  46690. return false
  46691. }
  46692. function pruneCache (keepAliveInstance, filter) {
  46693. var cache = keepAliveInstance.cache;
  46694. var keys = keepAliveInstance.keys;
  46695. var _vnode = keepAliveInstance._vnode;
  46696. for (var key in cache) {
  46697. var cachedNode = cache[key];
  46698. if (cachedNode) {
  46699. var name = getComponentName(cachedNode.componentOptions);
  46700. if (name && !filter(name)) {
  46701. pruneCacheEntry(cache, key, keys, _vnode);
  46702. }
  46703. }
  46704. }
  46705. }
  46706. function pruneCacheEntry (
  46707. cache,
  46708. key,
  46709. keys,
  46710. current
  46711. ) {
  46712. var cached$$1 = cache[key];
  46713. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46714. cached$$1.componentInstance.$destroy();
  46715. }
  46716. cache[key] = null;
  46717. remove(keys, key);
  46718. }
  46719. var patternTypes = [String, RegExp, Array];
  46720. var KeepAlive = {
  46721. name: 'keep-alive',
  46722. abstract: true,
  46723. props: {
  46724. include: patternTypes,
  46725. exclude: patternTypes,
  46726. max: [String, Number]
  46727. },
  46728. created: function created () {
  46729. this.cache = Object.create(null);
  46730. this.keys = [];
  46731. },
  46732. destroyed: function destroyed () {
  46733. for (var key in this.cache) {
  46734. pruneCacheEntry(this.cache, key, this.keys);
  46735. }
  46736. },
  46737. mounted: function mounted () {
  46738. var this$1 = this;
  46739. this.$watch('include', function (val) {
  46740. pruneCache(this$1, function (name) { return matches(val, name); });
  46741. });
  46742. this.$watch('exclude', function (val) {
  46743. pruneCache(this$1, function (name) { return !matches(val, name); });
  46744. });
  46745. },
  46746. render: function render () {
  46747. var slot = this.$slots.default;
  46748. var vnode = getFirstComponentChild(slot);
  46749. var componentOptions = vnode && vnode.componentOptions;
  46750. if (componentOptions) {
  46751. // check pattern
  46752. var name = getComponentName(componentOptions);
  46753. var ref = this;
  46754. var include = ref.include;
  46755. var exclude = ref.exclude;
  46756. if (
  46757. // not included
  46758. (include && (!name || !matches(include, name))) ||
  46759. // excluded
  46760. (exclude && name && matches(exclude, name))
  46761. ) {
  46762. return vnode
  46763. }
  46764. var ref$1 = this;
  46765. var cache = ref$1.cache;
  46766. var keys = ref$1.keys;
  46767. var key = vnode.key == null
  46768. // same constructor may get registered as different local components
  46769. // so cid alone is not enough (#3269)
  46770. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46771. : vnode.key;
  46772. if (cache[key]) {
  46773. vnode.componentInstance = cache[key].componentInstance;
  46774. // make current key freshest
  46775. remove(keys, key);
  46776. keys.push(key);
  46777. } else {
  46778. cache[key] = vnode;
  46779. keys.push(key);
  46780. // prune oldest entry
  46781. if (this.max && keys.length > parseInt(this.max)) {
  46782. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46783. }
  46784. }
  46785. vnode.data.keepAlive = true;
  46786. }
  46787. return vnode || (slot && slot[0])
  46788. }
  46789. };
  46790. var builtInComponents = {
  46791. KeepAlive: KeepAlive
  46792. };
  46793. /* */
  46794. function initGlobalAPI (Vue) {
  46795. // config
  46796. var configDef = {};
  46797. configDef.get = function () { return config; };
  46798. {
  46799. configDef.set = function () {
  46800. warn(
  46801. 'Do not replace the Vue.config object, set individual fields instead.'
  46802. );
  46803. };
  46804. }
  46805. Object.defineProperty(Vue, 'config', configDef);
  46806. // exposed util methods.
  46807. // NOTE: these are not considered part of the public API - avoid relying on
  46808. // them unless you are aware of the risk.
  46809. Vue.util = {
  46810. warn: warn,
  46811. extend: extend,
  46812. mergeOptions: mergeOptions,
  46813. defineReactive: defineReactive$$1
  46814. };
  46815. Vue.set = set;
  46816. Vue.delete = del;
  46817. Vue.nextTick = nextTick;
  46818. // 2.6 explicit observable API
  46819. Vue.observable = function (obj) {
  46820. observe(obj);
  46821. return obj
  46822. };
  46823. Vue.options = Object.create(null);
  46824. ASSET_TYPES.forEach(function (type) {
  46825. Vue.options[type + 's'] = Object.create(null);
  46826. });
  46827. // this is used to identify the "base" constructor to extend all plain-object
  46828. // components with in Weex's multi-instance scenarios.
  46829. Vue.options._base = Vue;
  46830. extend(Vue.options.components, builtInComponents);
  46831. initUse(Vue);
  46832. initMixin$1(Vue);
  46833. initExtend(Vue);
  46834. initAssetRegisters(Vue);
  46835. }
  46836. initGlobalAPI(Vue);
  46837. Object.defineProperty(Vue.prototype, '$isServer', {
  46838. get: isServerRendering
  46839. });
  46840. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46841. get: function get () {
  46842. /* istanbul ignore next */
  46843. return this.$vnode && this.$vnode.ssrContext
  46844. }
  46845. });
  46846. // expose FunctionalRenderContext for ssr runtime helper installation
  46847. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46848. value: FunctionalRenderContext
  46849. });
  46850. Vue.version = '2.6.11';
  46851. /* */
  46852. // these are reserved for web because they are directly compiled away
  46853. // during template compilation
  46854. var isReservedAttr = makeMap('style,class');
  46855. // attributes that should be using props for binding
  46856. var acceptValue = makeMap('input,textarea,option,select,progress');
  46857. var mustUseProp = function (tag, type, attr) {
  46858. return (
  46859. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46860. (attr === 'selected' && tag === 'option') ||
  46861. (attr === 'checked' && tag === 'input') ||
  46862. (attr === 'muted' && tag === 'video')
  46863. )
  46864. };
  46865. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46866. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46867. var convertEnumeratedValue = function (key, value) {
  46868. return isFalsyAttrValue(value) || value === 'false'
  46869. ? 'false'
  46870. // allow arbitrary string value for contenteditable
  46871. : key === 'contenteditable' && isValidContentEditableValue(value)
  46872. ? value
  46873. : 'true'
  46874. };
  46875. var isBooleanAttr = makeMap(
  46876. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46877. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46878. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46879. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46880. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46881. 'truespeed,typemustmatch,visible'
  46882. );
  46883. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46884. var isXlink = function (name) {
  46885. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46886. };
  46887. var getXlinkProp = function (name) {
  46888. return isXlink(name) ? name.slice(6, name.length) : ''
  46889. };
  46890. var isFalsyAttrValue = function (val) {
  46891. return val == null || val === false
  46892. };
  46893. /* */
  46894. function genClassForVnode (vnode) {
  46895. var data = vnode.data;
  46896. var parentNode = vnode;
  46897. var childNode = vnode;
  46898. while (isDef(childNode.componentInstance)) {
  46899. childNode = childNode.componentInstance._vnode;
  46900. if (childNode && childNode.data) {
  46901. data = mergeClassData(childNode.data, data);
  46902. }
  46903. }
  46904. while (isDef(parentNode = parentNode.parent)) {
  46905. if (parentNode && parentNode.data) {
  46906. data = mergeClassData(data, parentNode.data);
  46907. }
  46908. }
  46909. return renderClass(data.staticClass, data.class)
  46910. }
  46911. function mergeClassData (child, parent) {
  46912. return {
  46913. staticClass: concat(child.staticClass, parent.staticClass),
  46914. class: isDef(child.class)
  46915. ? [child.class, parent.class]
  46916. : parent.class
  46917. }
  46918. }
  46919. function renderClass (
  46920. staticClass,
  46921. dynamicClass
  46922. ) {
  46923. if (isDef(staticClass) || isDef(dynamicClass)) {
  46924. return concat(staticClass, stringifyClass(dynamicClass))
  46925. }
  46926. /* istanbul ignore next */
  46927. return ''
  46928. }
  46929. function concat (a, b) {
  46930. return a ? b ? (a + ' ' + b) : a : (b || '')
  46931. }
  46932. function stringifyClass (value) {
  46933. if (Array.isArray(value)) {
  46934. return stringifyArray(value)
  46935. }
  46936. if (isObject(value)) {
  46937. return stringifyObject(value)
  46938. }
  46939. if (typeof value === 'string') {
  46940. return value
  46941. }
  46942. /* istanbul ignore next */
  46943. return ''
  46944. }
  46945. function stringifyArray (value) {
  46946. var res = '';
  46947. var stringified;
  46948. for (var i = 0, l = value.length; i < l; i++) {
  46949. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46950. if (res) { res += ' '; }
  46951. res += stringified;
  46952. }
  46953. }
  46954. return res
  46955. }
  46956. function stringifyObject (value) {
  46957. var res = '';
  46958. for (var key in value) {
  46959. if (value[key]) {
  46960. if (res) { res += ' '; }
  46961. res += key;
  46962. }
  46963. }
  46964. return res
  46965. }
  46966. /* */
  46967. var namespaceMap = {
  46968. svg: 'http://www.w3.org/2000/svg',
  46969. math: 'http://www.w3.org/1998/Math/MathML'
  46970. };
  46971. var isHTMLTag = makeMap(
  46972. 'html,body,base,head,link,meta,style,title,' +
  46973. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46974. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46975. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46976. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46977. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46978. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46979. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46980. 'output,progress,select,textarea,' +
  46981. 'details,dialog,menu,menuitem,summary,' +
  46982. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46983. );
  46984. // this map is intentionally selective, only covering SVG elements that may
  46985. // contain child elements.
  46986. var isSVG = makeMap(
  46987. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46988. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46989. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46990. true
  46991. );
  46992. var isPreTag = function (tag) { return tag === 'pre'; };
  46993. var isReservedTag = function (tag) {
  46994. return isHTMLTag(tag) || isSVG(tag)
  46995. };
  46996. function getTagNamespace (tag) {
  46997. if (isSVG(tag)) {
  46998. return 'svg'
  46999. }
  47000. // basic support for MathML
  47001. // note it doesn't support other MathML elements being component roots
  47002. if (tag === 'math') {
  47003. return 'math'
  47004. }
  47005. }
  47006. var unknownElementCache = Object.create(null);
  47007. function isUnknownElement (tag) {
  47008. /* istanbul ignore if */
  47009. if (!inBrowser) {
  47010. return true
  47011. }
  47012. if (isReservedTag(tag)) {
  47013. return false
  47014. }
  47015. tag = tag.toLowerCase();
  47016. /* istanbul ignore if */
  47017. if (unknownElementCache[tag] != null) {
  47018. return unknownElementCache[tag]
  47019. }
  47020. var el = document.createElement(tag);
  47021. if (tag.indexOf('-') > -1) {
  47022. // http://stackoverflow.com/a/28210364/1070244
  47023. return (unknownElementCache[tag] = (
  47024. el.constructor === window.HTMLUnknownElement ||
  47025. el.constructor === window.HTMLElement
  47026. ))
  47027. } else {
  47028. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  47029. }
  47030. }
  47031. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  47032. /* */
  47033. /**
  47034. * Query an element selector if it's not an element already.
  47035. */
  47036. function query (el) {
  47037. if (typeof el === 'string') {
  47038. var selected = document.querySelector(el);
  47039. if (!selected) {
  47040. warn(
  47041. 'Cannot find element: ' + el
  47042. );
  47043. return document.createElement('div')
  47044. }
  47045. return selected
  47046. } else {
  47047. return el
  47048. }
  47049. }
  47050. /* */
  47051. function createElement$1 (tagName, vnode) {
  47052. var elm = document.createElement(tagName);
  47053. if (tagName !== 'select') {
  47054. return elm
  47055. }
  47056. // false or null will remove the attribute but undefined will not
  47057. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  47058. elm.setAttribute('multiple', 'multiple');
  47059. }
  47060. return elm
  47061. }
  47062. function createElementNS (namespace, tagName) {
  47063. return document.createElementNS(namespaceMap[namespace], tagName)
  47064. }
  47065. function createTextNode (text) {
  47066. return document.createTextNode(text)
  47067. }
  47068. function createComment (text) {
  47069. return document.createComment(text)
  47070. }
  47071. function insertBefore (parentNode, newNode, referenceNode) {
  47072. parentNode.insertBefore(newNode, referenceNode);
  47073. }
  47074. function removeChild (node, child) {
  47075. node.removeChild(child);
  47076. }
  47077. function appendChild (node, child) {
  47078. node.appendChild(child);
  47079. }
  47080. function parentNode (node) {
  47081. return node.parentNode
  47082. }
  47083. function nextSibling (node) {
  47084. return node.nextSibling
  47085. }
  47086. function tagName (node) {
  47087. return node.tagName
  47088. }
  47089. function setTextContent (node, text) {
  47090. node.textContent = text;
  47091. }
  47092. function setStyleScope (node, scopeId) {
  47093. node.setAttribute(scopeId, '');
  47094. }
  47095. var nodeOps = /*#__PURE__*/Object.freeze({
  47096. createElement: createElement$1,
  47097. createElementNS: createElementNS,
  47098. createTextNode: createTextNode,
  47099. createComment: createComment,
  47100. insertBefore: insertBefore,
  47101. removeChild: removeChild,
  47102. appendChild: appendChild,
  47103. parentNode: parentNode,
  47104. nextSibling: nextSibling,
  47105. tagName: tagName,
  47106. setTextContent: setTextContent,
  47107. setStyleScope: setStyleScope
  47108. });
  47109. /* */
  47110. var ref = {
  47111. create: function create (_, vnode) {
  47112. registerRef(vnode);
  47113. },
  47114. update: function update (oldVnode, vnode) {
  47115. if (oldVnode.data.ref !== vnode.data.ref) {
  47116. registerRef(oldVnode, true);
  47117. registerRef(vnode);
  47118. }
  47119. },
  47120. destroy: function destroy (vnode) {
  47121. registerRef(vnode, true);
  47122. }
  47123. };
  47124. function registerRef (vnode, isRemoval) {
  47125. var key = vnode.data.ref;
  47126. if (!isDef(key)) { return }
  47127. var vm = vnode.context;
  47128. var ref = vnode.componentInstance || vnode.elm;
  47129. var refs = vm.$refs;
  47130. if (isRemoval) {
  47131. if (Array.isArray(refs[key])) {
  47132. remove(refs[key], ref);
  47133. } else if (refs[key] === ref) {
  47134. refs[key] = undefined;
  47135. }
  47136. } else {
  47137. if (vnode.data.refInFor) {
  47138. if (!Array.isArray(refs[key])) {
  47139. refs[key] = [ref];
  47140. } else if (refs[key].indexOf(ref) < 0) {
  47141. // $flow-disable-line
  47142. refs[key].push(ref);
  47143. }
  47144. } else {
  47145. refs[key] = ref;
  47146. }
  47147. }
  47148. }
  47149. /**
  47150. * Virtual DOM patching algorithm based on Snabbdom by
  47151. * Simon Friis Vindum (@paldepind)
  47152. * Licensed under the MIT License
  47153. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  47154. *
  47155. * modified by Evan You (@yyx990803)
  47156. *
  47157. * Not type-checking this because this file is perf-critical and the cost
  47158. * of making flow understand it is not worth it.
  47159. */
  47160. var emptyNode = new VNode('', {}, []);
  47161. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  47162. function sameVnode (a, b) {
  47163. return (
  47164. a.key === b.key && (
  47165. (
  47166. a.tag === b.tag &&
  47167. a.isComment === b.isComment &&
  47168. isDef(a.data) === isDef(b.data) &&
  47169. sameInputType(a, b)
  47170. ) || (
  47171. isTrue(a.isAsyncPlaceholder) &&
  47172. a.asyncFactory === b.asyncFactory &&
  47173. isUndef(b.asyncFactory.error)
  47174. )
  47175. )
  47176. )
  47177. }
  47178. function sameInputType (a, b) {
  47179. if (a.tag !== 'input') { return true }
  47180. var i;
  47181. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  47182. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  47183. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  47184. }
  47185. function createKeyToOldIdx (children, beginIdx, endIdx) {
  47186. var i, key;
  47187. var map = {};
  47188. for (i = beginIdx; i <= endIdx; ++i) {
  47189. key = children[i].key;
  47190. if (isDef(key)) { map[key] = i; }
  47191. }
  47192. return map
  47193. }
  47194. function createPatchFunction (backend) {
  47195. var i, j;
  47196. var cbs = {};
  47197. var modules = backend.modules;
  47198. var nodeOps = backend.nodeOps;
  47199. for (i = 0; i < hooks.length; ++i) {
  47200. cbs[hooks[i]] = [];
  47201. for (j = 0; j < modules.length; ++j) {
  47202. if (isDef(modules[j][hooks[i]])) {
  47203. cbs[hooks[i]].push(modules[j][hooks[i]]);
  47204. }
  47205. }
  47206. }
  47207. function emptyNodeAt (elm) {
  47208. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  47209. }
  47210. function createRmCb (childElm, listeners) {
  47211. function remove$$1 () {
  47212. if (--remove$$1.listeners === 0) {
  47213. removeNode(childElm);
  47214. }
  47215. }
  47216. remove$$1.listeners = listeners;
  47217. return remove$$1
  47218. }
  47219. function removeNode (el) {
  47220. var parent = nodeOps.parentNode(el);
  47221. // element may have already been removed due to v-html / v-text
  47222. if (isDef(parent)) {
  47223. nodeOps.removeChild(parent, el);
  47224. }
  47225. }
  47226. function isUnknownElement$$1 (vnode, inVPre) {
  47227. return (
  47228. !inVPre &&
  47229. !vnode.ns &&
  47230. !(
  47231. config.ignoredElements.length &&
  47232. config.ignoredElements.some(function (ignore) {
  47233. return isRegExp(ignore)
  47234. ? ignore.test(vnode.tag)
  47235. : ignore === vnode.tag
  47236. })
  47237. ) &&
  47238. config.isUnknownElement(vnode.tag)
  47239. )
  47240. }
  47241. var creatingElmInVPre = 0;
  47242. function createElm (
  47243. vnode,
  47244. insertedVnodeQueue,
  47245. parentElm,
  47246. refElm,
  47247. nested,
  47248. ownerArray,
  47249. index
  47250. ) {
  47251. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47252. // This vnode was used in a previous render!
  47253. // now it's used as a new node, overwriting its elm would cause
  47254. // potential patch errors down the road when it's used as an insertion
  47255. // reference node. Instead, we clone the node on-demand before creating
  47256. // associated DOM element for it.
  47257. vnode = ownerArray[index] = cloneVNode(vnode);
  47258. }
  47259. vnode.isRootInsert = !nested; // for transition enter check
  47260. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47261. return
  47262. }
  47263. var data = vnode.data;
  47264. var children = vnode.children;
  47265. var tag = vnode.tag;
  47266. if (isDef(tag)) {
  47267. {
  47268. if (data && data.pre) {
  47269. creatingElmInVPre++;
  47270. }
  47271. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47272. warn(
  47273. 'Unknown custom element: <' + tag + '> - did you ' +
  47274. 'register the component correctly? For recursive components, ' +
  47275. 'make sure to provide the "name" option.',
  47276. vnode.context
  47277. );
  47278. }
  47279. }
  47280. vnode.elm = vnode.ns
  47281. ? nodeOps.createElementNS(vnode.ns, tag)
  47282. : nodeOps.createElement(tag, vnode);
  47283. setScope(vnode);
  47284. /* istanbul ignore if */
  47285. {
  47286. createChildren(vnode, children, insertedVnodeQueue);
  47287. if (isDef(data)) {
  47288. invokeCreateHooks(vnode, insertedVnodeQueue);
  47289. }
  47290. insert(parentElm, vnode.elm, refElm);
  47291. }
  47292. if (data && data.pre) {
  47293. creatingElmInVPre--;
  47294. }
  47295. } else if (isTrue(vnode.isComment)) {
  47296. vnode.elm = nodeOps.createComment(vnode.text);
  47297. insert(parentElm, vnode.elm, refElm);
  47298. } else {
  47299. vnode.elm = nodeOps.createTextNode(vnode.text);
  47300. insert(parentElm, vnode.elm, refElm);
  47301. }
  47302. }
  47303. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47304. var i = vnode.data;
  47305. if (isDef(i)) {
  47306. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47307. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47308. i(vnode, false /* hydrating */);
  47309. }
  47310. // after calling the init hook, if the vnode is a child component
  47311. // it should've created a child instance and mounted it. the child
  47312. // component also has set the placeholder vnode's elm.
  47313. // in that case we can just return the element and be done.
  47314. if (isDef(vnode.componentInstance)) {
  47315. initComponent(vnode, insertedVnodeQueue);
  47316. insert(parentElm, vnode.elm, refElm);
  47317. if (isTrue(isReactivated)) {
  47318. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47319. }
  47320. return true
  47321. }
  47322. }
  47323. }
  47324. function initComponent (vnode, insertedVnodeQueue) {
  47325. if (isDef(vnode.data.pendingInsert)) {
  47326. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47327. vnode.data.pendingInsert = null;
  47328. }
  47329. vnode.elm = vnode.componentInstance.$el;
  47330. if (isPatchable(vnode)) {
  47331. invokeCreateHooks(vnode, insertedVnodeQueue);
  47332. setScope(vnode);
  47333. } else {
  47334. // empty component root.
  47335. // skip all element-related modules except for ref (#3455)
  47336. registerRef(vnode);
  47337. // make sure to invoke the insert hook
  47338. insertedVnodeQueue.push(vnode);
  47339. }
  47340. }
  47341. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47342. var i;
  47343. // hack for #4339: a reactivated component with inner transition
  47344. // does not trigger because the inner node's created hooks are not called
  47345. // again. It's not ideal to involve module-specific logic in here but
  47346. // there doesn't seem to be a better way to do it.
  47347. var innerNode = vnode;
  47348. while (innerNode.componentInstance) {
  47349. innerNode = innerNode.componentInstance._vnode;
  47350. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47351. for (i = 0; i < cbs.activate.length; ++i) {
  47352. cbs.activate[i](emptyNode, innerNode);
  47353. }
  47354. insertedVnodeQueue.push(innerNode);
  47355. break
  47356. }
  47357. }
  47358. // unlike a newly created component,
  47359. // a reactivated keep-alive component doesn't insert itself
  47360. insert(parentElm, vnode.elm, refElm);
  47361. }
  47362. function insert (parent, elm, ref$$1) {
  47363. if (isDef(parent)) {
  47364. if (isDef(ref$$1)) {
  47365. if (nodeOps.parentNode(ref$$1) === parent) {
  47366. nodeOps.insertBefore(parent, elm, ref$$1);
  47367. }
  47368. } else {
  47369. nodeOps.appendChild(parent, elm);
  47370. }
  47371. }
  47372. }
  47373. function createChildren (vnode, children, insertedVnodeQueue) {
  47374. if (Array.isArray(children)) {
  47375. {
  47376. checkDuplicateKeys(children);
  47377. }
  47378. for (var i = 0; i < children.length; ++i) {
  47379. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47380. }
  47381. } else if (isPrimitive(vnode.text)) {
  47382. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47383. }
  47384. }
  47385. function isPatchable (vnode) {
  47386. while (vnode.componentInstance) {
  47387. vnode = vnode.componentInstance._vnode;
  47388. }
  47389. return isDef(vnode.tag)
  47390. }
  47391. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47392. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47393. cbs.create[i$1](emptyNode, vnode);
  47394. }
  47395. i = vnode.data.hook; // Reuse variable
  47396. if (isDef(i)) {
  47397. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47398. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47399. }
  47400. }
  47401. // set scope id attribute for scoped CSS.
  47402. // this is implemented as a special case to avoid the overhead
  47403. // of going through the normal attribute patching process.
  47404. function setScope (vnode) {
  47405. var i;
  47406. if (isDef(i = vnode.fnScopeId)) {
  47407. nodeOps.setStyleScope(vnode.elm, i);
  47408. } else {
  47409. var ancestor = vnode;
  47410. while (ancestor) {
  47411. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47412. nodeOps.setStyleScope(vnode.elm, i);
  47413. }
  47414. ancestor = ancestor.parent;
  47415. }
  47416. }
  47417. // for slot content they should also get the scopeId from the host instance.
  47418. if (isDef(i = activeInstance) &&
  47419. i !== vnode.context &&
  47420. i !== vnode.fnContext &&
  47421. isDef(i = i.$options._scopeId)
  47422. ) {
  47423. nodeOps.setStyleScope(vnode.elm, i);
  47424. }
  47425. }
  47426. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47427. for (; startIdx <= endIdx; ++startIdx) {
  47428. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47429. }
  47430. }
  47431. function invokeDestroyHook (vnode) {
  47432. var i, j;
  47433. var data = vnode.data;
  47434. if (isDef(data)) {
  47435. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47436. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47437. }
  47438. if (isDef(i = vnode.children)) {
  47439. for (j = 0; j < vnode.children.length; ++j) {
  47440. invokeDestroyHook(vnode.children[j]);
  47441. }
  47442. }
  47443. }
  47444. function removeVnodes (vnodes, startIdx, endIdx) {
  47445. for (; startIdx <= endIdx; ++startIdx) {
  47446. var ch = vnodes[startIdx];
  47447. if (isDef(ch)) {
  47448. if (isDef(ch.tag)) {
  47449. removeAndInvokeRemoveHook(ch);
  47450. invokeDestroyHook(ch);
  47451. } else { // Text node
  47452. removeNode(ch.elm);
  47453. }
  47454. }
  47455. }
  47456. }
  47457. function removeAndInvokeRemoveHook (vnode, rm) {
  47458. if (isDef(rm) || isDef(vnode.data)) {
  47459. var i;
  47460. var listeners = cbs.remove.length + 1;
  47461. if (isDef(rm)) {
  47462. // we have a recursively passed down rm callback
  47463. // increase the listeners count
  47464. rm.listeners += listeners;
  47465. } else {
  47466. // directly removing
  47467. rm = createRmCb(vnode.elm, listeners);
  47468. }
  47469. // recursively invoke hooks on child component root node
  47470. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47471. removeAndInvokeRemoveHook(i, rm);
  47472. }
  47473. for (i = 0; i < cbs.remove.length; ++i) {
  47474. cbs.remove[i](vnode, rm);
  47475. }
  47476. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47477. i(vnode, rm);
  47478. } else {
  47479. rm();
  47480. }
  47481. } else {
  47482. removeNode(vnode.elm);
  47483. }
  47484. }
  47485. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47486. var oldStartIdx = 0;
  47487. var newStartIdx = 0;
  47488. var oldEndIdx = oldCh.length - 1;
  47489. var oldStartVnode = oldCh[0];
  47490. var oldEndVnode = oldCh[oldEndIdx];
  47491. var newEndIdx = newCh.length - 1;
  47492. var newStartVnode = newCh[0];
  47493. var newEndVnode = newCh[newEndIdx];
  47494. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47495. // removeOnly is a special flag used only by <transition-group>
  47496. // to ensure removed elements stay in correct relative positions
  47497. // during leaving transitions
  47498. var canMove = !removeOnly;
  47499. {
  47500. checkDuplicateKeys(newCh);
  47501. }
  47502. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47503. if (isUndef(oldStartVnode)) {
  47504. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47505. } else if (isUndef(oldEndVnode)) {
  47506. oldEndVnode = oldCh[--oldEndIdx];
  47507. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47508. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47509. oldStartVnode = oldCh[++oldStartIdx];
  47510. newStartVnode = newCh[++newStartIdx];
  47511. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47512. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47513. oldEndVnode = oldCh[--oldEndIdx];
  47514. newEndVnode = newCh[--newEndIdx];
  47515. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47516. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47517. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47518. oldStartVnode = oldCh[++oldStartIdx];
  47519. newEndVnode = newCh[--newEndIdx];
  47520. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47521. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47522. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47523. oldEndVnode = oldCh[--oldEndIdx];
  47524. newStartVnode = newCh[++newStartIdx];
  47525. } else {
  47526. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47527. idxInOld = isDef(newStartVnode.key)
  47528. ? oldKeyToIdx[newStartVnode.key]
  47529. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47530. if (isUndef(idxInOld)) { // New element
  47531. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47532. } else {
  47533. vnodeToMove = oldCh[idxInOld];
  47534. if (sameVnode(vnodeToMove, newStartVnode)) {
  47535. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47536. oldCh[idxInOld] = undefined;
  47537. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47538. } else {
  47539. // same key but different element. treat as new element
  47540. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47541. }
  47542. }
  47543. newStartVnode = newCh[++newStartIdx];
  47544. }
  47545. }
  47546. if (oldStartIdx > oldEndIdx) {
  47547. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47548. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47549. } else if (newStartIdx > newEndIdx) {
  47550. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47551. }
  47552. }
  47553. function checkDuplicateKeys (children) {
  47554. var seenKeys = {};
  47555. for (var i = 0; i < children.length; i++) {
  47556. var vnode = children[i];
  47557. var key = vnode.key;
  47558. if (isDef(key)) {
  47559. if (seenKeys[key]) {
  47560. warn(
  47561. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47562. vnode.context
  47563. );
  47564. } else {
  47565. seenKeys[key] = true;
  47566. }
  47567. }
  47568. }
  47569. }
  47570. function findIdxInOld (node, oldCh, start, end) {
  47571. for (var i = start; i < end; i++) {
  47572. var c = oldCh[i];
  47573. if (isDef(c) && sameVnode(node, c)) { return i }
  47574. }
  47575. }
  47576. function patchVnode (
  47577. oldVnode,
  47578. vnode,
  47579. insertedVnodeQueue,
  47580. ownerArray,
  47581. index,
  47582. removeOnly
  47583. ) {
  47584. if (oldVnode === vnode) {
  47585. return
  47586. }
  47587. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47588. // clone reused vnode
  47589. vnode = ownerArray[index] = cloneVNode(vnode);
  47590. }
  47591. var elm = vnode.elm = oldVnode.elm;
  47592. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47593. if (isDef(vnode.asyncFactory.resolved)) {
  47594. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47595. } else {
  47596. vnode.isAsyncPlaceholder = true;
  47597. }
  47598. return
  47599. }
  47600. // reuse element for static trees.
  47601. // note we only do this if the vnode is cloned -
  47602. // if the new node is not cloned it means the render functions have been
  47603. // reset by the hot-reload-api and we need to do a proper re-render.
  47604. if (isTrue(vnode.isStatic) &&
  47605. isTrue(oldVnode.isStatic) &&
  47606. vnode.key === oldVnode.key &&
  47607. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47608. ) {
  47609. vnode.componentInstance = oldVnode.componentInstance;
  47610. return
  47611. }
  47612. var i;
  47613. var data = vnode.data;
  47614. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47615. i(oldVnode, vnode);
  47616. }
  47617. var oldCh = oldVnode.children;
  47618. var ch = vnode.children;
  47619. if (isDef(data) && isPatchable(vnode)) {
  47620. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47621. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47622. }
  47623. if (isUndef(vnode.text)) {
  47624. if (isDef(oldCh) && isDef(ch)) {
  47625. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47626. } else if (isDef(ch)) {
  47627. {
  47628. checkDuplicateKeys(ch);
  47629. }
  47630. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47631. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47632. } else if (isDef(oldCh)) {
  47633. removeVnodes(oldCh, 0, oldCh.length - 1);
  47634. } else if (isDef(oldVnode.text)) {
  47635. nodeOps.setTextContent(elm, '');
  47636. }
  47637. } else if (oldVnode.text !== vnode.text) {
  47638. nodeOps.setTextContent(elm, vnode.text);
  47639. }
  47640. if (isDef(data)) {
  47641. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47642. }
  47643. }
  47644. function invokeInsertHook (vnode, queue, initial) {
  47645. // delay insert hooks for component root nodes, invoke them after the
  47646. // element is really inserted
  47647. if (isTrue(initial) && isDef(vnode.parent)) {
  47648. vnode.parent.data.pendingInsert = queue;
  47649. } else {
  47650. for (var i = 0; i < queue.length; ++i) {
  47651. queue[i].data.hook.insert(queue[i]);
  47652. }
  47653. }
  47654. }
  47655. var hydrationBailed = false;
  47656. // list of modules that can skip create hook during hydration because they
  47657. // are already rendered on the client or has no need for initialization
  47658. // Note: style is excluded because it relies on initial clone for future
  47659. // deep updates (#7063).
  47660. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47661. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47662. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47663. var i;
  47664. var tag = vnode.tag;
  47665. var data = vnode.data;
  47666. var children = vnode.children;
  47667. inVPre = inVPre || (data && data.pre);
  47668. vnode.elm = elm;
  47669. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47670. vnode.isAsyncPlaceholder = true;
  47671. return true
  47672. }
  47673. // assert node match
  47674. {
  47675. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47676. return false
  47677. }
  47678. }
  47679. if (isDef(data)) {
  47680. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47681. if (isDef(i = vnode.componentInstance)) {
  47682. // child component. it should have hydrated its own tree.
  47683. initComponent(vnode, insertedVnodeQueue);
  47684. return true
  47685. }
  47686. }
  47687. if (isDef(tag)) {
  47688. if (isDef(children)) {
  47689. // empty element, allow client to pick up and populate children
  47690. if (!elm.hasChildNodes()) {
  47691. createChildren(vnode, children, insertedVnodeQueue);
  47692. } else {
  47693. // v-html and domProps: innerHTML
  47694. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47695. if (i !== elm.innerHTML) {
  47696. /* istanbul ignore if */
  47697. if (typeof console !== 'undefined' &&
  47698. !hydrationBailed
  47699. ) {
  47700. hydrationBailed = true;
  47701. console.warn('Parent: ', elm);
  47702. console.warn('server innerHTML: ', i);
  47703. console.warn('client innerHTML: ', elm.innerHTML);
  47704. }
  47705. return false
  47706. }
  47707. } else {
  47708. // iterate and compare children lists
  47709. var childrenMatch = true;
  47710. var childNode = elm.firstChild;
  47711. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47712. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47713. childrenMatch = false;
  47714. break
  47715. }
  47716. childNode = childNode.nextSibling;
  47717. }
  47718. // if childNode is not null, it means the actual childNodes list is
  47719. // longer than the virtual children list.
  47720. if (!childrenMatch || childNode) {
  47721. /* istanbul ignore if */
  47722. if (typeof console !== 'undefined' &&
  47723. !hydrationBailed
  47724. ) {
  47725. hydrationBailed = true;
  47726. console.warn('Parent: ', elm);
  47727. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47728. }
  47729. return false
  47730. }
  47731. }
  47732. }
  47733. }
  47734. if (isDef(data)) {
  47735. var fullInvoke = false;
  47736. for (var key in data) {
  47737. if (!isRenderedModule(key)) {
  47738. fullInvoke = true;
  47739. invokeCreateHooks(vnode, insertedVnodeQueue);
  47740. break
  47741. }
  47742. }
  47743. if (!fullInvoke && data['class']) {
  47744. // ensure collecting deps for deep class bindings for future updates
  47745. traverse(data['class']);
  47746. }
  47747. }
  47748. } else if (elm.data !== vnode.text) {
  47749. elm.data = vnode.text;
  47750. }
  47751. return true
  47752. }
  47753. function assertNodeMatch (node, vnode, inVPre) {
  47754. if (isDef(vnode.tag)) {
  47755. return vnode.tag.indexOf('vue-component') === 0 || (
  47756. !isUnknownElement$$1(vnode, inVPre) &&
  47757. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47758. )
  47759. } else {
  47760. return node.nodeType === (vnode.isComment ? 8 : 3)
  47761. }
  47762. }
  47763. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47764. if (isUndef(vnode)) {
  47765. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47766. return
  47767. }
  47768. var isInitialPatch = false;
  47769. var insertedVnodeQueue = [];
  47770. if (isUndef(oldVnode)) {
  47771. // empty mount (likely as component), create new root element
  47772. isInitialPatch = true;
  47773. createElm(vnode, insertedVnodeQueue);
  47774. } else {
  47775. var isRealElement = isDef(oldVnode.nodeType);
  47776. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47777. // patch existing root node
  47778. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47779. } else {
  47780. if (isRealElement) {
  47781. // mounting to a real element
  47782. // check if this is server-rendered content and if we can perform
  47783. // a successful hydration.
  47784. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47785. oldVnode.removeAttribute(SSR_ATTR);
  47786. hydrating = true;
  47787. }
  47788. if (isTrue(hydrating)) {
  47789. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47790. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47791. return oldVnode
  47792. } else {
  47793. warn(
  47794. 'The client-side rendered virtual DOM tree is not matching ' +
  47795. 'server-rendered content. This is likely caused by incorrect ' +
  47796. 'HTML markup, for example nesting block-level elements inside ' +
  47797. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47798. 'full client-side render.'
  47799. );
  47800. }
  47801. }
  47802. // either not server-rendered, or hydration failed.
  47803. // create an empty node and replace it
  47804. oldVnode = emptyNodeAt(oldVnode);
  47805. }
  47806. // replacing existing element
  47807. var oldElm = oldVnode.elm;
  47808. var parentElm = nodeOps.parentNode(oldElm);
  47809. // create new node
  47810. createElm(
  47811. vnode,
  47812. insertedVnodeQueue,
  47813. // extremely rare edge case: do not insert if old element is in a
  47814. // leaving transition. Only happens when combining transition +
  47815. // keep-alive + HOCs. (#4590)
  47816. oldElm._leaveCb ? null : parentElm,
  47817. nodeOps.nextSibling(oldElm)
  47818. );
  47819. // update parent placeholder node element, recursively
  47820. if (isDef(vnode.parent)) {
  47821. var ancestor = vnode.parent;
  47822. var patchable = isPatchable(vnode);
  47823. while (ancestor) {
  47824. for (var i = 0; i < cbs.destroy.length; ++i) {
  47825. cbs.destroy[i](ancestor);
  47826. }
  47827. ancestor.elm = vnode.elm;
  47828. if (patchable) {
  47829. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47830. cbs.create[i$1](emptyNode, ancestor);
  47831. }
  47832. // #6513
  47833. // invoke insert hooks that may have been merged by create hooks.
  47834. // e.g. for directives that uses the "inserted" hook.
  47835. var insert = ancestor.data.hook.insert;
  47836. if (insert.merged) {
  47837. // start at index 1 to avoid re-invoking component mounted hook
  47838. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47839. insert.fns[i$2]();
  47840. }
  47841. }
  47842. } else {
  47843. registerRef(ancestor);
  47844. }
  47845. ancestor = ancestor.parent;
  47846. }
  47847. }
  47848. // destroy old node
  47849. if (isDef(parentElm)) {
  47850. removeVnodes([oldVnode], 0, 0);
  47851. } else if (isDef(oldVnode.tag)) {
  47852. invokeDestroyHook(oldVnode);
  47853. }
  47854. }
  47855. }
  47856. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47857. return vnode.elm
  47858. }
  47859. }
  47860. /* */
  47861. var directives = {
  47862. create: updateDirectives,
  47863. update: updateDirectives,
  47864. destroy: function unbindDirectives (vnode) {
  47865. updateDirectives(vnode, emptyNode);
  47866. }
  47867. };
  47868. function updateDirectives (oldVnode, vnode) {
  47869. if (oldVnode.data.directives || vnode.data.directives) {
  47870. _update(oldVnode, vnode);
  47871. }
  47872. }
  47873. function _update (oldVnode, vnode) {
  47874. var isCreate = oldVnode === emptyNode;
  47875. var isDestroy = vnode === emptyNode;
  47876. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47877. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47878. var dirsWithInsert = [];
  47879. var dirsWithPostpatch = [];
  47880. var key, oldDir, dir;
  47881. for (key in newDirs) {
  47882. oldDir = oldDirs[key];
  47883. dir = newDirs[key];
  47884. if (!oldDir) {
  47885. // new directive, bind
  47886. callHook$1(dir, 'bind', vnode, oldVnode);
  47887. if (dir.def && dir.def.inserted) {
  47888. dirsWithInsert.push(dir);
  47889. }
  47890. } else {
  47891. // existing directive, update
  47892. dir.oldValue = oldDir.value;
  47893. dir.oldArg = oldDir.arg;
  47894. callHook$1(dir, 'update', vnode, oldVnode);
  47895. if (dir.def && dir.def.componentUpdated) {
  47896. dirsWithPostpatch.push(dir);
  47897. }
  47898. }
  47899. }
  47900. if (dirsWithInsert.length) {
  47901. var callInsert = function () {
  47902. for (var i = 0; i < dirsWithInsert.length; i++) {
  47903. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47904. }
  47905. };
  47906. if (isCreate) {
  47907. mergeVNodeHook(vnode, 'insert', callInsert);
  47908. } else {
  47909. callInsert();
  47910. }
  47911. }
  47912. if (dirsWithPostpatch.length) {
  47913. mergeVNodeHook(vnode, 'postpatch', function () {
  47914. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47915. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47916. }
  47917. });
  47918. }
  47919. if (!isCreate) {
  47920. for (key in oldDirs) {
  47921. if (!newDirs[key]) {
  47922. // no longer present, unbind
  47923. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47924. }
  47925. }
  47926. }
  47927. }
  47928. var emptyModifiers = Object.create(null);
  47929. function normalizeDirectives$1 (
  47930. dirs,
  47931. vm
  47932. ) {
  47933. var res = Object.create(null);
  47934. if (!dirs) {
  47935. // $flow-disable-line
  47936. return res
  47937. }
  47938. var i, dir;
  47939. for (i = 0; i < dirs.length; i++) {
  47940. dir = dirs[i];
  47941. if (!dir.modifiers) {
  47942. // $flow-disable-line
  47943. dir.modifiers = emptyModifiers;
  47944. }
  47945. res[getRawDirName(dir)] = dir;
  47946. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47947. }
  47948. // $flow-disable-line
  47949. return res
  47950. }
  47951. function getRawDirName (dir) {
  47952. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47953. }
  47954. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47955. var fn = dir.def && dir.def[hook];
  47956. if (fn) {
  47957. try {
  47958. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47959. } catch (e) {
  47960. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47961. }
  47962. }
  47963. }
  47964. var baseModules = [
  47965. ref,
  47966. directives
  47967. ];
  47968. /* */
  47969. function updateAttrs (oldVnode, vnode) {
  47970. var opts = vnode.componentOptions;
  47971. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47972. return
  47973. }
  47974. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47975. return
  47976. }
  47977. var key, cur, old;
  47978. var elm = vnode.elm;
  47979. var oldAttrs = oldVnode.data.attrs || {};
  47980. var attrs = vnode.data.attrs || {};
  47981. // clone observed objects, as the user probably wants to mutate it
  47982. if (isDef(attrs.__ob__)) {
  47983. attrs = vnode.data.attrs = extend({}, attrs);
  47984. }
  47985. for (key in attrs) {
  47986. cur = attrs[key];
  47987. old = oldAttrs[key];
  47988. if (old !== cur) {
  47989. setAttr(elm, key, cur);
  47990. }
  47991. }
  47992. // #4391: in IE9, setting type can reset value for input[type=radio]
  47993. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47994. /* istanbul ignore if */
  47995. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47996. setAttr(elm, 'value', attrs.value);
  47997. }
  47998. for (key in oldAttrs) {
  47999. if (isUndef(attrs[key])) {
  48000. if (isXlink(key)) {
  48001. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  48002. } else if (!isEnumeratedAttr(key)) {
  48003. elm.removeAttribute(key);
  48004. }
  48005. }
  48006. }
  48007. }
  48008. function setAttr (el, key, value) {
  48009. if (el.tagName.indexOf('-') > -1) {
  48010. baseSetAttr(el, key, value);
  48011. } else if (isBooleanAttr(key)) {
  48012. // set attribute for blank value
  48013. // e.g. <option disabled>Select one</option>
  48014. if (isFalsyAttrValue(value)) {
  48015. el.removeAttribute(key);
  48016. } else {
  48017. // technically allowfullscreen is a boolean attribute for <iframe>,
  48018. // but Flash expects a value of "true" when used on <embed> tag
  48019. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  48020. ? 'true'
  48021. : key;
  48022. el.setAttribute(key, value);
  48023. }
  48024. } else if (isEnumeratedAttr(key)) {
  48025. el.setAttribute(key, convertEnumeratedValue(key, value));
  48026. } else if (isXlink(key)) {
  48027. if (isFalsyAttrValue(value)) {
  48028. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  48029. } else {
  48030. el.setAttributeNS(xlinkNS, key, value);
  48031. }
  48032. } else {
  48033. baseSetAttr(el, key, value);
  48034. }
  48035. }
  48036. function baseSetAttr (el, key, value) {
  48037. if (isFalsyAttrValue(value)) {
  48038. el.removeAttribute(key);
  48039. } else {
  48040. // #7138: IE10 & 11 fires input event when setting placeholder on
  48041. // <textarea>... block the first input event and remove the blocker
  48042. // immediately.
  48043. /* istanbul ignore if */
  48044. if (
  48045. isIE && !isIE9 &&
  48046. el.tagName === 'TEXTAREA' &&
  48047. key === 'placeholder' && value !== '' && !el.__ieph
  48048. ) {
  48049. var blocker = function (e) {
  48050. e.stopImmediatePropagation();
  48051. el.removeEventListener('input', blocker);
  48052. };
  48053. el.addEventListener('input', blocker);
  48054. // $flow-disable-line
  48055. el.__ieph = true; /* IE placeholder patched */
  48056. }
  48057. el.setAttribute(key, value);
  48058. }
  48059. }
  48060. var attrs = {
  48061. create: updateAttrs,
  48062. update: updateAttrs
  48063. };
  48064. /* */
  48065. function updateClass (oldVnode, vnode) {
  48066. var el = vnode.elm;
  48067. var data = vnode.data;
  48068. var oldData = oldVnode.data;
  48069. if (
  48070. isUndef(data.staticClass) &&
  48071. isUndef(data.class) && (
  48072. isUndef(oldData) || (
  48073. isUndef(oldData.staticClass) &&
  48074. isUndef(oldData.class)
  48075. )
  48076. )
  48077. ) {
  48078. return
  48079. }
  48080. var cls = genClassForVnode(vnode);
  48081. // handle transition classes
  48082. var transitionClass = el._transitionClasses;
  48083. if (isDef(transitionClass)) {
  48084. cls = concat(cls, stringifyClass(transitionClass));
  48085. }
  48086. // set the class
  48087. if (cls !== el._prevClass) {
  48088. el.setAttribute('class', cls);
  48089. el._prevClass = cls;
  48090. }
  48091. }
  48092. var klass = {
  48093. create: updateClass,
  48094. update: updateClass
  48095. };
  48096. /* */
  48097. var validDivisionCharRE = /[\w).+\-_$\]]/;
  48098. function parseFilters (exp) {
  48099. var inSingle = false;
  48100. var inDouble = false;
  48101. var inTemplateString = false;
  48102. var inRegex = false;
  48103. var curly = 0;
  48104. var square = 0;
  48105. var paren = 0;
  48106. var lastFilterIndex = 0;
  48107. var c, prev, i, expression, filters;
  48108. for (i = 0; i < exp.length; i++) {
  48109. prev = c;
  48110. c = exp.charCodeAt(i);
  48111. if (inSingle) {
  48112. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  48113. } else if (inDouble) {
  48114. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  48115. } else if (inTemplateString) {
  48116. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  48117. } else if (inRegex) {
  48118. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  48119. } else if (
  48120. c === 0x7C && // pipe
  48121. exp.charCodeAt(i + 1) !== 0x7C &&
  48122. exp.charCodeAt(i - 1) !== 0x7C &&
  48123. !curly && !square && !paren
  48124. ) {
  48125. if (expression === undefined) {
  48126. // first filter, end of expression
  48127. lastFilterIndex = i + 1;
  48128. expression = exp.slice(0, i).trim();
  48129. } else {
  48130. pushFilter();
  48131. }
  48132. } else {
  48133. switch (c) {
  48134. case 0x22: inDouble = true; break // "
  48135. case 0x27: inSingle = true; break // '
  48136. case 0x60: inTemplateString = true; break // `
  48137. case 0x28: paren++; break // (
  48138. case 0x29: paren--; break // )
  48139. case 0x5B: square++; break // [
  48140. case 0x5D: square--; break // ]
  48141. case 0x7B: curly++; break // {
  48142. case 0x7D: curly--; break // }
  48143. }
  48144. if (c === 0x2f) { // /
  48145. var j = i - 1;
  48146. var p = (void 0);
  48147. // find first non-whitespace prev char
  48148. for (; j >= 0; j--) {
  48149. p = exp.charAt(j);
  48150. if (p !== ' ') { break }
  48151. }
  48152. if (!p || !validDivisionCharRE.test(p)) {
  48153. inRegex = true;
  48154. }
  48155. }
  48156. }
  48157. }
  48158. if (expression === undefined) {
  48159. expression = exp.slice(0, i).trim();
  48160. } else if (lastFilterIndex !== 0) {
  48161. pushFilter();
  48162. }
  48163. function pushFilter () {
  48164. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  48165. lastFilterIndex = i + 1;
  48166. }
  48167. if (filters) {
  48168. for (i = 0; i < filters.length; i++) {
  48169. expression = wrapFilter(expression, filters[i]);
  48170. }
  48171. }
  48172. return expression
  48173. }
  48174. function wrapFilter (exp, filter) {
  48175. var i = filter.indexOf('(');
  48176. if (i < 0) {
  48177. // _f: resolveFilter
  48178. return ("_f(\"" + filter + "\")(" + exp + ")")
  48179. } else {
  48180. var name = filter.slice(0, i);
  48181. var args = filter.slice(i + 1);
  48182. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  48183. }
  48184. }
  48185. /* */
  48186. /* eslint-disable no-unused-vars */
  48187. function baseWarn (msg, range) {
  48188. console.error(("[Vue compiler]: " + msg));
  48189. }
  48190. /* eslint-enable no-unused-vars */
  48191. function pluckModuleFunction (
  48192. modules,
  48193. key
  48194. ) {
  48195. return modules
  48196. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  48197. : []
  48198. }
  48199. function addProp (el, name, value, range, dynamic) {
  48200. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48201. el.plain = false;
  48202. }
  48203. function addAttr (el, name, value, range, dynamic) {
  48204. var attrs = dynamic
  48205. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  48206. : (el.attrs || (el.attrs = []));
  48207. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48208. el.plain = false;
  48209. }
  48210. // add a raw attr (use this in preTransforms)
  48211. function addRawAttr (el, name, value, range) {
  48212. el.attrsMap[name] = value;
  48213. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  48214. }
  48215. function addDirective (
  48216. el,
  48217. name,
  48218. rawName,
  48219. value,
  48220. arg,
  48221. isDynamicArg,
  48222. modifiers,
  48223. range
  48224. ) {
  48225. (el.directives || (el.directives = [])).push(rangeSetItem({
  48226. name: name,
  48227. rawName: rawName,
  48228. value: value,
  48229. arg: arg,
  48230. isDynamicArg: isDynamicArg,
  48231. modifiers: modifiers
  48232. }, range));
  48233. el.plain = false;
  48234. }
  48235. function prependModifierMarker (symbol, name, dynamic) {
  48236. return dynamic
  48237. ? ("_p(" + name + ",\"" + symbol + "\")")
  48238. : symbol + name // mark the event as captured
  48239. }
  48240. function addHandler (
  48241. el,
  48242. name,
  48243. value,
  48244. modifiers,
  48245. important,
  48246. warn,
  48247. range,
  48248. dynamic
  48249. ) {
  48250. modifiers = modifiers || emptyObject;
  48251. // warn prevent and passive modifier
  48252. /* istanbul ignore if */
  48253. if (
  48254. warn &&
  48255. modifiers.prevent && modifiers.passive
  48256. ) {
  48257. warn(
  48258. 'passive and prevent can\'t be used together. ' +
  48259. 'Passive handler can\'t prevent default event.',
  48260. range
  48261. );
  48262. }
  48263. // normalize click.right and click.middle since they don't actually fire
  48264. // this is technically browser-specific, but at least for now browsers are
  48265. // the only target envs that have right/middle clicks.
  48266. if (modifiers.right) {
  48267. if (dynamic) {
  48268. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48269. } else if (name === 'click') {
  48270. name = 'contextmenu';
  48271. delete modifiers.right;
  48272. }
  48273. } else if (modifiers.middle) {
  48274. if (dynamic) {
  48275. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48276. } else if (name === 'click') {
  48277. name = 'mouseup';
  48278. }
  48279. }
  48280. // check capture modifier
  48281. if (modifiers.capture) {
  48282. delete modifiers.capture;
  48283. name = prependModifierMarker('!', name, dynamic);
  48284. }
  48285. if (modifiers.once) {
  48286. delete modifiers.once;
  48287. name = prependModifierMarker('~', name, dynamic);
  48288. }
  48289. /* istanbul ignore if */
  48290. if (modifiers.passive) {
  48291. delete modifiers.passive;
  48292. name = prependModifierMarker('&', name, dynamic);
  48293. }
  48294. var events;
  48295. if (modifiers.native) {
  48296. delete modifiers.native;
  48297. events = el.nativeEvents || (el.nativeEvents = {});
  48298. } else {
  48299. events = el.events || (el.events = {});
  48300. }
  48301. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48302. if (modifiers !== emptyObject) {
  48303. newHandler.modifiers = modifiers;
  48304. }
  48305. var handlers = events[name];
  48306. /* istanbul ignore if */
  48307. if (Array.isArray(handlers)) {
  48308. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48309. } else if (handlers) {
  48310. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48311. } else {
  48312. events[name] = newHandler;
  48313. }
  48314. el.plain = false;
  48315. }
  48316. function getRawBindingAttr (
  48317. el,
  48318. name
  48319. ) {
  48320. return el.rawAttrsMap[':' + name] ||
  48321. el.rawAttrsMap['v-bind:' + name] ||
  48322. el.rawAttrsMap[name]
  48323. }
  48324. function getBindingAttr (
  48325. el,
  48326. name,
  48327. getStatic
  48328. ) {
  48329. var dynamicValue =
  48330. getAndRemoveAttr(el, ':' + name) ||
  48331. getAndRemoveAttr(el, 'v-bind:' + name);
  48332. if (dynamicValue != null) {
  48333. return parseFilters(dynamicValue)
  48334. } else if (getStatic !== false) {
  48335. var staticValue = getAndRemoveAttr(el, name);
  48336. if (staticValue != null) {
  48337. return JSON.stringify(staticValue)
  48338. }
  48339. }
  48340. }
  48341. // note: this only removes the attr from the Array (attrsList) so that it
  48342. // doesn't get processed by processAttrs.
  48343. // By default it does NOT remove it from the map (attrsMap) because the map is
  48344. // needed during codegen.
  48345. function getAndRemoveAttr (
  48346. el,
  48347. name,
  48348. removeFromMap
  48349. ) {
  48350. var val;
  48351. if ((val = el.attrsMap[name]) != null) {
  48352. var list = el.attrsList;
  48353. for (var i = 0, l = list.length; i < l; i++) {
  48354. if (list[i].name === name) {
  48355. list.splice(i, 1);
  48356. break
  48357. }
  48358. }
  48359. }
  48360. if (removeFromMap) {
  48361. delete el.attrsMap[name];
  48362. }
  48363. return val
  48364. }
  48365. function getAndRemoveAttrByRegex (
  48366. el,
  48367. name
  48368. ) {
  48369. var list = el.attrsList;
  48370. for (var i = 0, l = list.length; i < l; i++) {
  48371. var attr = list[i];
  48372. if (name.test(attr.name)) {
  48373. list.splice(i, 1);
  48374. return attr
  48375. }
  48376. }
  48377. }
  48378. function rangeSetItem (
  48379. item,
  48380. range
  48381. ) {
  48382. if (range) {
  48383. if (range.start != null) {
  48384. item.start = range.start;
  48385. }
  48386. if (range.end != null) {
  48387. item.end = range.end;
  48388. }
  48389. }
  48390. return item
  48391. }
  48392. /* */
  48393. /**
  48394. * Cross-platform code generation for component v-model
  48395. */
  48396. function genComponentModel (
  48397. el,
  48398. value,
  48399. modifiers
  48400. ) {
  48401. var ref = modifiers || {};
  48402. var number = ref.number;
  48403. var trim = ref.trim;
  48404. var baseValueExpression = '$$v';
  48405. var valueExpression = baseValueExpression;
  48406. if (trim) {
  48407. valueExpression =
  48408. "(typeof " + baseValueExpression + " === 'string'" +
  48409. "? " + baseValueExpression + ".trim()" +
  48410. ": " + baseValueExpression + ")";
  48411. }
  48412. if (number) {
  48413. valueExpression = "_n(" + valueExpression + ")";
  48414. }
  48415. var assignment = genAssignmentCode(value, valueExpression);
  48416. el.model = {
  48417. value: ("(" + value + ")"),
  48418. expression: JSON.stringify(value),
  48419. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48420. };
  48421. }
  48422. /**
  48423. * Cross-platform codegen helper for generating v-model value assignment code.
  48424. */
  48425. function genAssignmentCode (
  48426. value,
  48427. assignment
  48428. ) {
  48429. var res = parseModel(value);
  48430. if (res.key === null) {
  48431. return (value + "=" + assignment)
  48432. } else {
  48433. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48434. }
  48435. }
  48436. /**
  48437. * Parse a v-model expression into a base path and a final key segment.
  48438. * Handles both dot-path and possible square brackets.
  48439. *
  48440. * Possible cases:
  48441. *
  48442. * - test
  48443. * - test[key]
  48444. * - test[test1[key]]
  48445. * - test["a"][key]
  48446. * - xxx.test[a[a].test1[key]]
  48447. * - test.xxx.a["asa"][test1[key]]
  48448. *
  48449. */
  48450. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48451. function parseModel (val) {
  48452. // Fix https://github.com/vuejs/vue/pull/7730
  48453. // allow v-model="obj.val " (trailing whitespace)
  48454. val = val.trim();
  48455. len = val.length;
  48456. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48457. index$1 = val.lastIndexOf('.');
  48458. if (index$1 > -1) {
  48459. return {
  48460. exp: val.slice(0, index$1),
  48461. key: '"' + val.slice(index$1 + 1) + '"'
  48462. }
  48463. } else {
  48464. return {
  48465. exp: val,
  48466. key: null
  48467. }
  48468. }
  48469. }
  48470. str = val;
  48471. index$1 = expressionPos = expressionEndPos = 0;
  48472. while (!eof()) {
  48473. chr = next();
  48474. /* istanbul ignore if */
  48475. if (isStringStart(chr)) {
  48476. parseString(chr);
  48477. } else if (chr === 0x5B) {
  48478. parseBracket(chr);
  48479. }
  48480. }
  48481. return {
  48482. exp: val.slice(0, expressionPos),
  48483. key: val.slice(expressionPos + 1, expressionEndPos)
  48484. }
  48485. }
  48486. function next () {
  48487. return str.charCodeAt(++index$1)
  48488. }
  48489. function eof () {
  48490. return index$1 >= len
  48491. }
  48492. function isStringStart (chr) {
  48493. return chr === 0x22 || chr === 0x27
  48494. }
  48495. function parseBracket (chr) {
  48496. var inBracket = 1;
  48497. expressionPos = index$1;
  48498. while (!eof()) {
  48499. chr = next();
  48500. if (isStringStart(chr)) {
  48501. parseString(chr);
  48502. continue
  48503. }
  48504. if (chr === 0x5B) { inBracket++; }
  48505. if (chr === 0x5D) { inBracket--; }
  48506. if (inBracket === 0) {
  48507. expressionEndPos = index$1;
  48508. break
  48509. }
  48510. }
  48511. }
  48512. function parseString (chr) {
  48513. var stringQuote = chr;
  48514. while (!eof()) {
  48515. chr = next();
  48516. if (chr === stringQuote) {
  48517. break
  48518. }
  48519. }
  48520. }
  48521. /* */
  48522. var warn$1;
  48523. // in some cases, the event used has to be determined at runtime
  48524. // so we used some reserved tokens during compile.
  48525. var RANGE_TOKEN = '__r';
  48526. var CHECKBOX_RADIO_TOKEN = '__c';
  48527. function model (
  48528. el,
  48529. dir,
  48530. _warn
  48531. ) {
  48532. warn$1 = _warn;
  48533. var value = dir.value;
  48534. var modifiers = dir.modifiers;
  48535. var tag = el.tag;
  48536. var type = el.attrsMap.type;
  48537. {
  48538. // inputs with type="file" are read only and setting the input's
  48539. // value will throw an error.
  48540. if (tag === 'input' && type === 'file') {
  48541. warn$1(
  48542. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48543. "File inputs are read only. Use a v-on:change listener instead.",
  48544. el.rawAttrsMap['v-model']
  48545. );
  48546. }
  48547. }
  48548. if (el.component) {
  48549. genComponentModel(el, value, modifiers);
  48550. // component v-model doesn't need extra runtime
  48551. return false
  48552. } else if (tag === 'select') {
  48553. genSelect(el, value, modifiers);
  48554. } else if (tag === 'input' && type === 'checkbox') {
  48555. genCheckboxModel(el, value, modifiers);
  48556. } else if (tag === 'input' && type === 'radio') {
  48557. genRadioModel(el, value, modifiers);
  48558. } else if (tag === 'input' || tag === 'textarea') {
  48559. genDefaultModel(el, value, modifiers);
  48560. } else if (!config.isReservedTag(tag)) {
  48561. genComponentModel(el, value, modifiers);
  48562. // component v-model doesn't need extra runtime
  48563. return false
  48564. } else {
  48565. warn$1(
  48566. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48567. "v-model is not supported on this element type. " +
  48568. 'If you are working with contenteditable, it\'s recommended to ' +
  48569. 'wrap a library dedicated for that purpose inside a custom component.',
  48570. el.rawAttrsMap['v-model']
  48571. );
  48572. }
  48573. // ensure runtime directive metadata
  48574. return true
  48575. }
  48576. function genCheckboxModel (
  48577. el,
  48578. value,
  48579. modifiers
  48580. ) {
  48581. var number = modifiers && modifiers.number;
  48582. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48583. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48584. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48585. addProp(el, 'checked',
  48586. "Array.isArray(" + value + ")" +
  48587. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48588. trueValueBinding === 'true'
  48589. ? (":(" + value + ")")
  48590. : (":_q(" + value + "," + trueValueBinding + ")")
  48591. )
  48592. );
  48593. addHandler(el, 'change',
  48594. "var $$a=" + value + "," +
  48595. '$$el=$event.target,' +
  48596. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48597. 'if(Array.isArray($$a)){' +
  48598. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48599. '$$i=_i($$a,$$v);' +
  48600. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48601. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48602. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48603. null, true
  48604. );
  48605. }
  48606. function genRadioModel (
  48607. el,
  48608. value,
  48609. modifiers
  48610. ) {
  48611. var number = modifiers && modifiers.number;
  48612. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48613. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48614. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48615. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48616. }
  48617. function genSelect (
  48618. el,
  48619. value,
  48620. modifiers
  48621. ) {
  48622. var number = modifiers && modifiers.number;
  48623. var selectedVal = "Array.prototype.filter" +
  48624. ".call($event.target.options,function(o){return o.selected})" +
  48625. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48626. "return " + (number ? '_n(val)' : 'val') + "})";
  48627. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48628. var code = "var $$selectedVal = " + selectedVal + ";";
  48629. code = code + " " + (genAssignmentCode(value, assignment));
  48630. addHandler(el, 'change', code, null, true);
  48631. }
  48632. function genDefaultModel (
  48633. el,
  48634. value,
  48635. modifiers
  48636. ) {
  48637. var type = el.attrsMap.type;
  48638. // warn if v-bind:value conflicts with v-model
  48639. // except for inputs with v-bind:type
  48640. {
  48641. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48642. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48643. if (value$1 && !typeBinding) {
  48644. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48645. warn$1(
  48646. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48647. 'because the latter already expands to a value binding internally',
  48648. el.rawAttrsMap[binding]
  48649. );
  48650. }
  48651. }
  48652. var ref = modifiers || {};
  48653. var lazy = ref.lazy;
  48654. var number = ref.number;
  48655. var trim = ref.trim;
  48656. var needCompositionGuard = !lazy && type !== 'range';
  48657. var event = lazy
  48658. ? 'change'
  48659. : type === 'range'
  48660. ? RANGE_TOKEN
  48661. : 'input';
  48662. var valueExpression = '$event.target.value';
  48663. if (trim) {
  48664. valueExpression = "$event.target.value.trim()";
  48665. }
  48666. if (number) {
  48667. valueExpression = "_n(" + valueExpression + ")";
  48668. }
  48669. var code = genAssignmentCode(value, valueExpression);
  48670. if (needCompositionGuard) {
  48671. code = "if($event.target.composing)return;" + code;
  48672. }
  48673. addProp(el, 'value', ("(" + value + ")"));
  48674. addHandler(el, event, code, null, true);
  48675. if (trim || number) {
  48676. addHandler(el, 'blur', '$forceUpdate()');
  48677. }
  48678. }
  48679. /* */
  48680. // normalize v-model event tokens that can only be determined at runtime.
  48681. // it's important to place the event as the first in the array because
  48682. // the whole point is ensuring the v-model callback gets called before
  48683. // user-attached handlers.
  48684. function normalizeEvents (on) {
  48685. /* istanbul ignore if */
  48686. if (isDef(on[RANGE_TOKEN])) {
  48687. // IE input[type=range] only supports `change` event
  48688. var event = isIE ? 'change' : 'input';
  48689. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48690. delete on[RANGE_TOKEN];
  48691. }
  48692. // This was originally intended to fix #4521 but no longer necessary
  48693. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48694. /* istanbul ignore if */
  48695. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48696. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48697. delete on[CHECKBOX_RADIO_TOKEN];
  48698. }
  48699. }
  48700. var target$1;
  48701. function createOnceHandler$1 (event, handler, capture) {
  48702. var _target = target$1; // save current target element in closure
  48703. return function onceHandler () {
  48704. var res = handler.apply(null, arguments);
  48705. if (res !== null) {
  48706. remove$2(event, onceHandler, capture, _target);
  48707. }
  48708. }
  48709. }
  48710. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48711. // implementation and does not fire microtasks in between event propagation, so
  48712. // safe to exclude.
  48713. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48714. function add$1 (
  48715. name,
  48716. handler,
  48717. capture,
  48718. passive
  48719. ) {
  48720. // async edge case #6566: inner click event triggers patch, event handler
  48721. // attached to outer element during patch, and triggered again. This
  48722. // happens because browsers fire microtask ticks between event propagation.
  48723. // the solution is simple: we save the timestamp when a handler is attached,
  48724. // and the handler would only fire if the event passed to it was fired
  48725. // AFTER it was attached.
  48726. if (useMicrotaskFix) {
  48727. var attachedTimestamp = currentFlushTimestamp;
  48728. var original = handler;
  48729. handler = original._wrapper = function (e) {
  48730. if (
  48731. // no bubbling, should always fire.
  48732. // this is just a safety net in case event.timeStamp is unreliable in
  48733. // certain weird environments...
  48734. e.target === e.currentTarget ||
  48735. // event is fired after handler attachment
  48736. e.timeStamp >= attachedTimestamp ||
  48737. // bail for environments that have buggy event.timeStamp implementations
  48738. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48739. // #9681 QtWebEngine event.timeStamp is negative value
  48740. e.timeStamp <= 0 ||
  48741. // #9448 bail if event is fired in another document in a multi-page
  48742. // electron/nw.js app, since event.timeStamp will be using a different
  48743. // starting reference
  48744. e.target.ownerDocument !== document
  48745. ) {
  48746. return original.apply(this, arguments)
  48747. }
  48748. };
  48749. }
  48750. target$1.addEventListener(
  48751. name,
  48752. handler,
  48753. supportsPassive
  48754. ? { capture: capture, passive: passive }
  48755. : capture
  48756. );
  48757. }
  48758. function remove$2 (
  48759. name,
  48760. handler,
  48761. capture,
  48762. _target
  48763. ) {
  48764. (_target || target$1).removeEventListener(
  48765. name,
  48766. handler._wrapper || handler,
  48767. capture
  48768. );
  48769. }
  48770. function updateDOMListeners (oldVnode, vnode) {
  48771. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48772. return
  48773. }
  48774. var on = vnode.data.on || {};
  48775. var oldOn = oldVnode.data.on || {};
  48776. target$1 = vnode.elm;
  48777. normalizeEvents(on);
  48778. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48779. target$1 = undefined;
  48780. }
  48781. var events = {
  48782. create: updateDOMListeners,
  48783. update: updateDOMListeners
  48784. };
  48785. /* */
  48786. var svgContainer;
  48787. function updateDOMProps (oldVnode, vnode) {
  48788. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48789. return
  48790. }
  48791. var key, cur;
  48792. var elm = vnode.elm;
  48793. var oldProps = oldVnode.data.domProps || {};
  48794. var props = vnode.data.domProps || {};
  48795. // clone observed objects, as the user probably wants to mutate it
  48796. if (isDef(props.__ob__)) {
  48797. props = vnode.data.domProps = extend({}, props);
  48798. }
  48799. for (key in oldProps) {
  48800. if (!(key in props)) {
  48801. elm[key] = '';
  48802. }
  48803. }
  48804. for (key in props) {
  48805. cur = props[key];
  48806. // ignore children if the node has textContent or innerHTML,
  48807. // as these will throw away existing DOM nodes and cause removal errors
  48808. // on subsequent patches (#3360)
  48809. if (key === 'textContent' || key === 'innerHTML') {
  48810. if (vnode.children) { vnode.children.length = 0; }
  48811. if (cur === oldProps[key]) { continue }
  48812. // #6601 work around Chrome version <= 55 bug where single textNode
  48813. // replaced by innerHTML/textContent retains its parentNode property
  48814. if (elm.childNodes.length === 1) {
  48815. elm.removeChild(elm.childNodes[0]);
  48816. }
  48817. }
  48818. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48819. // store value as _value as well since
  48820. // non-string values will be stringified
  48821. elm._value = cur;
  48822. // avoid resetting cursor position when value is the same
  48823. var strCur = isUndef(cur) ? '' : String(cur);
  48824. if (shouldUpdateValue(elm, strCur)) {
  48825. elm.value = strCur;
  48826. }
  48827. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48828. // IE doesn't support innerHTML for SVG elements
  48829. svgContainer = svgContainer || document.createElement('div');
  48830. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48831. var svg = svgContainer.firstChild;
  48832. while (elm.firstChild) {
  48833. elm.removeChild(elm.firstChild);
  48834. }
  48835. while (svg.firstChild) {
  48836. elm.appendChild(svg.firstChild);
  48837. }
  48838. } else if (
  48839. // skip the update if old and new VDOM state is the same.
  48840. // `value` is handled separately because the DOM value may be temporarily
  48841. // out of sync with VDOM state due to focus, composition and modifiers.
  48842. // This #4521 by skipping the unnecesarry `checked` update.
  48843. cur !== oldProps[key]
  48844. ) {
  48845. // some property updates can throw
  48846. // e.g. `value` on <progress> w/ non-finite value
  48847. try {
  48848. elm[key] = cur;
  48849. } catch (e) {}
  48850. }
  48851. }
  48852. }
  48853. // check platforms/web/util/attrs.js acceptValue
  48854. function shouldUpdateValue (elm, checkVal) {
  48855. return (!elm.composing && (
  48856. elm.tagName === 'OPTION' ||
  48857. isNotInFocusAndDirty(elm, checkVal) ||
  48858. isDirtyWithModifiers(elm, checkVal)
  48859. ))
  48860. }
  48861. function isNotInFocusAndDirty (elm, checkVal) {
  48862. // return true when textbox (.number and .trim) loses focus and its value is
  48863. // not equal to the updated value
  48864. var notInFocus = true;
  48865. // #6157
  48866. // work around IE bug when accessing document.activeElement in an iframe
  48867. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48868. return notInFocus && elm.value !== checkVal
  48869. }
  48870. function isDirtyWithModifiers (elm, newVal) {
  48871. var value = elm.value;
  48872. var modifiers = elm._vModifiers; // injected by v-model runtime
  48873. if (isDef(modifiers)) {
  48874. if (modifiers.number) {
  48875. return toNumber(value) !== toNumber(newVal)
  48876. }
  48877. if (modifiers.trim) {
  48878. return value.trim() !== newVal.trim()
  48879. }
  48880. }
  48881. return value !== newVal
  48882. }
  48883. var domProps = {
  48884. create: updateDOMProps,
  48885. update: updateDOMProps
  48886. };
  48887. /* */
  48888. var parseStyleText = cached(function (cssText) {
  48889. var res = {};
  48890. var listDelimiter = /;(?![^(]*\))/g;
  48891. var propertyDelimiter = /:(.+)/;
  48892. cssText.split(listDelimiter).forEach(function (item) {
  48893. if (item) {
  48894. var tmp = item.split(propertyDelimiter);
  48895. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48896. }
  48897. });
  48898. return res
  48899. });
  48900. // merge static and dynamic style data on the same vnode
  48901. function normalizeStyleData (data) {
  48902. var style = normalizeStyleBinding(data.style);
  48903. // static style is pre-processed into an object during compilation
  48904. // and is always a fresh object, so it's safe to merge into it
  48905. return data.staticStyle
  48906. ? extend(data.staticStyle, style)
  48907. : style
  48908. }
  48909. // normalize possible array / string values into Object
  48910. function normalizeStyleBinding (bindingStyle) {
  48911. if (Array.isArray(bindingStyle)) {
  48912. return toObject(bindingStyle)
  48913. }
  48914. if (typeof bindingStyle === 'string') {
  48915. return parseStyleText(bindingStyle)
  48916. }
  48917. return bindingStyle
  48918. }
  48919. /**
  48920. * parent component style should be after child's
  48921. * so that parent component's style could override it
  48922. */
  48923. function getStyle (vnode, checkChild) {
  48924. var res = {};
  48925. var styleData;
  48926. if (checkChild) {
  48927. var childNode = vnode;
  48928. while (childNode.componentInstance) {
  48929. childNode = childNode.componentInstance._vnode;
  48930. if (
  48931. childNode && childNode.data &&
  48932. (styleData = normalizeStyleData(childNode.data))
  48933. ) {
  48934. extend(res, styleData);
  48935. }
  48936. }
  48937. }
  48938. if ((styleData = normalizeStyleData(vnode.data))) {
  48939. extend(res, styleData);
  48940. }
  48941. var parentNode = vnode;
  48942. while ((parentNode = parentNode.parent)) {
  48943. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48944. extend(res, styleData);
  48945. }
  48946. }
  48947. return res
  48948. }
  48949. /* */
  48950. var cssVarRE = /^--/;
  48951. var importantRE = /\s*!important$/;
  48952. var setProp = function (el, name, val) {
  48953. /* istanbul ignore if */
  48954. if (cssVarRE.test(name)) {
  48955. el.style.setProperty(name, val);
  48956. } else if (importantRE.test(val)) {
  48957. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48958. } else {
  48959. var normalizedName = normalize(name);
  48960. if (Array.isArray(val)) {
  48961. // Support values array created by autoprefixer, e.g.
  48962. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48963. // Set them one by one, and the browser will only set those it can recognize
  48964. for (var i = 0, len = val.length; i < len; i++) {
  48965. el.style[normalizedName] = val[i];
  48966. }
  48967. } else {
  48968. el.style[normalizedName] = val;
  48969. }
  48970. }
  48971. };
  48972. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48973. var emptyStyle;
  48974. var normalize = cached(function (prop) {
  48975. emptyStyle = emptyStyle || document.createElement('div').style;
  48976. prop = camelize(prop);
  48977. if (prop !== 'filter' && (prop in emptyStyle)) {
  48978. return prop
  48979. }
  48980. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48981. for (var i = 0; i < vendorNames.length; i++) {
  48982. var name = vendorNames[i] + capName;
  48983. if (name in emptyStyle) {
  48984. return name
  48985. }
  48986. }
  48987. });
  48988. function updateStyle (oldVnode, vnode) {
  48989. var data = vnode.data;
  48990. var oldData = oldVnode.data;
  48991. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48992. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48993. ) {
  48994. return
  48995. }
  48996. var cur, name;
  48997. var el = vnode.elm;
  48998. var oldStaticStyle = oldData.staticStyle;
  48999. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  49000. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  49001. var oldStyle = oldStaticStyle || oldStyleBinding;
  49002. var style = normalizeStyleBinding(vnode.data.style) || {};
  49003. // store normalized style under a different key for next diff
  49004. // make sure to clone it if it's reactive, since the user likely wants
  49005. // to mutate it.
  49006. vnode.data.normalizedStyle = isDef(style.__ob__)
  49007. ? extend({}, style)
  49008. : style;
  49009. var newStyle = getStyle(vnode, true);
  49010. for (name in oldStyle) {
  49011. if (isUndef(newStyle[name])) {
  49012. setProp(el, name, '');
  49013. }
  49014. }
  49015. for (name in newStyle) {
  49016. cur = newStyle[name];
  49017. if (cur !== oldStyle[name]) {
  49018. // ie9 setting to null has no effect, must use empty string
  49019. setProp(el, name, cur == null ? '' : cur);
  49020. }
  49021. }
  49022. }
  49023. var style = {
  49024. create: updateStyle,
  49025. update: updateStyle
  49026. };
  49027. /* */
  49028. var whitespaceRE = /\s+/;
  49029. /**
  49030. * Add class with compatibility for SVG since classList is not supported on
  49031. * SVG elements in IE
  49032. */
  49033. function addClass (el, cls) {
  49034. /* istanbul ignore if */
  49035. if (!cls || !(cls = cls.trim())) {
  49036. return
  49037. }
  49038. /* istanbul ignore else */
  49039. if (el.classList) {
  49040. if (cls.indexOf(' ') > -1) {
  49041. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  49042. } else {
  49043. el.classList.add(cls);
  49044. }
  49045. } else {
  49046. var cur = " " + (el.getAttribute('class') || '') + " ";
  49047. if (cur.indexOf(' ' + cls + ' ') < 0) {
  49048. el.setAttribute('class', (cur + cls).trim());
  49049. }
  49050. }
  49051. }
  49052. /**
  49053. * Remove class with compatibility for SVG since classList is not supported on
  49054. * SVG elements in IE
  49055. */
  49056. function removeClass (el, cls) {
  49057. /* istanbul ignore if */
  49058. if (!cls || !(cls = cls.trim())) {
  49059. return
  49060. }
  49061. /* istanbul ignore else */
  49062. if (el.classList) {
  49063. if (cls.indexOf(' ') > -1) {
  49064. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  49065. } else {
  49066. el.classList.remove(cls);
  49067. }
  49068. if (!el.classList.length) {
  49069. el.removeAttribute('class');
  49070. }
  49071. } else {
  49072. var cur = " " + (el.getAttribute('class') || '') + " ";
  49073. var tar = ' ' + cls + ' ';
  49074. while (cur.indexOf(tar) >= 0) {
  49075. cur = cur.replace(tar, ' ');
  49076. }
  49077. cur = cur.trim();
  49078. if (cur) {
  49079. el.setAttribute('class', cur);
  49080. } else {
  49081. el.removeAttribute('class');
  49082. }
  49083. }
  49084. }
  49085. /* */
  49086. function resolveTransition (def$$1) {
  49087. if (!def$$1) {
  49088. return
  49089. }
  49090. /* istanbul ignore else */
  49091. if (typeof def$$1 === 'object') {
  49092. var res = {};
  49093. if (def$$1.css !== false) {
  49094. extend(res, autoCssTransition(def$$1.name || 'v'));
  49095. }
  49096. extend(res, def$$1);
  49097. return res
  49098. } else if (typeof def$$1 === 'string') {
  49099. return autoCssTransition(def$$1)
  49100. }
  49101. }
  49102. var autoCssTransition = cached(function (name) {
  49103. return {
  49104. enterClass: (name + "-enter"),
  49105. enterToClass: (name + "-enter-to"),
  49106. enterActiveClass: (name + "-enter-active"),
  49107. leaveClass: (name + "-leave"),
  49108. leaveToClass: (name + "-leave-to"),
  49109. leaveActiveClass: (name + "-leave-active")
  49110. }
  49111. });
  49112. var hasTransition = inBrowser && !isIE9;
  49113. var TRANSITION = 'transition';
  49114. var ANIMATION = 'animation';
  49115. // Transition property/event sniffing
  49116. var transitionProp = 'transition';
  49117. var transitionEndEvent = 'transitionend';
  49118. var animationProp = 'animation';
  49119. var animationEndEvent = 'animationend';
  49120. if (hasTransition) {
  49121. /* istanbul ignore if */
  49122. if (window.ontransitionend === undefined &&
  49123. window.onwebkittransitionend !== undefined
  49124. ) {
  49125. transitionProp = 'WebkitTransition';
  49126. transitionEndEvent = 'webkitTransitionEnd';
  49127. }
  49128. if (window.onanimationend === undefined &&
  49129. window.onwebkitanimationend !== undefined
  49130. ) {
  49131. animationProp = 'WebkitAnimation';
  49132. animationEndEvent = 'webkitAnimationEnd';
  49133. }
  49134. }
  49135. // binding to window is necessary to make hot reload work in IE in strict mode
  49136. var raf = inBrowser
  49137. ? window.requestAnimationFrame
  49138. ? window.requestAnimationFrame.bind(window)
  49139. : setTimeout
  49140. : /* istanbul ignore next */ function (fn) { return fn(); };
  49141. function nextFrame (fn) {
  49142. raf(function () {
  49143. raf(fn);
  49144. });
  49145. }
  49146. function addTransitionClass (el, cls) {
  49147. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  49148. if (transitionClasses.indexOf(cls) < 0) {
  49149. transitionClasses.push(cls);
  49150. addClass(el, cls);
  49151. }
  49152. }
  49153. function removeTransitionClass (el, cls) {
  49154. if (el._transitionClasses) {
  49155. remove(el._transitionClasses, cls);
  49156. }
  49157. removeClass(el, cls);
  49158. }
  49159. function whenTransitionEnds (
  49160. el,
  49161. expectedType,
  49162. cb
  49163. ) {
  49164. var ref = getTransitionInfo(el, expectedType);
  49165. var type = ref.type;
  49166. var timeout = ref.timeout;
  49167. var propCount = ref.propCount;
  49168. if (!type) { return cb() }
  49169. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  49170. var ended = 0;
  49171. var end = function () {
  49172. el.removeEventListener(event, onEnd);
  49173. cb();
  49174. };
  49175. var onEnd = function (e) {
  49176. if (e.target === el) {
  49177. if (++ended >= propCount) {
  49178. end();
  49179. }
  49180. }
  49181. };
  49182. setTimeout(function () {
  49183. if (ended < propCount) {
  49184. end();
  49185. }
  49186. }, timeout + 1);
  49187. el.addEventListener(event, onEnd);
  49188. }
  49189. var transformRE = /\b(transform|all)(,|$)/;
  49190. function getTransitionInfo (el, expectedType) {
  49191. var styles = window.getComputedStyle(el);
  49192. // JSDOM may return undefined for transition properties
  49193. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  49194. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  49195. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  49196. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  49197. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  49198. var animationTimeout = getTimeout(animationDelays, animationDurations);
  49199. var type;
  49200. var timeout = 0;
  49201. var propCount = 0;
  49202. /* istanbul ignore if */
  49203. if (expectedType === TRANSITION) {
  49204. if (transitionTimeout > 0) {
  49205. type = TRANSITION;
  49206. timeout = transitionTimeout;
  49207. propCount = transitionDurations.length;
  49208. }
  49209. } else if (expectedType === ANIMATION) {
  49210. if (animationTimeout > 0) {
  49211. type = ANIMATION;
  49212. timeout = animationTimeout;
  49213. propCount = animationDurations.length;
  49214. }
  49215. } else {
  49216. timeout = Math.max(transitionTimeout, animationTimeout);
  49217. type = timeout > 0
  49218. ? transitionTimeout > animationTimeout
  49219. ? TRANSITION
  49220. : ANIMATION
  49221. : null;
  49222. propCount = type
  49223. ? type === TRANSITION
  49224. ? transitionDurations.length
  49225. : animationDurations.length
  49226. : 0;
  49227. }
  49228. var hasTransform =
  49229. type === TRANSITION &&
  49230. transformRE.test(styles[transitionProp + 'Property']);
  49231. return {
  49232. type: type,
  49233. timeout: timeout,
  49234. propCount: propCount,
  49235. hasTransform: hasTransform
  49236. }
  49237. }
  49238. function getTimeout (delays, durations) {
  49239. /* istanbul ignore next */
  49240. while (delays.length < durations.length) {
  49241. delays = delays.concat(delays);
  49242. }
  49243. return Math.max.apply(null, durations.map(function (d, i) {
  49244. return toMs(d) + toMs(delays[i])
  49245. }))
  49246. }
  49247. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49248. // in a locale-dependent way, using a comma instead of a dot.
  49249. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49250. // as a floor function) causing unexpected behaviors
  49251. function toMs (s) {
  49252. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49253. }
  49254. /* */
  49255. function enter (vnode, toggleDisplay) {
  49256. var el = vnode.elm;
  49257. // call leave callback now
  49258. if (isDef(el._leaveCb)) {
  49259. el._leaveCb.cancelled = true;
  49260. el._leaveCb();
  49261. }
  49262. var data = resolveTransition(vnode.data.transition);
  49263. if (isUndef(data)) {
  49264. return
  49265. }
  49266. /* istanbul ignore if */
  49267. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49268. return
  49269. }
  49270. var css = data.css;
  49271. var type = data.type;
  49272. var enterClass = data.enterClass;
  49273. var enterToClass = data.enterToClass;
  49274. var enterActiveClass = data.enterActiveClass;
  49275. var appearClass = data.appearClass;
  49276. var appearToClass = data.appearToClass;
  49277. var appearActiveClass = data.appearActiveClass;
  49278. var beforeEnter = data.beforeEnter;
  49279. var enter = data.enter;
  49280. var afterEnter = data.afterEnter;
  49281. var enterCancelled = data.enterCancelled;
  49282. var beforeAppear = data.beforeAppear;
  49283. var appear = data.appear;
  49284. var afterAppear = data.afterAppear;
  49285. var appearCancelled = data.appearCancelled;
  49286. var duration = data.duration;
  49287. // activeInstance will always be the <transition> component managing this
  49288. // transition. One edge case to check is when the <transition> is placed
  49289. // as the root node of a child component. In that case we need to check
  49290. // <transition>'s parent for appear check.
  49291. var context = activeInstance;
  49292. var transitionNode = activeInstance.$vnode;
  49293. while (transitionNode && transitionNode.parent) {
  49294. context = transitionNode.context;
  49295. transitionNode = transitionNode.parent;
  49296. }
  49297. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49298. if (isAppear && !appear && appear !== '') {
  49299. return
  49300. }
  49301. var startClass = isAppear && appearClass
  49302. ? appearClass
  49303. : enterClass;
  49304. var activeClass = isAppear && appearActiveClass
  49305. ? appearActiveClass
  49306. : enterActiveClass;
  49307. var toClass = isAppear && appearToClass
  49308. ? appearToClass
  49309. : enterToClass;
  49310. var beforeEnterHook = isAppear
  49311. ? (beforeAppear || beforeEnter)
  49312. : beforeEnter;
  49313. var enterHook = isAppear
  49314. ? (typeof appear === 'function' ? appear : enter)
  49315. : enter;
  49316. var afterEnterHook = isAppear
  49317. ? (afterAppear || afterEnter)
  49318. : afterEnter;
  49319. var enterCancelledHook = isAppear
  49320. ? (appearCancelled || enterCancelled)
  49321. : enterCancelled;
  49322. var explicitEnterDuration = toNumber(
  49323. isObject(duration)
  49324. ? duration.enter
  49325. : duration
  49326. );
  49327. if (explicitEnterDuration != null) {
  49328. checkDuration(explicitEnterDuration, 'enter', vnode);
  49329. }
  49330. var expectsCSS = css !== false && !isIE9;
  49331. var userWantsControl = getHookArgumentsLength(enterHook);
  49332. var cb = el._enterCb = once(function () {
  49333. if (expectsCSS) {
  49334. removeTransitionClass(el, toClass);
  49335. removeTransitionClass(el, activeClass);
  49336. }
  49337. if (cb.cancelled) {
  49338. if (expectsCSS) {
  49339. removeTransitionClass(el, startClass);
  49340. }
  49341. enterCancelledHook && enterCancelledHook(el);
  49342. } else {
  49343. afterEnterHook && afterEnterHook(el);
  49344. }
  49345. el._enterCb = null;
  49346. });
  49347. if (!vnode.data.show) {
  49348. // remove pending leave element on enter by injecting an insert hook
  49349. mergeVNodeHook(vnode, 'insert', function () {
  49350. var parent = el.parentNode;
  49351. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49352. if (pendingNode &&
  49353. pendingNode.tag === vnode.tag &&
  49354. pendingNode.elm._leaveCb
  49355. ) {
  49356. pendingNode.elm._leaveCb();
  49357. }
  49358. enterHook && enterHook(el, cb);
  49359. });
  49360. }
  49361. // start enter transition
  49362. beforeEnterHook && beforeEnterHook(el);
  49363. if (expectsCSS) {
  49364. addTransitionClass(el, startClass);
  49365. addTransitionClass(el, activeClass);
  49366. nextFrame(function () {
  49367. removeTransitionClass(el, startClass);
  49368. if (!cb.cancelled) {
  49369. addTransitionClass(el, toClass);
  49370. if (!userWantsControl) {
  49371. if (isValidDuration(explicitEnterDuration)) {
  49372. setTimeout(cb, explicitEnterDuration);
  49373. } else {
  49374. whenTransitionEnds(el, type, cb);
  49375. }
  49376. }
  49377. }
  49378. });
  49379. }
  49380. if (vnode.data.show) {
  49381. toggleDisplay && toggleDisplay();
  49382. enterHook && enterHook(el, cb);
  49383. }
  49384. if (!expectsCSS && !userWantsControl) {
  49385. cb();
  49386. }
  49387. }
  49388. function leave (vnode, rm) {
  49389. var el = vnode.elm;
  49390. // call enter callback now
  49391. if (isDef(el._enterCb)) {
  49392. el._enterCb.cancelled = true;
  49393. el._enterCb();
  49394. }
  49395. var data = resolveTransition(vnode.data.transition);
  49396. if (isUndef(data) || el.nodeType !== 1) {
  49397. return rm()
  49398. }
  49399. /* istanbul ignore if */
  49400. if (isDef(el._leaveCb)) {
  49401. return
  49402. }
  49403. var css = data.css;
  49404. var type = data.type;
  49405. var leaveClass = data.leaveClass;
  49406. var leaveToClass = data.leaveToClass;
  49407. var leaveActiveClass = data.leaveActiveClass;
  49408. var beforeLeave = data.beforeLeave;
  49409. var leave = data.leave;
  49410. var afterLeave = data.afterLeave;
  49411. var leaveCancelled = data.leaveCancelled;
  49412. var delayLeave = data.delayLeave;
  49413. var duration = data.duration;
  49414. var expectsCSS = css !== false && !isIE9;
  49415. var userWantsControl = getHookArgumentsLength(leave);
  49416. var explicitLeaveDuration = toNumber(
  49417. isObject(duration)
  49418. ? duration.leave
  49419. : duration
  49420. );
  49421. if (isDef(explicitLeaveDuration)) {
  49422. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49423. }
  49424. var cb = el._leaveCb = once(function () {
  49425. if (el.parentNode && el.parentNode._pending) {
  49426. el.parentNode._pending[vnode.key] = null;
  49427. }
  49428. if (expectsCSS) {
  49429. removeTransitionClass(el, leaveToClass);
  49430. removeTransitionClass(el, leaveActiveClass);
  49431. }
  49432. if (cb.cancelled) {
  49433. if (expectsCSS) {
  49434. removeTransitionClass(el, leaveClass);
  49435. }
  49436. leaveCancelled && leaveCancelled(el);
  49437. } else {
  49438. rm();
  49439. afterLeave && afterLeave(el);
  49440. }
  49441. el._leaveCb = null;
  49442. });
  49443. if (delayLeave) {
  49444. delayLeave(performLeave);
  49445. } else {
  49446. performLeave();
  49447. }
  49448. function performLeave () {
  49449. // the delayed leave may have already been cancelled
  49450. if (cb.cancelled) {
  49451. return
  49452. }
  49453. // record leaving element
  49454. if (!vnode.data.show && el.parentNode) {
  49455. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49456. }
  49457. beforeLeave && beforeLeave(el);
  49458. if (expectsCSS) {
  49459. addTransitionClass(el, leaveClass);
  49460. addTransitionClass(el, leaveActiveClass);
  49461. nextFrame(function () {
  49462. removeTransitionClass(el, leaveClass);
  49463. if (!cb.cancelled) {
  49464. addTransitionClass(el, leaveToClass);
  49465. if (!userWantsControl) {
  49466. if (isValidDuration(explicitLeaveDuration)) {
  49467. setTimeout(cb, explicitLeaveDuration);
  49468. } else {
  49469. whenTransitionEnds(el, type, cb);
  49470. }
  49471. }
  49472. }
  49473. });
  49474. }
  49475. leave && leave(el, cb);
  49476. if (!expectsCSS && !userWantsControl) {
  49477. cb();
  49478. }
  49479. }
  49480. }
  49481. // only used in dev mode
  49482. function checkDuration (val, name, vnode) {
  49483. if (typeof val !== 'number') {
  49484. warn(
  49485. "<transition> explicit " + name + " duration is not a valid number - " +
  49486. "got " + (JSON.stringify(val)) + ".",
  49487. vnode.context
  49488. );
  49489. } else if (isNaN(val)) {
  49490. warn(
  49491. "<transition> explicit " + name + " duration is NaN - " +
  49492. 'the duration expression might be incorrect.',
  49493. vnode.context
  49494. );
  49495. }
  49496. }
  49497. function isValidDuration (val) {
  49498. return typeof val === 'number' && !isNaN(val)
  49499. }
  49500. /**
  49501. * Normalize a transition hook's argument length. The hook may be:
  49502. * - a merged hook (invoker) with the original in .fns
  49503. * - a wrapped component method (check ._length)
  49504. * - a plain function (.length)
  49505. */
  49506. function getHookArgumentsLength (fn) {
  49507. if (isUndef(fn)) {
  49508. return false
  49509. }
  49510. var invokerFns = fn.fns;
  49511. if (isDef(invokerFns)) {
  49512. // invoker
  49513. return getHookArgumentsLength(
  49514. Array.isArray(invokerFns)
  49515. ? invokerFns[0]
  49516. : invokerFns
  49517. )
  49518. } else {
  49519. return (fn._length || fn.length) > 1
  49520. }
  49521. }
  49522. function _enter (_, vnode) {
  49523. if (vnode.data.show !== true) {
  49524. enter(vnode);
  49525. }
  49526. }
  49527. var transition = inBrowser ? {
  49528. create: _enter,
  49529. activate: _enter,
  49530. remove: function remove$$1 (vnode, rm) {
  49531. /* istanbul ignore else */
  49532. if (vnode.data.show !== true) {
  49533. leave(vnode, rm);
  49534. } else {
  49535. rm();
  49536. }
  49537. }
  49538. } : {};
  49539. var platformModules = [
  49540. attrs,
  49541. klass,
  49542. events,
  49543. domProps,
  49544. style,
  49545. transition
  49546. ];
  49547. /* */
  49548. // the directive module should be applied last, after all
  49549. // built-in modules have been applied.
  49550. var modules = platformModules.concat(baseModules);
  49551. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49552. /**
  49553. * Not type checking this file because flow doesn't like attaching
  49554. * properties to Elements.
  49555. */
  49556. /* istanbul ignore if */
  49557. if (isIE9) {
  49558. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49559. document.addEventListener('selectionchange', function () {
  49560. var el = document.activeElement;
  49561. if (el && el.vmodel) {
  49562. trigger(el, 'input');
  49563. }
  49564. });
  49565. }
  49566. var directive = {
  49567. inserted: function inserted (el, binding, vnode, oldVnode) {
  49568. if (vnode.tag === 'select') {
  49569. // #6903
  49570. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49571. mergeVNodeHook(vnode, 'postpatch', function () {
  49572. directive.componentUpdated(el, binding, vnode);
  49573. });
  49574. } else {
  49575. setSelected(el, binding, vnode.context);
  49576. }
  49577. el._vOptions = [].map.call(el.options, getValue);
  49578. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49579. el._vModifiers = binding.modifiers;
  49580. if (!binding.modifiers.lazy) {
  49581. el.addEventListener('compositionstart', onCompositionStart);
  49582. el.addEventListener('compositionend', onCompositionEnd);
  49583. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49584. // switching focus before confirming composition choice
  49585. // this also fixes the issue where some browsers e.g. iOS Chrome
  49586. // fires "change" instead of "input" on autocomplete.
  49587. el.addEventListener('change', onCompositionEnd);
  49588. /* istanbul ignore if */
  49589. if (isIE9) {
  49590. el.vmodel = true;
  49591. }
  49592. }
  49593. }
  49594. },
  49595. componentUpdated: function componentUpdated (el, binding, vnode) {
  49596. if (vnode.tag === 'select') {
  49597. setSelected(el, binding, vnode.context);
  49598. // in case the options rendered by v-for have changed,
  49599. // it's possible that the value is out-of-sync with the rendered options.
  49600. // detect such cases and filter out values that no longer has a matching
  49601. // option in the DOM.
  49602. var prevOptions = el._vOptions;
  49603. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49604. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49605. // trigger change event if
  49606. // no matching option found for at least one value
  49607. var needReset = el.multiple
  49608. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49609. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49610. if (needReset) {
  49611. trigger(el, 'change');
  49612. }
  49613. }
  49614. }
  49615. }
  49616. };
  49617. function setSelected (el, binding, vm) {
  49618. actuallySetSelected(el, binding, vm);
  49619. /* istanbul ignore if */
  49620. if (isIE || isEdge) {
  49621. setTimeout(function () {
  49622. actuallySetSelected(el, binding, vm);
  49623. }, 0);
  49624. }
  49625. }
  49626. function actuallySetSelected (el, binding, vm) {
  49627. var value = binding.value;
  49628. var isMultiple = el.multiple;
  49629. if (isMultiple && !Array.isArray(value)) {
  49630. warn(
  49631. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49632. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49633. vm
  49634. );
  49635. return
  49636. }
  49637. var selected, option;
  49638. for (var i = 0, l = el.options.length; i < l; i++) {
  49639. option = el.options[i];
  49640. if (isMultiple) {
  49641. selected = looseIndexOf(value, getValue(option)) > -1;
  49642. if (option.selected !== selected) {
  49643. option.selected = selected;
  49644. }
  49645. } else {
  49646. if (looseEqual(getValue(option), value)) {
  49647. if (el.selectedIndex !== i) {
  49648. el.selectedIndex = i;
  49649. }
  49650. return
  49651. }
  49652. }
  49653. }
  49654. if (!isMultiple) {
  49655. el.selectedIndex = -1;
  49656. }
  49657. }
  49658. function hasNoMatchingOption (value, options) {
  49659. return options.every(function (o) { return !looseEqual(o, value); })
  49660. }
  49661. function getValue (option) {
  49662. return '_value' in option
  49663. ? option._value
  49664. : option.value
  49665. }
  49666. function onCompositionStart (e) {
  49667. e.target.composing = true;
  49668. }
  49669. function onCompositionEnd (e) {
  49670. // prevent triggering an input event for no reason
  49671. if (!e.target.composing) { return }
  49672. e.target.composing = false;
  49673. trigger(e.target, 'input');
  49674. }
  49675. function trigger (el, type) {
  49676. var e = document.createEvent('HTMLEvents');
  49677. e.initEvent(type, true, true);
  49678. el.dispatchEvent(e);
  49679. }
  49680. /* */
  49681. // recursively search for possible transition defined inside the component root
  49682. function locateNode (vnode) {
  49683. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49684. ? locateNode(vnode.componentInstance._vnode)
  49685. : vnode
  49686. }
  49687. var show = {
  49688. bind: function bind (el, ref, vnode) {
  49689. var value = ref.value;
  49690. vnode = locateNode(vnode);
  49691. var transition$$1 = vnode.data && vnode.data.transition;
  49692. var originalDisplay = el.__vOriginalDisplay =
  49693. el.style.display === 'none' ? '' : el.style.display;
  49694. if (value && transition$$1) {
  49695. vnode.data.show = true;
  49696. enter(vnode, function () {
  49697. el.style.display = originalDisplay;
  49698. });
  49699. } else {
  49700. el.style.display = value ? originalDisplay : 'none';
  49701. }
  49702. },
  49703. update: function update (el, ref, vnode) {
  49704. var value = ref.value;
  49705. var oldValue = ref.oldValue;
  49706. /* istanbul ignore if */
  49707. if (!value === !oldValue) { return }
  49708. vnode = locateNode(vnode);
  49709. var transition$$1 = vnode.data && vnode.data.transition;
  49710. if (transition$$1) {
  49711. vnode.data.show = true;
  49712. if (value) {
  49713. enter(vnode, function () {
  49714. el.style.display = el.__vOriginalDisplay;
  49715. });
  49716. } else {
  49717. leave(vnode, function () {
  49718. el.style.display = 'none';
  49719. });
  49720. }
  49721. } else {
  49722. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49723. }
  49724. },
  49725. unbind: function unbind (
  49726. el,
  49727. binding,
  49728. vnode,
  49729. oldVnode,
  49730. isDestroy
  49731. ) {
  49732. if (!isDestroy) {
  49733. el.style.display = el.__vOriginalDisplay;
  49734. }
  49735. }
  49736. };
  49737. var platformDirectives = {
  49738. model: directive,
  49739. show: show
  49740. };
  49741. /* */
  49742. var transitionProps = {
  49743. name: String,
  49744. appear: Boolean,
  49745. css: Boolean,
  49746. mode: String,
  49747. type: String,
  49748. enterClass: String,
  49749. leaveClass: String,
  49750. enterToClass: String,
  49751. leaveToClass: String,
  49752. enterActiveClass: String,
  49753. leaveActiveClass: String,
  49754. appearClass: String,
  49755. appearActiveClass: String,
  49756. appearToClass: String,
  49757. duration: [Number, String, Object]
  49758. };
  49759. // in case the child is also an abstract component, e.g. <keep-alive>
  49760. // we want to recursively retrieve the real component to be rendered
  49761. function getRealChild (vnode) {
  49762. var compOptions = vnode && vnode.componentOptions;
  49763. if (compOptions && compOptions.Ctor.options.abstract) {
  49764. return getRealChild(getFirstComponentChild(compOptions.children))
  49765. } else {
  49766. return vnode
  49767. }
  49768. }
  49769. function extractTransitionData (comp) {
  49770. var data = {};
  49771. var options = comp.$options;
  49772. // props
  49773. for (var key in options.propsData) {
  49774. data[key] = comp[key];
  49775. }
  49776. // events.
  49777. // extract listeners and pass them directly to the transition methods
  49778. var listeners = options._parentListeners;
  49779. for (var key$1 in listeners) {
  49780. data[camelize(key$1)] = listeners[key$1];
  49781. }
  49782. return data
  49783. }
  49784. function placeholder (h, rawChild) {
  49785. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49786. return h('keep-alive', {
  49787. props: rawChild.componentOptions.propsData
  49788. })
  49789. }
  49790. }
  49791. function hasParentTransition (vnode) {
  49792. while ((vnode = vnode.parent)) {
  49793. if (vnode.data.transition) {
  49794. return true
  49795. }
  49796. }
  49797. }
  49798. function isSameChild (child, oldChild) {
  49799. return oldChild.key === child.key && oldChild.tag === child.tag
  49800. }
  49801. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49802. var isVShowDirective = function (d) { return d.name === 'show'; };
  49803. var Transition = {
  49804. name: 'transition',
  49805. props: transitionProps,
  49806. abstract: true,
  49807. render: function render (h) {
  49808. var this$1 = this;
  49809. var children = this.$slots.default;
  49810. if (!children) {
  49811. return
  49812. }
  49813. // filter out text nodes (possible whitespaces)
  49814. children = children.filter(isNotTextNode);
  49815. /* istanbul ignore if */
  49816. if (!children.length) {
  49817. return
  49818. }
  49819. // warn multiple elements
  49820. if (children.length > 1) {
  49821. warn(
  49822. '<transition> can only be used on a single element. Use ' +
  49823. '<transition-group> for lists.',
  49824. this.$parent
  49825. );
  49826. }
  49827. var mode = this.mode;
  49828. // warn invalid mode
  49829. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49830. ) {
  49831. warn(
  49832. 'invalid <transition> mode: ' + mode,
  49833. this.$parent
  49834. );
  49835. }
  49836. var rawChild = children[0];
  49837. // if this is a component root node and the component's
  49838. // parent container node also has transition, skip.
  49839. if (hasParentTransition(this.$vnode)) {
  49840. return rawChild
  49841. }
  49842. // apply transition data to child
  49843. // use getRealChild() to ignore abstract components e.g. keep-alive
  49844. var child = getRealChild(rawChild);
  49845. /* istanbul ignore if */
  49846. if (!child) {
  49847. return rawChild
  49848. }
  49849. if (this._leaving) {
  49850. return placeholder(h, rawChild)
  49851. }
  49852. // ensure a key that is unique to the vnode type and to this transition
  49853. // component instance. This key will be used to remove pending leaving nodes
  49854. // during entering.
  49855. var id = "__transition-" + (this._uid) + "-";
  49856. child.key = child.key == null
  49857. ? child.isComment
  49858. ? id + 'comment'
  49859. : id + child.tag
  49860. : isPrimitive(child.key)
  49861. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49862. : child.key;
  49863. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49864. var oldRawChild = this._vnode;
  49865. var oldChild = getRealChild(oldRawChild);
  49866. // mark v-show
  49867. // so that the transition module can hand over the control to the directive
  49868. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49869. child.data.show = true;
  49870. }
  49871. if (
  49872. oldChild &&
  49873. oldChild.data &&
  49874. !isSameChild(child, oldChild) &&
  49875. !isAsyncPlaceholder(oldChild) &&
  49876. // #6687 component root is a comment node
  49877. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49878. ) {
  49879. // replace old child transition data with fresh one
  49880. // important for dynamic transitions!
  49881. var oldData = oldChild.data.transition = extend({}, data);
  49882. // handle transition mode
  49883. if (mode === 'out-in') {
  49884. // return placeholder node and queue update when leave finishes
  49885. this._leaving = true;
  49886. mergeVNodeHook(oldData, 'afterLeave', function () {
  49887. this$1._leaving = false;
  49888. this$1.$forceUpdate();
  49889. });
  49890. return placeholder(h, rawChild)
  49891. } else if (mode === 'in-out') {
  49892. if (isAsyncPlaceholder(child)) {
  49893. return oldRawChild
  49894. }
  49895. var delayedLeave;
  49896. var performLeave = function () { delayedLeave(); };
  49897. mergeVNodeHook(data, 'afterEnter', performLeave);
  49898. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49899. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49900. }
  49901. }
  49902. return rawChild
  49903. }
  49904. };
  49905. /* */
  49906. var props = extend({
  49907. tag: String,
  49908. moveClass: String
  49909. }, transitionProps);
  49910. delete props.mode;
  49911. var TransitionGroup = {
  49912. props: props,
  49913. beforeMount: function beforeMount () {
  49914. var this$1 = this;
  49915. var update = this._update;
  49916. this._update = function (vnode, hydrating) {
  49917. var restoreActiveInstance = setActiveInstance(this$1);
  49918. // force removing pass
  49919. this$1.__patch__(
  49920. this$1._vnode,
  49921. this$1.kept,
  49922. false, // hydrating
  49923. true // removeOnly (!important, avoids unnecessary moves)
  49924. );
  49925. this$1._vnode = this$1.kept;
  49926. restoreActiveInstance();
  49927. update.call(this$1, vnode, hydrating);
  49928. };
  49929. },
  49930. render: function render (h) {
  49931. var tag = this.tag || this.$vnode.data.tag || 'span';
  49932. var map = Object.create(null);
  49933. var prevChildren = this.prevChildren = this.children;
  49934. var rawChildren = this.$slots.default || [];
  49935. var children = this.children = [];
  49936. var transitionData = extractTransitionData(this);
  49937. for (var i = 0; i < rawChildren.length; i++) {
  49938. var c = rawChildren[i];
  49939. if (c.tag) {
  49940. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49941. children.push(c);
  49942. map[c.key] = c
  49943. ;(c.data || (c.data = {})).transition = transitionData;
  49944. } else {
  49945. var opts = c.componentOptions;
  49946. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49947. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49948. }
  49949. }
  49950. }
  49951. if (prevChildren) {
  49952. var kept = [];
  49953. var removed = [];
  49954. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49955. var c$1 = prevChildren[i$1];
  49956. c$1.data.transition = transitionData;
  49957. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49958. if (map[c$1.key]) {
  49959. kept.push(c$1);
  49960. } else {
  49961. removed.push(c$1);
  49962. }
  49963. }
  49964. this.kept = h(tag, null, kept);
  49965. this.removed = removed;
  49966. }
  49967. return h(tag, null, children)
  49968. },
  49969. updated: function updated () {
  49970. var children = this.prevChildren;
  49971. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49972. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49973. return
  49974. }
  49975. // we divide the work into three loops to avoid mixing DOM reads and writes
  49976. // in each iteration - which helps prevent layout thrashing.
  49977. children.forEach(callPendingCbs);
  49978. children.forEach(recordPosition);
  49979. children.forEach(applyTranslation);
  49980. // force reflow to put everything in position
  49981. // assign to this to avoid being removed in tree-shaking
  49982. // $flow-disable-line
  49983. this._reflow = document.body.offsetHeight;
  49984. children.forEach(function (c) {
  49985. if (c.data.moved) {
  49986. var el = c.elm;
  49987. var s = el.style;
  49988. addTransitionClass(el, moveClass);
  49989. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49990. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49991. if (e && e.target !== el) {
  49992. return
  49993. }
  49994. if (!e || /transform$/.test(e.propertyName)) {
  49995. el.removeEventListener(transitionEndEvent, cb);
  49996. el._moveCb = null;
  49997. removeTransitionClass(el, moveClass);
  49998. }
  49999. });
  50000. }
  50001. });
  50002. },
  50003. methods: {
  50004. hasMove: function hasMove (el, moveClass) {
  50005. /* istanbul ignore if */
  50006. if (!hasTransition) {
  50007. return false
  50008. }
  50009. /* istanbul ignore if */
  50010. if (this._hasMove) {
  50011. return this._hasMove
  50012. }
  50013. // Detect whether an element with the move class applied has
  50014. // CSS transitions. Since the element may be inside an entering
  50015. // transition at this very moment, we make a clone of it and remove
  50016. // all other transition classes applied to ensure only the move class
  50017. // is applied.
  50018. var clone = el.cloneNode();
  50019. if (el._transitionClasses) {
  50020. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  50021. }
  50022. addClass(clone, moveClass);
  50023. clone.style.display = 'none';
  50024. this.$el.appendChild(clone);
  50025. var info = getTransitionInfo(clone);
  50026. this.$el.removeChild(clone);
  50027. return (this._hasMove = info.hasTransform)
  50028. }
  50029. }
  50030. };
  50031. function callPendingCbs (c) {
  50032. /* istanbul ignore if */
  50033. if (c.elm._moveCb) {
  50034. c.elm._moveCb();
  50035. }
  50036. /* istanbul ignore if */
  50037. if (c.elm._enterCb) {
  50038. c.elm._enterCb();
  50039. }
  50040. }
  50041. function recordPosition (c) {
  50042. c.data.newPos = c.elm.getBoundingClientRect();
  50043. }
  50044. function applyTranslation (c) {
  50045. var oldPos = c.data.pos;
  50046. var newPos = c.data.newPos;
  50047. var dx = oldPos.left - newPos.left;
  50048. var dy = oldPos.top - newPos.top;
  50049. if (dx || dy) {
  50050. c.data.moved = true;
  50051. var s = c.elm.style;
  50052. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  50053. s.transitionDuration = '0s';
  50054. }
  50055. }
  50056. var platformComponents = {
  50057. Transition: Transition,
  50058. TransitionGroup: TransitionGroup
  50059. };
  50060. /* */
  50061. // install platform specific utils
  50062. Vue.config.mustUseProp = mustUseProp;
  50063. Vue.config.isReservedTag = isReservedTag;
  50064. Vue.config.isReservedAttr = isReservedAttr;
  50065. Vue.config.getTagNamespace = getTagNamespace;
  50066. Vue.config.isUnknownElement = isUnknownElement;
  50067. // install platform runtime directives & components
  50068. extend(Vue.options.directives, platformDirectives);
  50069. extend(Vue.options.components, platformComponents);
  50070. // install platform patch function
  50071. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  50072. // public mount method
  50073. Vue.prototype.$mount = function (
  50074. el,
  50075. hydrating
  50076. ) {
  50077. el = el && inBrowser ? query(el) : undefined;
  50078. return mountComponent(this, el, hydrating)
  50079. };
  50080. // devtools global hook
  50081. /* istanbul ignore next */
  50082. if (inBrowser) {
  50083. setTimeout(function () {
  50084. if (config.devtools) {
  50085. if (devtools) {
  50086. devtools.emit('init', Vue);
  50087. } else {
  50088. console[console.info ? 'info' : 'log'](
  50089. 'Download the Vue Devtools extension for a better development experience:\n' +
  50090. 'https://github.com/vuejs/vue-devtools'
  50091. );
  50092. }
  50093. }
  50094. if (config.productionTip !== false &&
  50095. typeof console !== 'undefined'
  50096. ) {
  50097. console[console.info ? 'info' : 'log'](
  50098. "You are running Vue in development mode.\n" +
  50099. "Make sure to turn on production mode when deploying for production.\n" +
  50100. "See more tips at https://vuejs.org/guide/deployment.html"
  50101. );
  50102. }
  50103. }, 0);
  50104. }
  50105. /* */
  50106. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  50107. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  50108. var buildRegex = cached(function (delimiters) {
  50109. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  50110. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  50111. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  50112. });
  50113. function parseText (
  50114. text,
  50115. delimiters
  50116. ) {
  50117. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  50118. if (!tagRE.test(text)) {
  50119. return
  50120. }
  50121. var tokens = [];
  50122. var rawTokens = [];
  50123. var lastIndex = tagRE.lastIndex = 0;
  50124. var match, index, tokenValue;
  50125. while ((match = tagRE.exec(text))) {
  50126. index = match.index;
  50127. // push text token
  50128. if (index > lastIndex) {
  50129. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  50130. tokens.push(JSON.stringify(tokenValue));
  50131. }
  50132. // tag token
  50133. var exp = parseFilters(match[1].trim());
  50134. tokens.push(("_s(" + exp + ")"));
  50135. rawTokens.push({ '@binding': exp });
  50136. lastIndex = index + match[0].length;
  50137. }
  50138. if (lastIndex < text.length) {
  50139. rawTokens.push(tokenValue = text.slice(lastIndex));
  50140. tokens.push(JSON.stringify(tokenValue));
  50141. }
  50142. return {
  50143. expression: tokens.join('+'),
  50144. tokens: rawTokens
  50145. }
  50146. }
  50147. /* */
  50148. function transformNode (el, options) {
  50149. var warn = options.warn || baseWarn;
  50150. var staticClass = getAndRemoveAttr(el, 'class');
  50151. if (staticClass) {
  50152. var res = parseText(staticClass, options.delimiters);
  50153. if (res) {
  50154. warn(
  50155. "class=\"" + staticClass + "\": " +
  50156. 'Interpolation inside attributes has been removed. ' +
  50157. 'Use v-bind or the colon shorthand instead. For example, ' +
  50158. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  50159. el.rawAttrsMap['class']
  50160. );
  50161. }
  50162. }
  50163. if (staticClass) {
  50164. el.staticClass = JSON.stringify(staticClass);
  50165. }
  50166. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  50167. if (classBinding) {
  50168. el.classBinding = classBinding;
  50169. }
  50170. }
  50171. function genData (el) {
  50172. var data = '';
  50173. if (el.staticClass) {
  50174. data += "staticClass:" + (el.staticClass) + ",";
  50175. }
  50176. if (el.classBinding) {
  50177. data += "class:" + (el.classBinding) + ",";
  50178. }
  50179. return data
  50180. }
  50181. var klass$1 = {
  50182. staticKeys: ['staticClass'],
  50183. transformNode: transformNode,
  50184. genData: genData
  50185. };
  50186. /* */
  50187. function transformNode$1 (el, options) {
  50188. var warn = options.warn || baseWarn;
  50189. var staticStyle = getAndRemoveAttr(el, 'style');
  50190. if (staticStyle) {
  50191. /* istanbul ignore if */
  50192. {
  50193. var res = parseText(staticStyle, options.delimiters);
  50194. if (res) {
  50195. warn(
  50196. "style=\"" + staticStyle + "\": " +
  50197. 'Interpolation inside attributes has been removed. ' +
  50198. 'Use v-bind or the colon shorthand instead. For example, ' +
  50199. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  50200. el.rawAttrsMap['style']
  50201. );
  50202. }
  50203. }
  50204. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  50205. }
  50206. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  50207. if (styleBinding) {
  50208. el.styleBinding = styleBinding;
  50209. }
  50210. }
  50211. function genData$1 (el) {
  50212. var data = '';
  50213. if (el.staticStyle) {
  50214. data += "staticStyle:" + (el.staticStyle) + ",";
  50215. }
  50216. if (el.styleBinding) {
  50217. data += "style:(" + (el.styleBinding) + "),";
  50218. }
  50219. return data
  50220. }
  50221. var style$1 = {
  50222. staticKeys: ['staticStyle'],
  50223. transformNode: transformNode$1,
  50224. genData: genData$1
  50225. };
  50226. /* */
  50227. var decoder;
  50228. var he = {
  50229. decode: function decode (html) {
  50230. decoder = decoder || document.createElement('div');
  50231. decoder.innerHTML = html;
  50232. return decoder.textContent
  50233. }
  50234. };
  50235. /* */
  50236. var isUnaryTag = makeMap(
  50237. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50238. 'link,meta,param,source,track,wbr'
  50239. );
  50240. // Elements that you can, intentionally, leave open
  50241. // (and which close themselves)
  50242. var canBeLeftOpenTag = makeMap(
  50243. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50244. );
  50245. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50246. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50247. var isNonPhrasingTag = makeMap(
  50248. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50249. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50250. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50251. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50252. 'title,tr,track'
  50253. );
  50254. /**
  50255. * Not type-checking this file because it's mostly vendor code.
  50256. */
  50257. // Regular Expressions for parsing tags and attributes
  50258. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50259. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50260. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50261. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50262. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50263. var startTagClose = /^\s*(\/?)>/;
  50264. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50265. var doctype = /^<!DOCTYPE [^>]+>/i;
  50266. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50267. var comment = /^<!\--/;
  50268. var conditionalComment = /^<!\[/;
  50269. // Special Elements (can contain anything)
  50270. var isPlainTextElement = makeMap('script,style,textarea', true);
  50271. var reCache = {};
  50272. var decodingMap = {
  50273. '&lt;': '<',
  50274. '&gt;': '>',
  50275. '&quot;': '"',
  50276. '&amp;': '&',
  50277. '&#10;': '\n',
  50278. '&#9;': '\t',
  50279. '&#39;': "'"
  50280. };
  50281. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50282. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50283. // #5992
  50284. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50285. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50286. function decodeAttr (value, shouldDecodeNewlines) {
  50287. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50288. return value.replace(re, function (match) { return decodingMap[match]; })
  50289. }
  50290. function parseHTML (html, options) {
  50291. var stack = [];
  50292. var expectHTML = options.expectHTML;
  50293. var isUnaryTag$$1 = options.isUnaryTag || no;
  50294. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50295. var index = 0;
  50296. var last, lastTag;
  50297. while (html) {
  50298. last = html;
  50299. // Make sure we're not in a plaintext content element like script/style
  50300. if (!lastTag || !isPlainTextElement(lastTag)) {
  50301. var textEnd = html.indexOf('<');
  50302. if (textEnd === 0) {
  50303. // Comment:
  50304. if (comment.test(html)) {
  50305. var commentEnd = html.indexOf('-->');
  50306. if (commentEnd >= 0) {
  50307. if (options.shouldKeepComment) {
  50308. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50309. }
  50310. advance(commentEnd + 3);
  50311. continue
  50312. }
  50313. }
  50314. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50315. if (conditionalComment.test(html)) {
  50316. var conditionalEnd = html.indexOf(']>');
  50317. if (conditionalEnd >= 0) {
  50318. advance(conditionalEnd + 2);
  50319. continue
  50320. }
  50321. }
  50322. // Doctype:
  50323. var doctypeMatch = html.match(doctype);
  50324. if (doctypeMatch) {
  50325. advance(doctypeMatch[0].length);
  50326. continue
  50327. }
  50328. // End tag:
  50329. var endTagMatch = html.match(endTag);
  50330. if (endTagMatch) {
  50331. var curIndex = index;
  50332. advance(endTagMatch[0].length);
  50333. parseEndTag(endTagMatch[1], curIndex, index);
  50334. continue
  50335. }
  50336. // Start tag:
  50337. var startTagMatch = parseStartTag();
  50338. if (startTagMatch) {
  50339. handleStartTag(startTagMatch);
  50340. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50341. advance(1);
  50342. }
  50343. continue
  50344. }
  50345. }
  50346. var text = (void 0), rest = (void 0), next = (void 0);
  50347. if (textEnd >= 0) {
  50348. rest = html.slice(textEnd);
  50349. while (
  50350. !endTag.test(rest) &&
  50351. !startTagOpen.test(rest) &&
  50352. !comment.test(rest) &&
  50353. !conditionalComment.test(rest)
  50354. ) {
  50355. // < in plain text, be forgiving and treat it as text
  50356. next = rest.indexOf('<', 1);
  50357. if (next < 0) { break }
  50358. textEnd += next;
  50359. rest = html.slice(textEnd);
  50360. }
  50361. text = html.substring(0, textEnd);
  50362. }
  50363. if (textEnd < 0) {
  50364. text = html;
  50365. }
  50366. if (text) {
  50367. advance(text.length);
  50368. }
  50369. if (options.chars && text) {
  50370. options.chars(text, index - text.length, index);
  50371. }
  50372. } else {
  50373. var endTagLength = 0;
  50374. var stackedTag = lastTag.toLowerCase();
  50375. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50376. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50377. endTagLength = endTag.length;
  50378. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50379. text = text
  50380. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50381. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50382. }
  50383. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50384. text = text.slice(1);
  50385. }
  50386. if (options.chars) {
  50387. options.chars(text);
  50388. }
  50389. return ''
  50390. });
  50391. index += html.length - rest$1.length;
  50392. html = rest$1;
  50393. parseEndTag(stackedTag, index - endTagLength, index);
  50394. }
  50395. if (html === last) {
  50396. options.chars && options.chars(html);
  50397. if (!stack.length && options.warn) {
  50398. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50399. }
  50400. break
  50401. }
  50402. }
  50403. // Clean up any remaining tags
  50404. parseEndTag();
  50405. function advance (n) {
  50406. index += n;
  50407. html = html.substring(n);
  50408. }
  50409. function parseStartTag () {
  50410. var start = html.match(startTagOpen);
  50411. if (start) {
  50412. var match = {
  50413. tagName: start[1],
  50414. attrs: [],
  50415. start: index
  50416. };
  50417. advance(start[0].length);
  50418. var end, attr;
  50419. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50420. attr.start = index;
  50421. advance(attr[0].length);
  50422. attr.end = index;
  50423. match.attrs.push(attr);
  50424. }
  50425. if (end) {
  50426. match.unarySlash = end[1];
  50427. advance(end[0].length);
  50428. match.end = index;
  50429. return match
  50430. }
  50431. }
  50432. }
  50433. function handleStartTag (match) {
  50434. var tagName = match.tagName;
  50435. var unarySlash = match.unarySlash;
  50436. if (expectHTML) {
  50437. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50438. parseEndTag(lastTag);
  50439. }
  50440. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50441. parseEndTag(tagName);
  50442. }
  50443. }
  50444. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50445. var l = match.attrs.length;
  50446. var attrs = new Array(l);
  50447. for (var i = 0; i < l; i++) {
  50448. var args = match.attrs[i];
  50449. var value = args[3] || args[4] || args[5] || '';
  50450. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50451. ? options.shouldDecodeNewlinesForHref
  50452. : options.shouldDecodeNewlines;
  50453. attrs[i] = {
  50454. name: args[1],
  50455. value: decodeAttr(value, shouldDecodeNewlines)
  50456. };
  50457. if (options.outputSourceRange) {
  50458. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50459. attrs[i].end = args.end;
  50460. }
  50461. }
  50462. if (!unary) {
  50463. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50464. lastTag = tagName;
  50465. }
  50466. if (options.start) {
  50467. options.start(tagName, attrs, unary, match.start, match.end);
  50468. }
  50469. }
  50470. function parseEndTag (tagName, start, end) {
  50471. var pos, lowerCasedTagName;
  50472. if (start == null) { start = index; }
  50473. if (end == null) { end = index; }
  50474. // Find the closest opened tag of the same type
  50475. if (tagName) {
  50476. lowerCasedTagName = tagName.toLowerCase();
  50477. for (pos = stack.length - 1; pos >= 0; pos--) {
  50478. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50479. break
  50480. }
  50481. }
  50482. } else {
  50483. // If no tag name is provided, clean shop
  50484. pos = 0;
  50485. }
  50486. if (pos >= 0) {
  50487. // Close all the open elements, up the stack
  50488. for (var i = stack.length - 1; i >= pos; i--) {
  50489. if (i > pos || !tagName &&
  50490. options.warn
  50491. ) {
  50492. options.warn(
  50493. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50494. { start: stack[i].start, end: stack[i].end }
  50495. );
  50496. }
  50497. if (options.end) {
  50498. options.end(stack[i].tag, start, end);
  50499. }
  50500. }
  50501. // Remove the open elements from the stack
  50502. stack.length = pos;
  50503. lastTag = pos && stack[pos - 1].tag;
  50504. } else if (lowerCasedTagName === 'br') {
  50505. if (options.start) {
  50506. options.start(tagName, [], true, start, end);
  50507. }
  50508. } else if (lowerCasedTagName === 'p') {
  50509. if (options.start) {
  50510. options.start(tagName, [], false, start, end);
  50511. }
  50512. if (options.end) {
  50513. options.end(tagName, start, end);
  50514. }
  50515. }
  50516. }
  50517. }
  50518. /* */
  50519. var onRE = /^@|^v-on:/;
  50520. var dirRE = /^v-|^@|^:|^#/;
  50521. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50522. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50523. var stripParensRE = /^\(|\)$/g;
  50524. var dynamicArgRE = /^\[.*\]$/;
  50525. var argRE = /:(.*)$/;
  50526. var bindRE = /^:|^\.|^v-bind:/;
  50527. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50528. var slotRE = /^v-slot(:|$)|^#/;
  50529. var lineBreakRE = /[\r\n]/;
  50530. var whitespaceRE$1 = /\s+/g;
  50531. var invalidAttributeRE = /[\s"'<>\/=]/;
  50532. var decodeHTMLCached = cached(he.decode);
  50533. var emptySlotScopeToken = "_empty_";
  50534. // configurable state
  50535. var warn$2;
  50536. var delimiters;
  50537. var transforms;
  50538. var preTransforms;
  50539. var postTransforms;
  50540. var platformIsPreTag;
  50541. var platformMustUseProp;
  50542. var platformGetTagNamespace;
  50543. var maybeComponent;
  50544. function createASTElement (
  50545. tag,
  50546. attrs,
  50547. parent
  50548. ) {
  50549. return {
  50550. type: 1,
  50551. tag: tag,
  50552. attrsList: attrs,
  50553. attrsMap: makeAttrsMap(attrs),
  50554. rawAttrsMap: {},
  50555. parent: parent,
  50556. children: []
  50557. }
  50558. }
  50559. /**
  50560. * Convert HTML string to AST.
  50561. */
  50562. function parse (
  50563. template,
  50564. options
  50565. ) {
  50566. warn$2 = options.warn || baseWarn;
  50567. platformIsPreTag = options.isPreTag || no;
  50568. platformMustUseProp = options.mustUseProp || no;
  50569. platformGetTagNamespace = options.getTagNamespace || no;
  50570. var isReservedTag = options.isReservedTag || no;
  50571. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50572. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50573. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50574. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50575. delimiters = options.delimiters;
  50576. var stack = [];
  50577. var preserveWhitespace = options.preserveWhitespace !== false;
  50578. var whitespaceOption = options.whitespace;
  50579. var root;
  50580. var currentParent;
  50581. var inVPre = false;
  50582. var inPre = false;
  50583. var warned = false;
  50584. function warnOnce (msg, range) {
  50585. if (!warned) {
  50586. warned = true;
  50587. warn$2(msg, range);
  50588. }
  50589. }
  50590. function closeElement (element) {
  50591. trimEndingWhitespace(element);
  50592. if (!inVPre && !element.processed) {
  50593. element = processElement(element, options);
  50594. }
  50595. // tree management
  50596. if (!stack.length && element !== root) {
  50597. // allow root elements with v-if, v-else-if and v-else
  50598. if (root.if && (element.elseif || element.else)) {
  50599. {
  50600. checkRootConstraints(element);
  50601. }
  50602. addIfCondition(root, {
  50603. exp: element.elseif,
  50604. block: element
  50605. });
  50606. } else {
  50607. warnOnce(
  50608. "Component template should contain exactly one root element. " +
  50609. "If you are using v-if on multiple elements, " +
  50610. "use v-else-if to chain them instead.",
  50611. { start: element.start }
  50612. );
  50613. }
  50614. }
  50615. if (currentParent && !element.forbidden) {
  50616. if (element.elseif || element.else) {
  50617. processIfConditions(element, currentParent);
  50618. } else {
  50619. if (element.slotScope) {
  50620. // scoped slot
  50621. // keep it in the children list so that v-else(-if) conditions can
  50622. // find it as the prev node.
  50623. var name = element.slotTarget || '"default"'
  50624. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50625. }
  50626. currentParent.children.push(element);
  50627. element.parent = currentParent;
  50628. }
  50629. }
  50630. // final children cleanup
  50631. // filter out scoped slots
  50632. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50633. // remove trailing whitespace node again
  50634. trimEndingWhitespace(element);
  50635. // check pre state
  50636. if (element.pre) {
  50637. inVPre = false;
  50638. }
  50639. if (platformIsPreTag(element.tag)) {
  50640. inPre = false;
  50641. }
  50642. // apply post-transforms
  50643. for (var i = 0; i < postTransforms.length; i++) {
  50644. postTransforms[i](element, options);
  50645. }
  50646. }
  50647. function trimEndingWhitespace (el) {
  50648. // remove trailing whitespace node
  50649. if (!inPre) {
  50650. var lastNode;
  50651. while (
  50652. (lastNode = el.children[el.children.length - 1]) &&
  50653. lastNode.type === 3 &&
  50654. lastNode.text === ' '
  50655. ) {
  50656. el.children.pop();
  50657. }
  50658. }
  50659. }
  50660. function checkRootConstraints (el) {
  50661. if (el.tag === 'slot' || el.tag === 'template') {
  50662. warnOnce(
  50663. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50664. 'contain multiple nodes.',
  50665. { start: el.start }
  50666. );
  50667. }
  50668. if (el.attrsMap.hasOwnProperty('v-for')) {
  50669. warnOnce(
  50670. 'Cannot use v-for on stateful component root element because ' +
  50671. 'it renders multiple elements.',
  50672. el.rawAttrsMap['v-for']
  50673. );
  50674. }
  50675. }
  50676. parseHTML(template, {
  50677. warn: warn$2,
  50678. expectHTML: options.expectHTML,
  50679. isUnaryTag: options.isUnaryTag,
  50680. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50681. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50682. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50683. shouldKeepComment: options.comments,
  50684. outputSourceRange: options.outputSourceRange,
  50685. start: function start (tag, attrs, unary, start$1, end) {
  50686. // check namespace.
  50687. // inherit parent ns if there is one
  50688. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50689. // handle IE svg bug
  50690. /* istanbul ignore if */
  50691. if (isIE && ns === 'svg') {
  50692. attrs = guardIESVGBug(attrs);
  50693. }
  50694. var element = createASTElement(tag, attrs, currentParent);
  50695. if (ns) {
  50696. element.ns = ns;
  50697. }
  50698. {
  50699. if (options.outputSourceRange) {
  50700. element.start = start$1;
  50701. element.end = end;
  50702. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50703. cumulated[attr.name] = attr;
  50704. return cumulated
  50705. }, {});
  50706. }
  50707. attrs.forEach(function (attr) {
  50708. if (invalidAttributeRE.test(attr.name)) {
  50709. warn$2(
  50710. "Invalid dynamic argument expression: attribute names cannot contain " +
  50711. "spaces, quotes, <, >, / or =.",
  50712. {
  50713. start: attr.start + attr.name.indexOf("["),
  50714. end: attr.start + attr.name.length
  50715. }
  50716. );
  50717. }
  50718. });
  50719. }
  50720. if (isForbiddenTag(element) && !isServerRendering()) {
  50721. element.forbidden = true;
  50722. warn$2(
  50723. 'Templates should only be responsible for mapping the state to the ' +
  50724. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50725. "<" + tag + ">" + ', as they will not be parsed.',
  50726. { start: element.start }
  50727. );
  50728. }
  50729. // apply pre-transforms
  50730. for (var i = 0; i < preTransforms.length; i++) {
  50731. element = preTransforms[i](element, options) || element;
  50732. }
  50733. if (!inVPre) {
  50734. processPre(element);
  50735. if (element.pre) {
  50736. inVPre = true;
  50737. }
  50738. }
  50739. if (platformIsPreTag(element.tag)) {
  50740. inPre = true;
  50741. }
  50742. if (inVPre) {
  50743. processRawAttrs(element);
  50744. } else if (!element.processed) {
  50745. // structural directives
  50746. processFor(element);
  50747. processIf(element);
  50748. processOnce(element);
  50749. }
  50750. if (!root) {
  50751. root = element;
  50752. {
  50753. checkRootConstraints(root);
  50754. }
  50755. }
  50756. if (!unary) {
  50757. currentParent = element;
  50758. stack.push(element);
  50759. } else {
  50760. closeElement(element);
  50761. }
  50762. },
  50763. end: function end (tag, start, end$1) {
  50764. var element = stack[stack.length - 1];
  50765. // pop stack
  50766. stack.length -= 1;
  50767. currentParent = stack[stack.length - 1];
  50768. if (options.outputSourceRange) {
  50769. element.end = end$1;
  50770. }
  50771. closeElement(element);
  50772. },
  50773. chars: function chars (text, start, end) {
  50774. if (!currentParent) {
  50775. {
  50776. if (text === template) {
  50777. warnOnce(
  50778. 'Component template requires a root element, rather than just text.',
  50779. { start: start }
  50780. );
  50781. } else if ((text = text.trim())) {
  50782. warnOnce(
  50783. ("text \"" + text + "\" outside root element will be ignored."),
  50784. { start: start }
  50785. );
  50786. }
  50787. }
  50788. return
  50789. }
  50790. // IE textarea placeholder bug
  50791. /* istanbul ignore if */
  50792. if (isIE &&
  50793. currentParent.tag === 'textarea' &&
  50794. currentParent.attrsMap.placeholder === text
  50795. ) {
  50796. return
  50797. }
  50798. var children = currentParent.children;
  50799. if (inPre || text.trim()) {
  50800. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50801. } else if (!children.length) {
  50802. // remove the whitespace-only node right after an opening tag
  50803. text = '';
  50804. } else if (whitespaceOption) {
  50805. if (whitespaceOption === 'condense') {
  50806. // in condense mode, remove the whitespace node if it contains
  50807. // line break, otherwise condense to a single space
  50808. text = lineBreakRE.test(text) ? '' : ' ';
  50809. } else {
  50810. text = ' ';
  50811. }
  50812. } else {
  50813. text = preserveWhitespace ? ' ' : '';
  50814. }
  50815. if (text) {
  50816. if (!inPre && whitespaceOption === 'condense') {
  50817. // condense consecutive whitespaces into single space
  50818. text = text.replace(whitespaceRE$1, ' ');
  50819. }
  50820. var res;
  50821. var child;
  50822. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50823. child = {
  50824. type: 2,
  50825. expression: res.expression,
  50826. tokens: res.tokens,
  50827. text: text
  50828. };
  50829. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50830. child = {
  50831. type: 3,
  50832. text: text
  50833. };
  50834. }
  50835. if (child) {
  50836. if (options.outputSourceRange) {
  50837. child.start = start;
  50838. child.end = end;
  50839. }
  50840. children.push(child);
  50841. }
  50842. }
  50843. },
  50844. comment: function comment (text, start, end) {
  50845. // adding anyting as a sibling to the root node is forbidden
  50846. // comments should still be allowed, but ignored
  50847. if (currentParent) {
  50848. var child = {
  50849. type: 3,
  50850. text: text,
  50851. isComment: true
  50852. };
  50853. if (options.outputSourceRange) {
  50854. child.start = start;
  50855. child.end = end;
  50856. }
  50857. currentParent.children.push(child);
  50858. }
  50859. }
  50860. });
  50861. return root
  50862. }
  50863. function processPre (el) {
  50864. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50865. el.pre = true;
  50866. }
  50867. }
  50868. function processRawAttrs (el) {
  50869. var list = el.attrsList;
  50870. var len = list.length;
  50871. if (len) {
  50872. var attrs = el.attrs = new Array(len);
  50873. for (var i = 0; i < len; i++) {
  50874. attrs[i] = {
  50875. name: list[i].name,
  50876. value: JSON.stringify(list[i].value)
  50877. };
  50878. if (list[i].start != null) {
  50879. attrs[i].start = list[i].start;
  50880. attrs[i].end = list[i].end;
  50881. }
  50882. }
  50883. } else if (!el.pre) {
  50884. // non root node in pre blocks with no attributes
  50885. el.plain = true;
  50886. }
  50887. }
  50888. function processElement (
  50889. element,
  50890. options
  50891. ) {
  50892. processKey(element);
  50893. // determine whether this is a plain element after
  50894. // removing structural attributes
  50895. element.plain = (
  50896. !element.key &&
  50897. !element.scopedSlots &&
  50898. !element.attrsList.length
  50899. );
  50900. processRef(element);
  50901. processSlotContent(element);
  50902. processSlotOutlet(element);
  50903. processComponent(element);
  50904. for (var i = 0; i < transforms.length; i++) {
  50905. element = transforms[i](element, options) || element;
  50906. }
  50907. processAttrs(element);
  50908. return element
  50909. }
  50910. function processKey (el) {
  50911. var exp = getBindingAttr(el, 'key');
  50912. if (exp) {
  50913. {
  50914. if (el.tag === 'template') {
  50915. warn$2(
  50916. "<template> cannot be keyed. Place the key on real elements instead.",
  50917. getRawBindingAttr(el, 'key')
  50918. );
  50919. }
  50920. if (el.for) {
  50921. var iterator = el.iterator2 || el.iterator1;
  50922. var parent = el.parent;
  50923. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50924. warn$2(
  50925. "Do not use v-for index as key on <transition-group> children, " +
  50926. "this is the same as not using keys.",
  50927. getRawBindingAttr(el, 'key'),
  50928. true /* tip */
  50929. );
  50930. }
  50931. }
  50932. }
  50933. el.key = exp;
  50934. }
  50935. }
  50936. function processRef (el) {
  50937. var ref = getBindingAttr(el, 'ref');
  50938. if (ref) {
  50939. el.ref = ref;
  50940. el.refInFor = checkInFor(el);
  50941. }
  50942. }
  50943. function processFor (el) {
  50944. var exp;
  50945. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50946. var res = parseFor(exp);
  50947. if (res) {
  50948. extend(el, res);
  50949. } else {
  50950. warn$2(
  50951. ("Invalid v-for expression: " + exp),
  50952. el.rawAttrsMap['v-for']
  50953. );
  50954. }
  50955. }
  50956. }
  50957. function parseFor (exp) {
  50958. var inMatch = exp.match(forAliasRE);
  50959. if (!inMatch) { return }
  50960. var res = {};
  50961. res.for = inMatch[2].trim();
  50962. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50963. var iteratorMatch = alias.match(forIteratorRE);
  50964. if (iteratorMatch) {
  50965. res.alias = alias.replace(forIteratorRE, '').trim();
  50966. res.iterator1 = iteratorMatch[1].trim();
  50967. if (iteratorMatch[2]) {
  50968. res.iterator2 = iteratorMatch[2].trim();
  50969. }
  50970. } else {
  50971. res.alias = alias;
  50972. }
  50973. return res
  50974. }
  50975. function processIf (el) {
  50976. var exp = getAndRemoveAttr(el, 'v-if');
  50977. if (exp) {
  50978. el.if = exp;
  50979. addIfCondition(el, {
  50980. exp: exp,
  50981. block: el
  50982. });
  50983. } else {
  50984. if (getAndRemoveAttr(el, 'v-else') != null) {
  50985. el.else = true;
  50986. }
  50987. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50988. if (elseif) {
  50989. el.elseif = elseif;
  50990. }
  50991. }
  50992. }
  50993. function processIfConditions (el, parent) {
  50994. var prev = findPrevElement(parent.children);
  50995. if (prev && prev.if) {
  50996. addIfCondition(prev, {
  50997. exp: el.elseif,
  50998. block: el
  50999. });
  51000. } else {
  51001. warn$2(
  51002. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  51003. "used on element <" + (el.tag) + "> without corresponding v-if.",
  51004. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  51005. );
  51006. }
  51007. }
  51008. function findPrevElement (children) {
  51009. var i = children.length;
  51010. while (i--) {
  51011. if (children[i].type === 1) {
  51012. return children[i]
  51013. } else {
  51014. if (children[i].text !== ' ') {
  51015. warn$2(
  51016. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  51017. "will be ignored.",
  51018. children[i]
  51019. );
  51020. }
  51021. children.pop();
  51022. }
  51023. }
  51024. }
  51025. function addIfCondition (el, condition) {
  51026. if (!el.ifConditions) {
  51027. el.ifConditions = [];
  51028. }
  51029. el.ifConditions.push(condition);
  51030. }
  51031. function processOnce (el) {
  51032. var once$$1 = getAndRemoveAttr(el, 'v-once');
  51033. if (once$$1 != null) {
  51034. el.once = true;
  51035. }
  51036. }
  51037. // handle content being passed to a component as slot,
  51038. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  51039. function processSlotContent (el) {
  51040. var slotScope;
  51041. if (el.tag === 'template') {
  51042. slotScope = getAndRemoveAttr(el, 'scope');
  51043. /* istanbul ignore if */
  51044. if (slotScope) {
  51045. warn$2(
  51046. "the \"scope\" attribute for scoped slots have been deprecated and " +
  51047. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  51048. "can also be used on plain elements in addition to <template> to " +
  51049. "denote scoped slots.",
  51050. el.rawAttrsMap['scope'],
  51051. true
  51052. );
  51053. }
  51054. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  51055. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  51056. /* istanbul ignore if */
  51057. if (el.attrsMap['v-for']) {
  51058. warn$2(
  51059. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  51060. "(v-for takes higher priority). Use a wrapper <template> for the " +
  51061. "scoped slot to make it clearer.",
  51062. el.rawAttrsMap['slot-scope'],
  51063. true
  51064. );
  51065. }
  51066. el.slotScope = slotScope;
  51067. }
  51068. // slot="xxx"
  51069. var slotTarget = getBindingAttr(el, 'slot');
  51070. if (slotTarget) {
  51071. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  51072. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  51073. // preserve slot as an attribute for native shadow DOM compat
  51074. // only for non-scoped slots.
  51075. if (el.tag !== 'template' && !el.slotScope) {
  51076. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  51077. }
  51078. }
  51079. // 2.6 v-slot syntax
  51080. {
  51081. if (el.tag === 'template') {
  51082. // v-slot on <template>
  51083. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  51084. if (slotBinding) {
  51085. {
  51086. if (el.slotTarget || el.slotScope) {
  51087. warn$2(
  51088. "Unexpected mixed usage of different slot syntaxes.",
  51089. el
  51090. );
  51091. }
  51092. if (el.parent && !maybeComponent(el.parent)) {
  51093. warn$2(
  51094. "<template v-slot> can only appear at the root level inside " +
  51095. "the receiving component",
  51096. el
  51097. );
  51098. }
  51099. }
  51100. var ref = getSlotName(slotBinding);
  51101. var name = ref.name;
  51102. var dynamic = ref.dynamic;
  51103. el.slotTarget = name;
  51104. el.slotTargetDynamic = dynamic;
  51105. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  51106. }
  51107. } else {
  51108. // v-slot on component, denotes default slot
  51109. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  51110. if (slotBinding$1) {
  51111. {
  51112. if (!maybeComponent(el)) {
  51113. warn$2(
  51114. "v-slot can only be used on components or <template>.",
  51115. slotBinding$1
  51116. );
  51117. }
  51118. if (el.slotScope || el.slotTarget) {
  51119. warn$2(
  51120. "Unexpected mixed usage of different slot syntaxes.",
  51121. el
  51122. );
  51123. }
  51124. if (el.scopedSlots) {
  51125. warn$2(
  51126. "To avoid scope ambiguity, the default slot should also use " +
  51127. "<template> syntax when there are other named slots.",
  51128. slotBinding$1
  51129. );
  51130. }
  51131. }
  51132. // add the component's children to its default slot
  51133. var slots = el.scopedSlots || (el.scopedSlots = {});
  51134. var ref$1 = getSlotName(slotBinding$1);
  51135. var name$1 = ref$1.name;
  51136. var dynamic$1 = ref$1.dynamic;
  51137. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  51138. slotContainer.slotTarget = name$1;
  51139. slotContainer.slotTargetDynamic = dynamic$1;
  51140. slotContainer.children = el.children.filter(function (c) {
  51141. if (!c.slotScope) {
  51142. c.parent = slotContainer;
  51143. return true
  51144. }
  51145. });
  51146. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  51147. // remove children as they are returned from scopedSlots now
  51148. el.children = [];
  51149. // mark el non-plain so data gets generated
  51150. el.plain = false;
  51151. }
  51152. }
  51153. }
  51154. }
  51155. function getSlotName (binding) {
  51156. var name = binding.name.replace(slotRE, '');
  51157. if (!name) {
  51158. if (binding.name[0] !== '#') {
  51159. name = 'default';
  51160. } else {
  51161. warn$2(
  51162. "v-slot shorthand syntax requires a slot name.",
  51163. binding
  51164. );
  51165. }
  51166. }
  51167. return dynamicArgRE.test(name)
  51168. // dynamic [name]
  51169. ? { name: name.slice(1, -1), dynamic: true }
  51170. // static name
  51171. : { name: ("\"" + name + "\""), dynamic: false }
  51172. }
  51173. // handle <slot/> outlets
  51174. function processSlotOutlet (el) {
  51175. if (el.tag === 'slot') {
  51176. el.slotName = getBindingAttr(el, 'name');
  51177. if (el.key) {
  51178. warn$2(
  51179. "`key` does not work on <slot> because slots are abstract outlets " +
  51180. "and can possibly expand into multiple elements. " +
  51181. "Use the key on a wrapping element instead.",
  51182. getRawBindingAttr(el, 'key')
  51183. );
  51184. }
  51185. }
  51186. }
  51187. function processComponent (el) {
  51188. var binding;
  51189. if ((binding = getBindingAttr(el, 'is'))) {
  51190. el.component = binding;
  51191. }
  51192. if (getAndRemoveAttr(el, 'inline-template') != null) {
  51193. el.inlineTemplate = true;
  51194. }
  51195. }
  51196. function processAttrs (el) {
  51197. var list = el.attrsList;
  51198. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  51199. for (i = 0, l = list.length; i < l; i++) {
  51200. name = rawName = list[i].name;
  51201. value = list[i].value;
  51202. if (dirRE.test(name)) {
  51203. // mark element as dynamic
  51204. el.hasBindings = true;
  51205. // modifiers
  51206. modifiers = parseModifiers(name.replace(dirRE, ''));
  51207. // support .foo shorthand syntax for the .prop modifier
  51208. if (modifiers) {
  51209. name = name.replace(modifierRE, '');
  51210. }
  51211. if (bindRE.test(name)) { // v-bind
  51212. name = name.replace(bindRE, '');
  51213. value = parseFilters(value);
  51214. isDynamic = dynamicArgRE.test(name);
  51215. if (isDynamic) {
  51216. name = name.slice(1, -1);
  51217. }
  51218. if (
  51219. value.trim().length === 0
  51220. ) {
  51221. warn$2(
  51222. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  51223. );
  51224. }
  51225. if (modifiers) {
  51226. if (modifiers.prop && !isDynamic) {
  51227. name = camelize(name);
  51228. if (name === 'innerHtml') { name = 'innerHTML'; }
  51229. }
  51230. if (modifiers.camel && !isDynamic) {
  51231. name = camelize(name);
  51232. }
  51233. if (modifiers.sync) {
  51234. syncGen = genAssignmentCode(value, "$event");
  51235. if (!isDynamic) {
  51236. addHandler(
  51237. el,
  51238. ("update:" + (camelize(name))),
  51239. syncGen,
  51240. null,
  51241. false,
  51242. warn$2,
  51243. list[i]
  51244. );
  51245. if (hyphenate(name) !== camelize(name)) {
  51246. addHandler(
  51247. el,
  51248. ("update:" + (hyphenate(name))),
  51249. syncGen,
  51250. null,
  51251. false,
  51252. warn$2,
  51253. list[i]
  51254. );
  51255. }
  51256. } else {
  51257. // handler w/ dynamic event name
  51258. addHandler(
  51259. el,
  51260. ("\"update:\"+(" + name + ")"),
  51261. syncGen,
  51262. null,
  51263. false,
  51264. warn$2,
  51265. list[i],
  51266. true // dynamic
  51267. );
  51268. }
  51269. }
  51270. }
  51271. if ((modifiers && modifiers.prop) || (
  51272. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51273. )) {
  51274. addProp(el, name, value, list[i], isDynamic);
  51275. } else {
  51276. addAttr(el, name, value, list[i], isDynamic);
  51277. }
  51278. } else if (onRE.test(name)) { // v-on
  51279. name = name.replace(onRE, '');
  51280. isDynamic = dynamicArgRE.test(name);
  51281. if (isDynamic) {
  51282. name = name.slice(1, -1);
  51283. }
  51284. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51285. } else { // normal directives
  51286. name = name.replace(dirRE, '');
  51287. // parse arg
  51288. var argMatch = name.match(argRE);
  51289. var arg = argMatch && argMatch[1];
  51290. isDynamic = false;
  51291. if (arg) {
  51292. name = name.slice(0, -(arg.length + 1));
  51293. if (dynamicArgRE.test(arg)) {
  51294. arg = arg.slice(1, -1);
  51295. isDynamic = true;
  51296. }
  51297. }
  51298. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51299. if (name === 'model') {
  51300. checkForAliasModel(el, value);
  51301. }
  51302. }
  51303. } else {
  51304. // literal attribute
  51305. {
  51306. var res = parseText(value, delimiters);
  51307. if (res) {
  51308. warn$2(
  51309. name + "=\"" + value + "\": " +
  51310. 'Interpolation inside attributes has been removed. ' +
  51311. 'Use v-bind or the colon shorthand instead. For example, ' +
  51312. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51313. list[i]
  51314. );
  51315. }
  51316. }
  51317. addAttr(el, name, JSON.stringify(value), list[i]);
  51318. // #6887 firefox doesn't update muted state if set via attribute
  51319. // even immediately after element creation
  51320. if (!el.component &&
  51321. name === 'muted' &&
  51322. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51323. addProp(el, name, 'true', list[i]);
  51324. }
  51325. }
  51326. }
  51327. }
  51328. function checkInFor (el) {
  51329. var parent = el;
  51330. while (parent) {
  51331. if (parent.for !== undefined) {
  51332. return true
  51333. }
  51334. parent = parent.parent;
  51335. }
  51336. return false
  51337. }
  51338. function parseModifiers (name) {
  51339. var match = name.match(modifierRE);
  51340. if (match) {
  51341. var ret = {};
  51342. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51343. return ret
  51344. }
  51345. }
  51346. function makeAttrsMap (attrs) {
  51347. var map = {};
  51348. for (var i = 0, l = attrs.length; i < l; i++) {
  51349. if (
  51350. map[attrs[i].name] && !isIE && !isEdge
  51351. ) {
  51352. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51353. }
  51354. map[attrs[i].name] = attrs[i].value;
  51355. }
  51356. return map
  51357. }
  51358. // for script (e.g. type="x/template") or style, do not decode content
  51359. function isTextTag (el) {
  51360. return el.tag === 'script' || el.tag === 'style'
  51361. }
  51362. function isForbiddenTag (el) {
  51363. return (
  51364. el.tag === 'style' ||
  51365. (el.tag === 'script' && (
  51366. !el.attrsMap.type ||
  51367. el.attrsMap.type === 'text/javascript'
  51368. ))
  51369. )
  51370. }
  51371. var ieNSBug = /^xmlns:NS\d+/;
  51372. var ieNSPrefix = /^NS\d+:/;
  51373. /* istanbul ignore next */
  51374. function guardIESVGBug (attrs) {
  51375. var res = [];
  51376. for (var i = 0; i < attrs.length; i++) {
  51377. var attr = attrs[i];
  51378. if (!ieNSBug.test(attr.name)) {
  51379. attr.name = attr.name.replace(ieNSPrefix, '');
  51380. res.push(attr);
  51381. }
  51382. }
  51383. return res
  51384. }
  51385. function checkForAliasModel (el, value) {
  51386. var _el = el;
  51387. while (_el) {
  51388. if (_el.for && _el.alias === value) {
  51389. warn$2(
  51390. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51391. "You are binding v-model directly to a v-for iteration alias. " +
  51392. "This will not be able to modify the v-for source array because " +
  51393. "writing to the alias is like modifying a function local variable. " +
  51394. "Consider using an array of objects and use v-model on an object property instead.",
  51395. el.rawAttrsMap['v-model']
  51396. );
  51397. }
  51398. _el = _el.parent;
  51399. }
  51400. }
  51401. /* */
  51402. function preTransformNode (el, options) {
  51403. if (el.tag === 'input') {
  51404. var map = el.attrsMap;
  51405. if (!map['v-model']) {
  51406. return
  51407. }
  51408. var typeBinding;
  51409. if (map[':type'] || map['v-bind:type']) {
  51410. typeBinding = getBindingAttr(el, 'type');
  51411. }
  51412. if (!map.type && !typeBinding && map['v-bind']) {
  51413. typeBinding = "(" + (map['v-bind']) + ").type";
  51414. }
  51415. if (typeBinding) {
  51416. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51417. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51418. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51419. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51420. // 1. checkbox
  51421. var branch0 = cloneASTElement(el);
  51422. // process for on the main node
  51423. processFor(branch0);
  51424. addRawAttr(branch0, 'type', 'checkbox');
  51425. processElement(branch0, options);
  51426. branch0.processed = true; // prevent it from double-processed
  51427. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51428. addIfCondition(branch0, {
  51429. exp: branch0.if,
  51430. block: branch0
  51431. });
  51432. // 2. add radio else-if condition
  51433. var branch1 = cloneASTElement(el);
  51434. getAndRemoveAttr(branch1, 'v-for', true);
  51435. addRawAttr(branch1, 'type', 'radio');
  51436. processElement(branch1, options);
  51437. addIfCondition(branch0, {
  51438. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51439. block: branch1
  51440. });
  51441. // 3. other
  51442. var branch2 = cloneASTElement(el);
  51443. getAndRemoveAttr(branch2, 'v-for', true);
  51444. addRawAttr(branch2, ':type', typeBinding);
  51445. processElement(branch2, options);
  51446. addIfCondition(branch0, {
  51447. exp: ifCondition,
  51448. block: branch2
  51449. });
  51450. if (hasElse) {
  51451. branch0.else = true;
  51452. } else if (elseIfCondition) {
  51453. branch0.elseif = elseIfCondition;
  51454. }
  51455. return branch0
  51456. }
  51457. }
  51458. }
  51459. function cloneASTElement (el) {
  51460. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51461. }
  51462. var model$1 = {
  51463. preTransformNode: preTransformNode
  51464. };
  51465. var modules$1 = [
  51466. klass$1,
  51467. style$1,
  51468. model$1
  51469. ];
  51470. /* */
  51471. function text (el, dir) {
  51472. if (dir.value) {
  51473. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51474. }
  51475. }
  51476. /* */
  51477. function html (el, dir) {
  51478. if (dir.value) {
  51479. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51480. }
  51481. }
  51482. var directives$1 = {
  51483. model: model,
  51484. text: text,
  51485. html: html
  51486. };
  51487. /* */
  51488. var baseOptions = {
  51489. expectHTML: true,
  51490. modules: modules$1,
  51491. directives: directives$1,
  51492. isPreTag: isPreTag,
  51493. isUnaryTag: isUnaryTag,
  51494. mustUseProp: mustUseProp,
  51495. canBeLeftOpenTag: canBeLeftOpenTag,
  51496. isReservedTag: isReservedTag,
  51497. getTagNamespace: getTagNamespace,
  51498. staticKeys: genStaticKeys(modules$1)
  51499. };
  51500. /* */
  51501. var isStaticKey;
  51502. var isPlatformReservedTag;
  51503. var genStaticKeysCached = cached(genStaticKeys$1);
  51504. /**
  51505. * Goal of the optimizer: walk the generated template AST tree
  51506. * and detect sub-trees that are purely static, i.e. parts of
  51507. * the DOM that never needs to change.
  51508. *
  51509. * Once we detect these sub-trees, we can:
  51510. *
  51511. * 1. Hoist them into constants, so that we no longer need to
  51512. * create fresh nodes for them on each re-render;
  51513. * 2. Completely skip them in the patching process.
  51514. */
  51515. function optimize (root, options) {
  51516. if (!root) { return }
  51517. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51518. isPlatformReservedTag = options.isReservedTag || no;
  51519. // first pass: mark all non-static nodes.
  51520. markStatic$1(root);
  51521. // second pass: mark static roots.
  51522. markStaticRoots(root, false);
  51523. }
  51524. function genStaticKeys$1 (keys) {
  51525. return makeMap(
  51526. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51527. (keys ? ',' + keys : '')
  51528. )
  51529. }
  51530. function markStatic$1 (node) {
  51531. node.static = isStatic(node);
  51532. if (node.type === 1) {
  51533. // do not make component slot content static. this avoids
  51534. // 1. components not able to mutate slot nodes
  51535. // 2. static slot content fails for hot-reloading
  51536. if (
  51537. !isPlatformReservedTag(node.tag) &&
  51538. node.tag !== 'slot' &&
  51539. node.attrsMap['inline-template'] == null
  51540. ) {
  51541. return
  51542. }
  51543. for (var i = 0, l = node.children.length; i < l; i++) {
  51544. var child = node.children[i];
  51545. markStatic$1(child);
  51546. if (!child.static) {
  51547. node.static = false;
  51548. }
  51549. }
  51550. if (node.ifConditions) {
  51551. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51552. var block = node.ifConditions[i$1].block;
  51553. markStatic$1(block);
  51554. if (!block.static) {
  51555. node.static = false;
  51556. }
  51557. }
  51558. }
  51559. }
  51560. }
  51561. function markStaticRoots (node, isInFor) {
  51562. if (node.type === 1) {
  51563. if (node.static || node.once) {
  51564. node.staticInFor = isInFor;
  51565. }
  51566. // For a node to qualify as a static root, it should have children that
  51567. // are not just static text. Otherwise the cost of hoisting out will
  51568. // outweigh the benefits and it's better off to just always render it fresh.
  51569. if (node.static && node.children.length && !(
  51570. node.children.length === 1 &&
  51571. node.children[0].type === 3
  51572. )) {
  51573. node.staticRoot = true;
  51574. return
  51575. } else {
  51576. node.staticRoot = false;
  51577. }
  51578. if (node.children) {
  51579. for (var i = 0, l = node.children.length; i < l; i++) {
  51580. markStaticRoots(node.children[i], isInFor || !!node.for);
  51581. }
  51582. }
  51583. if (node.ifConditions) {
  51584. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51585. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51586. }
  51587. }
  51588. }
  51589. }
  51590. function isStatic (node) {
  51591. if (node.type === 2) { // expression
  51592. return false
  51593. }
  51594. if (node.type === 3) { // text
  51595. return true
  51596. }
  51597. return !!(node.pre || (
  51598. !node.hasBindings && // no dynamic bindings
  51599. !node.if && !node.for && // not v-if or v-for or v-else
  51600. !isBuiltInTag(node.tag) && // not a built-in
  51601. isPlatformReservedTag(node.tag) && // not a component
  51602. !isDirectChildOfTemplateFor(node) &&
  51603. Object.keys(node).every(isStaticKey)
  51604. ))
  51605. }
  51606. function isDirectChildOfTemplateFor (node) {
  51607. while (node.parent) {
  51608. node = node.parent;
  51609. if (node.tag !== 'template') {
  51610. return false
  51611. }
  51612. if (node.for) {
  51613. return true
  51614. }
  51615. }
  51616. return false
  51617. }
  51618. /* */
  51619. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51620. var fnInvokeRE = /\([^)]*?\);*$/;
  51621. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51622. // KeyboardEvent.keyCode aliases
  51623. var keyCodes = {
  51624. esc: 27,
  51625. tab: 9,
  51626. enter: 13,
  51627. space: 32,
  51628. up: 38,
  51629. left: 37,
  51630. right: 39,
  51631. down: 40,
  51632. 'delete': [8, 46]
  51633. };
  51634. // KeyboardEvent.key aliases
  51635. var keyNames = {
  51636. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51637. esc: ['Esc', 'Escape'],
  51638. tab: 'Tab',
  51639. enter: 'Enter',
  51640. // #9112: IE11 uses `Spacebar` for Space key name.
  51641. space: [' ', 'Spacebar'],
  51642. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51643. up: ['Up', 'ArrowUp'],
  51644. left: ['Left', 'ArrowLeft'],
  51645. right: ['Right', 'ArrowRight'],
  51646. down: ['Down', 'ArrowDown'],
  51647. // #9112: IE11 uses `Del` for Delete key name.
  51648. 'delete': ['Backspace', 'Delete', 'Del']
  51649. };
  51650. // #4868: modifiers that prevent the execution of the listener
  51651. // need to explicitly return null so that we can determine whether to remove
  51652. // the listener for .once
  51653. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51654. var modifierCode = {
  51655. stop: '$event.stopPropagation();',
  51656. prevent: '$event.preventDefault();',
  51657. self: genGuard("$event.target !== $event.currentTarget"),
  51658. ctrl: genGuard("!$event.ctrlKey"),
  51659. shift: genGuard("!$event.shiftKey"),
  51660. alt: genGuard("!$event.altKey"),
  51661. meta: genGuard("!$event.metaKey"),
  51662. left: genGuard("'button' in $event && $event.button !== 0"),
  51663. middle: genGuard("'button' in $event && $event.button !== 1"),
  51664. right: genGuard("'button' in $event && $event.button !== 2")
  51665. };
  51666. function genHandlers (
  51667. events,
  51668. isNative
  51669. ) {
  51670. var prefix = isNative ? 'nativeOn:' : 'on:';
  51671. var staticHandlers = "";
  51672. var dynamicHandlers = "";
  51673. for (var name in events) {
  51674. var handlerCode = genHandler(events[name]);
  51675. if (events[name] && events[name].dynamic) {
  51676. dynamicHandlers += name + "," + handlerCode + ",";
  51677. } else {
  51678. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51679. }
  51680. }
  51681. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51682. if (dynamicHandlers) {
  51683. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51684. } else {
  51685. return prefix + staticHandlers
  51686. }
  51687. }
  51688. function genHandler (handler) {
  51689. if (!handler) {
  51690. return 'function(){}'
  51691. }
  51692. if (Array.isArray(handler)) {
  51693. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51694. }
  51695. var isMethodPath = simplePathRE.test(handler.value);
  51696. var isFunctionExpression = fnExpRE.test(handler.value);
  51697. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51698. if (!handler.modifiers) {
  51699. if (isMethodPath || isFunctionExpression) {
  51700. return handler.value
  51701. }
  51702. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51703. } else {
  51704. var code = '';
  51705. var genModifierCode = '';
  51706. var keys = [];
  51707. for (var key in handler.modifiers) {
  51708. if (modifierCode[key]) {
  51709. genModifierCode += modifierCode[key];
  51710. // left/right
  51711. if (keyCodes[key]) {
  51712. keys.push(key);
  51713. }
  51714. } else if (key === 'exact') {
  51715. var modifiers = (handler.modifiers);
  51716. genModifierCode += genGuard(
  51717. ['ctrl', 'shift', 'alt', 'meta']
  51718. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51719. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51720. .join('||')
  51721. );
  51722. } else {
  51723. keys.push(key);
  51724. }
  51725. }
  51726. if (keys.length) {
  51727. code += genKeyFilter(keys);
  51728. }
  51729. // Make sure modifiers like prevent and stop get executed after key filtering
  51730. if (genModifierCode) {
  51731. code += genModifierCode;
  51732. }
  51733. var handlerCode = isMethodPath
  51734. ? ("return " + (handler.value) + "($event)")
  51735. : isFunctionExpression
  51736. ? ("return (" + (handler.value) + ")($event)")
  51737. : isFunctionInvocation
  51738. ? ("return " + (handler.value))
  51739. : handler.value;
  51740. return ("function($event){" + code + handlerCode + "}")
  51741. }
  51742. }
  51743. function genKeyFilter (keys) {
  51744. return (
  51745. // make sure the key filters only apply to KeyboardEvents
  51746. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51747. // key events that do not have keyCode property...
  51748. "if(!$event.type.indexOf('key')&&" +
  51749. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51750. )
  51751. }
  51752. function genFilterCode (key) {
  51753. var keyVal = parseInt(key, 10);
  51754. if (keyVal) {
  51755. return ("$event.keyCode!==" + keyVal)
  51756. }
  51757. var keyCode = keyCodes[key];
  51758. var keyName = keyNames[key];
  51759. return (
  51760. "_k($event.keyCode," +
  51761. (JSON.stringify(key)) + "," +
  51762. (JSON.stringify(keyCode)) + "," +
  51763. "$event.key," +
  51764. "" + (JSON.stringify(keyName)) +
  51765. ")"
  51766. )
  51767. }
  51768. /* */
  51769. function on (el, dir) {
  51770. if (dir.modifiers) {
  51771. warn("v-on without argument does not support modifiers.");
  51772. }
  51773. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51774. }
  51775. /* */
  51776. function bind$1 (el, dir) {
  51777. el.wrapData = function (code) {
  51778. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51779. };
  51780. }
  51781. /* */
  51782. var baseDirectives = {
  51783. on: on,
  51784. bind: bind$1,
  51785. cloak: noop
  51786. };
  51787. /* */
  51788. var CodegenState = function CodegenState (options) {
  51789. this.options = options;
  51790. this.warn = options.warn || baseWarn;
  51791. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51792. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51793. this.directives = extend(extend({}, baseDirectives), options.directives);
  51794. var isReservedTag = options.isReservedTag || no;
  51795. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51796. this.onceId = 0;
  51797. this.staticRenderFns = [];
  51798. this.pre = false;
  51799. };
  51800. function generate (
  51801. ast,
  51802. options
  51803. ) {
  51804. var state = new CodegenState(options);
  51805. var code = ast ? genElement(ast, state) : '_c("div")';
  51806. return {
  51807. render: ("with(this){return " + code + "}"),
  51808. staticRenderFns: state.staticRenderFns
  51809. }
  51810. }
  51811. function genElement (el, state) {
  51812. if (el.parent) {
  51813. el.pre = el.pre || el.parent.pre;
  51814. }
  51815. if (el.staticRoot && !el.staticProcessed) {
  51816. return genStatic(el, state)
  51817. } else if (el.once && !el.onceProcessed) {
  51818. return genOnce(el, state)
  51819. } else if (el.for && !el.forProcessed) {
  51820. return genFor(el, state)
  51821. } else if (el.if && !el.ifProcessed) {
  51822. return genIf(el, state)
  51823. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51824. return genChildren(el, state) || 'void 0'
  51825. } else if (el.tag === 'slot') {
  51826. return genSlot(el, state)
  51827. } else {
  51828. // component or element
  51829. var code;
  51830. if (el.component) {
  51831. code = genComponent(el.component, el, state);
  51832. } else {
  51833. var data;
  51834. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51835. data = genData$2(el, state);
  51836. }
  51837. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51838. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51839. }
  51840. // module transforms
  51841. for (var i = 0; i < state.transforms.length; i++) {
  51842. code = state.transforms[i](el, code);
  51843. }
  51844. return code
  51845. }
  51846. }
  51847. // hoist static sub-trees out
  51848. function genStatic (el, state) {
  51849. el.staticProcessed = true;
  51850. // Some elements (templates) need to behave differently inside of a v-pre
  51851. // node. All pre nodes are static roots, so we can use this as a location to
  51852. // wrap a state change and reset it upon exiting the pre node.
  51853. var originalPreState = state.pre;
  51854. if (el.pre) {
  51855. state.pre = el.pre;
  51856. }
  51857. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51858. state.pre = originalPreState;
  51859. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51860. }
  51861. // v-once
  51862. function genOnce (el, state) {
  51863. el.onceProcessed = true;
  51864. if (el.if && !el.ifProcessed) {
  51865. return genIf(el, state)
  51866. } else if (el.staticInFor) {
  51867. var key = '';
  51868. var parent = el.parent;
  51869. while (parent) {
  51870. if (parent.for) {
  51871. key = parent.key;
  51872. break
  51873. }
  51874. parent = parent.parent;
  51875. }
  51876. if (!key) {
  51877. state.warn(
  51878. "v-once can only be used inside v-for that is keyed. ",
  51879. el.rawAttrsMap['v-once']
  51880. );
  51881. return genElement(el, state)
  51882. }
  51883. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51884. } else {
  51885. return genStatic(el, state)
  51886. }
  51887. }
  51888. function genIf (
  51889. el,
  51890. state,
  51891. altGen,
  51892. altEmpty
  51893. ) {
  51894. el.ifProcessed = true; // avoid recursion
  51895. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51896. }
  51897. function genIfConditions (
  51898. conditions,
  51899. state,
  51900. altGen,
  51901. altEmpty
  51902. ) {
  51903. if (!conditions.length) {
  51904. return altEmpty || '_e()'
  51905. }
  51906. var condition = conditions.shift();
  51907. if (condition.exp) {
  51908. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51909. } else {
  51910. return ("" + (genTernaryExp(condition.block)))
  51911. }
  51912. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51913. function genTernaryExp (el) {
  51914. return altGen
  51915. ? altGen(el, state)
  51916. : el.once
  51917. ? genOnce(el, state)
  51918. : genElement(el, state)
  51919. }
  51920. }
  51921. function genFor (
  51922. el,
  51923. state,
  51924. altGen,
  51925. altHelper
  51926. ) {
  51927. var exp = el.for;
  51928. var alias = el.alias;
  51929. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51930. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51931. if (state.maybeComponent(el) &&
  51932. el.tag !== 'slot' &&
  51933. el.tag !== 'template' &&
  51934. !el.key
  51935. ) {
  51936. state.warn(
  51937. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51938. "v-for should have explicit keys. " +
  51939. "See https://vuejs.org/guide/list.html#key for more info.",
  51940. el.rawAttrsMap['v-for'],
  51941. true /* tip */
  51942. );
  51943. }
  51944. el.forProcessed = true; // avoid recursion
  51945. return (altHelper || '_l') + "((" + exp + ")," +
  51946. "function(" + alias + iterator1 + iterator2 + "){" +
  51947. "return " + ((altGen || genElement)(el, state)) +
  51948. '})'
  51949. }
  51950. function genData$2 (el, state) {
  51951. var data = '{';
  51952. // directives first.
  51953. // directives may mutate the el's other properties before they are generated.
  51954. var dirs = genDirectives(el, state);
  51955. if (dirs) { data += dirs + ','; }
  51956. // key
  51957. if (el.key) {
  51958. data += "key:" + (el.key) + ",";
  51959. }
  51960. // ref
  51961. if (el.ref) {
  51962. data += "ref:" + (el.ref) + ",";
  51963. }
  51964. if (el.refInFor) {
  51965. data += "refInFor:true,";
  51966. }
  51967. // pre
  51968. if (el.pre) {
  51969. data += "pre:true,";
  51970. }
  51971. // record original tag name for components using "is" attribute
  51972. if (el.component) {
  51973. data += "tag:\"" + (el.tag) + "\",";
  51974. }
  51975. // module data generation functions
  51976. for (var i = 0; i < state.dataGenFns.length; i++) {
  51977. data += state.dataGenFns[i](el);
  51978. }
  51979. // attributes
  51980. if (el.attrs) {
  51981. data += "attrs:" + (genProps(el.attrs)) + ",";
  51982. }
  51983. // DOM props
  51984. if (el.props) {
  51985. data += "domProps:" + (genProps(el.props)) + ",";
  51986. }
  51987. // event handlers
  51988. if (el.events) {
  51989. data += (genHandlers(el.events, false)) + ",";
  51990. }
  51991. if (el.nativeEvents) {
  51992. data += (genHandlers(el.nativeEvents, true)) + ",";
  51993. }
  51994. // slot target
  51995. // only for non-scoped slots
  51996. if (el.slotTarget && !el.slotScope) {
  51997. data += "slot:" + (el.slotTarget) + ",";
  51998. }
  51999. // scoped slots
  52000. if (el.scopedSlots) {
  52001. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  52002. }
  52003. // component v-model
  52004. if (el.model) {
  52005. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  52006. }
  52007. // inline-template
  52008. if (el.inlineTemplate) {
  52009. var inlineTemplate = genInlineTemplate(el, state);
  52010. if (inlineTemplate) {
  52011. data += inlineTemplate + ",";
  52012. }
  52013. }
  52014. data = data.replace(/,$/, '') + '}';
  52015. // v-bind dynamic argument wrap
  52016. // v-bind with dynamic arguments must be applied using the same v-bind object
  52017. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  52018. if (el.dynamicAttrs) {
  52019. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  52020. }
  52021. // v-bind data wrap
  52022. if (el.wrapData) {
  52023. data = el.wrapData(data);
  52024. }
  52025. // v-on data wrap
  52026. if (el.wrapListeners) {
  52027. data = el.wrapListeners(data);
  52028. }
  52029. return data
  52030. }
  52031. function genDirectives (el, state) {
  52032. var dirs = el.directives;
  52033. if (!dirs) { return }
  52034. var res = 'directives:[';
  52035. var hasRuntime = false;
  52036. var i, l, dir, needRuntime;
  52037. for (i = 0, l = dirs.length; i < l; i++) {
  52038. dir = dirs[i];
  52039. needRuntime = true;
  52040. var gen = state.directives[dir.name];
  52041. if (gen) {
  52042. // compile-time directive that manipulates AST.
  52043. // returns true if it also needs a runtime counterpart.
  52044. needRuntime = !!gen(el, dir, state.warn);
  52045. }
  52046. if (needRuntime) {
  52047. hasRuntime = true;
  52048. 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))) : '') + "},";
  52049. }
  52050. }
  52051. if (hasRuntime) {
  52052. return res.slice(0, -1) + ']'
  52053. }
  52054. }
  52055. function genInlineTemplate (el, state) {
  52056. var ast = el.children[0];
  52057. if (el.children.length !== 1 || ast.type !== 1) {
  52058. state.warn(
  52059. 'Inline-template components must have exactly one child element.',
  52060. { start: el.start }
  52061. );
  52062. }
  52063. if (ast && ast.type === 1) {
  52064. var inlineRenderFns = generate(ast, state.options);
  52065. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  52066. }
  52067. }
  52068. function genScopedSlots (
  52069. el,
  52070. slots,
  52071. state
  52072. ) {
  52073. // by default scoped slots are considered "stable", this allows child
  52074. // components with only scoped slots to skip forced updates from parent.
  52075. // but in some cases we have to bail-out of this optimization
  52076. // for example if the slot contains dynamic names, has v-if or v-for on them...
  52077. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  52078. var slot = slots[key];
  52079. return (
  52080. slot.slotTargetDynamic ||
  52081. slot.if ||
  52082. slot.for ||
  52083. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  52084. )
  52085. });
  52086. // #9534: if a component with scoped slots is inside a conditional branch,
  52087. // it's possible for the same component to be reused but with different
  52088. // compiled slot content. To avoid that, we generate a unique key based on
  52089. // the generated code of all the slot contents.
  52090. var needsKey = !!el.if;
  52091. // OR when it is inside another scoped slot or v-for (the reactivity may be
  52092. // disconnected due to the intermediate scope variable)
  52093. // #9438, #9506
  52094. // TODO: this can be further optimized by properly analyzing in-scope bindings
  52095. // and skip force updating ones that do not actually use scope variables.
  52096. if (!needsForceUpdate) {
  52097. var parent = el.parent;
  52098. while (parent) {
  52099. if (
  52100. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  52101. parent.for
  52102. ) {
  52103. needsForceUpdate = true;
  52104. break
  52105. }
  52106. if (parent.if) {
  52107. needsKey = true;
  52108. }
  52109. parent = parent.parent;
  52110. }
  52111. }
  52112. var generatedSlots = Object.keys(slots)
  52113. .map(function (key) { return genScopedSlot(slots[key], state); })
  52114. .join(',');
  52115. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  52116. }
  52117. function hash(str) {
  52118. var hash = 5381;
  52119. var i = str.length;
  52120. while(i) {
  52121. hash = (hash * 33) ^ str.charCodeAt(--i);
  52122. }
  52123. return hash >>> 0
  52124. }
  52125. function containsSlotChild (el) {
  52126. if (el.type === 1) {
  52127. if (el.tag === 'slot') {
  52128. return true
  52129. }
  52130. return el.children.some(containsSlotChild)
  52131. }
  52132. return false
  52133. }
  52134. function genScopedSlot (
  52135. el,
  52136. state
  52137. ) {
  52138. var isLegacySyntax = el.attrsMap['slot-scope'];
  52139. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  52140. return genIf(el, state, genScopedSlot, "null")
  52141. }
  52142. if (el.for && !el.forProcessed) {
  52143. return genFor(el, state, genScopedSlot)
  52144. }
  52145. var slotScope = el.slotScope === emptySlotScopeToken
  52146. ? ""
  52147. : String(el.slotScope);
  52148. var fn = "function(" + slotScope + "){" +
  52149. "return " + (el.tag === 'template'
  52150. ? el.if && isLegacySyntax
  52151. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  52152. : genChildren(el, state) || 'undefined'
  52153. : genElement(el, state)) + "}";
  52154. // reverse proxy v-slot without scope on this.$slots
  52155. var reverseProxy = slotScope ? "" : ",proxy:true";
  52156. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  52157. }
  52158. function genChildren (
  52159. el,
  52160. state,
  52161. checkSkip,
  52162. altGenElement,
  52163. altGenNode
  52164. ) {
  52165. var children = el.children;
  52166. if (children.length) {
  52167. var el$1 = children[0];
  52168. // optimize single v-for
  52169. if (children.length === 1 &&
  52170. el$1.for &&
  52171. el$1.tag !== 'template' &&
  52172. el$1.tag !== 'slot'
  52173. ) {
  52174. var normalizationType = checkSkip
  52175. ? state.maybeComponent(el$1) ? ",1" : ",0"
  52176. : "";
  52177. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  52178. }
  52179. var normalizationType$1 = checkSkip
  52180. ? getNormalizationType(children, state.maybeComponent)
  52181. : 0;
  52182. var gen = altGenNode || genNode;
  52183. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  52184. }
  52185. }
  52186. // determine the normalization needed for the children array.
  52187. // 0: no normalization needed
  52188. // 1: simple normalization needed (possible 1-level deep nested array)
  52189. // 2: full normalization needed
  52190. function getNormalizationType (
  52191. children,
  52192. maybeComponent
  52193. ) {
  52194. var res = 0;
  52195. for (var i = 0; i < children.length; i++) {
  52196. var el = children[i];
  52197. if (el.type !== 1) {
  52198. continue
  52199. }
  52200. if (needsNormalization(el) ||
  52201. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  52202. res = 2;
  52203. break
  52204. }
  52205. if (maybeComponent(el) ||
  52206. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  52207. res = 1;
  52208. }
  52209. }
  52210. return res
  52211. }
  52212. function needsNormalization (el) {
  52213. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  52214. }
  52215. function genNode (node, state) {
  52216. if (node.type === 1) {
  52217. return genElement(node, state)
  52218. } else if (node.type === 3 && node.isComment) {
  52219. return genComment(node)
  52220. } else {
  52221. return genText(node)
  52222. }
  52223. }
  52224. function genText (text) {
  52225. return ("_v(" + (text.type === 2
  52226. ? text.expression // no need for () because already wrapped in _s()
  52227. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52228. }
  52229. function genComment (comment) {
  52230. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52231. }
  52232. function genSlot (el, state) {
  52233. var slotName = el.slotName || '"default"';
  52234. var children = genChildren(el, state);
  52235. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52236. var attrs = el.attrs || el.dynamicAttrs
  52237. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52238. // slot props are camelized
  52239. name: camelize(attr.name),
  52240. value: attr.value,
  52241. dynamic: attr.dynamic
  52242. }); }))
  52243. : null;
  52244. var bind$$1 = el.attrsMap['v-bind'];
  52245. if ((attrs || bind$$1) && !children) {
  52246. res += ",null";
  52247. }
  52248. if (attrs) {
  52249. res += "," + attrs;
  52250. }
  52251. if (bind$$1) {
  52252. res += (attrs ? '' : ',null') + "," + bind$$1;
  52253. }
  52254. return res + ')'
  52255. }
  52256. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52257. function genComponent (
  52258. componentName,
  52259. el,
  52260. state
  52261. ) {
  52262. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52263. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52264. }
  52265. function genProps (props) {
  52266. var staticProps = "";
  52267. var dynamicProps = "";
  52268. for (var i = 0; i < props.length; i++) {
  52269. var prop = props[i];
  52270. var value = transformSpecialNewlines(prop.value);
  52271. if (prop.dynamic) {
  52272. dynamicProps += (prop.name) + "," + value + ",";
  52273. } else {
  52274. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52275. }
  52276. }
  52277. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52278. if (dynamicProps) {
  52279. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52280. } else {
  52281. return staticProps
  52282. }
  52283. }
  52284. // #3895, #4268
  52285. function transformSpecialNewlines (text) {
  52286. return text
  52287. .replace(/\u2028/g, '\\u2028')
  52288. .replace(/\u2029/g, '\\u2029')
  52289. }
  52290. /* */
  52291. // these keywords should not appear inside expressions, but operators like
  52292. // typeof, instanceof and in are allowed
  52293. var prohibitedKeywordRE = new RegExp('\\b' + (
  52294. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52295. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52296. 'extends,finally,continue,debugger,function,arguments'
  52297. ).split(',').join('\\b|\\b') + '\\b');
  52298. // these unary operators should not be used as property/method names
  52299. var unaryOperatorsRE = new RegExp('\\b' + (
  52300. 'delete,typeof,void'
  52301. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52302. // strip strings in expressions
  52303. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52304. // detect problematic expressions in a template
  52305. function detectErrors (ast, warn) {
  52306. if (ast) {
  52307. checkNode(ast, warn);
  52308. }
  52309. }
  52310. function checkNode (node, warn) {
  52311. if (node.type === 1) {
  52312. for (var name in node.attrsMap) {
  52313. if (dirRE.test(name)) {
  52314. var value = node.attrsMap[name];
  52315. if (value) {
  52316. var range = node.rawAttrsMap[name];
  52317. if (name === 'v-for') {
  52318. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52319. } else if (name === 'v-slot' || name[0] === '#') {
  52320. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52321. } else if (onRE.test(name)) {
  52322. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52323. } else {
  52324. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52325. }
  52326. }
  52327. }
  52328. }
  52329. if (node.children) {
  52330. for (var i = 0; i < node.children.length; i++) {
  52331. checkNode(node.children[i], warn);
  52332. }
  52333. }
  52334. } else if (node.type === 2) {
  52335. checkExpression(node.expression, node.text, warn, node);
  52336. }
  52337. }
  52338. function checkEvent (exp, text, warn, range) {
  52339. var stripped = exp.replace(stripStringRE, '');
  52340. var keywordMatch = stripped.match(unaryOperatorsRE);
  52341. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52342. warn(
  52343. "avoid using JavaScript unary operator as property name: " +
  52344. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52345. range
  52346. );
  52347. }
  52348. checkExpression(exp, text, warn, range);
  52349. }
  52350. function checkFor (node, text, warn, range) {
  52351. checkExpression(node.for || '', text, warn, range);
  52352. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52353. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52354. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52355. }
  52356. function checkIdentifier (
  52357. ident,
  52358. type,
  52359. text,
  52360. warn,
  52361. range
  52362. ) {
  52363. if (typeof ident === 'string') {
  52364. try {
  52365. new Function(("var " + ident + "=_"));
  52366. } catch (e) {
  52367. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52368. }
  52369. }
  52370. }
  52371. function checkExpression (exp, text, warn, range) {
  52372. try {
  52373. new Function(("return " + exp));
  52374. } catch (e) {
  52375. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52376. if (keywordMatch) {
  52377. warn(
  52378. "avoid using JavaScript keyword as property name: " +
  52379. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52380. range
  52381. );
  52382. } else {
  52383. warn(
  52384. "invalid expression: " + (e.message) + " in\n\n" +
  52385. " " + exp + "\n\n" +
  52386. " Raw expression: " + (text.trim()) + "\n",
  52387. range
  52388. );
  52389. }
  52390. }
  52391. }
  52392. function checkFunctionParameterExpression (exp, text, warn, range) {
  52393. try {
  52394. new Function(exp, '');
  52395. } catch (e) {
  52396. warn(
  52397. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52398. " " + exp + "\n\n" +
  52399. " Raw expression: " + (text.trim()) + "\n",
  52400. range
  52401. );
  52402. }
  52403. }
  52404. /* */
  52405. var range = 2;
  52406. function generateCodeFrame (
  52407. source,
  52408. start,
  52409. end
  52410. ) {
  52411. if ( start === void 0 ) start = 0;
  52412. if ( end === void 0 ) end = source.length;
  52413. var lines = source.split(/\r?\n/);
  52414. var count = 0;
  52415. var res = [];
  52416. for (var i = 0; i < lines.length; i++) {
  52417. count += lines[i].length + 1;
  52418. if (count >= start) {
  52419. for (var j = i - range; j <= i + range || end > count; j++) {
  52420. if (j < 0 || j >= lines.length) { continue }
  52421. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52422. var lineLength = lines[j].length;
  52423. if (j === i) {
  52424. // push underline
  52425. var pad = start - (count - lineLength) + 1;
  52426. var length = end > count ? lineLength - pad : end - start;
  52427. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52428. } else if (j > i) {
  52429. if (end > count) {
  52430. var length$1 = Math.min(end - count, lineLength);
  52431. res.push(" | " + repeat$1("^", length$1));
  52432. }
  52433. count += lineLength + 1;
  52434. }
  52435. }
  52436. break
  52437. }
  52438. }
  52439. return res.join('\n')
  52440. }
  52441. function repeat$1 (str, n) {
  52442. var result = '';
  52443. if (n > 0) {
  52444. while (true) { // eslint-disable-line
  52445. if (n & 1) { result += str; }
  52446. n >>>= 1;
  52447. if (n <= 0) { break }
  52448. str += str;
  52449. }
  52450. }
  52451. return result
  52452. }
  52453. /* */
  52454. function createFunction (code, errors) {
  52455. try {
  52456. return new Function(code)
  52457. } catch (err) {
  52458. errors.push({ err: err, code: code });
  52459. return noop
  52460. }
  52461. }
  52462. function createCompileToFunctionFn (compile) {
  52463. var cache = Object.create(null);
  52464. return function compileToFunctions (
  52465. template,
  52466. options,
  52467. vm
  52468. ) {
  52469. options = extend({}, options);
  52470. var warn$$1 = options.warn || warn;
  52471. delete options.warn;
  52472. /* istanbul ignore if */
  52473. {
  52474. // detect possible CSP restriction
  52475. try {
  52476. new Function('return 1');
  52477. } catch (e) {
  52478. if (e.toString().match(/unsafe-eval|CSP/)) {
  52479. warn$$1(
  52480. 'It seems you are using the standalone build of Vue.js in an ' +
  52481. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52482. 'The template compiler cannot work in this environment. Consider ' +
  52483. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52484. 'templates into render functions.'
  52485. );
  52486. }
  52487. }
  52488. }
  52489. // check cache
  52490. var key = options.delimiters
  52491. ? String(options.delimiters) + template
  52492. : template;
  52493. if (cache[key]) {
  52494. return cache[key]
  52495. }
  52496. // compile
  52497. var compiled = compile(template, options);
  52498. // check compilation errors/tips
  52499. {
  52500. if (compiled.errors && compiled.errors.length) {
  52501. if (options.outputSourceRange) {
  52502. compiled.errors.forEach(function (e) {
  52503. warn$$1(
  52504. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52505. generateCodeFrame(template, e.start, e.end),
  52506. vm
  52507. );
  52508. });
  52509. } else {
  52510. warn$$1(
  52511. "Error compiling template:\n\n" + template + "\n\n" +
  52512. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52513. vm
  52514. );
  52515. }
  52516. }
  52517. if (compiled.tips && compiled.tips.length) {
  52518. if (options.outputSourceRange) {
  52519. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52520. } else {
  52521. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52522. }
  52523. }
  52524. }
  52525. // turn code into functions
  52526. var res = {};
  52527. var fnGenErrors = [];
  52528. res.render = createFunction(compiled.render, fnGenErrors);
  52529. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52530. return createFunction(code, fnGenErrors)
  52531. });
  52532. // check function generation errors.
  52533. // this should only happen if there is a bug in the compiler itself.
  52534. // mostly for codegen development use
  52535. /* istanbul ignore if */
  52536. {
  52537. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52538. warn$$1(
  52539. "Failed to generate render function:\n\n" +
  52540. fnGenErrors.map(function (ref) {
  52541. var err = ref.err;
  52542. var code = ref.code;
  52543. return ((err.toString()) + " in\n\n" + code + "\n");
  52544. }).join('\n'),
  52545. vm
  52546. );
  52547. }
  52548. }
  52549. return (cache[key] = res)
  52550. }
  52551. }
  52552. /* */
  52553. function createCompilerCreator (baseCompile) {
  52554. return function createCompiler (baseOptions) {
  52555. function compile (
  52556. template,
  52557. options
  52558. ) {
  52559. var finalOptions = Object.create(baseOptions);
  52560. var errors = [];
  52561. var tips = [];
  52562. var warn = function (msg, range, tip) {
  52563. (tip ? tips : errors).push(msg);
  52564. };
  52565. if (options) {
  52566. if (options.outputSourceRange) {
  52567. // $flow-disable-line
  52568. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52569. warn = function (msg, range, tip) {
  52570. var data = { msg: msg };
  52571. if (range) {
  52572. if (range.start != null) {
  52573. data.start = range.start + leadingSpaceLength;
  52574. }
  52575. if (range.end != null) {
  52576. data.end = range.end + leadingSpaceLength;
  52577. }
  52578. }
  52579. (tip ? tips : errors).push(data);
  52580. };
  52581. }
  52582. // merge custom modules
  52583. if (options.modules) {
  52584. finalOptions.modules =
  52585. (baseOptions.modules || []).concat(options.modules);
  52586. }
  52587. // merge custom directives
  52588. if (options.directives) {
  52589. finalOptions.directives = extend(
  52590. Object.create(baseOptions.directives || null),
  52591. options.directives
  52592. );
  52593. }
  52594. // copy other options
  52595. for (var key in options) {
  52596. if (key !== 'modules' && key !== 'directives') {
  52597. finalOptions[key] = options[key];
  52598. }
  52599. }
  52600. }
  52601. finalOptions.warn = warn;
  52602. var compiled = baseCompile(template.trim(), finalOptions);
  52603. {
  52604. detectErrors(compiled.ast, warn);
  52605. }
  52606. compiled.errors = errors;
  52607. compiled.tips = tips;
  52608. return compiled
  52609. }
  52610. return {
  52611. compile: compile,
  52612. compileToFunctions: createCompileToFunctionFn(compile)
  52613. }
  52614. }
  52615. }
  52616. /* */
  52617. // `createCompilerCreator` allows creating compilers that use alternative
  52618. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52619. // Here we just export a default compiler using the default parts.
  52620. var createCompiler = createCompilerCreator(function baseCompile (
  52621. template,
  52622. options
  52623. ) {
  52624. var ast = parse(template.trim(), options);
  52625. if (options.optimize !== false) {
  52626. optimize(ast, options);
  52627. }
  52628. var code = generate(ast, options);
  52629. return {
  52630. ast: ast,
  52631. render: code.render,
  52632. staticRenderFns: code.staticRenderFns
  52633. }
  52634. });
  52635. /* */
  52636. var ref$1 = createCompiler(baseOptions);
  52637. var compile = ref$1.compile;
  52638. var compileToFunctions = ref$1.compileToFunctions;
  52639. /* */
  52640. // check whether current browser encodes a char inside attribute values
  52641. var div;
  52642. function getShouldDecode (href) {
  52643. div = div || document.createElement('div');
  52644. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52645. return div.innerHTML.indexOf('&#10;') > 0
  52646. }
  52647. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52648. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52649. // #6828: chrome encodes content in a[href]
  52650. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52651. /* */
  52652. var idToTemplate = cached(function (id) {
  52653. var el = query(id);
  52654. return el && el.innerHTML
  52655. });
  52656. var mount = Vue.prototype.$mount;
  52657. Vue.prototype.$mount = function (
  52658. el,
  52659. hydrating
  52660. ) {
  52661. el = el && query(el);
  52662. /* istanbul ignore if */
  52663. if (el === document.body || el === document.documentElement) {
  52664. warn(
  52665. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52666. );
  52667. return this
  52668. }
  52669. var options = this.$options;
  52670. // resolve template/el and convert to render function
  52671. if (!options.render) {
  52672. var template = options.template;
  52673. if (template) {
  52674. if (typeof template === 'string') {
  52675. if (template.charAt(0) === '#') {
  52676. template = idToTemplate(template);
  52677. /* istanbul ignore if */
  52678. if (!template) {
  52679. warn(
  52680. ("Template element not found or is empty: " + (options.template)),
  52681. this
  52682. );
  52683. }
  52684. }
  52685. } else if (template.nodeType) {
  52686. template = template.innerHTML;
  52687. } else {
  52688. {
  52689. warn('invalid template option:' + template, this);
  52690. }
  52691. return this
  52692. }
  52693. } else if (el) {
  52694. template = getOuterHTML(el);
  52695. }
  52696. if (template) {
  52697. /* istanbul ignore if */
  52698. if (config.performance && mark) {
  52699. mark('compile');
  52700. }
  52701. var ref = compileToFunctions(template, {
  52702. outputSourceRange: "development" !== 'production',
  52703. shouldDecodeNewlines: shouldDecodeNewlines,
  52704. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52705. delimiters: options.delimiters,
  52706. comments: options.comments
  52707. }, this);
  52708. var render = ref.render;
  52709. var staticRenderFns = ref.staticRenderFns;
  52710. options.render = render;
  52711. options.staticRenderFns = staticRenderFns;
  52712. /* istanbul ignore if */
  52713. if (config.performance && mark) {
  52714. mark('compile end');
  52715. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52716. }
  52717. }
  52718. }
  52719. return mount.call(this, el, hydrating)
  52720. };
  52721. /**
  52722. * Get outerHTML of elements, taking care
  52723. * of SVG elements in IE as well.
  52724. */
  52725. function getOuterHTML (el) {
  52726. if (el.outerHTML) {
  52727. return el.outerHTML
  52728. } else {
  52729. var container = document.createElement('div');
  52730. container.appendChild(el.cloneNode(true));
  52731. return container.innerHTML
  52732. }
  52733. }
  52734. Vue.compile = compileToFunctions;
  52735. module.exports = Vue;
  52736. /* 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))
  52737. /***/ }),
  52738. /***/ "./node_modules/vue/dist/vue.common.js":
  52739. /*!*********************************************!*\
  52740. !*** ./node_modules/vue/dist/vue.common.js ***!
  52741. \*********************************************/
  52742. /*! no static exports found */
  52743. /***/ (function(module, exports, __webpack_require__) {
  52744. if (false) {} else {
  52745. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52746. }
  52747. /***/ }),
  52748. /***/ "./node_modules/webpack/buildin/global.js":
  52749. /*!***********************************!*\
  52750. !*** (webpack)/buildin/global.js ***!
  52751. \***********************************/
  52752. /*! no static exports found */
  52753. /***/ (function(module, exports) {
  52754. var g;
  52755. // This works in non-strict mode
  52756. g = (function() {
  52757. return this;
  52758. })();
  52759. try {
  52760. // This works if eval is allowed (see CSP)
  52761. g = g || new Function("return this")();
  52762. } catch (e) {
  52763. // This works if the window reference is available
  52764. if (typeof window === "object") g = window;
  52765. }
  52766. // g can still be undefined, but nothing to do about it...
  52767. // We return undefined, instead of nothing here, so it's
  52768. // easier to handle this case. if(!global) { ...}
  52769. module.exports = g;
  52770. /***/ }),
  52771. /***/ "./node_modules/webpack/buildin/module.js":
  52772. /*!***********************************!*\
  52773. !*** (webpack)/buildin/module.js ***!
  52774. \***********************************/
  52775. /*! no static exports found */
  52776. /***/ (function(module, exports) {
  52777. module.exports = function(module) {
  52778. if (!module.webpackPolyfill) {
  52779. module.deprecate = function() {};
  52780. module.paths = [];
  52781. // module.parent = undefined by default
  52782. if (!module.children) module.children = [];
  52783. Object.defineProperty(module, "loaded", {
  52784. enumerable: true,
  52785. get: function() {
  52786. return module.l;
  52787. }
  52788. });
  52789. Object.defineProperty(module, "id", {
  52790. enumerable: true,
  52791. get: function() {
  52792. return module.i;
  52793. }
  52794. });
  52795. module.webpackPolyfill = 1;
  52796. }
  52797. return module;
  52798. };
  52799. /***/ }),
  52800. /***/ "./resources/js/app.js":
  52801. /*!*****************************!*\
  52802. !*** ./resources/js/app.js ***!
  52803. \*****************************/
  52804. /*! no static exports found */
  52805. /***/ (function(module, exports, __webpack_require__) {
  52806. /**
  52807. * First we will load all of this project's JavaScript dependencies which
  52808. * includes Vue and other libraries. It is a great starting point when
  52809. * building robust, powerful web applications using Vue and Laravel.
  52810. */
  52811. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52812. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52813. /**
  52814. * The following block of code may be used to automatically register your
  52815. * Vue components. It will recursively scan this directory for the Vue
  52816. * components and automatically register them with their "basename".
  52817. *
  52818. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52819. */
  52820. // const files = require.context('./', true, /\.vue$/i)
  52821. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52822. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52823. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  52824. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  52825. Vue.component('credential', __webpack_require__(/*! ./components/credential.vue */ "./resources/js/components/credential.vue")["default"]);
  52826. /**
  52827. * Next, we will create a fresh Vue application instance and attach it to
  52828. * the page. Then, you may begin adding components to this application
  52829. * or customize the JavaScript scaffolding to fit your unique needs.
  52830. */
  52831. var app = new Vue({
  52832. el: '#app'
  52833. });
  52834. $(function () {
  52835. $('[data-toggle="tooltip"]').tooltip();
  52836. });
  52837. /***/ }),
  52838. /***/ "./resources/js/bootstrap.js":
  52839. /*!***********************************!*\
  52840. !*** ./resources/js/bootstrap.js ***!
  52841. \***********************************/
  52842. /*! no exports provided */
  52843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52844. "use strict";
  52845. __webpack_require__.r(__webpack_exports__);
  52846. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52847. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52848. /**
  52849. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52850. * for JavaScript based Bootstrap features such as modals and tabs. This
  52851. * code may be modified to fit the specific needs of your application.
  52852. */
  52853. try {
  52854. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52855. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52856. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52857. } catch (e) {}
  52858. /**
  52859. * We'll load the axios HTTP library which allows us to easily issue requests
  52860. * to our Laravel back-end. This library automatically handles sending the
  52861. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52862. */
  52863. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52864. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52865. /**
  52866. * Echo exposes an expressive API for subscribing to channels and listening
  52867. * for events that are broadcast by Laravel. Echo and event broadcasting
  52868. * allows your team to easily build robust real-time web applications.
  52869. */
  52870. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52871. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52872. broadcaster: 'pusher',
  52873. key: "upccrt",
  52874. wsHost: window.location.hostname,
  52875. wsPort: 6001,
  52876. disableStats: true
  52877. });
  52878. /***/ }),
  52879. /***/ "./resources/js/components/ExampleComponent.vue":
  52880. /*!******************************************************!*\
  52881. !*** ./resources/js/components/ExampleComponent.vue ***!
  52882. \******************************************************/
  52883. /*! exports provided: default */
  52884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52885. "use strict";
  52886. __webpack_require__.r(__webpack_exports__);
  52887. /* harmony import */ var _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52888. /* harmony import */ var _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=script&lang=js& */ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52889. /* 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");
  52890. /* normalize component */
  52891. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52892. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52893. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52894. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52895. false,
  52896. null,
  52897. null,
  52898. null
  52899. )
  52900. /* hot reload */
  52901. if (false) { var api; }
  52902. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52903. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52904. /***/ }),
  52905. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52906. /*!*******************************************************************************!*\
  52907. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52908. \*******************************************************************************/
  52909. /*! exports provided: default */
  52910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52911. "use strict";
  52912. __webpack_require__.r(__webpack_exports__);
  52913. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52914. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52915. /***/ }),
  52916. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52917. /*!*************************************************************************************!*\
  52918. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52919. \*************************************************************************************/
  52920. /*! exports provided: render, staticRenderFns */
  52921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52922. "use strict";
  52923. __webpack_require__.r(__webpack_exports__);
  52924. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52927. /***/ }),
  52928. /***/ "./resources/js/components/assetinfo.vue":
  52929. /*!***********************************************!*\
  52930. !*** ./resources/js/components/assetinfo.vue ***!
  52931. \***********************************************/
  52932. /*! exports provided: default */
  52933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52934. "use strict";
  52935. __webpack_require__.r(__webpack_exports__);
  52936. /* harmony import */ var _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52937. /* harmony import */ var _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52938. /* 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");
  52939. /* normalize component */
  52940. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52941. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52942. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  52943. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52944. false,
  52945. null,
  52946. null,
  52947. null
  52948. )
  52949. /* hot reload */
  52950. if (false) { var api; }
  52951. component.options.__file = "resources/js/components/assetinfo.vue"
  52952. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52953. /***/ }),
  52954. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  52955. /*!************************************************************************!*\
  52956. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  52957. \************************************************************************/
  52958. /*! exports provided: default */
  52959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52960. "use strict";
  52961. __webpack_require__.r(__webpack_exports__);
  52962. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./assetinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52963. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52964. /***/ }),
  52965. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  52966. /*!******************************************************************************!*\
  52967. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  52968. \******************************************************************************/
  52969. /*! exports provided: render, staticRenderFns */
  52970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52971. "use strict";
  52972. __webpack_require__.r(__webpack_exports__);
  52973. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52976. /***/ }),
  52977. /***/ "./resources/js/components/credential.vue":
  52978. /*!************************************************!*\
  52979. !*** ./resources/js/components/credential.vue ***!
  52980. \************************************************/
  52981. /*! exports provided: default */
  52982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52983. "use strict";
  52984. __webpack_require__.r(__webpack_exports__);
  52985. /* harmony import */ var _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./credential.vue?vue&type=template&id=0f5cc562& */ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  52986. /* harmony import */ var _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./credential.vue?vue&type=script&lang=js& */ "./resources/js/components/credential.vue?vue&type=script&lang=js&");
  52987. /* 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");
  52988. /* normalize component */
  52989. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52990. _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52991. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"],
  52992. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52993. false,
  52994. null,
  52995. null,
  52996. null
  52997. )
  52998. /* hot reload */
  52999. if (false) { var api; }
  53000. component.options.__file = "resources/js/components/credential.vue"
  53001. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  53002. /***/ }),
  53003. /***/ "./resources/js/components/credential.vue?vue&type=script&lang=js&":
  53004. /*!*************************************************************************!*\
  53005. !*** ./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  53006. \*************************************************************************/
  53007. /*! exports provided: default */
  53008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53009. "use strict";
  53010. __webpack_require__.r(__webpack_exports__);
  53011. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_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!./credential.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&");
  53012. /* 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_credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  53013. /***/ }),
  53014. /***/ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  53015. /*!*******************************************************************************!*\
  53016. !*** ./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  53017. \*******************************************************************************/
  53018. /*! exports provided: render, staticRenderFns */
  53019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53020. "use strict";
  53021. __webpack_require__.r(__webpack_exports__);
  53022. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_template_id_0f5cc562___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!./credential.vue?vue&type=template&id=0f5cc562& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  53023. /* 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_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  53024. /* 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_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  53025. /***/ }),
  53026. /***/ "./resources/js/components/woinfo.vue":
  53027. /*!********************************************!*\
  53028. !*** ./resources/js/components/woinfo.vue ***!
  53029. \********************************************/
  53030. /*! exports provided: default */
  53031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53032. "use strict";
  53033. __webpack_require__.r(__webpack_exports__);
  53034. /* harmony import */ var _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./woinfo.vue?vue&type=template&id=33ce32de& */ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  53035. /* harmony import */ var _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./woinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  53036. /* 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");
  53037. /* normalize component */
  53038. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  53039. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  53040. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  53041. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  53042. false,
  53043. null,
  53044. null,
  53045. null
  53046. )
  53047. /* hot reload */
  53048. if (false) { var api; }
  53049. component.options.__file = "resources/js/components/woinfo.vue"
  53050. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  53051. /***/ }),
  53052. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  53053. /*!*********************************************************************!*\
  53054. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  53055. \*********************************************************************/
  53056. /*! exports provided: default */
  53057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53058. "use strict";
  53059. __webpack_require__.r(__webpack_exports__);
  53060. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./woinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  53061. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  53062. /***/ }),
  53063. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  53064. /*!***************************************************************************!*\
  53065. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  53066. \***************************************************************************/
  53067. /*! exports provided: render, staticRenderFns */
  53068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53069. "use strict";
  53070. __webpack_require__.r(__webpack_exports__);
  53071. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./woinfo.vue?vue&type=template&id=33ce32de& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  53072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  53073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  53074. /***/ }),
  53075. /***/ "./resources/js/mixins/dateMixin.js":
  53076. /*!******************************************!*\
  53077. !*** ./resources/js/mixins/dateMixin.js ***!
  53078. \******************************************/
  53079. /*! exports provided: default */
  53080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53081. "use strict";
  53082. __webpack_require__.r(__webpack_exports__);
  53083. /* harmony default export */ __webpack_exports__["default"] = ({
  53084. methods: {
  53085. treatAsUTC: function treatAsUTC(date) {
  53086. var result = new Date(date);
  53087. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  53088. return result;
  53089. },
  53090. daysSinceToday: function daysSinceToday(date) {
  53091. var currentDate = new Date();
  53092. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  53093. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  53094. },
  53095. getHRDate: function getHRDate(dateString) {
  53096. var date = new Date(dateString);
  53097. var year = date.getFullYear();
  53098. var month = date.toLocaleString('default', {
  53099. month: 'short'
  53100. });
  53101. var day = date.getDate();
  53102. var hour = date.getHours() % 12;
  53103. var minute = date.getMinutes();
  53104. var period = date.getHours() < 24 ? 'AM' : 'PM';
  53105. return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
  53106. },
  53107. isZero: function isZero(dateString) {
  53108. return dateString === '0000-00-00 00:00:00';
  53109. }
  53110. }
  53111. });
  53112. /***/ }),
  53113. /***/ "./resources/sass/app.scss":
  53114. /*!*********************************!*\
  53115. !*** ./resources/sass/app.scss ***!
  53116. \*********************************/
  53117. /*! no static exports found */
  53118. /***/ (function(module, exports) {
  53119. // removed by extract-text-webpack-plugin
  53120. /***/ }),
  53121. /***/ 0:
  53122. /*!*************************************************************!*\
  53123. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  53124. \*************************************************************/
  53125. /*! no static exports found */
  53126. /***/ (function(module, exports, __webpack_require__) {
  53127. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  53128. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  53129. /***/ })
  53130. /******/ });